-
Notifications
You must be signed in to change notification settings - Fork 0
/
apply_calibration_coefficients.m
106 lines (84 loc) · 3.09 KB
/
apply_calibration_coefficients.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
function apply_calibration_coefficients(directories, parameters, image_type, run_name, save_inst, num_images, Cs)
% apply_calibration_coefficients Concentration statistics - MEAN and instantaneous.
%
% Syntax: apply_calibration_coefficients(directories, parameters, run_name, save_inst, num_images, Cs, use_complex_background)
%
% Inputs:
% directories
% parameters
% image_type
% run_name
% save_inst
% num_images
% Cs
% use_complex_background
%
% Ouputs:
% -
%
% Example:
% -
%
% See also: -
%
% Other m-files required: none
% Subfunctions: none
% MAT-files required: none
% Other files required: none
if ~exist(directories.folder_save, 'dir')
mkdir(directories.folder_save)
end
fsep = filesep;
load(strcat(directories.folder_save, fsep, 'C-Calib-dyecal.mat'), 'background_frame', 'A_cal');
load(strcat(directories.folder_save, fsep, 'geometric_scale.mat'), 'xy_scale', 'xy_offset');
% If we've already calculated the stats, then retreive from file. Otherwise
% calculate the properties. The things we want are kept in the AC struct.
stats_filename = strcat(directories.folder_save, run_name, '_PLIFstats.mat');
if exist(stats_filename, 'file')
load(stats_filename, 'AC');
else
mean_C = 0;
for i = 1:num_images
PLIF = get_plif_image(i, directories, image_type, background_frame, A_cal, Cs, xy_scale, xy_offset, ...
parameters.x0, parameters.y0, parameters.normalize_energy_monitor);
mean_C = mean_C + PLIF.C;
end
AC.mean_C = mean_C ./ num_images;
% Now we calculate the variance
variance_C = 0;
for i = 1:num_images
PLIF = get_plif_image(i, directories, image_type, background_frame, A_cal, Cs, xy_scale, ...
xy_offset, parameters.x0, parameters.y0, parameters.normalize_energy_monitor);
variance_C = variance_C + (PLIF.C - AC.mean_C).^2.0;
if save_inst == true
AC_frame.X = PLIF.X;
AC_frame.Y = PLIF.Y;
AC_frame.C = PLIF.C;
AC_frame.cc = (PLIF.C - AC.mean_C).^2.0;
save(strcat(directories.folder_save, fsep, run_name, '_PLIF_', num2str(i), '.mat'), 'AC_frame');
end
end
AC.variance_C = variance_C ./ (num_images - 1);
AC.X = PLIF.X;
AC.Y = PLIF.Y;
save(strcat(directories.folder_save, fsep, run_name, '_PLIFstats.mat'), 'AC')
end
% Plot the average
figure(1);
clf(1);
imagesc(AC.X, AC.Y, log10(AC.mean_C'));
colorbar;
axis equal tight;
clim([-6 -1])
set(gca, 'YDir', 'normal');
%saveas(gca, strcat(directories.folder_save, fsep, run_name, '_mean_C.png'));
% Plot the variance
figure(2);
clf(2);
imagesc(AC.X, AC.Y, log10(AC.variance_C'));
colorbar;
axis equal tight;
clim([-12 -4])
set(gca, 'YDir', 'normal');
%saveas(gca, strcat(directories.folder_save, fsep, run_name, '_variance_C.png'));
end