Cosmetic changes.
This commit is contained in:
parent
90f7d2b520
commit
cf577bfcde
@ -46,8 +46,8 @@ function [od_imgs, scan_parameter_values, file_list] = collectODImages(options)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
% --- General path to raw data folders ---
|
% --- General path to full od image folders ---
|
||||||
raw_data_folders = dir(fullfile(options.saveDirectory,'RawData_*'));
|
fullodimage_folders = dir(fullfile(options.saveDirectory,'FullODImages_*'));
|
||||||
|
|
||||||
% --- Specific sequence, data and run ---
|
% --- Specific sequence, data and run ---
|
||||||
dataSource = makeDataSourceStruct(options.folderPath);
|
dataSource = makeDataSourceStruct(options.folderPath);
|
||||||
@ -63,7 +63,7 @@ function [od_imgs, scan_parameter_values, file_list] = collectODImages(options)
|
|||||||
[options.SAVE_TO_WORKSPACE, ~] = Helper.estimateDatasetMemory(dataSource, options);
|
[options.SAVE_TO_WORKSPACE, ~] = Helper.estimateDatasetMemory(dataSource, options);
|
||||||
end
|
end
|
||||||
|
|
||||||
raw_data_folder = [];
|
fullodimage_folder = [];
|
||||||
|
|
||||||
% --- Prepare full_od_imgs, full_bkg_imgs, scan values, file list ---
|
% --- Prepare full_od_imgs, full_bkg_imgs, scan values, file list ---
|
||||||
if fullDataExists
|
if fullDataExists
|
||||||
@ -74,32 +74,32 @@ function [od_imgs, scan_parameter_values, file_list] = collectODImages(options)
|
|||||||
raw_file_list = evalin('base', 'raw_file_list');
|
raw_file_list = evalin('base', 'raw_file_list');
|
||||||
nFiles = size(full_od_imgs,3);
|
nFiles = size(full_od_imgs,3);
|
||||||
fprintf('\n[INFO] Cropping and subtracting background from images...\n');
|
fprintf('\n[INFO] Cropping and subtracting background from images...\n');
|
||||||
elseif ~options.SAVE_TO_WORKSPACE && ~isempty(raw_data_folders)
|
elseif ~options.SAVE_TO_WORKSPACE && ~isempty(fullodimage_folders)
|
||||||
matched = false;
|
matched = false;
|
||||||
for r = 1:numel(raw_data_folders)
|
for r = 1:numel(fullodimage_folders)
|
||||||
metaPath = fullfile(raw_data_folders(r).folder, raw_data_folders(r).name, 'metadata.mat');
|
metaPath = fullfile(fullodimage_folders(r).folder, fullodimage_folders(r).name, 'metadata.mat');
|
||||||
if ~isfile(metaPath), continue; end
|
if ~isfile(metaPath), continue; end
|
||||||
S = load(metaPath,'metadata');
|
S = load(metaPath,'metadata');
|
||||||
if isequaln(S.metadata.options, options)
|
if isequaln(S.metadata.options, options)
|
||||||
fprintf('\n[INFO] Found matching raw data folder: %s\n', raw_data_folders(r).name);
|
fprintf('\n[INFO] Found matching full OD images folder: %s\n', fullodimage_folders(r).name);
|
||||||
raw_data_folder = fullfile(raw_data_folders(r).folder, raw_data_folders(r).name);
|
fullodimage_folder = fullfile(fullodimage_folders(r).folder, fullodimage_folders(r).name);
|
||||||
matched = true;
|
matched = true;
|
||||||
break;
|
break;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if ~matched
|
if ~matched
|
||||||
fprintf('\n[INFO] No matching raw data folder for this run found.\n');
|
fprintf('\n[INFO] No matching full OD images folder for this run found.\n');
|
||||||
[~, ~, ~, ~] = Helper.processRawData(options);
|
[~, ~, ~, ~] = Helper.processRawData(options);
|
||||||
fprintf('\n[INFO] Completed computing OD images. Images will be stored on disk for reuse.\n');
|
fprintf('\n[INFO] Completed computing OD images. Images will be stored on disk for reuse.\n');
|
||||||
end
|
end
|
||||||
mat_files = dir(fullfile(raw_data_folder,'*.mat'));
|
mat_files = dir(fullfile(fullodimage_folder,'*.mat'));
|
||||||
mat_files = mat_files(~strcmp({mat_files.name}, 'metadata.mat')); % Exclude metadata.mat
|
mat_files = mat_files(~strcmp({mat_files.name}, 'metadata.mat')); % Exclude metadata.mat
|
||||||
nFiles = numel(mat_files);
|
nFiles = numel(mat_files);
|
||||||
raw_scan_parameter_values = zeros(1,nFiles);
|
raw_scan_parameter_values = zeros(1,nFiles);
|
||||||
raw_file_list = strings(1,nFiles);
|
raw_file_list = strings(1,nFiles);
|
||||||
fprintf('\n[INFO] Cropping and subtracting background from images in raw data folder on disk...\n');
|
fprintf('\n[INFO] Cropping and subtracting background from images in full OD images folder on disk...\n');
|
||||||
else
|
else
|
||||||
fprintf('\n[INFO] No raw data found in either the workspace or on disk.\n');
|
fprintf('\n[INFO] No full OD images found in either the workspace or on disk.\n');
|
||||||
[full_od_imgs, full_bkg_imgs, raw_scan_parameter_values, raw_file_list] = Helper.processRawData(options);
|
[full_od_imgs, full_bkg_imgs, raw_scan_parameter_values, raw_file_list] = Helper.processRawData(options);
|
||||||
if options.SAVE_TO_WORKSPACE
|
if options.SAVE_TO_WORKSPACE
|
||||||
nFiles = size(full_od_imgs,3);
|
nFiles = size(full_od_imgs,3);
|
||||||
@ -115,13 +115,13 @@ function [od_imgs, scan_parameter_values, file_list] = collectODImages(options)
|
|||||||
dataSource{1}.sequence, ...
|
dataSource{1}.sequence, ...
|
||||||
strrep(dataSource{1}.date,'/','-'), ...
|
strrep(dataSource{1}.date,'/','-'), ...
|
||||||
dataSource{1}.runs);
|
dataSource{1}.runs);
|
||||||
raw_data_folder = fullfile(options.saveDirectory, ['RawData_' runID]);
|
fullodimage_folder = fullfile(options.saveDirectory, ['FullODImages_' runID]);
|
||||||
mat_files = dir(fullfile(raw_data_folder,'*.mat'));
|
mat_files = dir(fullfile(fullodimage_folder,'*.mat'));
|
||||||
mat_files = mat_files(~strcmp({mat_files.name}, 'metadata.mat')); % Exclude metadata.mat
|
mat_files = mat_files(~strcmp({mat_files.name}, 'metadata.mat')); % Exclude metadata.mat
|
||||||
nFiles = numel(mat_files);
|
nFiles = numel(mat_files);
|
||||||
raw_scan_parameter_values = zeros(1,nFiles);
|
raw_scan_parameter_values = zeros(1,nFiles);
|
||||||
raw_file_list = strings(1,nFiles);
|
raw_file_list = strings(1,nFiles);
|
||||||
fprintf('\n[INFO] Cropping and subtracting background from images in raw data folder on disk...\n');
|
fprintf('\n[INFO] Cropping and subtracting background from images in full OD images folder on disk...\n');
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -136,12 +136,12 @@ function [od_imgs, scan_parameter_values, file_list] = collectODImages(options)
|
|||||||
end
|
end
|
||||||
|
|
||||||
for k = 1:nFiles
|
for k = 1:nFiles
|
||||||
if fullDataExists || ~isempty(raw_data_folder)
|
if fullDataExists || ~isempty(fullodimage_folder)
|
||||||
if fullDataExists
|
if fullDataExists
|
||||||
od_mat = full_od_imgs(:,:,k);
|
od_mat = full_od_imgs(:,:,k);
|
||||||
bkg_mat = full_bkg_imgs(:,:,k);
|
bkg_mat = full_bkg_imgs(:,:,k);
|
||||||
else
|
else
|
||||||
data = load(fullfile(raw_data_folder, mat_files(k).name));
|
data = load(fullfile(fullodimage_folder, mat_files(k).name));
|
||||||
od_mat = data.OD;
|
od_mat = data.OD;
|
||||||
bkg_mat = data.BKG;
|
bkg_mat = data.BKG;
|
||||||
raw_scan_parameter_values(k) = data.Scan;
|
raw_scan_parameter_values(k) = data.Scan;
|
||||||
|
|||||||
@ -58,10 +58,10 @@ function [SAVE_TO_WORKSPACE, runMemoryGB] = estimateDatasetMemory(dataSources, o
|
|||||||
% Decide workspace flag per run by comparing with 50% of available RAM
|
% Decide workspace flag per run by comparing with 50% of available RAM
|
||||||
if runBytes > 0.75 * availableRAM
|
if runBytes > 0.75 * availableRAM
|
||||||
SAVE_TO_WORKSPACE = false;
|
SAVE_TO_WORKSPACE = false;
|
||||||
fprintf('\n[INFO] Estimated size on memory of Run %s/%s too large (%.2f GB). Will save raw data to disk and partially to workspace if not done so already.\n', ...
|
fprintf('\n[INFO] Estimated size on memory of Run %s/%s too large (%.2f GB). Will save full OD images to disk and partially to workspace if not done so already.\n', ...
|
||||||
ds.sequence, runID, runBytes/1e9);
|
ds.sequence, runID, runBytes/1e9);
|
||||||
else
|
else
|
||||||
fprintf('\n[INFO] Estimated size on memory of Run %s/%s = %.2f GB. Will save raw data completely to workspace if not done so already.\n', ...
|
fprintf('\n[INFO] Estimated size on memory of Run %s/%s = %.2f GB. Will save full OD images data completely to workspace if not done so already.\n', ...
|
||||||
ds.sequence, runID, runBytes/1e9);
|
ds.sequence, runID, runBytes/1e9);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -33,16 +33,16 @@ function [full_od_imgs, full_bkg_imgs, raw_scan_parameter_values, raw_file_list]
|
|||||||
full_od_imgs = nan(ny, nx, nFiles, 'single');
|
full_od_imgs = nan(ny, nx, nFiles, 'single');
|
||||||
full_bkg_imgs = nan(ny, nx, nFiles, 'single');
|
full_bkg_imgs = nan(ny, nx, nFiles, 'single');
|
||||||
else
|
else
|
||||||
% --- Create uniquely identified RawData folder ---
|
% --- Create uniquely identified full OD image folder ---
|
||||||
dataSource = makeDataSourceStruct(options.folderPath);
|
dataSource = makeDataSourceStruct(options.folderPath);
|
||||||
runID = sprintf('%s_%s_Run%04d', ...
|
runID = sprintf('%s_%s_Run%04d', ...
|
||||||
dataSource{1}.sequence, ...
|
dataSource{1}.sequence, ...
|
||||||
strrep(dataSource{1}.date,'/','-'), ...
|
strrep(dataSource{1}.date,'/','-'), ...
|
||||||
dataSource{1}.runs);
|
dataSource{1}.runs);
|
||||||
|
|
||||||
rawFolder = fullfile(options.saveDirectory, ['RawData_' runID]);
|
fullODImageFolder = fullfile(options.saveDirectory, ['FullODImages_' runID]);
|
||||||
if ~exist(rawFolder,'dir'), mkdir(rawFolder); end
|
if ~exist(fullODImageFolder,'dir'), mkdir(fullODImageFolder); end
|
||||||
fprintf('\n[INFO] Creating folder of raw data on disk: %s\n', rawFolder);
|
fprintf('\n[INFO] Creating folder of full OD images on disk: %s\n', fullODImageFolder);
|
||||||
|
|
||||||
% --- Save metadata for this run ---
|
% --- Save metadata for this run ---
|
||||||
metadata.options = options;
|
metadata.options = options;
|
||||||
@ -50,10 +50,10 @@ function [full_od_imgs, full_bkg_imgs, raw_scan_parameter_values, raw_file_list]
|
|||||||
metadata.runID = runID; % traceable to experiment run
|
metadata.runID = runID; % traceable to experiment run
|
||||||
metadata.imageSize = [ny, nx];
|
metadata.imageSize = [ny, nx];
|
||||||
metadata.fileList = string(arrayfun(@(f) fullfile(f.folder, f.name), files, 'UniformOutput', false));
|
metadata.fileList = string(arrayfun(@(f) fullfile(f.folder, f.name), files, 'UniformOutput', false));
|
||||||
save(fullfile(rawFolder,'metadata.mat'),'metadata','-v7.3');
|
save(fullfile(fullODImageFolder,'metadata.mat'),'metadata','-v7.3');
|
||||||
|
|
||||||
full_od_imgs = rawFolder;
|
full_od_imgs = fullODImageFolder;
|
||||||
full_bkg_imgs = rawFolder;
|
full_bkg_imgs = fullODImageFolder;
|
||||||
end
|
end
|
||||||
|
|
||||||
% --- Prepare file names ---
|
% --- Prepare file names ---
|
||||||
@ -72,7 +72,7 @@ function [full_od_imgs, full_bkg_imgs, raw_scan_parameter_values, raw_file_list]
|
|||||||
% --- Parallel loop without progress bar ---
|
% --- Parallel loop without progress bar ---
|
||||||
parfor k = 1:nFiles
|
parfor k = 1:nFiles
|
||||||
[od_img, bkg_img, val] = readAndComputeOD(fullFileNames(k), options, groupList, ny, nx);
|
[od_img, bkg_img, val] = readAndComputeOD(fullFileNames(k), options, groupList, ny, nx);
|
||||||
writeRawImagesToDisk(rawFolder, od_img, bkg_img, val, fullFileNames(k), k);
|
writeFullODImagesToDisk(fullODImageFolder, od_img, bkg_img, val, fullFileNames(k), k);
|
||||||
raw_scan_parameter_values(k) = val;
|
raw_scan_parameter_values(k) = val;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -90,7 +90,7 @@ function [full_od_imgs, full_bkg_imgs, raw_scan_parameter_values, raw_file_list]
|
|||||||
full_od_imgs(:,:,k) = single(od_img);
|
full_od_imgs(:,:,k) = single(od_img);
|
||||||
full_bkg_imgs(:,:,k) = single(bkg_img);
|
full_bkg_imgs(:,:,k) = single(bkg_img);
|
||||||
else
|
else
|
||||||
writeRawImagesToDisk(rawFolder, od_img, bkg_img, val, fullFileNames(k), k);
|
writeFullODImagesToDisk(fullODImageFolder, od_img, bkg_img, val, fullFileNames(k), k);
|
||||||
end
|
end
|
||||||
raw_scan_parameter_values(k) = val;
|
raw_scan_parameter_values(k) = val;
|
||||||
raw_file_list(k) = fullFileNames(k);
|
raw_file_list(k) = fullFileNames(k);
|
||||||
@ -137,9 +137,9 @@ function [od_img, bkg_img, val] = readAndComputeOD(fullFileName, options, groupL
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function writeRawImagesToDisk(rawFolder, od_img, bkg_img, scan_val, file_name, idx)
|
function writeFullODImagesToDisk(fullODImageFolder, od_img, bkg_img, scan_val, file_name, idx)
|
||||||
% Writes a single OD/BKG image + scan parameter to a MAT file
|
% Writes a single OD/BKG image + scan parameter to a MAT file
|
||||||
matFilePath = fullfile(rawFolder, sprintf('Image_%04d.mat', idx));
|
matFilePath = fullfile(fullODImageFolder, sprintf('Image_%04d.mat', idx));
|
||||||
OD = single(od_img);
|
OD = single(od_img);
|
||||||
BKG = single(bkg_img);
|
BKG = single(bkg_img);
|
||||||
Scan = single(scan_val);
|
Scan = single(scan_val);
|
||||||
|
|||||||
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
% Specify data location to run analysis on
|
% Specify data location to run analysis on
|
||||||
dataSources = {
|
dataSources = {
|
||||||
struct('sequence', 'TwoDGas', ...
|
struct('sequence', 'StructuralPhaseTransition', ...
|
||||||
'date', '2025/06/23', ...
|
'date', '2025/08/16', ...
|
||||||
'runs', [300]) % specify run numbers as a string in "" or just as a numeric value
|
'runs', [8]) % specify run numbers as a string in "" or just as a numeric value
|
||||||
};
|
};
|
||||||
|
|
||||||
options = struct();
|
options = struct();
|
||||||
@ -18,7 +18,7 @@ options.saveDirectory = fileparts(scriptFullPath);
|
|||||||
% Camera / imaging
|
% Camera / imaging
|
||||||
options.cam = 5;
|
options.cam = 5;
|
||||||
options.angle = 0;
|
options.angle = 0;
|
||||||
options.center = [1410, 2030];
|
options.center = [1420, 2050];
|
||||||
options.span = [200, 200];
|
options.span = [200, 200];
|
||||||
options.fraction = [0.1, 0.1];
|
options.fraction = [0.1, 0.1];
|
||||||
options.pixel_size = 5.86e-6; % in meters
|
options.pixel_size = 5.86e-6; % in meters
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user