Commit 9caa8696 authored by Mark Winter's avatar Mark Winter

Export/rename images if data file is associated with old images. Also fix for...

Export/rename images if data file is associated with old images. Also fix for error in renaming in the case that only json file needs to be updated.
parent 96f0fdc0
......@@ -4,7 +4,7 @@ settings = Load.ReadSettings();
bOpened = 0;
while ( ~bOpened )
metadataPath = Load.ImageExportDialog(settings.imagePath,'Test');
metadataPath = Load.ImageLoadDialog(settings.imagePath,['Open Dataset Metadata or Image (' Metadata.GetDatasetName() '): ']);
if ( isempty(metadataPath) )
return;
end
......
function jsonPath = ImageExportDialog(initialPath,promptTitle)
filterSpecs = {'*.json','LEVER Metadata (*.json)';
'*.lif;*.lei','Leica LAS (*.lif,*.lei)';
'*.czi;*.lsm;*.zvi','Zeiss (*.czi,*.lsm,*.zvi)';
'*.tif;*.tiff','TIFF Images (*.tif,*.tiff)';
'*.*','All Files (*.*)'};
jsonPath = '';
[fileName,rootDir,filterIndex] = uigetfile(filterSpecs,promptTitle,initialPath);
if (filterIndex==0)
return
end
if ( filterIndex == 1 )
jsonPath = fullfile(rootDir,fileName);
return
end
[~,chkName,chkExt] = fileparts(fileName);
if ( filterIndex == length(filterSpecs) && strcmpi(chkExt,'.json') )
jsonPath = fullfile(rootDir,fileName);
return;
end
[bNeedsExport,bWriteable,renameStruct] = Load.CheckExportImages(rootDir,fileName);
function jsonPath = ImageExportDialog(rootDir,filename)
[bNeedsExport,bWriteable,renameStruct] = Load.CheckExportImages(rootDir,filename);
if ( ~bNeedsExport )
[~,chkName] = fileparts(filename);
jsonList = dir(fullfile(rootDir,[chkName '*.json']));
jsonPath = fullfile(rootDir,jsonList(1).name);
return;
......@@ -36,7 +13,7 @@ function jsonPath = ImageExportDialog(initialPath,promptTitle)
end
if ( isempty(renameStruct) )
jsonPath = Load.ExportImages(exportDir, rootDir,fileName);
jsonPath = Load.ExportImages(exportDir, rootDir,filename);
else
jsonPath = Load.RenameImages(exportDir, rootDir, renameStruct);
end
......
function jsonPath = ImageLoadDialog(initialPath,promptTitle)
filterSpecs = {'*.json','LEVER Metadata (*.json)';
'*.lif;*.lei','Leica LAS (*.lif,*.lei)';
'*.czi;*.lsm;*.zvi','Zeiss (*.czi,*.lsm,*.zvi)';
'*.tif;*.tiff','TIFF Images (*.tif,*.tiff)';
'*.*','All Files (*.*)'};
jsonPath = '';
[fileName,rootDir,filterIndex] = uigetfile(filterSpecs,promptTitle,initialPath);
if (filterIndex==0)
return
end
if ( filterIndex == 1 )
jsonPath = fullfile(rootDir,fileName);
return
end
[~,~,chkExt] = fileparts(fileName);
if ( filterIndex == length(filterSpecs) && strcmpi(chkExt,'.json') )
jsonPath = fullfile(rootDir,fileName);
return;
end
jsonPath = Load.ImageExportDialog(rootDir,fileName);
end
......@@ -141,10 +141,19 @@ switch answer
Load.AddConstant('imageData.DatasetName',oldName,true);
end
imageData = MicroscopeData.ReadMetadata(fullfile(CONSTANTS.rootImageFolder, [Metadata.GetDatasetName() '.json']), false);
imageData = MicroscopeData.ReadMetadataFile(fullfile(CONSTANTS.rootImageFolder, [Metadata.GetDatasetName() '.json']));
if ( isempty(imageData) )
if ( exist(CONSTANTS.rootImageFolder,'dir') )
error('No metadata found in image directory, currently unsupported!');
tifList = dir(fullfile(CONSTANTS.rootImageFolder,'*.tif'));
if ( exist(CONSTANTS.rootImageFolder,'dir') && ~isempty(tifList) )
% Try to export or rename old lever image data
metadataPath = Load.ImageExportDialog(CONSTANTS.rootImageFolder,tifList(1).name);
if ( isempty(metadataPath) )
CONSTANTS = oldCONSTANTS;
return;
end
imageData = MicroscopeData.ReadMetadataFile(metadataPath);
Metadata.SetMetadata(imageData);
elseif (~Helper.ImageFileDialog())
CONSTANTS = oldCONSTANTS;
return
......
......@@ -40,6 +40,10 @@ function jsonPath = RenameImages(exportDir,inRoot, renameStruct, bCreateDatasetD
paramCell = num2cell(paramVals(i,:)+paramOffset);
outName = sprintf(renameStruct.outPattern,paramCell{:});
if ( strcmp(outName,validNames{i}) )
continue;
end
fileOp(fullfile(inRoot,validNames{i}),fullfile(exportDir,outName));
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment