Added more verbose text to display in console, new scripts to analyse Stripe to Droplet transition.

This commit is contained in:
Karthik 2025-08-20 12:31:15 +02:00
parent b0f45aa7e6
commit dc360ed659
5 changed files with 378 additions and 3 deletions

View File

@ -89,14 +89,21 @@ function [od_imgs, scan_parameter_values, file_list] = collectODImages(options)
assignin('base', 'full_bkg_imgs', full_bkg_imgs); assignin('base', 'full_bkg_imgs', full_bkg_imgs);
assignin('base', 'raw_scan_parameter_values', raw_scan_parameter_values); assignin('base', 'raw_scan_parameter_values', raw_scan_parameter_values);
assignin('base', 'raw_file_list', raw_file_list); assignin('base', 'raw_file_list', raw_file_list);
fprintf('\nCompleted computing OD images and will be stored in workspace for reuse.\n'); fprintf('\nCompleted computing OD images. Images will be stored in workspace for reuse.\n');
end end
fprintf('\nCropping and subtracting background from images...\n');
nFiles = size(full_od_imgs, 3); nFiles = size(full_od_imgs, 3);
% --- Preallocate arrays for processed images --- % --- Preallocate arrays for processed images ---
absimages = zeros(options.span(1)+1, options.span(2)+1, nFiles, 'single'); absimages = zeros(options.span(1)+1, options.span(2)+1, nFiles, 'single');
refimages = zeros(options.span(1)+1, options.span(2)+1, nFiles, 'single'); refimages = zeros(options.span(1)+1, options.span(2)+1, nFiles, 'single');
% --- Progress bar ---
if isfield(options, 'showProgressBar') && options.showProgressBar
pb = Helper.ProgressBar();
pb.run('Progress: ');
end
% --- Process each image: crop and subtract background --- % --- Process each image: crop and subtract background ---
for k = 1:nFiles for k = 1:nFiles
@ -122,6 +129,17 @@ function [od_imgs, scan_parameter_values, file_list] = collectODImages(options)
% Store processed image (transpose to match orientation) % Store processed image (transpose to match orientation)
absimages(:,:,k) = processed_absimage'; absimages(:,:,k) = processed_absimage';
refimages(:,:,k) = processed_refimage'; refimages(:,:,k) = processed_refimage';
% Update progress bar
if isfield(options, 'showProgressBar') && options.showProgressBar
progressPercent = round(k / nFiles * 100);
pb.run(progressPercent);
end
end
% Finish progress bar
if isfield(options, 'showProgressBar') && options.showProgressBar
pb.run(' Done!');
end end
% --- Optional fringe removal --- % --- Optional fringe removal ---

View File

@ -35,7 +35,7 @@ function [full_od_imgs, full_bkg_imgs, raw_scan_parameter_values, raw_file_list]
% --- Progress bar --- % --- Progress bar ---
if isfield(options, 'showProgressBar') && options.showProgressBar if isfield(options, 'showProgressBar') && options.showProgressBar
pb = Helper.ProgressBar(); pb = Helper.ProgressBar();
pb.run('Computing OD images | Progress: '); pb.run('Progress: ');
end end
raw_file_list = strings(1, nFiles); % store full file paths raw_file_list = strings(1, nFiles); % store full file paths

View File

