Bugfixes and modifications of plotting routines.
This commit is contained in:
parent
7b7af70a24
commit
82a2cef456
@ -72,7 +72,7 @@ function compareMultipleDatasets(scanValsCell, meanValsCell, stderrValsCell, var
|
||||
|
||||
xlabel(opts.XLabel, 'Interpreter', 'latex', 'FontSize', axisFontSize);
|
||||
ylabel(opts.YLabel, 'Interpreter', 'latex', 'FontSize', axisFontSize);
|
||||
title(opts.Title, 'Interpreter', 'latex', 'FontSize', titleFontSize);
|
||||
title(opts.Title, 'FontName', opts.FontName, 'FontSize', titleFontSize);
|
||||
legend('Location', 'best');
|
||||
grid on;
|
||||
|
||||
|
@ -20,6 +20,7 @@ function plotMeanWithSE(scan_values, data_values, varargin)
|
||||
addParameter(p, 'SkipSaveFigures', false, @islogical);
|
||||
addParameter(p, 'SaveFileName', 'mean_with_se.fig', @ischar);
|
||||
addParameter(p, 'SaveDirectory', pwd, @ischar);
|
||||
addParameter(p, 'HoldOn', false, @islogical);
|
||||
parse(p, varargin{:});
|
||||
opts = p.Results;
|
||||
|
||||
@ -48,13 +49,19 @@ function plotMeanWithSE(scan_values, data_values, varargin)
|
||||
else
|
||||
fig = figure(opts.FigNum);
|
||||
end
|
||||
clf(fig);
|
||||
if ~opts.HoldOn
|
||||
clf(fig);
|
||||
end
|
||||
set(fig, 'Color', 'w', 'Position', [100 100 950 750]);
|
||||
|
||||
% --- Plot error bars ---
|
||||
errorbar(unique_vals, mean_vals, stderr_vals, 'o--', ...
|
||||
'LineWidth', 1.8, 'MarkerSize', 6, 'CapSize', 5);
|
||||
|
||||
if opts.HoldOn
|
||||
hold on;
|
||||
end
|
||||
|
||||
% --- Axis formatting ---
|
||||
set(gca, 'FontName', opts.FontName, 'FontSize', opts.FontSize);
|
||||
if ~isempty(opts.YLim)
|
||||
@ -71,4 +78,4 @@ function plotMeanWithSE(scan_values, data_values, varargin)
|
||||
'SaveDirectory', opts.SaveDirectory, ...
|
||||
'SkipSaveFigures', opts.SkipSaveFigures);
|
||||
|
||||
end
|
||||
end
|
@ -1,33 +1,43 @@
|
||||
% --- User chooses which dataset to load ---
|
||||
datasetIdx = 1; % <-- change this to 1, 2, 3, ...
|
||||
datasetName = sprintf('Dataset_%d', datasetIdx);
|
||||
%% --- User chooses which dataset to load ---
|
||||
datasetIdx = 1; % <-- change this to 1, 2, 3, ...
|
||||
datasetName = sprintf('Dataset_%d', datasetIdx);
|
||||
|
||||
% Detect the folder where this script is located and set that as the Base Directory
|
||||
thisScriptPath = mfilename('fullpath');
|
||||
[thisScriptDir, ~, ~] = fileparts(thisScriptPath);
|
||||
baseDir = thisScriptDir; % override if needed
|
||||
% --- Base directory selection ---
|
||||
useLocalBaseDir = false; % <-- set true to use script location, false to use manual path
|
||||
|
||||
% Build path to dataset file
|
||||
dataFile = fullfile(baseDir, "Results", "SavedData", datasetName + ".mat");
|
||||
data = load(dataFile);
|
||||
if useLocalBaseDir
|
||||
% Use folder where this script is located
|
||||
thisScriptPath = mfilename('fullpath');
|
||||
[thisScriptDir, ~, ~] = fileparts(thisScriptPath);
|
||||
baseDir = fullfile(thisScriptDir, 'Results');
|
||||
else
|
||||
% Use manually specified folder
|
||||
baseDir = 'E:\Results - Experiment\202507\BECToDroplets\';
|
||||
end
|
||||
|
||||
% Access dataset struct dynamically
|
||||
datasetStruct = data.(datasetName);
|
||||
compiled_results = datasetStruct.results;
|
||||
scan_parameter_values = datasetStruct.scan_parameter_values;
|
||||
scan_reference_values = datasetStruct.scan_reference_values;
|
||||
% --- Build paths ---
|
||||
dataFile = fullfile(baseDir, 'SavedData', [datasetName '.mat']);
|
||||
figSaveDir = fullfile(baseDir, 'SavedFigures', datasetName);
|
||||
|
||||
% Load the original options used during analysis
|
||||
options = datasetStruct.options; % exact options used for this dataset
|
||||
options.font = 'Bahnschrift'; % override if needed
|
||||
options.skipSaveFigures = false; % override if needed
|
||||
% --- Load dataset ---
|
||||
data = load(dataFile);
|
||||
|
||||
%% ------------------ Create dataset-specific figure folder ------------------
|
||||
figSaveDir = fullfile(baseDir,'Results', 'SavedFigures', datasetName);
|
||||
% --- Ensure figure folder exists ---
|
||||
if ~exist(figSaveDir, 'dir')
|
||||
mkdir(figSaveDir);
|
||||
end
|
||||
|
||||
% --- Access dataset struct dynamically ---
|
||||
datasetStruct = data.(datasetName);
|
||||
compiled_results = datasetStruct.results;
|
||||
scan_parameter_values = datasetStruct.scan_parameter_values;
|
||||
scan_reference_values = datasetStruct.scan_reference_values;
|
||||
|
||||
% --- Load options used during analysis ---
|
||||
options = datasetStruct.options;
|
||||
options.font = 'Bahnschrift'; % override if needed
|
||||
options.skipSaveFigures = false; % override if needed
|
||||
|
||||
%% ------------------ 1. Mean ± Std Plots ------------------
|
||||
% Plot Radial Spectral Contrast
|
||||
Plotter.plotMeanWithSE(scan_parameter_values, compiled_results.spectral_analysis_results.radial_spectral_contrast, ...
|
||||
@ -63,7 +73,76 @@ Plotter.plotMeanWithSE(scan_parameter_values, compiled_results.custom_g_results.
|
||||
'SaveDirectory', figSaveDir, ...
|
||||
'SkipSaveFigures', options.skipSaveFigures);
|
||||
|
||||
%% ------------------ 2. g²(θ) across transition ------------------
|
||||
%% ------------------ 2. PDF of Radial Spectral Contrast across transition ------------------
|
||||
|
||||
% Ensure row vectors
|
||||
contrast = compiled_results.spectral_analysis_results.radial_spectral_contrast(:)';
|
||||
params = scan_parameter_values(:)';
|
||||
reference = scan_reference_values(:)';
|
||||
|
||||
% Preallocate a cell array to hold grouped results
|
||||
grouped_contrast = cell(size(reference)); % 1x21
|
||||
|
||||
% Loop over each unique reference value
|
||||
for i = 1:length(reference)
|
||||
ref_val = reference(i);
|
||||
|
||||
% Find indices where the scan param matches this reference
|
||||
idx = params == ref_val;
|
||||
|
||||
% Store corresponding contrast values
|
||||
grouped_contrast{i} = contrast(idx);
|
||||
end
|
||||
|
||||
Plotter.plotPDF(grouped_contrast, ...
|
||||
scan_reference_values, ...
|
||||
'Title', options.titleString, ...
|
||||
'XLabel', 'B (G)', ...
|
||||
'YLabel', 'Radial Spectral Contrast', ...
|
||||
'FigNum', 4, ...
|
||||
'FontName', options.font, ...
|
||||
'SkipSaveFigures', options.skipSaveFigures, ...
|
||||
'SaveFileName', 'PDF_MaxG2AcrossTransition.fig', ...
|
||||
'SaveDirectory', figSaveDir, ...
|
||||
'NumberOfBins', 20, ...
|
||||
'NormalizeHistogram', true, ...
|
||||
'DataRange', [0 0.1], ...
|
||||
'Colormap', @Colormaps.coolwarm, ...
|
||||
'XLim', [min(scan_reference_values) max(scan_reference_values)]);
|
||||
|
||||
%% ------------------ 3. Cumulants across transition ------------------
|
||||
|
||||
maxOrder = 4; % Set the order of cumulants you want
|
||||
numGroups = length(grouped_contrast);
|
||||
|
||||
% Preallocate matrix to store cumulants
|
||||
% Each row corresponds to a group (i.e., a scan_reference_value)
|
||||
% Each column corresponds to a cumulant order (1 to maxOrder)
|
||||
cumulant_matrix = NaN(numGroups, maxOrder);
|
||||
|
||||
for i = 1:numGroups
|
||||
data_i = grouped_contrast{i};
|
||||
cumulant_matrix(i, :) = Calculator.computeCumulants(data_i, maxOrder);
|
||||
end
|
||||
|
||||
mean_rsc = cumulant_matrix(:, 1);
|
||||
var_rsc = cumulant_matrix(:, 2);
|
||||
skew_rsc = cumulant_matrix(:, 3);
|
||||
binder_rsc = cumulant_matrix(:, 4);
|
||||
|
||||
Plotter.plotCumulants(scan_reference_values, ...
|
||||
{mean_rsc, var_rsc, skew_rsc, binder_rsc}, ...
|
||||
'Title', 'Cumulants of Radial Spectral Contrast', ...
|
||||
'XLabel', 'B (G)', ...
|
||||
'FigNum', 5, ...
|
||||
'FontName', options.font, ...
|
||||
'MarkerSize', 6, ...
|
||||
'LineWidth', 1.5, ...
|
||||
'SkipSaveFigures', options.skipSaveFigures, ...
|
||||
'SaveFileName', 'CumulantOfPeakOffsetAngularCorrelation.fig', ...
|
||||
'SaveDirectory', figSaveDir);
|
||||
|
||||
%% ------------------ 4. g²(θ) across transition ------------------
|
||||
Plotter.plotG2(compiled_results.full_g2_results.g2_mean, ...
|
||||
compiled_results.full_g2_results.g2_error, ...
|
||||
compiled_results.full_g2_results.theta_values, ...
|
||||
@ -72,13 +151,14 @@ Plotter.plotG2(compiled_results.full_g2_results.g2_mean, ...
|
||||
'Title', options.titleString, ...
|
||||
'XLabel', '$\delta\theta / \pi$', ...
|
||||
'YLabel', '$g^{(2)}(\delta\theta)$', ...
|
||||
'FigNum', 4, ...
|
||||
'FigNum', 6, ...
|
||||
'FontName', options.font, ...
|
||||
'SkipSaveFigures', options.skipSaveFigures, ...
|
||||
'SaveFileName', 'G2ThetaAcrossTransition.fig', ...
|
||||
'SaveDirectory', figSaveDir, ...
|
||||
'Colormap', @Colormaps.coolwarm);
|
||||
%% ------------------ 3. Feature extraction of g²(θ) across transition ------------------
|
||||
|
||||
%% ------------------ 5. Feature extraction of g²(θ) across transition ------------------
|
||||
|
||||
Plotter.plotG2Curves(compiled_results.full_g2_results, ...
|
||||
'Title', options.titleString, ...
|
||||
@ -86,7 +166,7 @@ Plotter.plotG2Curves(compiled_results.full_g2_results, ...
|
||||
'YLabel', 'g^{(2)}(\theta)', ...
|
||||
'HighlightEvery', 10, ... % highlight every 10th repetition
|
||||
'FontName', options.font, ...
|
||||
'FigNum', 5, ...
|
||||
'FigNum', 7, ...
|
||||
'TileTitlePrefix', 'B', ... % user-defined tile prefix
|
||||
'TileTitleSuffix', 'G', ... % user-defined suffix (e.g., Gauss symbol)...
|
||||
'SkipSaveFigures', options.skipSaveFigures, ...
|
||||
@ -101,7 +181,7 @@ Plotter.plotG2Features(g2_analysis_results, ...
|
||||
'Title', options.titleString, ...
|
||||
'XLabel', 'B (G)', ...
|
||||
'FontName', options.font, ...
|
||||
'FigNum', 6, ...
|
||||
'FigNum', 8, ...
|
||||
'SkipSaveFigures', options.skipSaveFigures, ...
|
||||
'SaveFileName', 'G2Features.fig', ...
|
||||
'SaveDirectory', figSaveDir);
|
||||
@ -111,18 +191,18 @@ Plotter.plotG2Cumulants(g2_analysis_results, ...
|
||||
'Title', options.titleString, ...
|
||||
'XLabel', 'B (G)', ...
|
||||
'FontName', options.font, ...
|
||||
'FigNum', 7, ...
|
||||
'FigNum', 9, ...
|
||||
'SkipSaveFigures', options.skipSaveFigures, ...
|
||||
'SaveFileName', 'G2Cumulants.fig', ...
|
||||
'SaveDirectory', figSaveDir);
|
||||
|
||||
%% ------------------ 4. PDF of max g² across transition ------------------
|
||||
%% ------------------ 6. PDF of max g² across transition ------------------
|
||||
Plotter.plotPDF(compiled_results.custom_g_results.max_g2_all_per_scan_parameter_value, ...
|
||||
scan_reference_values, ...
|
||||
'Title', options.titleString, ...
|
||||
'XLabel', 'B (G)', ...
|
||||
'YLabel', '$\mathrm{max}[g^{(2)}]$', ...
|
||||
'FigNum', 8, ...
|
||||
'FigNum', 10, ...
|
||||
'FontName', options.font, ...
|
||||
'SkipSaveFigures', options.skipSaveFigures, ...
|
||||
'SaveFileName', 'PDF_MaxG2AcrossTransition.fig', ...
|
||||
@ -134,12 +214,12 @@ Plotter.plotPDF(compiled_results.custom_g_results.max_g2_all_per_scan_parameter_
|
||||
'XLim', [min(scan_reference_values) max(scan_reference_values)]);
|
||||
|
||||
|
||||
%% ------------------ 5. Cumulants across transition ------------------
|
||||
%% ------------------ 7. Cumulants across transition ------------------
|
||||
Plotter.plotCumulants(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', 9, ...
|
||||
'FigNum', 11, ...
|
||||
'FontName', options.font, ...
|
||||
'MarkerSize', 6, ...
|
||||
'LineWidth', 1.5, ...
|
||||
@ -147,15 +227,13 @@ Plotter.plotCumulants(scan_reference_values, ...
|
||||
'SaveFileName', 'CumulantOfPeakOffsetAngularCorrelation.fig', ...
|
||||
'SaveDirectory', figSaveDir);
|
||||
|
||||
%% ------------------ 6. PCA ------------------
|
||||
%% ------------------ 8. PCA ------------------
|
||||
Plotter.plotPCAResults(compiled_results.pca_results, scan_parameter_values, scan_reference_values, ...
|
||||
'FigNumRange', [10,11,12,13,14,15], ...
|
||||
'FigNumRange', [12,13,14,15,16,17], ...
|
||||
'FontName', options.font, ...
|
||||
'SkipSaveFigures', options.skipSaveFigures, ...
|
||||
'SaveDirectory', figSaveDir);
|
||||
|
||||
|
||||
|
||||
%%
|
||||
%{
|
||||
|
||||
|
@ -3,15 +3,15 @@
|
||||
% 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
|
||||
'date', '2025/07/25', ...
|
||||
'runs', [25]) % 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/202508';
|
||||
options.FullODImagesFolder = 'E:/Data - Experiment/FullODImages/202507';
|
||||
options.measurementName = 'BECToDroplets';
|
||||
scriptFullPath = mfilename('fullpath');
|
||||
options.saveDirectory = fileparts(scriptFullPath);
|
||||
@ -23,7 +23,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 = 24.6;
|
||||
options.magnification = 23.94;
|
||||
options.ImagingMode = 'HighIntensity';
|
||||
options.PulseDuration = 5e-6; % in s
|
||||
|
||||
|
@ -1,26 +1,42 @@
|
||||
% --- User chooses which dataset to load ---
|
||||
datasetIdx = 4; % <-- change this to 1, 2, 3, ...
|
||||
datasetName = sprintf('Dataset_%d', datasetIdx);
|
||||
%% --- User chooses which dataset to load ---
|
||||
datasetIdx = 6; % <-- change this to 1, 2, 3, ...
|
||||
datasetName = sprintf('Dataset_%d', datasetIdx);
|
||||
|
||||
% Detect the folder where this script is located and set that as the Base Directory
|
||||
thisScriptPath = mfilename('fullpath');
|
||||
[thisScriptDir, ~, ~] = fileparts(thisScriptPath);
|
||||
baseDir = thisScriptDir; % override if needed
|
||||
% --- Base directory selection ---
|
||||
useLocalBaseDir = false; % <-- set true to use script location, false to use manual path
|
||||
|
||||
% Build path to dataset file
|
||||
dataFile = fullfile(baseDir, "Results", "SavedData", datasetName + ".mat");
|
||||
data = load(dataFile);
|
||||
if useLocalBaseDir
|
||||
% Use folder where this script is located
|
||||
thisScriptPath = mfilename('fullpath');
|
||||
[thisScriptDir, ~, ~] = fileparts(thisScriptPath);
|
||||
baseDir = fullfile(thisScriptDir, 'Results');
|
||||
else
|
||||
% Use manually specified folder
|
||||
baseDir = 'E:\Results - Experiment\202508\BECToDropletsToStripes\';
|
||||
end
|
||||
|
||||
% Access dataset struct dynamically
|
||||
datasetStruct = data.(datasetName);
|
||||
compiled_results = datasetStruct.results;
|
||||
scan_parameter_values = datasetStruct.scan_parameter_values;
|
||||
scan_reference_values = datasetStruct.scan_reference_values;
|
||||
% --- Build paths ---
|
||||
dataFile = fullfile(baseDir, 'SavedData', [datasetName '.mat']);
|
||||
figSaveDir = fullfile(baseDir, 'SavedFigures', datasetName);
|
||||
|
||||
% Load the original options used during analysis
|
||||
options = datasetStruct.options; % exact options used for this dataset
|
||||
options.font = 'Bahnschrift'; % override if needed
|
||||
options.skipSaveFigures = false; % override if needed
|
||||
% --- Load dataset ---
|
||||
data = load(dataFile);
|
||||
|
||||
% --- Ensure figure folder exists ---
|
||||
if ~exist(figSaveDir, 'dir')
|
||||
mkdir(figSaveDir);
|
||||
end
|
||||
|
||||
% --- Access dataset struct dynamically ---
|
||||
datasetStruct = data.(datasetName);
|
||||
compiled_results = datasetStruct.results;
|
||||
scan_parameter_values = datasetStruct.scan_parameter_values;
|
||||
scan_reference_values = datasetStruct.scan_reference_values;
|
||||
|
||||
% --- Load options used during analysis ---
|
||||
options = datasetStruct.options;
|
||||
options.font = 'Bahnschrift'; % override if needed
|
||||
options.skipSaveFigures = false; % override if needed
|
||||
|
||||
%% ------------------ Create dataset-specific figure folder ------------------
|
||||
figSaveDir = fullfile(baseDir,'Results', 'SavedFigures', datasetName);
|
||||
@ -147,6 +163,8 @@ Plotter.plotCumulants(scan_reference_values, ...
|
||||
'SaveFileName', 'CumulantOfPeakOffsetAngularCorrelation.fig', ...
|
||||
'SaveDirectory', figSaveDir);
|
||||
|
||||
%{
|
||||
|
||||
%% ------------------ 6. PCA ------------------
|
||||
Plotter.plotPCAResults(compiled_results.pca_results, scan_parameter_values, scan_reference_values, ...
|
||||
'FigNumRange', [10,11,12,13,14,15], ...
|
||||
@ -154,12 +172,7 @@ Plotter.plotPCAResults(compiled_results.pca_results, scan_parameter_values, scan
|
||||
'SkipSaveFigures', options.skipSaveFigures, ...
|
||||
'SaveDirectory', figSaveDir);
|
||||
|
||||
|
||||
|
||||
%%
|
||||
%{
|
||||
|
||||
%% ------------------ 6. Average of Spectra Plots ------------------
|
||||
%% ------------------ 7. Average of Spectra Plots ------------------
|
||||
|
||||
Plotter.plotAverageSpectra(scan_parameter_values, ...
|
||||
spectral_analysis_results, ...
|
||||
@ -171,7 +184,7 @@ Plotter.plotAverageSpectra(scan_parameter_values, ...
|
||||
'SaveDirectory', figSaveDir, ...
|
||||
'SkipSaveFigures', options.skipSaveFigures);
|
||||
|
||||
%% ------------------ 7. Compare quantities ------------------
|
||||
%% ------------------ 8. Compare quantities ------------------
|
||||
% Load Droplets → Stripes data
|
||||
Data = load(dtsFile, ...
|
||||
'unique_scan_parameter_values', ...
|
||||
@ -211,7 +224,7 @@ compareMultipleDatasets(scanValsCell, meanValsCell, stderrValsCell, ...
|
||||
'SaveDirectory', figSaveDir, ...
|
||||
'SaveFileName', 'AngularCorrelation_Comparison.fig');
|
||||
|
||||
%% ------------------ 8. Heatmaps ------------------
|
||||
%% ------------------ 9. Heatmaps ------------------
|
||||
|
||||
BFields = [2.35, 2.15, 2.0, 1.85, 1.7, 1.55, 1.4, 1.35];
|
||||
|
||||
|
@ -0,0 +1,147 @@
|
||||
%% ------------------ 1. Compare radial spectral contrast across datasets ------------------
|
||||
datasetIdxList = 1:6;
|
||||
|
||||
% --- Base directory selection ---
|
||||
useLocalBaseDir = false; % <-- set true to use script location, false to use manual path
|
||||
|
||||
if useLocalBaseDir
|
||||
% Use folder where this script is located
|
||||
thisScriptPath = mfilename('fullpath');
|
||||
[thisScriptDir, ~, ~] = fileparts(thisScriptPath);
|
||||
baseDir = fullfile(thisScriptDir, 'Results');
|
||||
else
|
||||
% Use manually specified folder
|
||||
baseDir = 'E:\Results - Experiment\202508\BECToDropletsToStripes\';
|
||||
end
|
||||
|
||||
% Prepare storage
|
||||
scanValsCell = cell(1, numel(datasetIdxList));
|
||||
meanValsCell = cell(1, numel(datasetIdxList));
|
||||
stderrValsCell = cell(1, numel(datasetIdxList));
|
||||
labelsCell = {'2.25 G', '2.20 G', '2.15 G', '2.10 G', '2.05 G', '2.00 G'};
|
||||
|
||||
% --- Load options from first dataset to set plotting defaults ---
|
||||
datasetIdx = datasetIdxList(1);
|
||||
datasetName = sprintf('Dataset_%d', datasetIdx);
|
||||
dataFile = fullfile(baseDir, 'SavedData', [datasetName '.mat']);
|
||||
data = load(dataFile);
|
||||
datasetStruct = data.(datasetName);
|
||||
options = datasetStruct.options;
|
||||
options.font = 'Bahnschrift';
|
||||
options.skipSaveFigures = false;
|
||||
|
||||
% --- Ensure combined figure folder exists ---
|
||||
combinedSaveDir = fullfile(baseDir, 'SavedFigures', 'Combined');
|
||||
if ~exist(combinedSaveDir, 'dir')
|
||||
mkdir(combinedSaveDir);
|
||||
end
|
||||
|
||||
% --- Loop over datasets to extract mean ± SE ---
|
||||
for i = 1:numel(datasetIdxList)
|
||||
datasetIdx = datasetIdxList(i);
|
||||
datasetName = sprintf('Dataset_%d', datasetIdx);
|
||||
|
||||
% Build paths for this dataset
|
||||
dataFile = fullfile(baseDir, 'SavedData', [datasetName '.mat']);
|
||||
|
||||
% Load dataset
|
||||
data = load(dataFile);
|
||||
datasetStruct = data.(datasetName);
|
||||
|
||||
% Extract values
|
||||
scanVals = datasetStruct.scan_parameter_values;
|
||||
dataVals = datasetStruct.results.spectral_analysis_results.radial_spectral_contrast;
|
||||
|
||||
% --- Compute mean and standard error ---
|
||||
[unique_vals, ~, idx] = unique(scanVals);
|
||||
mean_vals = zeros(size(unique_vals));
|
||||
stderr_vals = zeros(size(unique_vals));
|
||||
for k = 1:length(unique_vals)
|
||||
if iscell(dataVals)
|
||||
group = dataVals{idx == k};
|
||||
else
|
||||
group = dataVals(idx == k);
|
||||
end
|
||||
if iscell(group)
|
||||
groupVals = [group{:}];
|
||||
else
|
||||
groupVals = group;
|
||||
end
|
||||
mean_vals(k) = mean(groupVals);
|
||||
stderr_vals(k) = std(groupVals) / sqrt(length(groupVals));
|
||||
end
|
||||
|
||||
% Store results
|
||||
scanValsCell{i} = unique_vals;
|
||||
meanValsCell{i} = mean_vals;
|
||||
stderrValsCell{i} = stderr_vals;
|
||||
end
|
||||
|
||||
% --- Call compare function ---
|
||||
Plotter.compareMultipleDatasets(scanValsCell, meanValsCell, stderrValsCell, ...
|
||||
'FigNum', 16, ...
|
||||
'FontName', options.font, ...
|
||||
'Labels', labelsCell, ...
|
||||
'Title', 'Radial Spectral Contrast Across Datasets', ...
|
||||
'XLabel', 'B (G)', ...
|
||||
'YLabel', 'Radial Spectral Contrast', ...
|
||||
'SaveDirectory', combinedSaveDir, ...
|
||||
'SaveFileName', 'RadialSpectralContrast_Combined.fig', ...
|
||||
'SkipSaveFigures', false);
|
||||
|
||||
%% ------------------ 2. Compare max g2 across datasets ------------------
|
||||
|
||||
% Prepare storage
|
||||
maxG2ValsCell = cell(1, numel(datasetIdxList));
|
||||
maxG2MeanCell = cell(1, numel(datasetIdxList));
|
||||
maxG2StderrCell = cell(1, numel(datasetIdxList));
|
||||
|
||||
for i = 1:numel(datasetIdxList)
|
||||
datasetIdx = datasetIdxList(i);
|
||||
datasetName = sprintf('Dataset_%d', datasetIdx);
|
||||
|
||||
% Load dataset
|
||||
dataFile = fullfile(baseDir, 'SavedData', [datasetName '.mat']);
|
||||
data = load(dataFile);
|
||||
datasetStruct = data.(datasetName);
|
||||
|
||||
% Extract values
|
||||
scanVals = datasetStruct.scan_parameter_values;
|
||||
dataVals = datasetStruct.results.custom_g_results.max_g2_all_per_scan_parameter_value;
|
||||
|
||||
% --- Compute mean and standard error ---
|
||||
[unique_vals, ~, idx] = unique(scanVals);
|
||||
mean_vals = zeros(size(unique_vals));
|
||||
stderr_vals = zeros(size(unique_vals));
|
||||
for k = 1:length(unique_vals)
|
||||
if iscell(dataVals)
|
||||
group = dataVals{idx == k};
|
||||
else
|
||||
group = dataVals(idx == k);
|
||||
end
|
||||
if iscell(group)
|
||||
groupVals = [group{:}];
|
||||
else
|
||||
groupVals = group;
|
||||
end
|
||||
mean_vals(k) = mean(groupVals);
|
||||
stderr_vals(k) = std(groupVals) / sqrt(length(groupVals));
|
||||
end
|
||||
|
||||
% Store results
|
||||
maxG2ValsCell{i} = unique_vals;
|
||||
maxG2MeanCell{i} = mean_vals;
|
||||
maxG2StderrCell{i} = stderr_vals;
|
||||
end
|
||||
|
||||
% --- Call compare function ---
|
||||
Plotter.compareMultipleDatasets(maxG2ValsCell, maxG2MeanCell, maxG2StderrCell, ...
|
||||
'FigNum', 17, ...
|
||||
'FontName', options.font, ...
|
||||
'Labels', labelsCell, ...
|
||||
'Title', 'Peak Offset Angular Correlation Across Datasets', ...
|
||||
'XLabel', 'B (G)', ...
|
||||
'YLabel', '$\mathrm{max}[g^{(2)}_{[50,70]}(\delta\theta)]$', ...
|
||||
'SaveDirectory', combinedSaveDir, ...
|
||||
'SaveFileName', 'MaxG2_Combined.fig', ...
|
||||
'SkipSaveFigures', false);
|
@ -1,33 +1,44 @@
|
||||
% --- User chooses which dataset to load ---
|
||||
datasetIdx = 1; % <-- change this to 1, 2, 3, ...
|
||||
datasetName = sprintf('Dataset_%d', datasetIdx);
|
||||
%% --- User chooses which dataset to load ---
|
||||
datasetIdx = 1; % <-- change this to 1, 2, 3, ...
|
||||
datasetName = sprintf('Dataset_%d', datasetIdx);
|
||||
|
||||
% Detect the folder where this script is located and set that as the Base Directory
|
||||
thisScriptPath = mfilename('fullpath');
|
||||
[thisScriptDir, ~, ~] = fileparts(thisScriptPath);
|
||||
baseDir = thisScriptDir; % override if needed
|
||||
% --- Base directory selection ---
|
||||
useLocalBaseDir = false; % <-- set true to use script location, false to use manual path
|
||||
|
||||
% Build path to dataset file
|
||||
dataFile = fullfile(baseDir, "Results", "SavedData", datasetName + ".mat");
|
||||
data = load(dataFile);
|
||||
if useLocalBaseDir
|
||||
% Use folder where this script is located
|
||||
thisScriptPath = mfilename('fullpath');
|
||||
[thisScriptDir, ~, ~] = fileparts(thisScriptPath);
|
||||
baseDir = fullfile(thisScriptDir, 'Results');
|
||||
else
|
||||
% Use manually specified folder
|
||||
baseDir = 'E:\Results - Experiment\202507\BECToStripes\';
|
||||
end
|
||||
|
||||
% Access dataset struct dynamically
|
||||
datasetStruct = data.(datasetName);
|
||||
compiled_results = datasetStruct.results;
|
||||
scan_parameter_values = datasetStruct.scan_parameter_values;
|
||||
scan_reference_values = datasetStruct.scan_reference_values;
|
||||
% --- Build paths ---
|
||||
dataFile = fullfile(baseDir, 'SavedData', [datasetName '.mat']);
|
||||
figSaveDir = fullfile(baseDir, 'SavedFigures', datasetName);
|
||||
|
||||
% Load the original options used during analysis
|
||||
options = datasetStruct.options; % exact options used for this dataset
|
||||
options.font = 'Bahnschrift'; % override if needed
|
||||
options.skipSaveFigures = false; % override if needed
|
||||
% --- Load dataset ---
|
||||
data = load(dataFile);
|
||||
|
||||
%% ------------------ Create dataset-specific figure folder ------------------
|
||||
figSaveDir = fullfile(baseDir,'Results', 'SavedFigures', datasetName);
|
||||
% --- Ensure figure folder exists ---
|
||||
if ~exist(figSaveDir, 'dir')
|
||||
mkdir(figSaveDir);
|
||||
end
|
||||
|
||||
% --- Access dataset struct dynamically ---
|
||||
datasetStruct = data.(datasetName);
|
||||
compiled_results = datasetStruct.results;
|
||||
scan_parameter_values = datasetStruct.scan_parameter_values;
|
||||
scan_reference_values = datasetStruct.scan_reference_values;
|
||||
|
||||
% --- Load options used during analysis ---
|
||||
options = datasetStruct.options;
|
||||
options.font = 'Bahnschrift'; % override if needed
|
||||
options.skipSaveFigures = false; % override if needed
|
||||
|
||||
|
||||
%% ------------------ 1. Mean ± Std Plots ------------------
|
||||
% Plot Radial Spectral Contrast
|
||||
Plotter.plotMeanWithSE(scan_parameter_values, compiled_results.spectral_analysis_results.radial_spectral_contrast, ...
|
||||
@ -63,7 +74,76 @@ Plotter.plotMeanWithSE(scan_parameter_values, compiled_results.custom_g_results.
|
||||
'SaveDirectory', figSaveDir, ...
|
||||
'SkipSaveFigures', options.skipSaveFigures);
|
||||
|
||||
%% ------------------ 2. g²(θ) across transition ------------------
|
||||
%% ------------------ 2. PDF of Radial Spectral Contrast across transition ------------------
|
||||
|
||||
% Ensure row vectors
|
||||
contrast = compiled_results.spectral_analysis_results.radial_spectral_contrast(:)';
|
||||
params = scan_parameter_values(:)';
|
||||
reference = scan_reference_values(:)';
|
||||
|
||||
% Preallocate a cell array to hold grouped results
|
||||
grouped_contrast = cell(size(reference)); % 1x21
|
||||
|
||||
% Loop over each unique reference value
|
||||
for i = 1:length(reference)
|
||||
ref_val = reference(i);
|
||||
|
||||
% Find indices where the scan param matches this reference
|
||||
idx = params == ref_val;
|
||||
|
||||
% Store corresponding contrast values
|
||||
grouped_contrast{i} = contrast(idx);
|
||||
end
|
||||
|
||||
Plotter.plotPDF(grouped_contrast, ...
|
||||
scan_reference_values, ...
|
||||
'Title', options.titleString, ...
|
||||
'XLabel', 'B (G)', ...
|
||||
'YLabel', 'Radial Spectral Contrast', ...
|
||||
'FigNum', 4, ...
|
||||
'FontName', options.font, ...
|
||||
'SkipSaveFigures', options.skipSaveFigures, ...
|
||||
'SaveFileName', 'PDF_MaxG2AcrossTransition.fig', ...
|
||||
'SaveDirectory', figSaveDir, ...
|
||||
'NumberOfBins', 20, ...
|
||||
'NormalizeHistogram', true, ...
|
||||
'DataRange', [0 0.1], ...
|
||||
'Colormap', @Colormaps.coolwarm, ...
|
||||
'XLim', [min(scan_reference_values) max(scan_reference_values)]);
|
||||
|
||||
%% ------------------ 3. Cumulants across transition ------------------
|
||||
|
||||
maxOrder = 4; % Set the order of cumulants you want
|
||||
numGroups = length(grouped_contrast);
|
||||
|
||||
% Preallocate matrix to store cumulants
|
||||
% Each row corresponds to a group (i.e., a scan_reference_value)
|
||||
% Each column corresponds to a cumulant order (1 to maxOrder)
|
||||
cumulant_matrix = NaN(numGroups, maxOrder);
|
||||
|
||||
for i = 1:numGroups
|
||||
data_i = grouped_contrast{i};
|
||||
cumulant_matrix(i, :) = Calculator.computeCumulants(data_i, maxOrder);
|
||||
end
|
||||
|
||||
mean_rsc = cumulant_matrix(:, 1);
|
||||
var_rsc = cumulant_matrix(:, 2);
|
||||
skew_rsc = cumulant_matrix(:, 3);
|
||||
binder_rsc = cumulant_matrix(:, 4);
|
||||
|
||||
Plotter.plotCumulants(scan_reference_values, ...
|
||||
{mean_rsc, var_rsc, skew_rsc, binder_rsc}, ...
|
||||
'Title', 'Cumulants of Radial Spectral Contrast', ...
|
||||
'XLabel', 'B (G)', ...
|
||||
'FigNum', 5, ...
|
||||
'FontName', options.font, ...
|
||||
'MarkerSize', 6, ...
|
||||
'LineWidth', 1.5, ...
|
||||
'SkipSaveFigures', options.skipSaveFigures, ...
|
||||
'SaveFileName', 'CumulantOfPeakOffsetAngularCorrelation.fig', ...
|
||||
'SaveDirectory', figSaveDir);
|
||||
|
||||
%% ------------------ 4. g²(θ) across transition ------------------
|
||||
Plotter.plotG2(compiled_results.full_g2_results.g2_mean, ...
|
||||
compiled_results.full_g2_results.g2_error, ...
|
||||
compiled_results.full_g2_results.theta_values, ...
|
||||
@ -72,13 +152,14 @@ Plotter.plotG2(compiled_results.full_g2_results.g2_mean, ...
|
||||
'Title', options.titleString, ...
|
||||
'XLabel', '$\delta\theta / \pi$', ...
|
||||
'YLabel', '$g^{(2)}(\delta\theta)$', ...
|
||||
'FigNum', 4, ...
|
||||
'FigNum', 6, ...
|
||||
'FontName', options.font, ...
|
||||
'SkipSaveFigures', options.skipSaveFigures, ...
|
||||
'SaveFileName', 'G2ThetaAcrossTransition.fig', ...
|
||||
'SaveDirectory', figSaveDir, ...
|
||||
'Colormap', @Colormaps.coolwarm);
|
||||
%% ------------------ 3. Feature extraction of g²(θ) across transition ------------------
|
||||
|
||||
%% ------------------ 5. Feature extraction of g²(θ) across transition ------------------
|
||||
|
||||
Plotter.plotG2Curves(compiled_results.full_g2_results, ...
|
||||
'Title', options.titleString, ...
|
||||
@ -86,7 +167,7 @@ Plotter.plotG2Curves(compiled_results.full_g2_results, ...
|
||||
'YLabel', 'g^{(2)}(\theta)', ...
|
||||
'HighlightEvery', 10, ... % highlight every 10th repetition
|
||||
'FontName', options.font, ...
|
||||
'FigNum', 5, ...
|
||||
'FigNum', 7, ...
|
||||
'TileTitlePrefix', 'B', ... % user-defined tile prefix
|
||||
'TileTitleSuffix', 'G', ... % user-defined suffix (e.g., Gauss symbol)...
|
||||
'SkipSaveFigures', options.skipSaveFigures, ...
|
||||
@ -101,7 +182,7 @@ Plotter.plotG2Features(g2_analysis_results, ...
|
||||
'Title', options.titleString, ...
|
||||
'XLabel', 'B (G)', ...
|
||||
'FontName', options.font, ...
|
||||
'FigNum', 6, ...
|
||||
'FigNum', 8, ...
|
||||
'SkipSaveFigures', options.skipSaveFigures, ...
|
||||
'SaveFileName', 'G2Features.fig', ...
|
||||
'SaveDirectory', figSaveDir);
|
||||
@ -111,18 +192,18 @@ Plotter.plotG2Cumulants(g2_analysis_results, ...
|
||||
'Title', options.titleString, ...
|
||||
'XLabel', 'B (G)', ...
|
||||
'FontName', options.font, ...
|
||||
'FigNum', 7, ...
|
||||
'FigNum', 9, ...
|
||||
'SkipSaveFigures', options.skipSaveFigures, ...
|
||||
'SaveFileName', 'G2Cumulants.fig', ...
|
||||
'SaveDirectory', figSaveDir);
|
||||
|
||||
%% ------------------ 4. PDF of max g² across transition ------------------
|
||||
%% ------------------ 6. PDF of max g² across transition ------------------
|
||||
Plotter.plotPDF(compiled_results.custom_g_results.max_g2_all_per_scan_parameter_value, ...
|
||||
scan_reference_values, ...
|
||||
'Title', options.titleString, ...
|
||||
'XLabel', 'B (G)', ...
|
||||
'YLabel', '$\mathrm{max}[g^{(2)}]$', ...
|
||||
'FigNum', 8, ...
|
||||
'FigNum', 10, ...
|
||||
'FontName', options.font, ...
|
||||
'SkipSaveFigures', options.skipSaveFigures, ...
|
||||
'SaveFileName', 'PDF_MaxG2AcrossTransition.fig', ...
|
||||
@ -134,12 +215,12 @@ Plotter.plotPDF(compiled_results.custom_g_results.max_g2_all_per_scan_parameter_
|
||||
'XLim', [min(scan_reference_values) max(scan_reference_values)]);
|
||||
|
||||
|
||||
%% ------------------ 5. Cumulants across transition ------------------
|
||||
%% ------------------ 7. Cumulants across transition ------------------
|
||||
Plotter.plotCumulants(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', 9, ...
|
||||
'FigNum', 11, ...
|
||||
'FontName', options.font, ...
|
||||
'MarkerSize', 6, ...
|
||||
'LineWidth', 1.5, ...
|
||||
@ -147,15 +228,13 @@ Plotter.plotCumulants(scan_reference_values, ...
|
||||
'SaveFileName', 'CumulantOfPeakOffsetAngularCorrelation.fig', ...
|
||||
'SaveDirectory', figSaveDir);
|
||||
|
||||
%% ------------------ 6. PCA ------------------
|
||||
%% ------------------ 8. PCA ------------------
|
||||
Plotter.plotPCAResults(compiled_results.pca_results, scan_parameter_values, scan_reference_values, ...
|
||||
'FigNumRange', [10,11,12,13,14,15], ...
|
||||
'FigNumRange', [12,13,14,15,16,17], ...
|
||||
'FontName', options.font, ...
|
||||
'SkipSaveFigures', options.skipSaveFigures, ...
|
||||
'SaveDirectory', figSaveDir);
|
||||
|
||||
|
||||
|
||||
%%
|
||||
%{
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
%% ===== BEC-Droplets Settings =====
|
||||
%% ===== BEC-Stripes 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
|
||||
'date', '2025/07/26', ...
|
||||
'runs', [8]) % 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/202508';
|
||||
options.FullODImagesFolder = 'E:/Data - Experiment/FullODImages/202507';
|
||||
options.measurementName = 'BECToStripes';
|
||||
scriptFullPath = mfilename('fullpath');
|
||||
options.saveDirectory = fileparts(scriptFullPath);
|
||||
@ -23,7 +23,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 = 24.6;
|
||||
options.magnification = 23.94;
|
||||
options.ImagingMode = 'HighIntensity';
|
||||
options.PulseDuration = 5e-6; % in s
|
||||
|
||||
|
@ -1,33 +1,43 @@
|
||||
% --- User chooses which dataset to load ---
|
||||
datasetIdx = 6; % <-- change this to 1, 2, 3, ...
|
||||
datasetName = sprintf('Dataset_%d', datasetIdx);
|
||||
%% --- User chooses which dataset to load ---
|
||||
datasetIdx = 1; % <-- change this to 1, 2, 3, ...
|
||||
datasetName = sprintf('Dataset_%d', datasetIdx);
|
||||
|
||||
% Detect the folder where this script is located and set that as the Base Directory
|
||||
thisScriptPath = mfilename('fullpath');
|
||||
[thisScriptDir, ~, ~] = fileparts(thisScriptPath);
|
||||
baseDir = thisScriptDir; % override if needed
|
||||
% --- Base directory selection ---
|
||||
useLocalBaseDir = false; % <-- set true to use script location, false to use manual path
|
||||
|
||||
% Build path to dataset file
|
||||
dataFile = fullfile(baseDir, "Results", "SavedData", datasetName + ".mat");
|
||||
data = load(dataFile);
|
||||
if useLocalBaseDir
|
||||
% Use folder where this script is located
|
||||
thisScriptPath = mfilename('fullpath');
|
||||
[thisScriptDir, ~, ~] = fileparts(thisScriptPath);
|
||||
baseDir = fullfile(thisScriptDir, 'Results');
|
||||
else
|
||||
% Use manually specified folder
|
||||
baseDir = 'E:\Results - Experiment\202508\BECToStripesToDroplets\';
|
||||
end
|
||||
|
||||
% Access dataset struct dynamically
|
||||
datasetStruct = data.(datasetName);
|
||||
compiled_results = datasetStruct.results;
|
||||
scan_parameter_values = datasetStruct.scan_parameter_values;
|
||||
scan_reference_values = datasetStruct.scan_reference_values;
|
||||
% --- Build paths ---
|
||||
dataFile = fullfile(baseDir, 'SavedData', [datasetName '.mat']);
|
||||
figSaveDir = fullfile(baseDir, 'SavedFigures', datasetName);
|
||||
|
||||
% Load the original options used during analysis
|
||||
options = datasetStruct.options; % exact options used for this dataset
|
||||
options.font = 'Bahnschrift'; % override if needed
|
||||
options.skipSaveFigures = false; % override if needed
|
||||
% --- Load dataset ---
|
||||
data = load(dataFile);
|
||||
|
||||
%% ------------------ Create dataset-specific figure folder ------------------
|
||||
figSaveDir = fullfile(baseDir,'Results', 'SavedFigures', datasetName);
|
||||
% --- Ensure figure folder exists ---
|
||||
if ~exist(figSaveDir, 'dir')
|
||||
mkdir(figSaveDir);
|
||||
end
|
||||
|
||||
% --- Access dataset struct dynamically ---
|
||||
datasetStruct = data.(datasetName);
|
||||
compiled_results = datasetStruct.results;
|
||||
scan_parameter_values = datasetStruct.scan_parameter_values;
|
||||
scan_reference_values = datasetStruct.scan_reference_values;
|
||||
|
||||
% --- Load options used during analysis ---
|
||||
options = datasetStruct.options;
|
||||
options.font = 'Bahnschrift'; % override if needed
|
||||
options.skipSaveFigures = false; % override if needed
|
||||
|
||||
%% ------------------ 1. Mean ± Std Plots ------------------
|
||||
% Plot Radial Spectral Contrast
|
||||
Plotter.plotMeanWithSE(scan_parameter_values, compiled_results.spectral_analysis_results.radial_spectral_contrast, ...
|
||||
@ -146,6 +156,9 @@ Plotter.plotCumulants(scan_reference_values, ...
|
||||
'SaveFileName', 'CumulantOfPeakOffsetAngularCorrelation.fig', ...
|
||||
'SaveDirectory', figSaveDir);
|
||||
|
||||
%%
|
||||
%{
|
||||
|
||||
%% ------------------ 6. PCA ------------------
|
||||
Plotter.plotPCAResults(compiled_results.pca_results, scan_parameter_values, scan_reference_values, ...
|
||||
'FigNumRange', [10,11,12,13,14,15], ...
|
||||
@ -153,10 +166,7 @@ Plotter.plotPCAResults(compiled_results.pca_results, scan_parameter_values, scan
|
||||
'SkipSaveFigures', options.skipSaveFigures, ...
|
||||
'SaveDirectory', figSaveDir);
|
||||
|
||||
%%
|
||||
%{
|
||||
|
||||
%% ------------------ 6. Average of Spectra Plots ------------------
|
||||
%% ------------------ 7. Average of Spectra Plots ------------------
|
||||
|
||||
Plotter.plotAverageSpectra(scan_parameter_values, ...
|
||||
spectral_analysis_results, ...
|
||||
@ -168,7 +178,7 @@ Plotter.plotAverageSpectra(scan_parameter_values, ...
|
||||
'SaveDirectory', figSaveDir, ...
|
||||
'SkipSaveFigures', options.skipSaveFigures);
|
||||
|
||||
%% ------------------ 7. Compare quantities ------------------
|
||||
%% ------------------ 8. Compare quantities ------------------
|
||||
% Load Droplets → Stripes data
|
||||
Data = load(dtsFile, ...
|
||||
'unique_scan_parameter_values', ...
|
||||
@ -208,7 +218,7 @@ compareMultipleDatasets(scanValsCell, meanValsCell, stderrValsCell, ...
|
||||
'SaveDirectory', figSaveDir, ...
|
||||
'SaveFileName', 'AngularCorrelation_Comparison.fig');
|
||||
|
||||
%% ------------------ 8. Heatmaps ------------------
|
||||
%% ------------------ 9. Heatmaps ------------------
|
||||
|
||||
BFields = [2.35, 2.15, 2.0, 1.85, 1.7, 1.55, 1.4, 1.35];
|
||||
|
||||
|
@ -0,0 +1,147 @@
|
||||
%% ------------------ 1. Compare radial spectral contrast across datasets ------------------
|
||||
datasetIdxList = 1:6;
|
||||
|
||||
% --- Base directory selection ---
|
||||
useLocalBaseDir = false; % <-- set true to use script location, false to use manual path
|
||||
|
||||
if useLocalBaseDir
|
||||
% Use folder where this script is located
|
||||
thisScriptPath = mfilename('fullpath');
|
||||
[thisScriptDir, ~, ~] = fileparts(thisScriptPath);
|
||||
baseDir = fullfile(thisScriptDir, 'Results');
|
||||
else
|
||||
% Use manually specified folder
|
||||
baseDir = 'E:\Results - Experiment\202508\BECToDropletsToStripes\';
|
||||
end
|
||||
|
||||
% Prepare storage
|
||||
scanValsCell = cell(1, numel(datasetIdxList));
|
||||
meanValsCell = cell(1, numel(datasetIdxList));
|
||||
stderrValsCell = cell(1, numel(datasetIdxList));
|
||||
labelsCell = {'2.25 G', '2.20 G', '2.15 G', '2.10 G', '2.05 G', '2.00 G'};
|
||||
|
||||
% --- Load options from first dataset to set plotting defaults ---
|
||||
datasetIdx = datasetIdxList(1);
|
||||
datasetName = sprintf('Dataset_%d', datasetIdx);
|
||||
dataFile = fullfile(baseDir, 'SavedData', [datasetName '.mat']);
|
||||
data = load(dataFile);
|
||||
datasetStruct = data.(datasetName);
|
||||
options = datasetStruct.options;
|
||||
options.font = 'Bahnschrift';
|
||||
options.skipSaveFigures = false;
|
||||
|
||||
% --- Ensure combined figure folder exists ---
|
||||
combinedSaveDir = fullfile(baseDir, 'SavedFigures', 'Combined');
|
||||
if ~exist(combinedSaveDir, 'dir')
|
||||
mkdir(combinedSaveDir);
|
||||
end
|
||||
|
||||
% --- Loop over datasets to extract mean ± SE ---
|
||||
for i = 1:numel(datasetIdxList)
|
||||
datasetIdx = datasetIdxList(i);
|
||||
datasetName = sprintf('Dataset_%d', datasetIdx);
|
||||
|
||||
% Build paths for this dataset
|
||||
dataFile = fullfile(baseDir, 'SavedData', [datasetName '.mat']);
|
||||
|
||||
% Load dataset
|
||||
data = load(dataFile);
|
||||
datasetStruct = data.(datasetName);
|
||||
|
||||
% Extract values
|
||||
scanVals = datasetStruct.scan_parameter_values;
|
||||
dataVals = datasetStruct.results.spectral_analysis_results.radial_spectral_contrast;
|
||||
|
||||
% --- Compute mean and standard error ---
|
||||
[unique_vals, ~, idx] = unique(scanVals);
|
||||
mean_vals = zeros(size(unique_vals));
|
||||
stderr_vals = zeros(size(unique_vals));
|
||||
for k = 1:length(unique_vals)
|
||||
if iscell(dataVals)
|
||||
group = dataVals{idx == k};
|
||||
else
|
||||
group = dataVals(idx == k);
|
||||
end
|
||||
if iscell(group)
|
||||
groupVals = [group{:}];
|
||||
else
|
||||
groupVals = group;
|
||||
end
|
||||
mean_vals(k) = mean(groupVals);
|
||||
stderr_vals(k) = std(groupVals) / sqrt(length(groupVals));
|
||||
end
|
||||
|
||||
% Store results
|
||||
scanValsCell{i} = unique_vals;
|
||||
meanValsCell{i} = mean_vals;
|
||||
stderrValsCell{i} = stderr_vals;
|
||||
end
|
||||
|
||||
% --- Call compare function ---
|
||||
Plotter.compareMultipleDatasets(scanValsCell, meanValsCell, stderrValsCell, ...
|
||||
'FigNum', 16, ...
|
||||
'FontName', options.font, ...
|
||||
'Labels', labelsCell, ...
|
||||
'Title', 'Radial Spectral Contrast Across Datasets', ...
|
||||
'XLabel', 'B (G)', ...
|
||||
'YLabel', 'Radial Spectral Contrast', ...
|
||||
'SaveDirectory', combinedSaveDir, ...
|
||||
'SaveFileName', 'RadialSpectralContrast_Combined.fig', ...
|
||||
'SkipSaveFigures', false);
|
||||
|
||||
%% ------------------ 2. Compare max g2 across datasets ------------------
|
||||
|
||||
% Prepare storage
|
||||
maxG2ValsCell = cell(1, numel(datasetIdxList));
|
||||
maxG2MeanCell = cell(1, numel(datasetIdxList));
|
||||
maxG2StderrCell = cell(1, numel(datasetIdxList));
|
||||
|
||||
for i = 1:numel(datasetIdxList)
|
||||
datasetIdx = datasetIdxList(i);
|
||||
datasetName = sprintf('Dataset_%d', datasetIdx);
|
||||
|
||||
% Load dataset
|
||||
dataFile = fullfile(baseDir, 'SavedData', [datasetName '.mat']);
|
||||
data = load(dataFile);
|
||||
datasetStruct = data.(datasetName);
|
||||
|
||||
% Extract values
|
||||
scanVals = datasetStruct.scan_parameter_values;
|
||||
dataVals = datasetStruct.results.custom_g_results.max_g2_all_per_scan_parameter_value;
|
||||
|
||||
% --- Compute mean and standard error ---
|
||||
[unique_vals, ~, idx] = unique(scanVals);
|
||||
mean_vals = zeros(size(unique_vals));
|
||||
stderr_vals = zeros(size(unique_vals));
|
||||
for k = 1:length(unique_vals)
|
||||
if iscell(dataVals)
|
||||
group = dataVals{idx == k};
|
||||
else
|
||||
group = dataVals(idx == k);
|
||||
end
|
||||
if iscell(group)
|
||||
groupVals = [group{:}];
|
||||
else
|
||||
groupVals = group;
|
||||
end
|
||||
mean_vals(k) = mean(groupVals);
|
||||
stderr_vals(k) = std(groupVals) / sqrt(length(groupVals));
|
||||
end
|
||||
|
||||
% Store results
|
||||
maxG2ValsCell{i} = unique_vals;
|
||||
maxG2MeanCell{i} = mean_vals;
|
||||
maxG2StderrCell{i} = stderr_vals;
|
||||
end
|
||||
|
||||
% --- Call compare function ---
|
||||
Plotter.compareMultipleDatasets(maxG2ValsCell, maxG2MeanCell, maxG2StderrCell, ...
|
||||
'FigNum', 17, ...
|
||||
'FontName', options.font, ...
|
||||
'Labels', labelsCell, ...
|
||||
'Title', 'Peak Offset Angular Correlation Across Datasets', ...
|
||||
'XLabel', 'B (G)', ...
|
||||
'YLabel', '$\mathrm{max}[g^{(2)}_{[50,70]}(\delta\theta)]$', ...
|
||||
'SaveDirectory', combinedSaveDir, ...
|
||||
'SaveFileName', 'MaxG2_Combined.fig', ...
|
||||
'SkipSaveFigures', false);
|
Loading…
Reference in New Issue
Block a user