-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJC_ROIFCstats.m
505 lines (437 loc) · 20.9 KB
/
JC_ROIFCstats.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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% CREATED BY: JOCHEN WEBER
% CREATED ON: 2017-12-13
%
% USAGE: TESTING PAIN ROI CORRELATIONS ACROSS GROUPS
%
% MODIFIED ON: 2017_12_13
% MODIFIED ON: 2018_02_01
% MODIFIED ON: 2018_02_02
% MODIFIED ON: 2018_02_12
% MODIFIED ON: 2018_02_13
% MODIFIED ON: 2018_03_20
% MODIFIED ON: 2018_04_24
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
% BASIC SETUP FOR ANALYSES
% neuroelf library
n = neuroelf;
% SET PRIMARY PATH
rootpath = '/Volumes/Data/Imaging/R01/preprocessed/';
cd(rootpath);
% load variable
% contains slistd! WHICH CONATAINS THE SUBJECT LIST
load FCvars.mat
% load VOI
%voi = xff('Craggs_VOIs.voi');
voi = xff('/Users/jcraggs/Documents/GitHub/Psychometric/ROIs/AALmasks1.voi');
voinames = voi.VOINames;
% indices for pain
pain = find(~cellfun('isempty', regexpi(voinames, '^Pain')));
dmn = find(~cellfun('isempty', regexpi(voinames, '^DMN')));
both = find(~cellfun('isempty', regexpi(voinames, '^Both')));
%voiorder = [pain; dmn];
voiorder = [pain; dmn; both];
nvs = numel(voiorder);
% find subjects in three groups
g1 = find(slistd(:, 3) == 1 & ~any(isnan(slistd(:, 4:11)), 2));
g2 = find(slistd(:, 3) == 2 & ~any(isnan(slistd(:, 4:11)), 2));
g3 = find(slistd(:, 3) == 3 & ~any(isnan(slistd(:, 4:11)), 2));
g123 = [g1; g2; g3];
i1 = 1:numel(g1);
i2 = i1(end) + (1:numel(g2));
i3 = i2(end) + (1:numel(g3));
ns = numel(g123);
glistd = slistd(g123, :);
rlistd = glistd(:, 4:11);
% create cc arrays
% THESE ARE THE CROSS CORRELATIONS OF ALL THE BRAIN REGIONS LISTED IN THE VOI FILE
afcccs = cat(3, fcccs{:});
gfcccs = reshape(afcccs(voiorder, voiorder, rlistd(:)), [nvs, nvs, ns, 2, 2, 2]);
% fisher transform
zgfcccs = n.fisherr2z(gfcccs);
zgfcccs(isinf(zgfcccs)) = 0;
% average over first and second run of each half-session
% THESE ARE THE 'PRE' MANIPULATION RESTING STATE SCANS
zgfcccs = squeeze(mean(zgfcccs, 4));
% this leaves 5-dimensions
% THE 5 DIMENSIONS FOR THE zgfcccs ARRAY ARE:
% 1 (ROIs IN THE PAIN NETWORK (i.e., REGIONS [1-16], AS OF February 12, 2018)
% 2 (ROIs IN THE DMN NETWORK (i.e., REGIONS [17-22], AS OF February 12, 2018)
% 3 subjects (in order of groups, 1-31 HC, 32-73 CLBP, 74-90 FM)
% 4 pre/post treatment (1 pre, 2 post)
% 5 neg/pos session (1 neg, 2 pos)
% to split into within network matrices
% THESE ARE ARRAYS OF CROSS CORRELATIONS AMONG REGIONS IN EACH NETWORK
% THE ARRAYS ARE ORGANIZED AS (REGIONS^REGIONS, ALL SUBJECTS, PRE & POST, POS & NEG)
%painstart = bothend +1;
painstart = 1;
painend = length(pain);
dmnstart = painend + 1;
dmnend = length(pain) + length(dmn);
bothstart = dmnend + 1;
bothend = length(both) + length(pain) + length(dmn);
% painend = length(both)+length(pain);
% dmnstart = painend +1;
% dmnend = length(both) + length(pain) + length(dmn);
% bothstart = 1;
% bothend = length(both)+1;
bothzgfcccs = zgfcccs(bothstart:bothend, bothstart:bothend, :, :, :);
painzgfcccs = zgfcccs(painstart:painend, painstart:painend, :, :, :);
dmnzgfcccs = zgfcccs(dmnstart:dmnend, dmnstart:dmnend, :, :, :);
%painzgfcccs = zgfcccs(1:16, 1:16, :, :, :);
%dmnzgfcccs = zgfcccs(17:22, 17:22, :, :, :);
% average connectivity strengths
% THESE ARE THE CCs FOR ALL 90 SUBJECTS ACROSS THE PAIN REGIONS
painnet = squeeze(sum(sum(painzgfcccs, 1), 2)) ./ (length(pain) * (length(pain) -1));
% THESE ARE THE CCs FOR ALL 90 SUBJECTS ACROSS THE DMN REGIONS
dmnnet = squeeze(sum(sum(dmnzgfcccs, 1), 2)) ./ (length(dmn) * (length(dmn) -1));
%
%%
% THESE ARE THE CCs FOR ALL 90 SUBJECTS ACROSS THE 16 PAIN REGIONS
%painnet = squeeze(sum(sum(painzgfcccs, 1), 2)) ./ (16 * 15);
% THESE ARE THE CCs FOR ALL 90 SUBJECTS ACROSS THE 6 DMN REGIONS
%dmnnet = squeeze(sum(sum(dmnzgfcccs, 1), 2)) ./ (6 * 5);
% get left amygdala (region 2) to left anterior insula (region 8) from pain network
%pain_lamyg_2_linsula = squeeze(painzgfcccs(2, 8, :, :, :));
% to unpack:
% - i1 and i2 are the indices for groups HC and CLBP
% - the next ", 1" is the "pre" (treatment) selection
% - the next ", 1" is the "neg session" selection
%
% LIST OUT THE BRAIN REGIONS IN THE PAIN AND DMN NETWORKS
char(voinames(voiorder));
painnames = char(voinames(voiorder(painstart:painend)));
dmnnames = char(voinames(voiorder(dmnstart:dmnend)));
bothnames = char(voinames(voiorder(bothstart:bothend)));
%painnames = char(voinames(voiorder(1:16)));
%dmnnames = char(voinames(voiorder(17:22)));
% computing the ANOVA for all pairs
pain_anovaresults_effect = zeros(length(pain),length(pain));
pain_anovaresults_pvalue = zeros(length(pain),length(pain));
%pain_anovaresults_effect = zeros(16, 16);
%pain_anovaresults_pvalue = zeros(16, 16);
% for node1 = 1:16
% for node2 = 1:16
for node1 = 1:length(pain)
for node2 = 1:length(pain)
prePainHC = mean(squeeze(painzgfcccs(node1, node2, i1, 1, :)), 2);
prePainCLBP = mean(squeeze(painzgfcccs(node1, node2, i2, 1, :)), 2);
prePainFM = mean(squeeze(painzgfcccs(node1, node2, i3, 1, :)), 2);
%
% % place the code between lines 116 and 131 here
gpNames = {'HC','CLBP','FM'}; % VARIABLE OF GROUP NAMES
% STEP 2 = CREATE AN ARRAY OF THE COMBINED VARIABLES FROM ABOVE
% THE ARRAY NEEDS TO BE PADDED BECAUSE OF UNEVEN GROUP SIZES
% IDENTIFY THE LARGEST GROUP
A = max([length(i1),length(i2),length(i3)]);
A = zeros(A,3); % INITIALIZE ARRAY OF ALL ZEROS FOR LARGEST GROUP
A(A == 0) = NaN; % CONVERT ALL '0' TO 'NaN' (MISSING VALUES)
A(1:length(prePainHC),1) = prePainHC; % HC TO COLUMN 1
A(1:length(prePainCLBP),2) = prePainCLBP; % CLBP TO COLUMN 2
A(1:length(prePainFM),3) = prePainFM; % FM TO COLUMN 3
% STEP 3 = RUNNING THE ANOVA AND MULTIPLE COMPARISONS
% CREATE A TABLE OF OVERALL F-TEST
[p,tbl,stats] = anova1(A,gpNames, 'off'); % TABLE OF OVERALL RESULTS
% ftestNames = tbl(1,:); % VARIABLE NAMES FOR THE TABLE
% ftestNames{1,6} = 'Prob_F'; % FIX THE SYMBOL ISSUE
% tableFtest = array2table(tbl(2:4,:),'VariableNames',ftestNames);
% pain_anovaresults_effect(node1, node2) = SOME_VALUE;
pain_anovaresults_pvalue(node1, node2) = p;
end
end
for i = 1:24
for j=i+1:24
pain_anovaresults_pvalue(i,j)=NaN;
pain_anovaresults_pvalue(i,j)=NaN;
end
end
%{
%
%% ANALYSIS #0 (3 GROUP ANOVA FOR PRE)
% COMPUTING 3-GROUP ANOVA FOR THE PRE-MANIPULATION RESTING STATE SCANS
% STEP 1 = CREATE VARIABLES OF THE MEAN CORRELATION OF ALL PAIN REGIONS
% FOR EACH GROUP OF THE PRE SCANS ACROSS BOTH VISITS
prePainHC = mean(painnet(i1,1,:),3); % MEAN OF HC
prePainCLBP = mean(painnet(i2,1,:),3); % MEAN OF CLBP
prePainFM = mean(painnet(i3,1,:),3); % MEAN OF FM
gpNames = {'HC','CLBP','FM'}; % VARIABLE OF GROUP NAMES
% STEP 2 = CREATE AN ARRAY OF THE COMBINED VARIABLES FROM ABOVE
% THE ARRAY NEEDS TO BE PADDED BECAUSE OF UNEVEN GROUP SIZES
% IDENTIFY THE LARGEST GROUP
A = max([length(i1),length(i2),length(i3)]);
A = zeros(A,3); % INITIALIZE ARRAY OF ALL ZEROS FOR LARGEST GROUP
A(A == 0) = NaN; % CONVERT ALL '0' TO 'NaN' (MISSING VALUES)
A(1:length(prePainHC),1) = prePainHC; % HC TO COLUMN 1
A(1:length(prePainCLBP),2) = prePainCLBP; % CLBP TO COLUMN 2
A(1:length(prePainFM),3) = prePainFM; % FM TO COLUMN 3
% STEP 3 = RUNNING THE ANOVA AND MULTIPLE COMPARISONS
% CREATE A TABLE OF OVERALL F-TEST
[p,tbl,stats] = anova1(A,gpNames); % TABLE OF OVERALL RESULTS
ftestNames = tbl(1,:); % VARIABLE NAMES FOR THE TABLE
ftestNames{1,6} = 'Prob_F'; % FIX THE SYMBOL ISSUE
tableFtest = array2table(tbl(2:4,:),'VariableNames',ftestNames);
figure;
%[~,~,stats] = anova1(A,gpNames); % I AM NOT SURE WHAT THIS DOES ...
[c,~,~,gnames] = multcompare(stats); % EVALUATE MULTIPLE COMPARISONS
% STEP 4 = PREPARING STATS OUTPUT
% CREATE AN ARRAY OF ANOVA OUTPUT
anovaPreOutput = [gnames(c(:,1)), gnames(c(:,2)), num2cell(c(:,3:6))];
% INITIAL ORDER OF OUTPUT FROM THE MULTICOMPARISON STEP
% COLUMNS 1-6 = {'gp1','gp2','lCI','gpDiff','uCI','pval'}
% CHANGING THE VARIABLE ORDER IN THE OUTPUT ARRAY TO
% COLUMNS 1-6 = {'gp1','gp2', 'pval','gpDiff','lCI','uCI'}) AND THEN
% CREATE A TABLE OF THE MULTICOMPARISON OUTPUT
anovaPreOutput = anovaPreOutput(:,[1 2 6 4 3 5]);
tableAnovaPre = array2table(anovaPreOutput, 'VariableNames',{'gp1','gp2', 'pval','gpDiff','lCI','uCI'});
%% SYNTAX FOR PERFORMING A MANOVA
% START BY CREATING A VECTOR REPRESENTING ALL THE GROUPS
gp1 = ones(length(i1),1);
gp2 = 2*ones(length(i2),1);
gp3 = 3*ones(length(i3),1);
gps123 = cat(1,gp1,gp2,gp3);
groups = nominal(gps123); % SPECIFY THIS AS AN ORDINAL VARIABLE
groups = setlabels(groups,{'HC','CLBP','FM'}); % SET THE VARIABLE LABELS
prePain123 = cat(1,prePainHC, prePainCLBP,prePainFM); % CREATE ANOTHER VECTOR TO INCLUDE
% RUN THE MANOVA
[d,p,stats] = manova1(prePain123,groups)
%% ANALYSIS #1 (3 GROUP ANOVA FOR POST COLLAPSED ACROSS CONDITIONS)
% COMPUTING 3-GROUP ANOVA FOR THE POST-MANIPULATION RESTING STATE SCANS
% STEP 1 = CREATE VARIABLES OF THE MEAN CORRELATION OF ALL PAIN REGIONS
% FOR EACH GROUP OF THE POST SCANS ACROSS BOTH VISITS
postPainHC = mean(painnet(i1,2,:),3); % MEAN OF HC
postPainCLBP = mean(painnet(i2,2,:),3); % MEAN OF CLBP
postPainFM = mean(painnet(i3,2,:),3); % MEAN OF FM
gpNames = {'HC post','CLBP post','FM post'}; % VARIABLE OF GROUP NAMES
% STEP 2 = CREATE AN ARRAY OF THE COMBINED VARIABLES FROM ABOVE
% THE ARRAY NEEDS TO BE PADDED BECAUSE OF UNEVEN GROUP SIZES
% IDENTIFY THE LARGEST GROUP
A = max([length(i1),length(i2),length(i3)]);
A = zeros(A,3); % INITIALIZE ARRAY OF ALL ZEROS FOR LARGEST GROUP
A(A == 0) = NaN; % CONVERT ALL '0' TO 'NaN' (MISSING VALUES)
A(1:length(postPainHC),1) = postPainHC; % HC TO COLUMN 1
A(1:length(postPainCLBP),2) = postPainCLBP; % CLBP TO COLUMN 2
A(1:length(postPainFM),3) = postPainFM; % FM TO COLUMN 3
% STEP 3 = RUNNING THE ANOVA AND MULTIPLE COMPARISONS
% CREATE A TABLE OF OVERALL F-TEST
[p,tbl,stats] = anova1(A,gpNames,'off'); % TABLE OF OVERALL RESULTS
ftestNames = tbl(1,:); % VARIABLE NAMES FOR THE TABLE
ftestNames{1,6} = 'Prob_F'; % FIX THE SYMBOL ISSUE
tableFtest = array2table(tbl(2:4,:),'VariableNames',ftestNames);
figure;
%[~,~,stats] = anova1(A,gpNames); % I AM NOT SURE WHAT THIS DOES ...
[c,~,~,gnames] = multcompare(stats); % EVALUATE MULTIPLE COMPARISONS
% STEP 4 = PREPARING STATS OUTPUT
% CREATE AN ARRAY OF ANOVA OUTPUT
anovaPostOutput = [gnames(c(:,1)), gnames(c(:,2)), num2cell(c(:,3:6))];
% INITIAL ORDER OF OUTPUT FROM THE MULTICOMPARISON STEP
% COLUMNS 1-6 = {'gp1','gp2','lCI','gpDiff','uCI','pval'}
% CHANGING THE VARIABLE ORDER IN THE OUTPUT ARRAY TO
% COLUMNS 1-6 = {'gp1','gp2', 'pval','gpDiff','lCI','uCI'}) AND THEN
% CREATE A TABLE OF THE MULTICOMPARISON OUTPUT
anovaPostOutput = anovaPostOutput(:,[1 2 6 4 3 5]);
tableAnovaPost = array2table(anovaPostOutput, 'VariableNames',{'gp1','gp2', 'pval','gpDiff','lCI','uCI'});
%% ANALYSIS #2 (3 GROUP ANOVA FOR POST NEGAVIVE MANIPULATION)
% COMPUTING 3-GROUP ANOVA FOR THE PRE-MANIPULATION RESTING STATE SCANS
% STEP 1 = CREATE VARIABLES OF THE MEAN CORRELATION OF ALL PAIN REGIONS
% FOR EACH GROUP OF THE PRE SCANS ACROSS BOTH VISITS
postNegPainHC = mean(painnet(i1,2,1),3); % MEAN OF HC
postNegPainCLBP = mean(painnet(i2,2,1),3); % MEAN OF CLBP
postNegPainFM = mean(painnet(i3,2,1),3); % MEAN OF FM
gpNames = {'HC neg','CLBP neg','FM neg'}; % VARIABLE OF GROUP NAMES
% STEP 2 = CREATE AN ARRAY OF THE COMBINED VARIABLES FROM ABOVE
% THE ARRAY NEEDS TO BE PADDED BECAUSE OF UNEVEN GROUP SIZES
% IDENTIFY THE LARGEST GROUP
A = max([length(i1),length(i2),length(i3)]);
A = zeros(A,3); % INITIALIZE ARRAY OF ALL ZEROS FOR LARGEST GROUP
A(A == 0) = NaN; % CONVERT ALL '0' TO 'NaN' (MISSING VALUES)
A(1:length(postNegPainHC),1) = postNegPainHC; % HC TO COLUMN 1
A(1:length(postNegPainCLBP),2) = postNegPainCLBP; % CLBP TO COLUMN 2
A(1:length(postNegPainFM),3) = postNegPainFM; % FM TO COLUMN 3
% STEP 3 = RUNNING THE ANOVA AND MULTIPLE COMPARISONS
% CREATE A TABLE OF OVERALL F-TEST
[p,tbl,stats] = anova1(A,gpNames,'off'); % TABLE OF OVERALL RESULTS
ftestNames = tbl(1,:); % VARIABLE NAMES FOR THE TABLE
ftestNames{1,6} = 'Prob_F'; % FIX THE SYMBOL ISSUE
tableFtest = array2table(tbl(2:4,:),'VariableNames',ftestNames);
figure;
%[~,~,stats] = anova1(A,gpNames); % I AM NOT SURE WHAT THIS DOES ...
[c,~,~,gnames] = multcompare(stats); % EVALUATE MULTIPLE COMPARISONS
% STEP 4 = PREPARING STATS OUTPUT
% CREATE AN ARRAY OF ANOVA OUTPUT
anovaPostNegOutput = [gnames(c(:,1)), gnames(c(:,2)), num2cell(c(:,3:6))];
% INITIAL ORDER OF OUTPUT FROM THE MULTICOMPARISON STEP
% COLUMNS 1-6 = {'gp1','gp2','lCI','gpDiff','uCI','pval'}
% CHANGING THE VARIABLE ORDER IN THE OUTPUT ARRAY TO
% COLUMNS 1-6 = {'gp1','gp2', 'pval','gpDiff','lCI','uCI'}) AND THEN
% CREATE A TABLE OF THE MULTICOMPARISON OUTPUT
anovaPostNegOutput = anovaPostNegOutput(:,[1 2 6 4 3 5]);
tableAnovaNegPost = array2table(anovaPostNegOutput, 'VariableNames',{'gp1','gp2', 'pval','gpDiff','lCI','uCI'});
%% ANALYSIS #3 (3 GROUP ANOVA FOR POST POSITIVE MANIPULATION)
% COMPUTING 3-GROUP ANOVA FOR THE PRE-MANIPULATION RESTING STATE SCANS
% STEP 1 = CREATE VARIABLES OF THE MEAN CORRELATION OF ALL PAIN REGIONS
% FOR EACH GROUP OF THE PRE SCANS ACROSS BOTH VISITS
postPosPainHC = mean(painnet(i1,2,2),3); % MEAN OF HC
postPosPainCLBP = mean(painnet(i2,2,2),3); % MEAN OF CLBP
postPosPainFM = mean(painnet(i3,2,2),3); % MEAN OF FM
gpNames = {'HC pos','CLBP pos','FM pos'}; % VARIABLE OF GROUP NAMES
% STEP 2 = CREATE AN ARRAY OF THE COMBINED VARIABLES FROM ABOVE
% THE ARRAY NEEDS TO BE PADDED BECAUSE OF UNEVEN GROUP SIZES
% IDENTIFY THE LARGEST GROUP
A = max([length(i1),length(i2),length(i3)]);
A = zeros(A,3); % INITIALIZE ARRAY OF ALL ZEROS FOR LARGEST GROUP
A(A == 0) = NaN; % CONVERT ALL '0' TO 'NaN' (MISSING VALUES)
A(1:length(postPosPainHC),1) = postPosPainHC; % HC TO COLUMN 1
A(1:length(postPosPainCLBP),2) = postPosPainCLBP; % CLBP TO COLUMN 2
A(1:length(postPosPainFM),3) = postPosPainFM; % FM TO COLUMN 3
% STEP 3 = RUNNING THE ANOVA AND MULTIPLE COMPARISONS
% CREATE A TABLE OF OVERALL F-TEST
[p,tbl,stats] = anova1(A,gpNames,'off'); % TABLE OF OVERALL RESULTS
ftestNames = tbl(1,:); % VARIABLE NAMES FOR THE TABLE
ftestNames{1,6} = 'Prob_F'; % FIX THE SYMBOL ISSUE
tableFtest = array2table(tbl(2:4,:),'VariableNames',ftestNames);
figure;
%[~,~,stats] = anova1(A,gpNames); % I AM NOT SURE WHAT THIS DOES ...
[c,~,~,gnames] = multcompare(stats); % EVALUATE MULTIPLE COMPARISONS
% STEP 4 = PREPARING STATS OUTPUT
% CREATE AN ARRAY OF ANOVA OUTPUT
anovaPostPosOutput = [gnames(c(:,1)), gnames(c(:,2)), num2cell(c(:,3:6))];
% INITIAL ORDER OF OUTPUT FROM THE MULTICOMPARISON STEP
% COLUMNS 1-6 = {'gp1','gp2','lCI','gpDiff','uCI','pval'}
% CHANGING THE VARIABLE ORDER IN THE OUTPUT ARRAY TO
% COLUMNS 1-6 = {'gp1','gp2', 'pval','gpDiff','lCI','uCI'}) AND THEN
% CREATE A TABLE OF THE MULTICOMPARISON OUTPUT
anovaPostPosOutput = anovaPostPosOutput(:,[1 2 6 4 3 5]);
tableAnovaPosPost = array2table(anovaPostPosOutput, 'VariableNames',{'gp1','gp2', 'pval','gpDiff','lCI','uCI'});
%% ANALYSIS #4 (T-TEST, HC vs. CLBP [pre, both visits])
% to compute a compound "pre" score
% ttest2(group-1, pre/post, neg/post, group-2, pre/post, neg/post)
% Below = (HC, pre, both visits vs. CLBP, pre, both visits)
[h, p, ci, stats] = ttest2(mean(painnet(i1, 1, :), 3), mean(painnet(i2, 1, :), 3), ...
'tail', 'both', 'vartype', 'unequal');
% p
% stats
Gps = (['HC v CLBP']);
pval = ([p]);
tVal = ([stats.tstat]);
scanSet = (['combined pre']);
cond = (['both']);
Hy = ([h]);
%% ANALYSIS #5 (T-TEST [HC v CLBP], COMPARING PRE FROM THE NEG VISITS, NOT OVERLY USEFUL)
% to then run differences in group tests HC vs. CLBP
% ttest2(group-1, pre/post, neg/post, group-2, pre/post, neg/post)
% Below = (HC, pre, neg vs. CLBP, pre, neg)
[h, p, ci, stats] = ttest2(painnet(i1, 1, 1), painnet(i2, 1, 1), ...
'tail', 'both', 'vartype', 'unequal');
% p
% stats
Gps = ([Gps;{'HC v CLBP'}]);
pval = ([pval;p]);
tVal = ([tVal;stats.tstat]);
scanSet = ([scanSet;{'pre'}]);
cond = ([cond;{'neg'}]);
Hy = ([Hy;h]);
%% ANALYSIS #6 (T-TEST [HC v CLBP], COMPARING PRE FROM THE POS VISITS, NOT OVERLY USEFUL)
% ttest2(group-1, pre/post, neg/post, group-2, pre/post, neg/post)
% Below = (HC, pre, pos vs. CLBP, pre, pos)
[h, p, ci, stats] = ttest2(painnet(i1, 1, 2), painnet(i2, 1, 2), ...
'tail', 'both', 'vartype', 'unequal');
Gps = ([Gps;{'HC v CLBP'}]);
pval = ([pval;p]);
tVal = ([tVal;stats.tstat]);
scanSet = ([scanSet;{'pre'}]);
cond = ([cond;{'pos'}]);
Hy = ([Hy;h]);
%% ANALYSIS #7 (T-TEST [HC v CLBP], POST > PRE (NEG), WHAT DID THE NEG MANIPULATION INCREASE)
% TO TEST GROUP DIFFERENCES IN POST-PRE IN THE NEGATIVE CONDITION
% THAT IS, GROUP DIFFERENCES IN HOW MUCH THE NEGATIVE MOOD MANIPULATION
% INCREASED ACTIVITY IN THE ROIs
[h, p, ci, stats] = ttest2(painnet(i1, 2, 1) - painnet(i1, 1, 1), painnet(i2, 2, 1) - painnet(i2, 1, 1), ...
'tail', 'both', 'vartype', 'unequal');
Gps = ([Gps;{'HC v CLBP'}]);
pval = ([pval;p]);
tVal = ([tVal;stats.tstat]);
scanSet = ([scanSet;{'post > pre'}]);
cond = ([cond;{'neg'}]);
Hy = ([Hy;h]);
%% ANALYSIS #8 (T-TEST [HC v CLBP], POST > PRE (POS), WHAT DID THE POS MANIPULATION INCREASE)
% TO TEST GROUP DIFFERENCES IN POST-PRE IN THE POSITIVE CONDITION
% THAT IS, GROUP DIFFERENCES IN HOW MUCH THE POSITIVE MOOD MANIPULATION
% INCREASED ACTIVITY IN THE ROIs
[h, p, ci, stats] = ttest2(painnet(i1, 2, 2) - painnet(i1, 1, 2), painnet(i2, 2, 2) - painnet(i2, 1, 2), ...
'tail', 'both', 'vartype', 'unequal');
Gps = ([Gps;{'HC v CLBP'}]);
pval = ([pval;p]);
tVal = ([tVal;stats.tstat]);
scanSet = ([scanSet;{'post > pre'}]);
cond = ([cond;{'pos'}]);
Hy = ([Hy;h]);
%% ANALYSIS #9 (T-TEST [HC v FM], POST > PRE (NEG), WHAT DID THE NEG MANIPULATION INCREASE)
% TO TEST GROUP DIFFERENCES IN POST-PRE IN THE NEGATIVE CONDITION
% THAT IS, GROUP DIFFERENCES IN HOW MUCH THE NEGATIVE MOOD MANIPULATION
% INCREASED ACTIVITY IN THE ROIs
[h, p, ci, stats] = ttest2(painnet(i1, 2, 1) - painnet(i1, 1, 1), painnet(i3, 2, 1) - painnet(i3, 1, 1), ...
'tail', 'both', 'vartype', 'unequal');
Gps = ([Gps;{'HC v FM'}]);
pval = ([pval;p]);
tVal = ([tVal;stats.tstat]);
scanSet = ([scanSet;{'post > pre'}]);
cond = ([cond;{'neg'}]);
Hy = ([Hy;h]);
%% ANALYSIS #10 (T-TEST [HC v FM], POST > PRE (POS), WHAT DID THE POS MANIPULATION INCREASE)
% TO TEST GROUP DIFFERENCES IN POST-PRE IN THE POSITIVE CONDITION
% THAT IS, GROUP DIFFERENCES IN HOW MUCH THE POSITIVE MOOD MANIPULATION
% INCREASED ACTIVITY IN THE ROIs
[h, p, ci, stats] = ttest2(painnet(i1, 2, 2) - painnet(i1, 1, 2), painnet(i3, 2, 2) - painnet(i3, 1, 2), ...
'tail', 'both', 'vartype', 'unequal');
Gps = ([Gps;{'HC v FM'}]);
pval = ([pval;p]);
tVal = ([tVal;stats.tstat]);
scanSet = ([scanSet;{'post > pre'}]);
cond = ([cond;{'pos'}]);
Hy = ([Hy;h]);
%% CREATING A TABLE OF OUTPUT VARIABLES
tableTtest = table(Gps,scanSet,cond,Hy,pval,tVal,'VariableNames',{'group','scanSet','Condition','Sig','pvalue','tvalue'});
writetable(tableTtest,'t-tests.txt','Delimiter',' ');
%% SAVE WORKSPACE
PainROIFCstatsOutput = ['PainROIFCstats_',datestr(now, 'yyyy-mm-dd'),'.mat']
save(PainROIFCstatsOutput);
%}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% END SCRIPT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Below = (HC, pre, neg vs. CLBP, pre, pos)
% [h, p, ci, stats] = ttest2(painnet(i1, 1, 1), painnet(i2, 1, 1), ...
% 'tail', 'both', 'vartype', 'unequal');
%
%% EXTRA STUFF
% pval2 = p;
%Qs = ([Qs;Q2]);
%Qs = ([Qs;{'HC ver CLBP'}]);
% % to compute a "difference" for pre-post neg treatment (between groups)
% %[h, p, ci, stats] = ttest2(painnet(i1, 2, 1) - painnet(i1, 1, 1), painnet(i2, 1, 2) - painnet(i2, 1, 1), ...
% [h, p, ci, stats] = ttest2(painnet(i1, 2, 1) - painnet(i1, 1, 1), painnet(i2, 2, 1) - painnet(i2, 1, 1), ...
% 'tail', 'both', 'vartype', 'unequal');
% p
% stats
%pval = {pval;p};
% as a paired t-test (across all participants)
% [h, p, ci, stats] = ttest(painnet(:, 1, 1), painnet(:, 1, 2), ...
% 'tail', 'both');
% p
% stats
% pval = ([pval;p]);
% tVal = ([tVal;stats.tstat]);
% pval3 = p;
% as a one-sample t-test
%
%
%
%
%
%
%
% END SCRIPT