193 lines
7.1 KiB
Matlab
193 lines
7.1 KiB
Matlab
%% ===== BEC-Stripes-Droplets Settings =====
|
|
|
|
% Specify data location to run analysis on
|
|
dataSources = {
|
|
struct('sequence', 'TwoDGas', ...
|
|
'date', '2025/06/24', ...
|
|
'runs', [1]) % specify run numbers as a string in "" or just as a numeric value
|
|
};
|
|
|
|
options = struct();
|
|
|
|
% File paths
|
|
options.baseDataFolder = '//DyLabNAS/Data';
|
|
options.FullODImagesFolder = 'E:/Data - Experiment/FullODImages/202506';
|
|
options.measurementName = 'StripesToDroplets';
|
|
scriptFullPath = mfilename('fullpath');
|
|
options.saveDirectory = fileparts(scriptFullPath);
|
|
|
|
% Camera / imaging settings
|
|
options.cam = 4; % 1 - ODT_1_Axis_Camera; 2 - ODT_2_Axis_Camera; 3 - Horizontal_Axis_Camera;, 4 - Vertical_Axis_Camera;
|
|
options.angle = 0; % angle by which image will be rotated
|
|
options.center = [1410, 2030];
|
|
options.span = [200, 200];
|
|
options.fraction = [0.1, 0.1];
|
|
options.pixel_size = 5.86e-6; % in meters
|
|
options.magnification = 23.94;
|
|
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;
|
|
|
|
%
|
|
options.maximumShift = 8;
|
|
options.Radial_Theta = deg2rad(45);
|
|
options.Radial_Minimum = 2;
|
|
options.Radial_Maximum = 6;
|
|
options.skipLivePlot = false;
|
|
|
|
% Flags
|
|
options.skipUnshuffling = false;
|
|
options.skipNormalization = false;
|
|
|
|
options.skipFringeRemoval = true;
|
|
options.skipPreprocessing = true;
|
|
options.skipMasking = true;
|
|
options.skipIntensityThresholding = true;
|
|
options.skipBinarization = true;
|
|
|
|
options.skipFullODImagesFolderUse = false;
|
|
options.skipSaveData = false;
|
|
options.skipSaveFigures = true;
|
|
options.skipSaveProcessedOD = true;
|
|
options.skipLivePlot = true;
|
|
options.showProgressBar = true;
|
|
|
|
|
|
% Extras
|
|
options.font = 'Bahnschrift';
|
|
switch options.measurementName
|
|
case 'BECToDroplets'
|
|
options.scan_parameter = 'rot_mag_field';
|
|
options.flipSortOrder = false;
|
|
options.scanParameterUnits = 'gauss';
|
|
options.titleString = 'BEC to Droplets';
|
|
case 'BECToStripes'
|
|
options.scan_parameter = 'rot_mag_field';
|
|
options.flipSortOrder = false;
|
|
options.scanParameterUnits = 'gauss';
|
|
options.titleString = 'BEC to Stripes';
|
|
case 'DropletsToStripes'
|
|
options.scan_parameter = 'ps_rot_mag_fin_pol_angle';
|
|
options.flipSortOrder = false;
|
|
options.scanParameterUnits = 'degrees';
|
|
options.titleString = 'Droplets to Stripes';
|
|
case 'StripesToDroplets'
|
|
options.scan_parameter = 'ps_rot_mag_fin_pol_angle';
|
|
options.flipSortOrder = false;
|
|
options.scanParameterUnits = 'degrees';
|
|
options.titleString = 'Stripes to Droplets';
|
|
end
|
|
%% ===== Collect Images and Launch Viewer =====
|
|
|
|
[options.selectedPath, options.folderPath] = Helper.selectDataSourcePath(dataSources, options);
|
|
|
|
[od_imgs, scan_parameter_values, scan_reference_values, file_list] = Helper.collectODImages(options);
|
|
|
|
%% Conduct correlation analysis
|
|
|
|
g2_analysis_results = Analyzer.conductCorrelationAnalysis(od_imgs, scan_parameter_values, options);
|
|
|
|
%% Analyze G2 matrices
|
|
|
|
% ROI definition
|
|
options.roi.center = [3, 3]; % center of ROI in µm (x0, y0)
|
|
options.roi.size = [3, 11]; % width and height in µm
|
|
options.roi.angle = pi/4; % rotation angle (radians, CCW)
|
|
options.threshold = 0.85;
|
|
|
|
options.deviationThreshold = 0.30;
|
|
options.minEllipseFraction = 0.30;
|
|
options.angleLimit = deg2rad(45);
|
|
options.angleTolerance = deg2rad(5);
|
|
|
|
% Plot control
|
|
options.skipLivePlot = true;
|
|
analysis_results = Analyzer.analyzeG2Structures(g2_analysis_results, options);
|
|
|
|
%% Plot raw OD images and the corresponding real space g2 matrix
|
|
|
|
options.skipLivePlot = true;
|
|
options.skipSaveFigures = true;
|
|
saveDirectory = 'C:\Users\Karthik-OfficePC\Documents\GitRepositories\Calculations\Data-Analyzer\+Scripts';
|
|
Plotter.plotODG2withAnalysis(od_imgs, scan_parameter_values, g2_analysis_results, analysis_results, options, ...
|
|
'FontName', options.font, ...
|
|
'FontSize', 14, ...
|
|
'ShowOverlays', true, ...
|
|
'RepsPerPage', 5, ... % paginate 10 repetitions per figure
|
|
'SaveDirectory', saveDirectory, ...
|
|
'SkipLivePlot', options.skipLivePlot, ...
|
|
'SkipSaveFigures', options.skipSaveFigures);
|
|
|
|
%% Plot mean and standard error of anisotropy
|
|
|
|
Plotter.plotMeanWithSE(scan_parameter_values, analysis_results.anisotropy_vals, ...
|
|
'Title', options.titleString, ...
|
|
'YLim', [0,10], ...
|
|
'XLabel', '\alpha (degrees)', ...
|
|
'YLabel', 'Anisotropy of correlation peaks', ...
|
|
'FigNum', 1, ...
|
|
'FontName', options.font, ...
|
|
'SaveFileName', 'RadialSpectralContrast.fig', ...
|
|
'SaveDirectory', pwd, ... % save figures inside dataset-specific folder
|
|
'SkipSaveFigures', options.skipSaveFigures);
|
|
|
|
%% Plot distribution of anisotropy
|
|
grouped_data = groupDataByScan(scan_parameter_values, analysis_results.anisotropy_vals);
|
|
|
|
% call plotPDF
|
|
Plotter.plotPDF(grouped_data, ...
|
|
scan_reference_values, ...
|
|
'Title', options.titleString, ...
|
|
'XLabel', '\alpha (degrees)', ...
|
|
'YLabel', 'Anisotropy of correlation peaks', ...
|
|
'FigNum', 2, ...
|
|
'FontName', options.font, ...
|
|
'SkipSaveFigures', options.skipSaveFigures, ...
|
|
'SaveFileName', 'PDF_MaxG2AcrossTransition.fig', ...
|
|
'SaveDirectory', pwd, ...
|
|
'NumberOfBins', 20, ...
|
|
'NormalizeHistogram', true, ...
|
|
'DataRange', [0 15], ...
|
|
'Colormap', @Colormaps.coolwarm, ...
|
|
'XLim', [min(scan_reference_values) max(scan_reference_values)]);
|
|
|
|
function groupedData = groupDataByScan(scan_values, data_values)
|
|
%% groupByScanValues
|
|
% Groups data according to unique scan parameter values.
|
|
%
|
|
% Inputs:
|
|
% scan_values : array of scan parameters (length = N_reps * N_scan)
|
|
% data_values : numeric array or cell array of measured values
|
|
% (same length as scan_values)
|
|
%
|
|
% Output:
|
|
% groupedData : 1 x N_unique cell array, each containing all repetitions
|
|
% corresponding to a unique scan value
|
|
|
|
[unique_vals, ~, idx] = unique(scan_values, 'stable'); % preserve order
|
|
groupedData = cell(1, numel(unique_vals));
|
|
|
|
for i = 1:numel(unique_vals)
|
|
if iscell(data_values)
|
|
group = data_values(idx == i);
|
|
groupedData{i} = [group{:}]; % concatenate if nested cells
|
|
else
|
|
groupedData{i} = data_values(idx == i);
|
|
end
|
|
end
|
|
end
|