@ -0,0 +1,163 @@
idx = 1;
compiled_results = results_all{idx}.results;
options.skipSaveFigures = false;
%% ------------------ 1. Mean ± Std Plots ------------------
% Plot Radial Spectral Contrast
Plotter.plotMeanWithSE(scan_parameter_values, compiled_results.spectral_analysis_results.radial_spectral_contrast, ...
'Title', options.titleString, ...
'XLabel', 'B (G)', ...
'YLabel', 'Radial Spectral Contrast', ...
'FigNum', 1, ...
'FontName', options.font, ...
'SaveFileName', 'RadialSpectralContrast.fig', ...
'SaveDirectory', [options.saveDirectory '/Results'], ...
'SkipSaveFigures', options.skipSaveFigures);
% Plot Angular Spectral Weight
Plotter.plotMeanWithSE(scan_parameter_values, compiled_results.spectral_analysis_results.angular_spectral_weight, ...
'Title', options.titleString, ...
'XLabel', 'B (G)', ...
'YLabel', 'Angular Spectral Weight', ...
'FigNum', 2, ...
'FontName', options.font, ...
'SaveFileName', 'AngularSpectralWeight.fig', ...
'SaveDirectory', [options.saveDirectory '/Results'], ...
'SkipSaveFigures', options.skipSaveFigures);
% Plot Peak Offset Angular Correlation
Plotter.plotMeanWithSE(options.scan_reference_values, compiled_results.custom_g_results.max_g2_all_per_scan_parameter_value, ...
'Title', options.titleString, ...
'XLabel', 'B (G)', ...
'YLabel', '$\mathrm{max}[g^{(2)}_{[50,70]}(\delta\theta)]$', ...
'FigNum', 3, ...
'YLim', [0 1], ...
'FontName', options.font, ...
'SaveFileName', 'PeakOffsetAngularCorrelation.fig', ...
'SaveDirectory', [options.saveDirectory '/Results'], ...
'SkipSaveFigures', options.skipSaveFigures);
%% ------------------ 2. g²(θ) across transition ------------------
Plotter.plotG2(compiled_results.full_g2_results.g2_all, ...
compiled_results.full_g2_results.g2_error_all, ...
compiled_results.full_g2_results.theta_values, ...
options.scan_reference_values, ...
'rot_mag_field', ...
'Title', options.titleString, ...
'XLabel', '$\delta\theta / \pi$', ...
'YLabel', '$g^{(2)}(\delta\theta)$', ...
'FigNum', 4, ...
'FontName', options.font, ...
'SkipSaveFigures', options.skipSaveFigures, ...
'SaveFileName', 'G2ThetaAcrossTransition.fig', ...
'SaveDirectory', [options.saveDirectory '/Results'], ...
'Colormap', @Colormaps.coolwarm);
%% ------------------ 3. PDF of max g² across transition ------------------
Plotter.plotPDF(compiled_results.custom_g_results.max_g2_all_per_scan_parameter_value, options.scan_reference_values, ...
'Title', options.titleString, ...
'XLabel', 'B (G)', ...
'YLabel', '$\mathrm{max}[g^{(2)}]$', ...
'FigNum', 5, ...
'FontName', options.font, ...
'SkipSaveFigures', options.skipSaveFigures, ...
'SaveFileName', 'PDF_MaxG2AcrossTransition.fig', ...
'SaveDirectory', [options.saveDirectory '/Results'], ...
'NumPoints', 200, ...
'DataRange', [0 1.5], ...
'Colormap', @Colormaps.coolwarm, ...
'XLim', [min(options.scan_reference_values) max(options.scan_reference_values)]);
%% ------------------ 4. Cumulants across transition ------------------
Plotter.plotCumulants(options.scan_reference_values, ...
{compiled_results.custom_g_results.mean_max_g2, compiled_results.custom_g_results.var_max_g2, compiled_results.custom_g_results.skew_max_g2_angle, compiled_results.custom_g_results.fourth_order_cumulant_max_g2}, ...
'Title', 'Cumulants of Peak Offset Angular Correlation', ...
'XLabel', 'B (G)', ...
'FigNum', 6, ...
'FontName', options.font, ...
'MarkerSize', 6, ...
'LineWidth', 1.5, ...
'SkipSaveFigures', options.skipSaveFigures, ...
'SaveFileName', 'CumulantOfPeakOffsetAngularCorrelation.fig', ...
'SaveDirectory', [options.saveDirectory '/Results']);
%{
%% ------------------ 6. Average of Spectra Plots ------------------
Plotter.plotAverageSpectra(scan_parameter_values, ...
spectral_analysis_results, ...
'ScanParameterName', scan_parameter, ...
'FigNum', 7, ...
'ColormapPS', Colormaps.coolwarm(), ...
'Font', 'Bahnschrift', ...
'SaveFileName', 'avgSpectra.fig', ...
'SaveDirectory', [options.saveDirectory '/Results'], ...
'SkipSaveFigures', options.skipSaveFigures);
%% ------------------ 7. Compare quantities ------------------
% Load Droplets Stripes data
Data = load(dtsFile, ...
'unique_scan_parameter_values', ...
'mean_max_g2_values', ...
'std_error_g2_values');
dts_scan_parameter_values = Data.unique_scan_parameter_values;
dts_mean_mg2 = Data.mean_max_g2_values;
dts_stderr_mg2 = Data.std_error_g2_values;
% Load Stripes Droplets data
Data = load(stdFile, ...
'unique_scan_parameter_values', ...
'mean_max_g2_values', ...
'std_error_g2_values');
std_scan_parameter_values = Data.unique_scan_parameter_values;
std_mean_mg2 = Data.mean_max_g2_values;
std_stderr_mg2 = Data.std_error_g2_values;
% Prepare cell arrays for multiple datasets
scanValsCell = {dts_scan_parameter_values, std_scan_parameter_values};
meanValsCell = {dts_mean_mg2, std_mean_mg2};
stderrValsCell = {dts_stderr_mg2, std_stderr_mg2};
% Compare datasets
compareMultipleDatasets(scanValsCell, meanValsCell, stderrValsCell, ...
'FigNum', 8, ...
'FontName', 'Bahnschrift', ...
'MarkerSize', 6, ...
'LineWidth', 1.5, ...
'CapSize', 5, ...
'YLim', [0 1], ...
'Labels', {'Droplets Stripes', 'Stripes Droplets'}, ...
'Title', 'AngularCorrelation_Comparison', ...
'XLabel', 'B (G)', ...
'YLabel', '$\mathrm{max}[g^{(2)}_{[50,70]}(\delta\theta)]$', ...
'SkipSaveFigures', options.skipSaveFigures, ...
'SaveDirectory', [options.saveDirectory '/Results'], ...
'SaveFileName', 'AngularCorrelation_Comparison.fig');
%% ------------------ 8. Heatmaps ------------------
BFields = [2.35, 2.15, 2.0, 1.85, 1.7, 1.55, 1.4, 1.35];
% Heatmap of mean_max_g2_values
Plotter.plotHeatmap(compiled_results, options.scan_groups, BFields, 'mean_max_g2_values', ...
'Colormap', @sky, ...
'CLim', [0 1], ...
'XLabel', '\alpha (degrees)', ...
'YLabel', 'BField (G)', ...
'Title', '$\mathrm{max}[g^{(2)}_{[50,70]}(\delta\theta)]$', ...
'FigNum', 9, ...
'SaveFileName', 'Heatmap_MaxG2.fig', ...
'SaveDirectory', options.resultsDir);
% Heatmap of radial_spectral_contrast
Plotter.plotHeatmap(compiled_results, options.scan_groups, BFields, 'radial_spectral_contrast', ...
'Colormap', @sky, ...
'CLim', [0 0.008], ...
'XLabel', '\alpha (degrees)', ...
'YLabel', 'BField (G)', ...
'Title', 'Radial Spectral Contrast', ...
'FigNum', 10, ...
'SaveFileName', 'Heatmap_RadialSpectralContrast.fig', ...
'SaveDirectory', options.resultsDir);
%}

