Modified to save analysis data that once done does not need to be redone if it needs to be plotted again or differently.
This commit is contained in:
parent
628a29971f
commit
db298413d1
@ -32,6 +32,8 @@ function results = performAnalysis(options)
|
||||
options.skipNormalization (1,1) logical
|
||||
options.skipLivePlot (1,1) logical
|
||||
options.skipSaveFigures (1,1) logical
|
||||
options.skipSaveData (1,1) logical
|
||||
options.skipSaveOD (1,1) logical
|
||||
options.showProgressBar (1,1) logical
|
||||
options.measurementName (1,:) char
|
||||
options.folderPath (1,:) char
|
||||
|
@ -57,6 +57,11 @@ function results_all = batchAnalyze(dataSources, options)
|
||||
result.path = folderPath;
|
||||
result.results = analysisResults;
|
||||
|
||||
% Save each dataset as its own MAT file
|
||||
if ~isfield(options, 'skipSaveData') || ~options.skipSaveData
|
||||
saveResultStruct(result, options.saveDirectory);
|
||||
end
|
||||
|
||||
% Append to output
|
||||
results_all{end+1,1} = result;
|
||||
|
||||
@ -67,3 +72,35 @@ function results_all = batchAnalyze(dataSources, options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
%% ---- Local function for saving results ----
|
||||
function saveResultStruct(result, saveDirectory)
|
||||
% Define results folder
|
||||
resultsFolder = fullfile(saveDirectory, "Results", "AnalysisSavedData");
|
||||
if ~exist(resultsFolder, 'dir')
|
||||
mkdir(resultsFolder);
|
||||
end
|
||||
|
||||
% Path to index file
|
||||
indexFile = fullfile(resultsFolder, "datasetsIndex.mat");
|
||||
|
||||
% Load or initialize index
|
||||
if isfile(indexFile)
|
||||
S = load(indexFile, "nextIdx");
|
||||
nextIdx = S.nextIdx;
|
||||
else
|
||||
nextIdx = 1;
|
||||
end
|
||||
|
||||
% Variable name and file path
|
||||
varName = sprintf('Dataset_%d', nextIdx);
|
||||
savePath = fullfile(resultsFolder, varName + ".mat");
|
||||
|
||||
% Save dataset as struct inside MAT file
|
||||
S.(varName) = result;
|
||||
save(savePath, '-struct', 'S');
|
||||
|
||||
% Update index
|
||||
nextIdx = nextIdx + 1;
|
||||
save(indexFile, "nextIdx");
|
||||
end
|
||||
|
@ -38,7 +38,7 @@ function [od_imgs, scan_parameter_values, file_list] = collectODImages(options)
|
||||
file_list = evalin('base','file_list');
|
||||
|
||||
% --- Ensure figures exist if requested now ---
|
||||
if ~options.skipSaveFigures
|
||||
if ~options.skipSaveOD
|
||||
saveODFigures(od_imgs, options.saveDirectory);
|
||||
end
|
||||
|
||||
@ -200,7 +200,7 @@ function [od_imgs, scan_parameter_values, file_list] = collectODImages(options)
|
||||
assignin('base', 'prior_options', options);
|
||||
|
||||
% --- Save OD images as figures if requested ---
|
||||
if ~options.skipSaveFigures
|
||||
if ~options.skipSaveOD
|
||||
saveODFigures(od_imgs, options.saveDirectory);
|
||||
end
|
||||
|
||||
|
@ -68,6 +68,8 @@ options.skipMasking = true;
|
||||
options.skipIntensityThresholding = true;
|
||||
options.skipBinarization = true;
|
||||
options.skipSaveFigures = true;
|
||||
options.skipSaveData = false;
|
||||
options.skipSaveOD = true;
|
||||
options.skipLivePlot = false;
|
||||
options.showProgressBar = true;
|
||||
|
||||
|
@ -67,8 +67,8 @@ options.skipPreprocessing = true;
|
||||
options.skipMasking = true;
|
||||
options.skipIntensityThresholding = true;
|
||||
options.skipBinarization = true;
|
||||
options.skipMovieRender = true;
|
||||
options.skipSaveFigures = true;
|
||||
options.skipSaveData = false;
|
||||
options.skipSaveOD = true;
|
||||
options.skipLivePlot = false;
|
||||
options.showProgressBar = true;
|
||||
|
Loading…
Reference in New Issue
Block a user