-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathreport_results.m
259 lines (240 loc) · 13.3 KB
/
report_results.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
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
%Summarize results of F-test at the command window
%
%EXAMPLE USAGE
% >> report_results(GND, 1)
%
%REQUIRED INPUTS
% GND - A GND or GRP variable with F-test results
% test_id - The test number of the results to report within the GND or
% GRP variable
%
%VERSION DATE: 14 July 2017
%AUTHOR: Eric Fields
%
%NOTE: This function is provided "as is" and any express or implied warranties
%are disclaimed.
%Copyright (c) 2017, Eric Fields
%All rights reserved.
%This code is free and open source software made available under the 3-clause BSD license.
function report_results(GND, test_id)
switch GND.F_tests(test_id).mult_comp_method
case 'Fmax perm test'
report_Fmax(GND, test_id)
case 'cluster mass perm test'
report_clust(GND, test_id)
otherwise
if any(strcmpi(GND.F_tests(test_id), {'bh', 'by', 'bky'}))
report_fdr(GND, test_id)
end
end
end
function report_Fmax(GND, test_id)
results = GND.F_tests(test_id);
[effects, effects_labels] = get_effects(results.factors);
if isstruct(results.F_obs)
assert(all(strcmpi(fieldnames(results.F_obs), effects_labels)))
end
fprintf('\n##### RESULTS #####\n');
for i = 1:length(effects)
fprintf('\n%s effect\n', effects_labels{i});
if length(effects) == 1
if any(results.null_test(:))
fprintf('Critical F-value: %.3f\n', results.F_crit);
fprintf('That corresponds to a test-wise alpha level of %.3f.\n', ...
fcdf(results.F_crit, results.df(1), results.df(2), 'upper'));
if strcmpi(results.mean_wind, 'yes') || strcmpi(results.mean_wind, 'y')
for t = 1:size(results.time_wind, 1)
fprintf('Significant electrodes for time window %d - %d: ', results.time_wind(t, 1), results.time_wind(t, 2));
fprintf('%s ', results.include_chans{results.null_test(:, t)});
fprintf('\n');
end
else
fprintf('Electrodes and time points with significant effects:\n');
for t = 1:length(results.used_tpt_ids)
if any(results.null_test(:, t))
fprintf('%d ms, electrode(s): ', GND.time_pts(results.used_tpt_ids(t)));
fprintf('%s ', results.include_chans{results.null_test(:, t)});
fprintf('\n');
end
end
end
fprintf('All significant corrected p-values are between %f and %f.\n', ...
max(results.adj_pval(results.adj_pval <= .05)), ...
min(results.adj_pval(:)));
else
fprintf('NO significant time points or electrodes.\n');
end
else
if any(results.null_test.(effects_labels{i})(:))
fprintf('Critical F-value: %.3f\n', results.F_crit.(effects_labels{i}));
fprintf('That corresponds to a test-wise alpha level of %.3f.\n', ...
fcdf(results.F_crit.(effects_labels{i}), results.df.(effects_labels{i})(1), results.df.(effects_labels{i})(2), 'upper'));
if strcmpi(results.mean_wind, 'yes') || strcmpi(results.mean_wind, 'y')
for t = 1:size(results.time_wind, 1)
fprintf('Significant electrodes for time windonw %d - %d: ', results.time_wind(t, 1), results.time_wind(t, 2));
fprintf('%s ', results.include_chans{results.null_test.(effects_labels{i})(:, t)});
fprintf('\n');
end
else
fprintf('Electrodes and time points with significant effects:\n');
for t = 1:length(results.used_tpt_ids)
if any(results.null_test.(effects_labels{i})(:, t))
fprintf('%d ms, electrode(s): ', GND.time_pts(results.used_tpt_ids(t)));
fprintf('%s ', results.include_chans{results.null_test.(effects_labels{i})(:, t)});
fprintf('\n');
end
end
end
fprintf('All significant corrected p-values are between %f and %f.\n', ...
max(results.adj_pval.(effects_labels{i})(results.adj_pval.(effects_labels{i}) <= .05)), ...
min(results.adj_pval.(effects_labels{i})(:)));
else
fprintf('NO significant time points or electrodes.\n');
end
end
end
end
function report_clust(GND, test_id)
results = GND.F_tests(test_id);
[effects, effects_labels] = get_effects(results.factors);
if isstruct(results.F_obs)
assert(all(strcmpi(fieldnames(results.F_obs), effects_labels)))
end
fprintf('\n##### RESULTS #####\n\n');
if length(effects) == 1
fprintf('%s effect\n', effects_labels{1});
fprintf('# of clusters found: %d\n', length(results.clust_info.null_test));
fprintf('# of significant clusters found: %d\n', sum(results.clust_info.null_test));
if sum(results.clust_info.null_test)
fprintf('Significant cluster p-values range from %f to %f.\n', ...
max(results.clust_info.pval(results.clust_info.null_test)), ...
min(results.clust_info.pval(results.clust_info.null_test)));
if strcmpi(results.mean_wind, 'yes') || strcmpi(results.mean_wind, 'y')
for t = 1:size(results.time_wind, 1)
fprintf('Electrodes in a significant cluster for time window %d - %d: ', results.time_wind(t, 1), results.time_wind(t, 2));
fprintf('%s ', results.include_chans{results.null_test(:, t)});
fprintf('\n');
end
fprintf('\n');
else
fprintf('Electrodes and time points included in a significant cluster:\n');
for t = 1:length(results.used_tpt_ids)
if any(results.null_test(:, t))
fprintf('%d ms, electrode(s): ', GND.time_pts(results.used_tpt_ids(t)));
fprintf('%s ', results.include_chans{results.null_test(:, t)});
fprintf('\n');
end
end
fprintf('\n');
end
else
fprintf('All p-values >= %f\n\n', min(results.clust_info.pval));
end
else
for i = 1:length(effects)
fprintf('%s effect\n', effects_labels{i});
fprintf('# of clusters found: %d\n', length(results.clust_info.(effects_labels{i}).null_test));
fprintf('# of significant clusters found: %d\n', sum(results.clust_info.(effects_labels{i}).null_test));
if sum(results.clust_info.(effects_labels{i}).null_test)
fprintf('Significant cluster p-values range from %f to %f.\n', ...
max(results.clust_info.(effects_labels{i}).pval(results.clust_info.(effects_labels{i}).null_test)), ...
min(results.clust_info.(effects_labels{i}).pval(results.clust_info.(effects_labels{i}).null_test)));
if strcmpi(results.mean_wind, 'yes') || strcmpi(results.mean_wind, 'y')
for t = 1:size(results.time_wind, 1)
fprintf('Electrodes in a significant cluster for time window %d - %d: ', results.time_wind(t, 1), results.time_wind(t, 2));
fprintf('%s ', results.include_chans{results.null_test.(effects_labels{i})(:, t)});
fprintf('\n');
end
fprintf('\n');
else
fprintf('Electrodes and time points included in a significant cluster:\n');
for t = 1:length(results.used_tpt_ids)
if any(results.null_test.(effects_labels{i})(:, t))
fprintf('%d ms, electrode(s): ', GND.time_pts(results.used_tpt_ids(t)));
fprintf('%s ', results.include_chans{results.null_test.(effects_labels{i})(:, t)});
fprintf('\n');
end
end
fprintf('\n');
end
else
fprintf('All p-values >= %f.\n\n', min(results.clust_info.(effects_labels{i}).pval));
end
end
end
end
function report_fdr(GND, test_id)
results = GND.F_tests(test_id);
[effects, effects_labels] = get_effects(results.factors);
if isstruct(results.F_obs)
assert(all(strcmpi(fieldnames(results.F_obs), effects_labels)))
end
fprintf('\n##### RESULTS #####\n');
if length(effects) == 1
fprintf('\n%s effect\n', effects_labels{1});
if any(results.null_test(:))
fprintf('Critical F-value: %.3f\n', results.F_crit);
fprintf('That corresponds to a test-wise alpha level of %.3f.\n', ...
fcdf(results.F_crit, results.df(1), results.df(2), 'upper'));
fprintf('Total number of significant differences: %d\n', sum(results.null_test(:)));
fprintf('Estimated upper bound on expected number of false discoveries: %.1f.\n', sum(results.null_test(:))*q);
if strcmpi(results.mean_wind, 'yes') || strcmpi(results.mean_wind, 'y')
for t = 1:size(results.time_wind, 1)
fprintf('Significant electrodes for time window %d - %d: ', results.time_wind(t, 1), results.time_wind(t, 2));
fprintf('%s ', results.include_chans{results.null_test(:, t)});
fprintf('\n');
end
else
fprintf('Electrodes and time points with significant effects:\n');
for t = 1:length(results.used_tpt_ids)
if any(results.null_test(:, t))
fprintf('%d ms, electrode(s): ', GND.time_pts(results.used_tpt_ids(t)));
fprintf('%s ', results.include_chans{results.null_test(:, t)});
fprintf('\n');
end
end
end
if ~strcmpi(method, 'bky')
fprintf('All significant corrected p-values are between %f and %f.\n', ...
max(results.adj_pval(results.adj_pval <= .05)), ...
min(results.adj_pval(:)));
end
else
fprintf('NO significant time points or electrodes.\n\n');
end
else
for i = 1:length(effects)
fprintf('\n%s effect\n', effects_labels{i});
if any(results.null_test.(effects_labels{i})(:))
fprintf('Critical F-value: %.3f\n', results.F_crit.(effects_labels{i}));
fprintf('That corresponds to a test-wise alpha level of %.3f.\n', ...
fcdf(results.F_crit.(effects_labels{i}), results.df.(effects_labels{i})(1), results.df.(effects_labels{i})(2), 'upper'));
fprintf('Total number of significant differences: %d\n', sum(results.null_test.(effects_labels{i})(:)));
fprintf('Estimated upper bound on expected number of false discoveries: %.1f\n', sum(results.null_test.(effects_labels{i})(:))*q);
if strcmpi(results.mean_wind, 'yes') || strcmpi(results.mean_wind, 'y')
for t = 1:size(results.time_wind, 1)
fprintf('Significant electrodes for time windonw %d - %d: ', results.time_wind(t, 1), results.time_wind(t, 2));
fprintf('%s ', results.include_chans{results.null_test.(effects_labels{i})(:, t)});
fprintf('\n');
end
else
fprintf('Electrodes and time points with significant effects:\n');
for t = 1:length(results.used_tpt_ids)
if any(results.null_test.(effects_labels{i})(:, t))
fprintf('%d ms, electrode(s): ', GND.time_pts(results.used_tpt_ids(t)));
fprintf('%s ', results.include_chans{results.null_test.(effects_labels{i})(:, t)});
fprintf('\n');
end
end
end
if ~strcmpi(method, 'bky')
fprintf('All significant corrected p-values are between %f and %f.\n', ...
max(results.adj_pval.(effects_labels{i})(results.adj_pval.(effects_labels{i}) <= .05)), ...
min(results.adj_pval.(effects_labels{i})(:)));
end
else
fprintf('NO significant time points or electrodes.\n\n');
end
end
end
end