View File

@ -0,0 +1,116 @@
%% ===== BEC-Droplets-Stripes Settings =====
% Specify data location to run analysis on
dataSources = {
struct('sequence', 'StructuralPhaseTransition', ...
'date', '2025/08/18', ...
'runs', [12]) % specify run numbers as a string in "" or just as a numeric value
};
options = struct();
% File / paths
options.baseDataFolder = '//DyLabNAS/Data';
options.measurementName = 'StripesToDroplets';
scriptFullPath = mfilename('fullpath');
options.saveDirectory = fileparts(scriptFullPath);
% Camera / imaging
options.cam = 5;
options.angle = 0;
options.center = [1420, 2050];
options.span = [200, 200];
options.fraction = [0.1, 0.1];
options.pixel_size = 5.86e-6; % in meters
options.magnification = 24.6;
options.removeFringes = false;
options.ImagingMode = 'HighIntensity';
options.PulseDuration = 5e-6; % in s
% Fourier analysis settings
options.theta_min = deg2rad(0);
options.theta_max = deg2rad(180);
options.N_radial_bins = 500;
options.Radial_Sigma = 2;
options.Radial_WindowSize = 5; % odd number
options.k_min = 1.2771; % μm¹
options.k_max = 2.5541; % μm¹
options.N_angular_bins = 180;
options.Angular_Threshold = 75;
options.Angular_Sigma = 2;
options.Angular_WindowSize = 5;
options.zoom_size = 50;
% Scan parameter
options.scan_parameter = 'ps_rot_mag_fin_pol_angle';
switch options.measurementName
case 'BECToDroplets'
options.scan_reference_values = [2.40, 2.39, 2.38, 2.37, 2.35, 2.34, 2.32, 2.30, 2.28, 2.26, 2.24, 2.22, 2.2, 2.15, 2.10, 2.05, 2, 1.95, 1.90, 1.85, 1.8];
options.titleString = 'BEC to Droplets';
case 'BECToStripes'
options.scan_reference_values = [2.45, 2.44, 2.43, 2.42, 2.4, 2.39, 2.38, 2.37, 2.36, 2.35, 2.34, 2.32, 2.3, 2.28, 2.25, 2.2, 2.15, 2.10, 2.0, 1.90, 1.8];
options.titleString = 'BEC to Stripes';
case 'DropletsToStripes'
options.scan_reference_values = [0, 5, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 35, 40];
options.titleString = 'Droplets to Stripes';
case 'StripesToDroplets'
options.scan_reference_values = fliplr([0, 5, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 35, 40]);
options.titleString = 'Stripes to Droplets';
end
% Flags
options.skipNormalization = false;
options.skipUnshuffling = true;
options.skipPreprocessing = true;
options.skipMasking = true;
options.skipIntensityThresholding = true;
options.skipBinarization = true;
options.skipSaveFigures = true;
options.skipLivePlot = false;
options.showProgressBar = true;
% Extras
options.font = 'Bahnschrift';
%% ===== Build Paths from Data Sources =====
allPaths = {}; % initialize
for i = 1:length(dataSources)
ds = dataSources{i};
% Split the date string into year/month/day
dateParts = strsplit(ds.date, '/');
for run = ds.runs
runStr = sprintf('%04d', run); % 4-digit run number
fullPath = fullfile(options.baseDataFolder, ds.sequence, dateParts{:}, runStr);
if isfolder(fullPath) % only include valid directories
allPaths{end+1} = fullPath;
else
warning('Path does not exist: %s', fullPath);
end
end
end
% Let user select a single path
set(0,'DefaultUicontrolFontSize',10); % increase default font size
[selectedIndex, tf] = listdlg('PromptString','Select a path to analyze:', ...
'SelectionMode','single', ...
'ListString', allPaths, ...
'ListSize',[400, 300]); % width x height in pixels
if tf
options.folderPath = fullfile(allPaths{selectedIndex}); % store in options
fprintf('Path set to selection: %s\n', options.folderPath);
else
error('No path selected. Aborting.');
end
%% ===== Collect Images and Launch Viewer =====
[od_imgs, scan_parameter_values, file_list] = Helper.collectODImages(options);
Analyzer.runInteractiveODImageViewer(od_imgs, scan_parameter_values, file_list, options);

