-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport_group_models.m
More file actions
263 lines (208 loc) · 7.66 KB
/
Copy pathreport_group_models.m
File metadata and controls
263 lines (208 loc) · 7.66 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
function [] = report_group_models(group_efp, metric, ...
R, prob, pval, path_img_out, path_pars)
%
% [] = report_group_models(group_models, metric, ...
% R, prob, report, path_img_out) plots and saves the
% group-level tstat profiles (thresholded and
% unthresholded) in the form of topographic maps
% or bar graphs
%
% Inputs:
%
% group_models the group correlation/model values
% metric the current EEG-BOLD metric
% R the report object
% prob the probability of topographic
% consistency
% pval the p-value of topographic consistency
% path_img_out path where plots are to be saved
%
import mlreportgen.dom.*;
import mlreportgen.report.*;
% Get the parameters for
% the current metric
get_metric_pars;
% -------------------------------------------------
% Compute measures
% -------------------------------------------------
group_efp = group_efp';
efp_avg = mean(group_efp);
efp_std = std(group_efp);
% Figure settings
ax = gca;outerpos = ax.OuterPosition;ti = ax.TightInset;
left = outerpos(1) + ti(1); bottom = outerpos(2) + ti(2);
ax_width = outerpos(3) - ti(1) - ti(3);
ax_height = outerpos(4) - ti(2) - ti(4);
ax.Position = [left bottom ax_width ax_height];
% Write default settings for topoplot
topo_settings = {'electrodes', 'labels', ...
'conv', 'on', 'whitebk', ...
'on', 'gridscale', 100};
% -------------------------------------------------
% Channel profiles - report
% -------------------------------------------------
% Minimum and maximum intensity values
min_val = min(min(min(efp_avg)));
min_int = min_val;
max_val = max(max(max(efp_avg)));
max_int = max_val;
int = max(abs(min_int), abs(max_int));
% Write report title for each t
my_title = ["Average Coefficient Estimates", ...
"Standard Deviation of Coefficient Estimates"];
% Write topoplot tags for each t
topo_out = ["EFP_AVG", "EFP_STD"];
for t = 1 : 2
if t == 1
efp = squeeze(efp_avg);
elseif t == 2
efp = squeeze(efp_std);
end
efp = reshape(efp, dim);
H3 = get_report_heading(3, my_title(t));
add(R,H3);
% only one band
% only one delay
if n_bands == 1 && n_delays == 1
% Create figure
% current band
fig = figure();
%Increase your figure pixel resolution
fig.Position(3:4) = fig.Position(3:4)*5;
% Specify signal for plotting
signal = squeeze(efp(:, 1, 1));
topoplot(signal, chanlocs, topo_settings{:});
colorbar; caxis([-int int]);
img_out = strcat(metric,'_',...
topo_out(t), '.png');
source = fullfile(path_img_out, img_out);
saveas(fig, source);
I = FormalImage(source);
I.ScaleToFit=true; add(R, I);
% only one band
% many delays
elseif n_bands == 1
% For the report
subp_rows = 2;
subp_cols = n_delays/subp_rows;
% Create title for current band
H4 = get_report_heading(4, upper(id_bands));
add(R, H4);
% Create figure
% current band
fig = figure();
%Increase your figure pixel resolution
fig.Position(3:4) = fig.Position(3:4)*5;
for d = 1 : n_delays
% Specify signal for plotting
signal = squeeze(efp(:, d, 1));
% Plots for the report
subplot(subp_rows, subp_cols, d);
title(strcat(id_delays(d), ' SECONDS'));
topoplot(signal, chanlocs, topo_settings{:});
colorbar; caxis([-int int]);
end % finish looping through delays
% Generate caption string
my_cap = "";
for d = 1 : n_delays
my_cap = strjoin(cat(2, my_cap, strcat(" ", ...
id_delays(d), ' seconds -', " ", ...
num2str(prob(d,1)),'%; (p-value =', ...
" ", num2str(pval(d,1)), ')')));
end
my_cap = strcat('Probability of',...
' significance:', my_cap);
img_out = strcat(metric, '_', ...
'alldelays_', topo_out(t), '.png');
source = fullfile(path_img_out, img_out);
saveas(fig, source); I = FormalImage(source);
I.ScaleToFit=true;
I.Caption = my_cap;
add(R,I);
% only one delay
% many bands
elseif n_delays == 1
% For the report
subp_rows = 2;
subp_cols = n_bands/subp_rows;
% Create figure
% current band
fig = figure();
%Increase your figure pixel resolution
fig.Position(3:4) = fig.Position(3:4)*5;
for b = 1 : n_bands
% Specify signal for plotting
signal = squeeze(efp(:, 1, b));
% Plots for the report
subplot(subp_rows, subp_cols, b);
title(upper(id_bands(b)));
topoplot(signal, chanlocs, topo_settings{:});
colorbar; caxis([-int int]);
end
% Generate caption strings
my_cap ="";
for b = 1 : n_bands
my_cap=strjoin(cat(2,my_cap, strcat(" ", ...
id_bands(b), ' band -'," ", ...
num2str(prob(1,b)), '% (p-value = ;', ...
" ", num2str(pval(1,b)), ')')));
end
my_cap = strcat('Probability of',...
' significance:', my_cap);
img_out = strcat(metric, '_',...
'allbands_', topo_out(t), '.png');
source = fullfile(path_img_out, img_out);
saveas(fig, source); I = FormalImage(source);
I.ScaleToFit=true;
I.Caption = my_cap;
add(R, I);
% many delays
% many bands
else
% Initialize the band index
% For models with more then 4,
% bands, don't plot delta and
% theta correlations
if n_bands > 5; b1 = 3;
else; b1 = 1; end
% For the report
subp_rows = 2;
subp_cols = n_delays/subp_rows;
for b = b1 : n_bands
% Create title for current band
H4 = get_report_heading(4, upper(id_bands(b)));
add(R, H4);
% Create figure
% current band
fig = figure();
%Increase your figure pixel resolution
fig.Position(3:4) = fig.Position(3:4)*5;
for d = 1 : n_delays
% Specify signal for plotting
signal = squeeze(efp(:, d, b));
% Plots for the report
subplot(subp_rows, subp_cols, d);
title(strcat(id_delays(d), ' SECONDS'));
topoplot(signal, chanlocs, topo_settings{:});
colorbar; caxis([-int int]);
end % finish looping through delays
% Generate caption strings
my_cap ="";
for d = 1 : n_delays
my_cap=strjoin(cat(2, my_cap, strcat(" ", ...
id_delays(d), ' seconds -', " ", ...
num2str(prob(d,b)), '%; (p-value =', ...
" ", num2str(pval(d,b)), ')')));
end
my_cap = strcat('Probability of',...
' significance:', my_cap);
img_out = strcat(metric, '_', ...
id_bands(b), '_', topo_out(t), '.png');
source = fullfile(path_img_out, img_out);
saveas(fig, source); I = FormalImage(source);
I.ScaleToFit=true;
I.Caption = my_cap;
add(R,I);
end % finish looping through bands
end
end % finish looping through types of maps