Calculations/Data-Analyzer/+Helper/batchAnalyze.m

48 lines
1.3 KiB
Matlab

function results_all = batchAnalyze(baseFolder, dates, runs, options)
arguments
baseFolder (1,:) char
dates (1,:) string
runs (1,:) cell
options struct
end
assert(length(dates) == length(runs), ...
'Each entry in `dates` must correspond to a cell in `runs`.');
results_all = [];
for i = 1:length(dates)
currentDate = dates(i);
currentRuns = runs{i};
for j = 1:length(currentRuns)
runID = currentRuns(j);
folderPath = fullfile(baseFolder, currentDate, runID);
if ~endsWith(folderPath, filesep)
options.folderPath = [char(folderPath) filesep];
else
options.folderPath = char(folderPath);
end
try
args = [fieldnames(options), struct2cell(options)]';
args = args(:)';
% Single struct result
results = Analyzer.performAnalysis(args{:});
% Attach metadata
results.date = currentDate;
results.run = runID;
% Append to results_all
results_all = [results_all; results];
catch ME
warning("Error processing %s/%s: %s", currentDate, runID, ME.message);
end
end
end
end