View File

@ -0,0 +1,78 @@
%% ===== BEC-Droplets-Stripes Settings =====
% Specify data location to run analysis on
dataSources = {
struct('sequence', 'StructuralPhaseTransition', ...
'date', '2025/08/16', ...
'runs', [8]) % specify run numbers as a string in "" or just as a numeric value
};
options = struct();
% File / paths
options.baseDataFolder = '//DyLabNAS/Data';
options.measurementName = 'DropletsToStripes';
scriptFullPath = mfilename('fullpath');
options.saveDirectory = fileparts(scriptFullPath);
% Camera / imaging
options.cam = 5;
options.angle = 0;
options.center = [1420, 2050];
options.span = [200, 200];
options.fraction = [0.1, 0.1];
options.pixel_size = 5.86e-6; % in meters
options.magnification = 24.6;
options.removeFringes = false;
options.ImagingMode = 'HighIntensity';
options.PulseDuration = 5e-6; % in s
% Fourier analysis settings
options.theta_min = deg2rad(0);
options.theta_max = deg2rad(180);
options.N_radial_bins = 500;
options.Radial_Sigma = 2;
options.Radial_WindowSize = 5; % odd number
options.k_min = 1.2771; % μm¹
options.k_max = 2.5541; % μm¹
options.N_angular_bins = 180;
options.Angular_Threshold = 75;
options.Angular_Sigma = 2;
options.Angular_WindowSize = 5;
options.zoom_size = 50;
% Scan parameter
options.scan_parameter = 'ps_rot_mag_fin_pol_angle';
switch options.measurementName
case 'BECToDroplets'
options.scan_reference_values = [2.40, 2.39, 2.38, 2.37, 2.35, 2.34, 2.32, 2.30, 2.28, 2.26, 2.24, 2.22, 2.2, 2.15, 2.10, 2.05, 2, 1.95, 1.90, 1.85, 1.8];
options.titleString = 'BEC to Droplets';
case 'BECToStripes'
options.scan_reference_values = [2.45, 2.44, 2.43, 2.42, 2.4, 2.39, 2.38, 2.37, 2.36, 2.35, 2.34, 2.32, 2.3, 2.28, 2.25, 2.2, 2.15, 2.10, 2.0, 1.90, 1.8];
options.titleString = 'BEC to Stripes';
case 'DropletsToStripes'
options.scan_reference_values = [0, 5, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 35, 40];
options.titleString = 'Droplets to Stripes';
case 'StripesToDroplets'
options.scan_reference_values = fliplr([0, 5, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 35, 40]);
options.titleString = 'Stripes to Droplets';
end
% Flags
options.skipNormalization = false;
options.skipUnshuffling = false;
options.skipPreprocessing = true;
options.skipMasking = true;
options.skipIntensityThresholding = true;
options.skipBinarization = true;
options.skipSaveFigures = true;
options.skipLivePlot = false;
options.showProgressBar = true;
% Extras
options.font = 'Bahnschrift';
%% ===== Run Batch Analysis =====
results_all = Helper.batchAnalyze(dataSources, options);