From 1a99ff2c2a10471c8edebe95dff716d0267846b9 Mon Sep 17 00:00:00 2001 From: Karthik Chandrashekara Date: Mon, 18 Aug 2025 16:12:49 +0200 Subject: [PATCH] Change in magnification, added scripts to analyse BEC to Droplets dataset. --- .../+Scripts/BECToDroplets/runFullAnalysis.m | 2 +- .../BECToStripes/plotAnalysisResults.m | 163 ++++++++++++++++++ .../+Scripts/BECToStripes/plotImages.m | 118 +++++++++++++ .../+Scripts/BECToStripes/runFullAnalysis.m | 80 +++++++++ 4 files changed, 362 insertions(+), 1 deletion(-) create mode 100644 Data-Analyzer/+Scripts/BECToStripes/plotAnalysisResults.m create mode 100644 Data-Analyzer/+Scripts/BECToStripes/plotImages.m create mode 100644 Data-Analyzer/+Scripts/BECToStripes/runFullAnalysis.m diff --git a/Data-Analyzer/+Scripts/BECToDroplets/runFullAnalysis.m b/Data-Analyzer/+Scripts/BECToDroplets/runFullAnalysis.m index fc27058..53e0aee 100644 --- a/Data-Analyzer/+Scripts/BECToDroplets/runFullAnalysis.m +++ b/Data-Analyzer/+Scripts/BECToDroplets/runFullAnalysis.m @@ -22,7 +22,7 @@ options.center = [1420, 2050]; options.span = [200, 200]; options.fraction = [0.1, 0.1]; options.pixel_size = 5.86e-6; % in meters -options.magnification = 23.94; +options.magnification = 24.6; options.removeFringes = false; options.ImagingMode = 'HighIntensity'; options.PulseDuration = 5e-6; % in s diff --git a/Data-Analyzer/+Scripts/BECToStripes/plotAnalysisResults.m b/Data-Analyzer/+Scripts/BECToStripes/plotAnalysisResults.m new file mode 100644 index 0000000..3051592 --- /dev/null +++ b/Data-Analyzer/+Scripts/BECToStripes/plotAnalysisResults.m @@ -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); +%} \ No newline at end of file diff --git a/Data-Analyzer/+Scripts/BECToStripes/plotImages.m b/Data-Analyzer/+Scripts/BECToStripes/plotImages.m new file mode 100644 index 0000000..d35c330 --- /dev/null +++ b/Data-Analyzer/+Scripts/BECToStripes/plotImages.m @@ -0,0 +1,118 @@ +%% ===== BEC-Droplets Settings ===== + +% Specify data location to run analysis on +dataSources = { + struct('sequence', 'StructuralPhaseTransition', ... + 'date', '2025/08/13', ... + 'runs', [62]) % specify run numbers as a string in "" or just as a numeric value +}; + +options = struct(); + +% File / paths +options.baseDataFolder = '//DyLabNAS/Data'; +options.savefileName = 'BECToDroplets'; +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 = 23.94; +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 = 'rot_mag_field'; + +switch options.savefileName + 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.skipMovieRender = true; +options.skipSaveFigures = true; +options.skipSaveOD = 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 = 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); \ No newline at end of file diff --git a/Data-Analyzer/+Scripts/BECToStripes/runFullAnalysis.m b/Data-Analyzer/+Scripts/BECToStripes/runFullAnalysis.m new file mode 100644 index 0000000..e3aed21 --- /dev/null +++ b/Data-Analyzer/+Scripts/BECToStripes/runFullAnalysis.m @@ -0,0 +1,80 @@ +%% ===== BEC-Droplets Settings ===== + +% Specify data location to run analysis on +dataSources = { + struct('sequence', 'StructuralPhaseTransition', ... + 'date', '2025/08/15', ... + 'runs', [3]) % specify run numbers as a string in "" or just as a numeric value +}; + +options = struct(); + +% File / paths +options.baseDataFolder = '//DyLabNAS/Data'; +options.savefileName = 'BECToStripes'; +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 = 'rot_mag_field'; + +switch options.savefileName + 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.skipMovieRender = true; +options.skipSaveFigures = true; +options.skipSaveOD = true; +options.skipLivePlot = false; +options.showProgressBar = true; + +% Extras +options.font = 'Bahnschrift'; + +%% ===== Run Batch Analysis ===== +results_all = Helper.batchAnalyze(dataSources, options);