-
Notifications
You must be signed in to change notification settings - Fork 1
/
QC_main.html
2766 lines (2215 loc) · 122 KB
/
QC_main.html
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
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--
This HTML was auto-generated from MATLAB code.
To make changes, update the MATLAB code and republish this document.
--><title>QC_main</title><meta name="generator" content="MATLAB 9.5"><link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"><meta name="DC.date" content="2020-04-28"><meta name="DC.source" content="QC_main.m"><style type="text/css">
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}:focus{outine:0}ins{text-decoration:none}del{text-decoration:line-through}table{border-collapse:collapse;border-spacing:0}
html { min-height:100%; margin-bottom:1px; }
html body { height:100%; margin:0px; font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#000; line-height:140%; background:#fff none; overflow-y:scroll; }
html body td { vertical-align:top; text-align:left; }
h1 { padding:0px; margin:0px 0px 25px; font-family:Arial, Helvetica, sans-serif; font-size:1.5em; color:#d55000; line-height:100%; font-weight:normal; }
h2 { padding:0px; margin:0px 0px 8px; font-family:Arial, Helvetica, sans-serif; font-size:1.2em; color:#000; font-weight:bold; line-height:140%; border-bottom:1px solid #d6d4d4; display:block; }
h3 { padding:0px; margin:0px 0px 5px; font-family:Arial, Helvetica, sans-serif; font-size:1.1em; color:#000; font-weight:bold; line-height:140%; }
a { color:#005fce; text-decoration:none; }
a:hover { color:#005fce; text-decoration:underline; }
a:visited { color:#004aa0; text-decoration:none; }
p { padding:0px; margin:0px 0px 20px; }
img { padding:0px; margin:0px 0px 20px; border:none; }
p img, pre img, tt img, li img, h1 img, h2 img { margin-bottom:0px; }
ul { padding:0px; margin:0px 0px 20px 23px; list-style:square; }
ul li { padding:0px; margin:0px 0px 7px 0px; }
ul li ul { padding:5px 0px 0px; margin:0px 0px 7px 23px; }
ul li ol li { list-style:decimal; }
ol { padding:0px; margin:0px 0px 20px 0px; list-style:decimal; }
ol li { padding:0px; margin:0px 0px 7px 23px; list-style-type:decimal; }
ol li ol { padding:5px 0px 0px; margin:0px 0px 7px 0px; }
ol li ol li { list-style-type:lower-alpha; }
ol li ul { padding-top:7px; }
ol li ul li { list-style:square; }
.content { font-size:1.2em; line-height:140%; padding: 20px; }
pre, code { font-size:12px; }
tt { font-size: 1.2em; }
pre { margin:0px 0px 20px; }
pre.codeinput { padding:10px; border:1px solid #d3d3d3; background:#f7f7f7; }
pre.codeoutput { padding:10px 11px; margin:0px 0px 20px; color:#4c4c4c; }
pre.error { color:red; }
@media print { pre.codeinput, pre.codeoutput { word-wrap:break-word; width:100%; } }
span.keyword { color:#0000FF }
span.comment { color:#228B22 }
span.string { color:#A020F0 }
span.untermstring { color:#B20000 }
span.syscmd { color:#B28C00 }
.footer { width:auto; padding:10px 0px; margin:25px 0px 0px; border-top:1px dotted #878787; font-size:0.8em; line-height:140%; font-style:italic; color:#878787; text-align:left; float:none; }
.footer p { margin:0px; }
.footer a { color:#878787; }
.footer a:hover { color:#878787; text-decoration:underline; }
.footer a:visited { color:#878787; }
table th { padding:7px 5px; text-align:left; vertical-align:middle; border: 1px solid #d6d4d4; font-weight:bold; }
table td { padding:7px 5px; text-align:left; vertical-align:top; border:1px solid #d6d4d4; }
</style></head><body><div class="content"><h2>Contents</h2><div><ul><li><a href="#2">import and prep data</a></li><li><a href="#3">plot experimental variance in each dataset</a></li><li><a href="#4">Quantify signal strength using SVR brain decoding</a></li><li><a href="#5">Bad datasets</a></li></ul></div><pre class="codeinput"><span class="comment">% We then compute SS_regressor following the method for computing R2</span>
<span class="comment">% detailed here:</span>
<span class="comment">% https://www.researchgate.net/publication/306347340_A_Pseudo_Decomposition_of_R2_in_Multiple_Linear_Regression</span>
<span class="comment">% and here:</span>
<span class="comment">% http://biol09.biol.umontreal.ca/borcardd/partialr2.pdf (no. 1)</span>
close <span class="string">all</span>;
clear <span class="string">all</span>;
warning(<span class="string">'off'</span>,<span class="string">'all'</span>)
addpath(genpath(<span class="string">'/projects/bope9760/CanlabCore/CanlabCore'</span>));
addpath(genpath(<span class="string">'/projects/bope9760/spm12'</span>));
addpath(genpath(<span class="string">'/projects/bope9760/single_trials_overview/repo'</span>)); <span class="comment">% single_trials repo</span>
addpath(<span class="string">'/work/ics/data/projects/wagerlab/labdata/projects/canlab_single_trials_for_git_repo/'</span>); <span class="comment">% single trial data on blanca</span>
</pre><h2 id="2">import and prep data</h2><p>- concatenate subject data matrices from canlab_dataset objects</p><p>- remove trials with high_vif or vif > 2.5, for consistency with subsequent imaging datasets</p><p>- separate pain from non-pain datasets</p><p>- remove trials with missing responses (rating == nan)</p><p>- add subject and study ids</p><pre class="codeinput">st_datasets = {<span class="string">'nsf'</span>,<span class="string">'bmrk3'</span>,<span class="string">'bmrk4'</span>,<span class="string">'bmrk5'</span>,<span class="string">'remi'</span>,<span class="string">'scebl'</span>,<span class="string">'ie2'</span>,<span class="string">'ie'</span>,<span class="keyword">...</span>
<span class="string">'exp'</span>,<span class="string">'levoderm'</span>,<span class="string">'stephan'</span>,<span class="string">'romantic'</span>,<span class="string">'ilcp'</span>};
n_datasets = length(st_datasets);
dat = cell(n_datasets,1);
<span class="keyword">for</span> i = 1:length(st_datasets)
this_dat = importdata([st_datasets{i}, <span class="string">'_dataset_obj.mat'</span>]);
dat{i} = array2table(cell2mat(this_dat.Event_Level.data'),<span class="keyword">...</span>
<span class="string">'VariableNames'</span>,this_dat.Event_Level.names);
uniq_subject_id = this_dat.Subj_Level.id;
subject_id = [];
<span class="keyword">for</span> j = 1:length(uniq_subject_id)
subject_id = [subject_id, repmat(uniq_subject_id(j),1,size(this_dat.Event_Level.data{j},1))];
<span class="keyword">end</span>
dat{i}.subject_id = subject_id';
<span class="comment">% this removes non-thermal data, we'll add these back in later</span>
dat{i} = dat{i}(~isnan(dat{i}.rating) & ~isnan(dat{i}.T),:);
<span class="keyword">if</span> contains(st_datasets{i},<span class="string">'bmrk5'</span>)
dat{i}.soundintensity = [];
<span class="keyword">end</span>
fnames = dat{i}.Properties.VariableNames;
<span class="keyword">if</span> any(ismember(fnames,<span class="string">'high_vif'</span>))
dat{i}(dat{i}.high_vif == 1,:) = [];
<span class="keyword">end</span>
<span class="keyword">if</span> any(ismember(fnames,<span class="string">'vif'</span>))
dat{i}(dat{i}.vif >= 2.5,:) = [];
<span class="keyword">end</span>
<span class="keyword">end</span>
<span class="comment">% remove warm (non-painful) trials (rating <= 100)</span>
<span class="comment">% note, this makes it harder to interpret some self regulation effects,</span>
<span class="comment">% since many regulate down conditions end up getting dropped this way, but</span>
<span class="comment">% because outcome measures mean different things at sub 100 vs. over 100,</span>
<span class="comment">% we drop them for linear outcome modeling purposes</span>
bmrk3rating = dat{ismember(st_datasets,<span class="string">'bmrk3'</span>)}.rating - 100;
dat{ismember(st_datasets,<span class="string">'bmrk3'</span>)}.rating = bmrk3rating;
dat{ismember(st_datasets,<span class="string">'bmrk3'</span>)} = dat{ismember(st_datasets,<span class="string">'bmrk3'</span>)}(bmrk3rating > 0,:);
<span class="comment">% take care of non-pain data</span>
this_dat = importdata(<span class="string">'bmrk3_dataset_obj'</span>);
dat{end+1} = array2table(cell2mat(this_dat.Event_Level.data'),<span class="keyword">...</span>
<span class="string">'VariableNames'</span>,this_dat.Event_Level.names);
uniq_subject_id = this_dat.Subj_Level.id;
subject_id = [];
<span class="keyword">for</span> j = 1:length(uniq_subject_id)
subject_id = [subject_id, repmat(uniq_subject_id(j),1,size(this_dat.Event_Level.data{j},1))];
<span class="keyword">end</span>
dat{end}.subject_id = subject_id';
dat{end} = dat{end}(dat{end}.rating <= 100,:);
this_dat = importdata(<span class="string">'bmrk5_dataset_obj'</span>);
dat{end+1} = array2table(cell2mat(this_dat.Event_Level.data'),<span class="keyword">...</span>
<span class="string">'VariableNames'</span>,this_dat.Event_Level.names);
uniq_subject_id = this_dat.Subj_Level.id;
subject_id = [];
<span class="keyword">for</span> j = 1:length(uniq_subject_id)
subject_id = [subject_id, repmat(uniq_subject_id(j),1,size(this_dat.Event_Level.data{j},1))];
<span class="keyword">end</span>
dat{end}.subject_id = subject_id';
dat{end} = dat{end}(isnan(dat{end}.T) & ~isnan(dat{end}.rating),:);
dat{end}.T = [];
<span class="comment">%c = seaborn_colors;</span>
<span class="comment">%c = shuffles(c);</span>
</pre><h2 id="3">plot experimental variance in each dataset</h2><p>- We model subjects as fixed effects</p><p>- We use backwards stepwise regression to select additional experimental factors</p><p>- Not all subject have trial sequence data, but for datasets where this is missing we provide the mean</p><p>- model interactions in cases where these were key factors (e.g. plaebo*value in stephan's placebo dataset), but otherwise stick to linear effects.</p><p>- adjust labels in pie plots to avoid overlapping numbers</p><p>- use consistent units across datasets, and concatenate all data for a final aggregate analyses (top left pie plot). Use within-dataset z-scored pain ratings for aggregate analyses. Exclude non pain data.</p><p>- standardize all variables before regression modeling to get standardized regression coefficients (necessary for partial R2 calculation)</p><p>Note that for agregate analysis "subject fixed effects" are colinear with study effects, so you should expect the "subject effects" to explain a disproportionate amount of the variance relative to what they explain in individual dataset analyses.</p><pre class="codeinput">c = colormap(<span class="string">'lines'</span>);
<span class="comment">%</span>
<span class="comment">% eval nsf</span>
<span class="comment">%</span>
this_st_id = 1;
newdat_st = dat{this_st_id};
[t, cov_names] = get_std_tbl_with_fixed_fx(newdat_st);
m = fitlm(t,<span class="string">'ResponseVar'</span>,<span class="string">'rating'</span>,<span class="keyword">...</span>
<span class="string">'PredictorVar'</span>,cov_names(~ismember(cov_names,{<span class="string">'sid'</span>,<span class="string">'rating'</span>,<span class="string">'overallN'</span>,<span class="string">'siteN'</span>,<span class="string">'runN'</span>})),<span class="keyword">...</span>
<span class="string">'Intercept'</span>,false);
<span class="comment">% compute partial r2</span>
partialR2 = partialRsquared(m);
<span class="keyword">if</span> abs(sum(partialR2.partialR2) - m.Rsquared.Ordinary) > 0.0001
warning([<span class="string">'Partial R2 computation doesn''t seem to be working for study '</span> int2str(this_st_id)]);
<span class="keyword">end</span>
R2 = table2array(partialR2);
figure(1)
T_idx = ismember(partialR2.Row,{<span class="string">'T'</span>});
sens_idx = ismember(partialR2.Row,{<span class="string">'siteN'</span>,<span class="string">'overallN'</span>,<span class="string">'runN'</span>});
sid_idx = find(contains(partialR2.Row,<span class="string">'sub'</span>));
cog_idx = ismember(partialR2.Row,{<span class="string">'cue'</span>,<span class="string">'ctrl'</span>,<span class="string">'social'</span>,<span class="string">'placebo'</span>,<span class="string">'value'</span>,<span class="string">'reveal'</span>,<span class="string">'handholding'</span>});
subplot(ceil(sqrt(1+n_datasets)), ceil((1+n_datasets)/ceil(sqrt(1+n_datasets))), this_st_id+1);
f = pie([sum(R2(T_idx)),sum(R2(sens_idx)),sum(R2(cog_idx)),sum(R2(sid_idx))],ones(4,1));
<span class="keyword">for</span> i = 2:2:4
<span class="keyword">if</span> strmatch(f(i).String,<span class="string">'0%'</span>)
f(i).String = <span class="string">''</span>
<span class="keyword">end</span>
<span class="keyword">end</span>
f = f(1:2:end);
f(1).FaceColor = c(7,:); <span class="comment">% Temp</span>
f(2).FaceColor = <span class="string">'white'</span>; <span class="comment">% Subj fixed fx variance</span>
title(sprintf([[strrep(strrep(st_datasets{this_st_id},<span class="string">'_data.mat'</span>,<span class="string">''</span>),<span class="string">'_'</span>,<span class="string">' '</span>), <span class="string">'\n'</span>], <span class="string">'\n'</span>]));
<span class="comment">%</span>
<span class="comment">% eval bmrk3pain</span>
<span class="comment">%</span>
this_st_id = 2;
newdat_st = dat{this_st_id};
newdat_st = newdat_st(~newdat_st.high_vif,:);
[t, cov_names] = get_std_tbl_with_fixed_fx(newdat_st);
m = fitlm(t,<span class="string">'ResponseVar'</span>,<span class="string">'rating'</span>,<span class="keyword">...</span>
<span class="string">'PredictorVar'</span>,cov_names(~ismember(cov_names,{<span class="string">'sid'</span>,<span class="string">'rating'</span>,<span class="string">'siteN'</span>,<span class="string">'overallN'</span>,<span class="string">'high_vif'</span>})),<span class="keyword">...</span>
<span class="string">'Intercept'</span>,false);
partialR2 = partialRsquared(m);
<span class="keyword">if</span> abs(sum(partialR2.partialR2) - m.Rsquared.Ordinary) > 0.0001
warning([<span class="string">'Partial R2 computation doesn''t seem to be working for study '</span> int2str(this_st_id)]);
<span class="keyword">end</span>
R2 = table2array(partialR2);
figure(1)
T_idx = ismember(partialR2.Row,{<span class="string">'T'</span>});
sens_idx = ismember(partialR2.Row,{<span class="string">'siteN'</span>,<span class="string">'overallN'</span>,<span class="string">'runN'</span>});
sid_idx = find(contains(partialR2.Row,<span class="string">'sub'</span>));
cog_idx = ismember(partialR2.Row,{<span class="string">'cue'</span>,<span class="string">'ctrl'</span>,<span class="string">'social'</span>,<span class="string">'placebo'</span>,<span class="string">'value'</span>,<span class="string">'reveal'</span>,<span class="string">'handholding'</span>,<span class="string">'reg'</span>});
subplot(ceil(sqrt(1+n_datasets)), ceil((1+n_datasets)/ceil(sqrt(1+n_datasets))), this_st_id+1);
f = pie([sum(R2(T_idx)),sum(R2(cog_idx)),sum(R2(sid_idx))],ones(3,1));
<span class="keyword">for</span> i = 2:2:6
<span class="keyword">if</span> strmatch(f(i).String,<span class="string">'0%'</span>)
f(i).String = <span class="string">''</span>
<span class="keyword">end</span>
<span class="keyword">end</span>
f = f(1:2:end);
f(1).FaceColor = c(7,:); <span class="comment">% Temp</span>
f(3).FaceColor = <span class="string">'white'</span>; <span class="comment">% Subj fixed fx variance</span>
f(2).FaceColor = c(1,:); <span class="comment">% cog variance</span>
title(sprintf([[strrep(strrep(st_datasets{this_st_id},<span class="string">'_data.mat'</span>,<span class="string">''</span>),<span class="string">'_'</span>,<span class="string">' '</span>), <span class="string">'pain\n'</span>], <span class="string">'\n'</span>]));
<span class="comment">%</span>
<span class="comment">% eval bmrk4</span>
<span class="comment">%</span>
this_st_id = 3;
newdat_st = dat{this_st_id};
[t, cov_names] = get_std_tbl_with_fixed_fx(newdat_st);
m = fitlm(t,<span class="string">'ResponseVar'</span>,<span class="string">'rating'</span>,<span class="keyword">...</span>
<span class="string">'PredictorVar'</span>,cov_names(~ismember(cov_names,{<span class="string">'sid'</span>,<span class="string">'rating'</span>,<span class="string">'siteN'</span>,<span class="string">'runN'</span>,<span class="string">'high_vif'</span>})),<span class="keyword">...</span>
<span class="string">'Intercept'</span>,false);
partialR2 = partialRsquared(m);
<span class="keyword">if</span> abs(sum(partialR2.partialR2) - m.Rsquared.Ordinary) > 0.0001
warning([<span class="string">'Partial R2 computation doesn''t seem to be working for study '</span> int2str(this_st_id)]);
<span class="keyword">end</span>
R2 = table2array(partialR2);
figure(1)
T_idx = ismember(partialR2.Row,{<span class="string">'T'</span>});
sens_idx = ismember(partialR2.Row,{<span class="string">'siteN'</span>,<span class="string">'overallN'</span>,<span class="string">'runN'</span>});
sid_idx = find(contains(partialR2.Row,<span class="string">'sub'</span>));
cog_idx = ismember(partialR2.Row,{<span class="string">'cue'</span>,<span class="string">'ctrl'</span>,<span class="string">'social'</span>,<span class="string">'placebo'</span>,<span class="string">'value'</span>,<span class="string">'reveal'</span>,<span class="string">'handholding'</span>});
subplot(ceil(sqrt(1+n_datasets)), ceil((1+n_datasets)/ceil(sqrt(1+n_datasets))), this_st_id+1);
f = pie([sum(R2(T_idx)),sum(R2(sens_idx)),sum(R2(cog_idx)),sum(R2(sid_idx))],ones(4,1));
<span class="keyword">for</span> i = 2:2:8
<span class="keyword">if</span> strmatch(f(i).String,<span class="string">'0%'</span>)
f(i).String = <span class="string">''</span>
<span class="keyword">end</span>
<span class="keyword">end</span>
f(4).Position = f(4).Position + [0,0.25,0];
f(6).Position = f(6).Position - [0,0.25,0];
f = f(1:2:end);
f(1).FaceColor = c(7,:); <span class="comment">% Temp</span>
f(2).FaceColor = c(3,:); <span class="comment">% Sensitization/Habituation</span>
f(4).FaceColor = <span class="string">'white'</span>; <span class="comment">% Subj fixed fx variance</span>
f(3).FaceColor = c(1,:); <span class="comment">% cog variance</span>
title(sprintf([[strrep(strrep(st_datasets{this_st_id},<span class="string">'_data.mat'</span>,<span class="string">''</span>),<span class="string">'_'</span>,<span class="string">' '</span>), <span class="string">'\n'</span>], <span class="string">'\n'</span>]));
<span class="comment">%</span>
<span class="comment">% bmrk5pain</span>
<span class="comment">%</span>
this_st_id = 4;
newdat_st = dat{this_st_id};
[t, cov_names] = get_std_tbl_with_fixed_fx(newdat_st);
m = fitlm(t,<span class="string">'ResponseVar'</span>,<span class="string">'rating'</span>,<span class="keyword">...</span>
<span class="string">'PredictorVar'</span>,cov_names(~ismember(cov_names,{<span class="string">'sid'</span>,<span class="string">'rating'</span>,<span class="string">'vif'</span>})),<span class="keyword">...</span>
<span class="string">'Intercept'</span>,false);
partialR2 = partialRsquared(m);
<span class="keyword">if</span> abs(sum(partialR2.partialR2) - m.Rsquared.Ordinary) > 0.0001
warning([<span class="string">'Partial R2 computation doesn''t seem to be working for study '</span> int2str(this_st_id)]);
<span class="keyword">end</span>
R2 = table2array(partialR2);
figure(1)
T_idx = ismember(partialR2.Row,{<span class="string">'T'</span>});
sens_idx = ismember(partialR2.Row,{<span class="string">'siteN'</span>,<span class="string">'overallN'</span>,<span class="string">'runN'</span>});
sid_idx = find(contains(partialR2.Row,<span class="string">'sub'</span>));
cog_idx = ismember(partialR2.Row,{<span class="string">'cue'</span>,<span class="string">'ctrl'</span>,<span class="string">'social'</span>,<span class="string">'placebo'</span>,<span class="string">'value'</span>,<span class="string">'reveal'</span>,<span class="string">'handholding'</span>});
subplot(ceil(sqrt(1+n_datasets)), ceil((1+n_datasets)/ceil(sqrt(1+n_datasets))), this_st_id+1);
f = pie([sum(R2(T_idx)),sum(R2(sens_idx)),sum(R2(cog_idx)),sum(R2(sid_idx))],ones(4,1));
<span class="keyword">for</span> i = 2:2:6
<span class="keyword">if</span> strmatch(f(i).String,<span class="string">'0%'</span>)
f(i).String = <span class="string">''</span>;
<span class="keyword">end</span>
<span class="keyword">end</span>
f = f(1:2:end);
f(1).FaceColor = c(7,:); <span class="comment">% Temp</span>
f(2).FaceColor = c(3,:); <span class="comment">% Sensitization/Habituation</span>
f(3).FaceColor = <span class="string">'white'</span>; <span class="comment">% Subj fixed fx variance</span>
title(sprintf([[strrep(strrep(st_datasets{this_st_id},<span class="string">'_data.mat'</span>,<span class="string">''</span>),<span class="string">'_'</span>,<span class="string">' '</span>), <span class="string">'pain\n'</span>], <span class="string">'\n'</span>]));
<span class="comment">%</span>
<span class="comment">% remi</span>
<span class="comment">%</span>
this_st_id = 5;
newdat_st = dat{this_st_id};
[t, cov_names] = get_std_tbl_with_fixed_fx(newdat_st);
m = fitlm(t,<span class="string">'ResponseVar'</span>,<span class="string">'rating'</span>,<span class="keyword">...</span>
<span class="string">'PredictorVar'</span>,cov_names(~ismember(cov_names,{<span class="string">'sid'</span>,<span class="string">'rating'</span>,<span class="string">'runN'</span>,<span class="string">'overallN'</span>,<span class="string">'vif'</span>,<span class="string">'placebo'</span>})),<span class="keyword">...</span>
<span class="string">'Intercept'</span>,false);
partialR2 = partialRsquared(m);
<span class="keyword">if</span> abs(sum(partialR2.partialR2) - m.Rsquared.Ordinary) > 0.0001
warning([<span class="string">'Partial R2 computation doesn''t seem to be working for study '</span> int2str(this_st_id)]);
<span class="keyword">end</span>
R2 = table2array(partialR2);
figure(1)
T_idx = ismember(partialR2.Row,{<span class="string">'T'</span>});
drug_idx = ismember(partialR2.Row,{<span class="string">'drug'</span>});
sens_idx = ismember(partialR2.Row,{<span class="string">'siteN'</span>,<span class="string">'overallN'</span>,<span class="string">'runN'</span>});
sid_idx = find(contains(partialR2.Row,<span class="string">'sub'</span>));
cog_idx = ismember(partialR2.Row,{<span class="string">'cue'</span>,<span class="string">'ctrl'</span>,<span class="string">'social'</span>,<span class="string">'placebo'</span>,<span class="string">'value'</span>,<span class="string">'reveal'</span>,<span class="string">'handholding'</span>,<span class="string">'open'</span>});
subplot(ceil(sqrt(1+n_datasets)), ceil((1+n_datasets)/ceil(sqrt(1+n_datasets))), this_st_id+1);
f = pie([sum(R2(T_idx)),sum(R2(sens_idx)),sum(R2(cog_idx)),sum(R2(sid_idx)),sum(R2(drug_idx))],ones(5,1));
<span class="keyword">for</span> i = 2:2:10
<span class="keyword">if</span> strmatch(f(i).String,<span class="string">'0%'</span>)
f(i).String = <span class="string">''</span>
<span class="keyword">end</span>
<span class="keyword">end</span>
f(4).Position = f(4).Position - [0.2,0,0];
f = f(1:2:end);
f(1).FaceColor = c(7,:); <span class="comment">% Temp</span>
f(2).FaceColor = c(3,:); <span class="comment">% Sensitization/Habituation</span>
f(4).FaceColor = <span class="string">'white'</span>; <span class="comment">% Subj fixed fx variance</span>
f(3).FaceColor = c(1,:); <span class="comment">% cog variance</span>
f(5).FaceColor = c(2,:); <span class="comment">% drug variance</span>
title(sprintf([[strrep(strrep(st_datasets{this_st_id},<span class="string">'_data.mat'</span>,<span class="string">''</span>),<span class="string">'_'</span>,<span class="string">' '</span>), <span class="string">'\n'</span>], <span class="string">'\n'</span>]));
<span class="comment">%</span>
<span class="comment">% eval scebl</span>
<span class="comment">%</span>
this_st_id = 6;
newdat_st = dat{this_st_id};
[t, cov_names] = get_std_tbl_with_fixed_fx(newdat_st);
m = fitlm(t,<span class="string">'ResponseVar'</span>,<span class="string">'rating'</span>,<span class="keyword">...</span>
<span class="string">'PredictorVar'</span>,cov_names(~ismember(cov_names,{<span class="string">'sid'</span>,<span class="string">'rating'</span>,<span class="string">'overallN'</span>,<span class="string">'cue'</span>,<span class="string">'vif'</span>})),<span class="keyword">...</span>
<span class="string">'Intercept'</span>,false);
partialR2 = partialRsquared(m);
<span class="keyword">if</span> abs(sum(partialR2.partialR2) - m.Rsquared.Ordinary) > 0.0001
warning([<span class="string">'Partial R2 computation doesn''t seem to be working for study '</span> int2str(this_st_id)]);
<span class="keyword">end</span>
R2 = table2array(partialR2);
figure(1)
T_idx = ismember(partialR2.Row,{<span class="string">'T'</span>});
sens_idx = ismember(partialR2.Row,{<span class="string">'siteN'</span>,<span class="string">'overallN'</span>,<span class="string">'runN'</span>});
sid_idx = find(contains(partialR2.Row,<span class="string">'sub'</span>));
cog_idx = ismember(partialR2.Row,{<span class="string">'cue'</span>,<span class="string">'ctrl'</span>,<span class="string">'social'</span>,<span class="string">'placebo'</span>,<span class="string">'value'</span>,<span class="string">'reveal'</span>,<span class="string">'handholding'</span>});
subplot(ceil(sqrt(1+n_datasets)), ceil((1+n_datasets)/ceil(sqrt(1+n_datasets))), this_st_id+1);
f = pie([sum(R2(T_idx)),sum(R2(sens_idx)),sum(R2(cog_idx)),sum(R2(sid_idx))],ones(4,1));
<span class="keyword">for</span> i = 2:2:8
<span class="keyword">if</span> strmatch(f(i).String,<span class="string">'0%'</span>)
f(i).String = <span class="string">''</span>
<span class="keyword">end</span>
<span class="keyword">end</span>
f(4).Position = f(4).Position - [0.25,-0.25,0];
f = f(1:2:end);
f(1).FaceColor = c(7,:); <span class="comment">% Temp</span>
f(2).FaceColor = c(3,:); <span class="comment">% Sensitization/Habituation</span>
f(4).FaceColor = <span class="string">'white'</span>; <span class="comment">% Subj fixed fx variance</span>
f(3).FaceColor = c(1,:); <span class="comment">% cog variance</span>
title(sprintf([[strrep(strrep(st_datasets{this_st_id},<span class="string">'_data.mat'</span>,<span class="string">''</span>),<span class="string">'_'</span>,<span class="string">' '</span>), <span class="string">'\n'</span>], <span class="string">'\n'</span>]));
<span class="comment">%</span>
<span class="comment">% eval ie2</span>
<span class="comment">%</span>
this_st_id = 7;
newdat_st = dat{this_st_id};
[t, cov_names] = get_std_tbl_with_fixed_fx(newdat_st);
m = fitlm(t,<span class="string">'ResponseVar'</span>,<span class="string">'rating'</span>,<span class="keyword">...</span>
<span class="string">'PredictorVar'</span>,cov_names(~ismember(cov_names,{<span class="string">'sid'</span>,<span class="string">'rating'</span>,<span class="string">'high_vif'</span>,<span class="string">'overallN'</span>})),<span class="keyword">...</span>
<span class="string">'Intercept'</span>,false);
partialR2 = partialRsquared(m);
<span class="keyword">if</span> abs(sum(partialR2.partialR2) - m.Rsquared.Ordinary) > 0.0001
warning([<span class="string">'Partial R2 computation doesn''t seem to be working for study '</span> int2str(this_st_id)]);
<span class="keyword">end</span>
R2 = table2array(partialR2);
figure(1)
T_idx = ismember(partialR2.Row,{<span class="string">'T'</span>});
sens_idx = ismember(partialR2.Row,{<span class="string">'siteN'</span>,<span class="string">'overallN'</span>,<span class="string">'runN'</span>});
sid_idx = find(contains(partialR2.Row,<span class="string">'sub'</span>));
cog_idx = ismember(partialR2.Row,{<span class="string">'cue'</span>,<span class="string">'ctrl'</span>,<span class="string">'social'</span>,<span class="string">'placebo'</span>,<span class="string">'value'</span>,<span class="string">'reveal'</span>,<span class="string">'handholding'</span>});
subplot(ceil(sqrt(1+n_datasets)), ceil((1+n_datasets)/ceil(sqrt(1+n_datasets))), this_st_id+1);
f = pie([sum(R2(T_idx)),sum(R2(sens_idx)),sum(R2(cog_idx)),sum(R2(sid_idx))],ones(4,1));
<span class="keyword">for</span> i = 2:2:8
<span class="keyword">if</span> strmatch(f(i).String,<span class="string">'0%'</span>)
f(i).String = <span class="string">''</span>
<span class="keyword">end</span>
<span class="keyword">end</span>
f(4).Position = f(4).Position - [0.25,-0.25,0];
f = f(1:2:end);
f(1).FaceColor = c(7,:); <span class="comment">% Temp</span>
f(2).FaceColor = c(3,:); <span class="comment">% Sensitization/Habituation</span>
f(4).FaceColor = <span class="string">'white'</span>; <span class="comment">% Subj fixed fx variance</span>
f(3).FaceColor = c(1,:); <span class="comment">% cog variance</span>
title(sprintf([[strrep(strrep(st_datasets{this_st_id},<span class="string">'_data.mat'</span>,<span class="string">''</span>),<span class="string">'_'</span>,<span class="string">' '</span>), <span class="string">'\n'</span>], <span class="string">'\n'</span>]));
<span class="comment">%</span>
<span class="comment">% eval ie</span>
<span class="comment">%</span>
this_st_id = 8;
newdat_st = dat{this_st_id};
[t, cov_names] = get_std_tbl_with_fixed_fx(newdat_st);
m = fitlm(t,<span class="string">'ResponseVar'</span>,<span class="string">'rating'</span>,<span class="keyword">...</span>
<span class="string">'PredictorVar'</span>,cov_names(~ismember(cov_names,{<span class="string">'sid'</span>,<span class="string">'rating'</span>,<span class="string">'siteN'</span>,<span class="string">'runN'</span>,<span class="string">'overallN'</span>})),<span class="keyword">...</span>
<span class="string">'Intercept'</span>,false);
partialR2 = partialRsquared(m);
<span class="keyword">if</span> abs(sum(partialR2.partialR2) - m.Rsquared.Ordinary) > 0.0001
warning([<span class="string">'Partial R2 computation doesn''t seem to be working for study '</span> int2str(this_st_id)]);
<span class="keyword">end</span>
R2 = table2array(partialR2);
figure(1)
T_idx = ismember(partialR2.Row,{<span class="string">'T'</span>});
sens_idx = ismember(partialR2.Row,{<span class="string">'siteN'</span>,<span class="string">'overallN'</span>,<span class="string">'runN'</span>});
sid_idx = find(contains(partialR2.Row,<span class="string">'sub'</span>));
cog_idx = ismember(partialR2.Row,{<span class="string">'cue'</span>,<span class="string">'ctrl'</span>,<span class="string">'social'</span>,<span class="string">'placebo'</span>,<span class="string">'value'</span>,<span class="string">'reveal'</span>,<span class="string">'handholding'</span>});
subplot(ceil(sqrt(1+n_datasets)), ceil((1+n_datasets)/ceil(sqrt(1+n_datasets))), this_st_id+1);
f = pie([sum(R2(T_idx)),sum(R2(sens_idx)),sum(R2(cog_idx)),sum(R2(sid_idx))],ones(4,1));
<span class="keyword">for</span> i = 2:2:6
<span class="keyword">if</span> strmatch(f(i).String,<span class="string">'0%'</span>)
f(i).String = <span class="string">''</span>
<span class="keyword">end</span>
<span class="keyword">end</span>
f = f(1:2:end);
f(1).FaceColor = c(7,:); <span class="comment">% Temp</span>
f(3).FaceColor = <span class="string">'white'</span>; <span class="comment">% Subj fixed fx variance</span>
f(2).FaceColor = c(1,:); <span class="comment">% cog variance</span>
title(sprintf([[strrep(strrep(st_datasets{this_st_id},<span class="string">'_data.mat'</span>,<span class="string">''</span>),<span class="string">'_'</span>,<span class="string">' '</span>), <span class="string">'\n'</span>], <span class="string">'\n'</span>]));
<span class="comment">%</span>
<span class="comment">% eval_exp</span>
<span class="comment">%</span>
this_st_id = 9;
newdat_st = dat{this_st_id};
[t, cov_names] = get_std_tbl_with_fixed_fx(newdat_st);
m = fitlm(t,<span class="string">'ResponseVar'</span>,<span class="string">'rating'</span>,<span class="keyword">...</span>
<span class="string">'PredictorVar'</span>,cov_names(~ismember(cov_names,{<span class="string">'sid'</span>,<span class="string">'rating'</span>,<span class="string">'runN'</span>,<span class="string">'siteN'</span>,<span class="string">'vif'</span>})),<span class="keyword">...</span>
<span class="string">'Intercept'</span>,false);
partialR2 = partialRsquared(m);
<span class="keyword">if</span> abs(sum(partialR2.partialR2) - m.Rsquared.Ordinary) > 0.0001
warning([<span class="string">'Partial R2 computation doesn''t seem to be working for study '</span> int2str(this_st_id)]);
<span class="keyword">end</span>
R2 = table2array(partialR2);
figure(1)
T_idx = ismember(partialR2.Row,{<span class="string">'T'</span>});
sens_idx = ismember(partialR2.Row,{<span class="string">'siteN'</span>,<span class="string">'overallN'</span>,<span class="string">'runN'</span>});
sid_idx = find(contains(partialR2.Row,<span class="string">'sub'</span>));
cog_idx = ismember(partialR2.Row,{<span class="string">'cue'</span>,<span class="string">'ctrl'</span>,<span class="string">'social'</span>,<span class="string">'placebo'</span>,<span class="string">'value'</span>,<span class="string">'reveal'</span>,<span class="string">'handholding'</span>});
subplot(ceil(sqrt(1+n_datasets)), ceil((1+n_datasets)/ceil(sqrt(1+n_datasets))), this_st_id+1);
f = pie([sum(R2(T_idx)),sum(R2(sens_idx)),sum(R2(cog_idx)),sum(R2(sid_idx))],ones(4,1));
<span class="keyword">for</span> i = 2:2:8
<span class="keyword">if</span> strmatch(f(i).String,<span class="string">'0%'</span>)
f(i).String = <span class="string">''</span>
<span class="keyword">end</span>
<span class="keyword">end</span>
f = f(1:2:end);
f(1).FaceColor = c(7,:); <span class="comment">% Temp</span>
f(2).FaceColor = c(3,:); <span class="comment">% Sensitization/Habituation</span>
f(4).FaceColor = <span class="string">'white'</span>; <span class="comment">% Subj fixed fx variance</span>
f(3).FaceColor = c(1,:); <span class="comment">% cog variance</span>
title(sprintf([[strrep(strrep(st_datasets{this_st_id},<span class="string">'_data.mat'</span>,<span class="string">''</span>),<span class="string">'_'</span>,<span class="string">' '</span>), <span class="string">'\n'</span>], <span class="string">'\n'</span>]));
<span class="comment">%</span>
<span class="comment">% eval levoderm</span>
<span class="comment">%</span>
this_st_id = 10;
newdat_st = dat{this_st_id};
[t, cov_names] = get_std_tbl_with_fixed_fx(newdat_st);
m = fitlm(t,<span class="string">'ResponseVar'</span>,<span class="string">'rating'</span>,<span class="keyword">...</span>
<span class="string">'PredictorVar'</span>,cov_names(~ismember(cov_names,{<span class="string">'sid'</span>,<span class="string">'rating'</span>,<span class="string">'vif'</span>,<span class="string">'reveal'</span>,<span class="string">'conditioningN'</span>,<span class="string">'runN'</span>,<span class="string">'siteN'</span>,<span class="string">'overallN'</span>})),<span class="keyword">...</span>
<span class="string">'Intercept'</span>,false);
partialR2 = partialRsquared(m);
<span class="keyword">if</span> abs(sum(partialR2.partialR2) - m.Rsquared.Ordinary) > 0.0001
warning([<span class="string">'Partial R2 computation doesn''t seem to be working for study '</span> int2str(this_st_id)]);
<span class="keyword">end</span>
R2 = table2array(partialR2);
figure(1)
T_idx = ismember(partialR2.Row,{<span class="string">'T'</span>});
sens_idx = ismember(partialR2.Row,{<span class="string">'siteN'</span>,<span class="string">'overallN'</span>,<span class="string">'runN'</span>});
sid_idx = find(contains(partialR2.Row,<span class="string">'sub'</span>));
cog_idx = ismember(partialR2.Row,{<span class="string">'cue'</span>,<span class="string">'ctrl'</span>,<span class="string">'social'</span>,<span class="string">'placebo'</span>,<span class="string">'value'</span>,<span class="string">'reveal'</span>,<span class="string">'handholding'</span>,<span class="string">'reveal'</span>});
subplot(ceil(sqrt(1+n_datasets)), ceil((1+n_datasets)/ceil(sqrt(1+n_datasets))), this_st_id+1);
f = pie([sum(R2(T_idx)),sum(R2(sens_idx)),sum(R2(cog_idx)),sum(R2(sid_idx))],ones(4,1));
<span class="keyword">for</span> i = 2:2:6
<span class="keyword">if</span> strmatch(f(i).String,<span class="string">'0%'</span>)
f(i).String = <span class="string">''</span>
<span class="keyword">end</span>
<span class="keyword">end</span>
f = f(1:2:end);
f(1).FaceColor = c(7,:); <span class="comment">% Temp</span>
f(3).FaceColor = <span class="string">'white'</span>; <span class="comment">% Subj fixed fx variance</span>
f(2).FaceColor = c(1,:); <span class="comment">% cog variance</span>
title(sprintf([[strrep(strrep(st_datasets{this_st_id},<span class="string">'_data.mat'</span>,<span class="string">''</span>),<span class="string">'_'</span>,<span class="string">' '</span>), <span class="string">'\n'</span>], <span class="string">'\n'</span>]));
<span class="comment">%</span>
<span class="comment">% eval stephan</span>
<span class="comment">%</span>
this_st_id = 11;
newdat_st = dat{this_st_id};
[t, cov_names] = get_std_tbl_with_fixed_fx(newdat_st);
t.int = zscore(t.placebo.*t.value);
cov_names = [cov_names,<span class="string">'int'</span>];
m = fitlm(t,<span class="string">'ResponseVar'</span>,<span class="string">'rating'</span>,<span class="keyword">...</span>
<span class="string">'PredictorVar'</span>,cov_names(~ismember(cov_names,{<span class="string">'T'</span>,<span class="string">'sid'</span>,<span class="string">'rating'</span>,<span class="string">'overallN'</span>,<span class="string">'vif'</span>,<span class="string">'runN'</span>})),<span class="keyword">...</span>
<span class="string">'Intercept'</span>,false);
partialR2 = partialRsquared(m);
<span class="keyword">if</span> abs(sum(partialR2.partialR2) - m.Rsquared.Ordinary) > 0.0001
warning([<span class="string">'Partial R2 computation doesn''t seem to be working for study '</span> int2str(this_st_id)]);
<span class="keyword">end</span>
R2 = table2array(partialR2);
figure(1)
T_idx = ismember(partialR2.Row,{<span class="string">'T'</span>});
sens_idx = ismember(partialR2.Row,{<span class="string">'siteN'</span>,<span class="string">'overallN'</span>,<span class="string">'runN'</span>});
sid_idx = find(contains(partialR2.Row,<span class="string">'sub'</span>));
cog_idx = ismember(partialR2.Row,{<span class="string">'cue'</span>,<span class="string">'ctrl'</span>,<span class="string">'social'</span>,<span class="string">'placebo'</span>,<span class="string">'value'</span>,<span class="string">'int'</span>,<span class="string">'reveal'</span>,<span class="string">'handholding'</span>});
subplot(ceil(sqrt(1+n_datasets)), ceil((1+n_datasets)/ceil(sqrt(1+n_datasets))), this_st_id+1);
f = pie([sum(R2(T_idx)),sum(R2(sens_idx)),sum(R2(cog_idx)),sum(R2(sid_idx))],ones(4,1));
<span class="keyword">for</span> i = 2:2:6
<span class="keyword">if</span> strmatch(f(i).String,<span class="string">'0%'</span>)
f(i).String = <span class="string">''</span>
<span class="keyword">end</span>
<span class="keyword">end</span>
f = f(1:2:end);
f(1).FaceColor = c(3,:); <span class="comment">% Sensitization/Habituation</span>
f(3).FaceColor = <span class="string">'white'</span>; <span class="comment">% Subj fixed fx variance</span>
f(2).FaceColor = c(1,:); <span class="comment">% cog variance</span>
title(sprintf([[strrep(strrep(st_datasets{this_st_id},<span class="string">'_data.mat'</span>,<span class="string">''</span>),<span class="string">'_'</span>,<span class="string">' '</span>), <span class="string">'\n'</span>], <span class="string">'\n'</span>]));
<span class="comment">%</span>
<span class="comment">% eval romantic</span>
<span class="comment">%</span>
this_st_id = 12;
newdat_st = dat{this_st_id};
[t, cov_names] = get_std_tbl_with_fixed_fx(newdat_st);
m = fitlm(t,<span class="string">'ResponseVar'</span>,<span class="string">'rating'</span>,<span class="keyword">...</span>
<span class="string">'PredictorVar'</span>,cov_names(~ismember(cov_names,{<span class="string">'sid'</span>,<span class="string">'rating'</span>,<span class="string">'overallN'</span>,<span class="string">'runN'</span>,<span class="string">'T'</span>,<span class="string">'high_vif'</span>})),<span class="keyword">...</span>
<span class="string">'Intercept'</span>,false);
partialR2 = partialRsquared(m);
<span class="keyword">if</span> abs(sum(partialR2.partialR2) - m.Rsquared.Ordinary) > 0.0001
warning([<span class="string">'Partial R2 computation doesn''t seem to be working for study '</span> int2str(this_st_id)]);
<span class="keyword">end</span>
R2 = table2array(partialR2);
figure(1)
T_idx = ismember(partialR2.Row,{<span class="string">'T'</span>});
sens_idx = ismember(partialR2.Row,{<span class="string">'siteN'</span>,<span class="string">'overallN'</span>,<span class="string">'runN'</span>});
sid_idx = find(contains(partialR2.Row,<span class="string">'sub'</span>));
cog_idx = ismember(partialR2.Row,{<span class="string">'cue'</span>,<span class="string">'ctrl'</span>,<span class="string">'social'</span>,<span class="string">'placebo'</span>,<span class="string">'value'</span>,<span class="string">'reveal'</span>,<span class="string">'handholding'</span>});
subplot(ceil(sqrt(1+n_datasets)), ceil((1+n_datasets)/ceil(sqrt(1+n_datasets))), this_st_id+1);
f = pie([sum(R2(T_idx)),sum(R2(sens_idx)),sum(R2(cog_idx)),sum(R2(sid_idx))],ones(4,1));
<span class="keyword">for</span> i = 2:2:4
<span class="keyword">if</span> strmatch(f(i).String,<span class="string">'0%'</span>)
f(i).String = <span class="string">''</span>
<span class="keyword">end</span>
<span class="keyword">end</span>
f(2).Position = f(2).Position - [-0.25,0,0];
f(4).Position = f(4).Position - [0.25,0,0];
f = f(1:2:end);
f(1).FaceColor = c(3,:); <span class="comment">% Sensitization/Habituation</span>
f(3).FaceColor = <span class="string">'white'</span>; <span class="comment">% Subj fixed fx variance</span>
f(2).FaceColor = c(1,:); <span class="comment">% cog variance</span>
title(sprintf([[strrep(strrep(st_datasets{this_st_id},<span class="string">'_data.mat'</span>,<span class="string">''</span>),<span class="string">'_'</span>,<span class="string">' '</span>), <span class="string">'\n'</span>], <span class="string">'\n'</span>]));
<span class="comment">%</span>
<span class="comment">% eval ilcp</span>
<span class="comment">%</span>
this_st_id = 13;
newdat_st = dat{this_st_id};
[t, cov_names] = get_std_tbl_with_fixed_fx(newdat_st);
m = fitlm(t,<span class="string">'ResponseVar'</span>,<span class="string">'rating'</span>,<span class="keyword">...</span>
<span class="string">'PredictorVar'</span>,cov_names(~ismember(cov_names,{<span class="string">'sid'</span>,<span class="string">'rating'</span>,<span class="string">'cue'</span>,<span class="string">'overallN'</span>,<span class="string">'runN'</span>,<span class="string">'vif'</span>})),<span class="keyword">...</span>
<span class="string">'Intercept'</span>,false);
partialR2 = partialRsquared(m);
<span class="keyword">if</span> abs(sum(partialR2.partialR2) - m.Rsquared.Ordinary) > 0.0001
warning([<span class="string">'Partial R2 computation doesn''t seem to be working for study '</span> int2str(this_st_id)]);
<span class="keyword">end</span>
R2 = table2array(partialR2);
figure(1)
T_idx = ismember(partialR2.Row,{<span class="string">'T'</span>});
sens_idx = ismember(partialR2.Row,{<span class="string">'siteN'</span>,<span class="string">'overallN'</span>,<span class="string">'runN'</span>});
sid_idx = find(contains(partialR2.Row,<span class="string">'sub'</span>));
cog_idx = ismember(partialR2.Row,{<span class="string">'cue'</span>,<span class="string">'ctrl'</span>,<span class="string">'social'</span>,<span class="string">'placebo'</span>,<span class="string">'value'</span>,<span class="string">'reveal'</span>,<span class="string">'handholding'</span>});
subplot(ceil(sqrt(1+n_datasets)), ceil((1+n_datasets)/ceil(sqrt(1+n_datasets))), this_st_id+1);
f = pie([sum(R2(T_idx)),sum(R2(sens_idx)),sum(R2(cog_idx)),sum(R2(sid_idx))],ones(4,1));
<span class="keyword">for</span> i = 2:2:8
<span class="keyword">if</span> strmatch(f(i).String,<span class="string">'0%'</span>)
f(i).String = <span class="string">''</span>
<span class="keyword">end</span>
<span class="keyword">end</span>
f = f(1:2:end);
f(1).FaceColor = c(7,:); <span class="comment">% Temp</span>
f(2).FaceColor = c(3,:); <span class="comment">% Sensitization/Habituation</span>
f(4).FaceColor = <span class="string">'white'</span>; <span class="comment">% Subj fixed fx variance</span>
f(3).FaceColor = c(1,:); <span class="comment">% cog variance</span>
title(sprintf([[strrep(strrep(st_datasets{this_st_id},<span class="string">'_data.mat'</span>,<span class="string">''</span>),<span class="string">'_'</span>,<span class="string">' '</span>), <span class="string">'\n'</span>], <span class="string">'\n'</span>]));
<span class="comment">%</span>
<span class="comment">% bmr3heat</span>
<span class="comment">%</span>
this_st_id = 14;
newdat_st = dat{this_st_id};
[t, cov_names] = get_std_tbl_with_fixed_fx(newdat_st);
m = fitlm(t,<span class="string">'ResponseVar'</span>,<span class="string">'rating'</span>,<span class="keyword">...</span>
<span class="string">'PredictorVar'</span>,cov_names(~ismember(cov_names,{<span class="string">'sid'</span>,<span class="string">'rating'</span>,<span class="string">'high_vif'</span>,<span class="string">'overallN'</span>,<span class="string">'siteN'</span>})),<span class="keyword">...</span>
<span class="string">'Intercept'</span>,false);
partialR2 = partialRsquared(m);
<span class="keyword">if</span> abs(sum(partialR2.partialR2) - m.Rsquared.Ordinary) > 0.0001
warning([<span class="string">'Partial R2 computation doesn''t seem to be working for study '</span> int2str(this_st_id)]);
<span class="keyword">end</span>
R2 = table2array(partialR2);
figure(1)
T_idx = ismember(partialR2.Row,{<span class="string">'T'</span>});
sens_idx = ismember(partialR2.Row,{<span class="string">'siteN'</span>,<span class="string">'overallN'</span>,<span class="string">'runN'</span>});
sid_idx = find(contains(partialR2.Row,<span class="string">'sub'</span>));
cog_idx = ismember(partialR2.Row,{<span class="string">'cue'</span>,<span class="string">'ctrl'</span>,<span class="string">'social'</span>,<span class="string">'placebo'</span>,<span class="string">'value'</span>,<span class="string">'reveal'</span>,<span class="string">'handholding'</span>});
subplot(ceil(sqrt(1+n_datasets)), ceil((1+n_datasets)/ceil(sqrt(1+n_datasets))), this_st_id+1);
f = pie([sum(R2(T_idx)),sum(R2(sens_idx)),sum(R2(cog_idx)),sum(R2(sid_idx))],ones(4,1));
<span class="keyword">for</span> i = 2:2:6
<span class="keyword">if</span> strmatch(f(i).String,<span class="string">'0%'</span>)
f(i).String = <span class="string">''</span>
<span class="keyword">end</span>
<span class="keyword">end</span>
f(2).Position = f(2).Position - [-0.25,0,0];
f = f(1:2:end);
f(1).FaceColor = c(7,:); <span class="comment">% Temp</span>
f(2).FaceColor = c(3,:); <span class="comment">% Sensitization/Habituation</span>
f(3).FaceColor = <span class="string">'white'</span>; <span class="comment">% Subj fixed fx variance</span>
title(sprintf(<span class="string">'bmrk3warm\n\n'</span>));
<span class="comment">%</span>
<span class="comment">% bmrk5snd</span>
<span class="comment">%</span>
this_st_id = 15;
newdat_st = dat{this_st_id};
[t, cov_names] = get_std_tbl_with_fixed_fx(newdat_st);
m = fitlm(t,<span class="string">'ResponseVar'</span>,<span class="string">'rating'</span>,<span class="keyword">...</span>
<span class="string">'PredictorVar'</span>,cov_names(~ismember(cov_names,{<span class="string">'sid'</span>,<span class="string">'rating'</span>,<span class="string">'high_vif'</span>,<span class="string">'vif'</span>,<span class="string">'overallN'</span>,<span class="string">'siteN'</span>})),<span class="keyword">...</span>
<span class="string">'Intercept'</span>,false);
partialR2 = partialRsquared(m);
<span class="keyword">if</span> abs(sum(partialR2.partialR2) - m.Rsquared.Ordinary) > 0.0001
warning([<span class="string">'Partial R2 computation doesn''t seem to be working for study '</span> int2str(this_st_id)]);
<span class="keyword">end</span>
R2 = table2array(partialR2);
figure(1)
T_idx = ismember(partialR2.Row,{<span class="string">'T'</span>,<span class="string">'soundintensity'</span>});
sens_idx = ismember(partialR2.Row,{<span class="string">'siteN'</span>,<span class="string">'overallN'</span>,<span class="string">'runN'</span>});
sid_idx = find(contains(partialR2.Row,<span class="string">'sub'</span>));
cog_idx = ismember(partialR2.Row,{<span class="string">'cue'</span>,<span class="string">'ctrl'</span>,<span class="string">'social'</span>,<span class="string">'placebo'</span>,<span class="string">'value'</span>,<span class="string">'reveal'</span>,<span class="string">'handholding'</span>});
subplot(ceil(sqrt(1+n_datasets)), ceil((1+n_datasets)/ceil(sqrt(1+n_datasets))), this_st_id+1);
f = pie([sum(R2(T_idx)),sum(R2(sens_idx)),sum(R2(cog_idx)),sum(R2(sid_idx))],ones(4,1));
<span class="keyword">for</span> i = 2:2:6
<span class="keyword">if</span> strmatch(f(i).String,<span class="string">'0%'</span>)
f(i).String = <span class="string">''</span>
<span class="keyword">end</span>
<span class="keyword">end</span>
f(2).Position = f(2).Position - [-0.3,0,0];
f(4).Position = f(4).Position - [0.3,0,0];
f = f(1:2:end);
f(1).FaceColor = c(4,:); <span class="comment">% sound</span>
f(2).FaceColor = c(3,:); <span class="comment">% Sensitization/Habituation</span>
f(3).FaceColor = <span class="string">'white'</span>; <span class="comment">% Subj fixed fx variance</span>
title(sprintf(<span class="string">'bmrk5snd\n\n'</span>));
<span class="comment">%</span>
<span class="comment">% eval all pain</span>
<span class="comment">%</span>
t = expand_metadata_table(dat{1:length(st_datasets)});
<span class="keyword">for</span> i = 1:length(t)
t{i}.st_id = cellstr(repmat(st_datasets{i},height(t{i}),1));
t{i}.rating = zscore(t{i}.rating);
<span class="keyword">end</span>
t = tbl_vcat(t{:});
[~,~,sid] = unique([char(t.subject_id), char(t.st_id)],<span class="string">'rows'</span>,<span class="string">'stable'</span>);
t.subject_id = sid;
[~,~,st_id] = unique(char(t.st_id),<span class="string">'rows'</span>,<span class="string">'stable'</span>);
t.st_id = st_id;
<span class="comment">% manually set some defaults</span>
t.placebo(isnan(t.placebo)) = 0;
t.drug(isnan(t.drug)) = 0;
t.open(isnan(t.open)) = 0;
t.open(t.placebo == 1) = 1; <span class="comment">% all placebos are effectively "open" drug label in the sense used in the remifentanil study</span>
t.handholding(isnan(t.handholding)) = 0;
t.reg(isnan(t.reg)) = 0;
t.reveal(isnan(t.reveal)) = 0;
t.social(isnan(t.social)) = 0;
t.value(isnan(t.value)) = 0;
t.ctrl(isnan(t.ctrl)) = 0;
t.high_vif(isnan(t.high_vif)) = 0;
t.vif(isnan(t.vif)) = 0;
new_t = t(~t.high_vif | t.vif > 2.5,:);
t = new_t;
t.int = t.value.*t.placebo;
[t, cov_names] = get_std_tbl_with_fixed_fx(t);
m = fitlm(t,<span class="string">'ResponseVar'</span>,<span class="string">'rating'</span>,<span class="keyword">...</span>
<span class="string">'PredictorVar'</span>,cov_names(~ismember(cov_names,<span class="keyword">...</span>
{<span class="string">'conditioningN'</span>,<span class="string">'high_vif'</span>,<span class="string">'rating'</span>,<span class="keyword">...</span>
<span class="string">'soundintensity'</span>,<span class="string">'st_id'</span>,<span class="string">'subject_id'</span>,<span class="string">'vif'</span>,<span class="string">'reveal'</span>})),<span class="keyword">...</span>
<span class="string">'Intercept'</span>,false);
partialR2 = partialRsquared(m);
<span class="keyword">if</span> abs(sum(partialR2.partialR2) - m.Rsquared.Ordinary) > 0.0001
warning([<span class="string">'Partial R2 computation doesn''t seem to be working for study '</span> int2str(this_st_id)]);
<span class="keyword">end</span>
R2 = table2array(partialR2);
figure(1)
T_idx = ismember(partialR2.Row,{<span class="string">'T'</span>});
sens_idx = ismember(partialR2.Row,{<span class="string">'siteN'</span>,<span class="string">'overallN'</span>,<span class="string">'runN'</span>});
sid_idx = find(contains(partialR2.Row,<span class="string">'sub'</span>));
cog_idx = ismember(partialR2.Row,{<span class="string">'cue'</span>,<span class="string">'ctrl'</span>,<span class="string">'social'</span>,<span class="string">'placebo'</span>,<span class="string">'value'</span>,<span class="string">'reveal'</span>,<span class="string">'handholding'</span>});
drug_idx = ismember(partialR2.Row,<span class="string">'drug'</span>);
subplot(ceil(sqrt(1+n_datasets)), ceil((1+n_datasets)/ceil(sqrt(1+n_datasets))), 1);
f = pie([sum(R2(T_idx)),sum(R2(sens_idx)),sum(R2(cog_idx)),sum(R2(sid_idx)),sum(R2(drug_idx))],ones(5,1));
<span class="keyword">for</span> i = 2:2:10
<span class="keyword">if</span> strmatch(f(i).String,<span class="string">'0%'</span>)
f(i).String = <span class="string">''</span>
<span class="keyword">end</span>
<span class="keyword">end</span>
f(4).Position = f(4).Position - [0.1,-0.1,0];
f(6).Position = f(6).Position - [0.1,0.2,0];
f = f(1:2:end);
f(1).FaceColor = c(7,:); <span class="comment">% Temp</span>
f(2).FaceColor = c(3,:); <span class="comment">% Sensitization/Habituation</span>
f(4).FaceColor = <span class="string">'white'</span>; <span class="comment">% Subj fixed fx variance</span>
f(3).FaceColor = c(1,:); <span class="comment">% cog variance</span>
f(5).FaceColor = c(2,:); <span class="comment">% drug variance</span>
title(sprintf(<span class="string">'Pain Datasets (n=13) \n Aggregate\n'</span>))
l = legend({<span class="string">'T'</span>,<span class="string">'Sens/Habit'</span>,<span class="string">'Cog'</span>,<span class="string">'Subject'</span>,<span class="string">'Drug'</span>},<span class="string">'location'</span>,<span class="string">'southwest'</span>);
l.Position = l.Position - [0.17,0,0,0];
set(get(gca,<span class="string">'Legend'</span>),<span class="string">'FontSize'</span>,10)
p = get(gcf,<span class="string">'Position'</span>);
set(gcf,<span class="string">'Position'</span>,[p(1:2), 1248, 966]);
</pre><img vspace="5" hspace="5" src="QC_main_01.png" alt=""> <h2 id="4">Quantify signal strength using SVR brain decoding</h2><p>- obfuscate dataset identity to discourage chery picking for future analysis based on SNR. Any studies with SNR so low as to suggest corrupt data will be identified. Otherwise, the purpose of what follows is to provide guidelines for what one can expect in terms of decoding performance when using linear MVPA methods.</p><p>- control for subject fixed effects, since experience suggests between subject effects aren't detected very well. We will print out raw r^2 values for predicted vs. observed though for comparison for those who are curious.</p><pre class="codeinput">st_datasets = {<span class="string">'nsf'</span>,<span class="string">'bmrk3pain'</span>,<span class="string">'bmrk4'</span>,<span class="string">'bmrk5pain'</span>,<span class="string">'remi'</span>,<span class="string">'scebl'</span>,<span class="string">'ie2'</span>,<span class="string">'ie'</span>,<span class="keyword">...</span>
<span class="string">'exp'</span>,<span class="string">'levoderm'</span>,<span class="string">'stephan'</span>,<span class="string">'romantic'</span>,<span class="string">'ilcp'</span>,<span class="string">'bmrk3warm'</span>,<span class="string">'bmrk5snd'</span>};
<span class="comment">% obfuscate identity</span>
st_datsets = st_datasets(randperm(length(st_datasets)));
[cverr, stats, optout, obs, subject_id] = deal(cell(length(st_datasets),1));
<span class="keyword">if</span> ~isempty(gcp(<span class="string">'nocreate'</span>))
delete(gcp(<span class="string">'nocreate'</span>))
<span class="keyword">end</span>
parpool(16);
<span class="keyword">parfor</span> i = 1:length(st_datasets)
warning(<span class="string">'off'</span>,<span class="string">'all'</span>)
<span class="comment">% capture output to prevent clues that might reveal which dataset this</span>
<span class="comment">% is</span>
this_data = load_image_set(st_datasets{i});
<span class="comment">% remove any trials lacking responses (dat.Y = nan), or with high VIF</span>
good_trials = ones(length(this_data.Y),1);
fnames = this_data.metadata_table.Properties.VariableNames;
<span class="keyword">if</span> any(ismember(fnames,<span class="string">'high_vif'</span>))
good_trials(this_data.metadata_table.high_vif == 1) = 0;
<span class="keyword">end</span>
<span class="keyword">if</span> any(ismember(fnames,<span class="string">'vif'</span>))
good_trials(this_data.metadata_table.vif >= 2.5) = 0;
<span class="keyword">end</span>
good_trials(isnan(this_data.Y)) = 0;
good_trials = logical(good_trials);
this_data = this_data.get_wh_image(good_trials);
<span class="comment">% specify folds manually to maintain subject groupings across fold</span>
<span class="comment">% slicings</span>
[~,~,subject_id{i}] = unique(char(this_data.metadata_table.subject_id),<span class="string">'rows'</span>,<span class="string">'stable'</span>);
cv = cvpartition2(ones(size(this_data.dat,2),1), <span class="string">'KFOLD'</span>, 5, <span class="string">'Stratify'</span>, subject_id{i});
fold_labels = zeros(size(this_data.dat,2),1);
<span class="keyword">for</span> j = 1:cv.NumTestSets
fold_labels(cv.test(j)) = j;
<span class="keyword">end</span>
[cverr{i},stats{i},optout{i}] = this_data.predict(<span class="string">'algorithm_name'</span>, <span class="string">'cv_svr'</span>, <span class="string">'nfolds'</span>, fold_labels, <span class="string">'error_type'</span>, <span class="string">'mse'</span>, <span class="string">'useparallel'</span>, 0, <span class="string">'verbose'</span>, 0);
obs{i} = this_data.Y;
<span class="keyword">end</span>
<span class="keyword">for</span> i = 1:length(st_datasets)
<span class="comment">% plot results</span>
figure(2)
subplot(ceil(sqrt(n_datasets)), ceil((n_datasets)/ceil(sqrt(n_datasets))), i);
r2 = corr(stats{i}.yfit, obs{i}).^2;
f = pie(r2);
f = f(1:2:end);
f(1).FaceColor = [0.5,0.5,0.5]; <span class="comment">% svr</span>
<span class="keyword">if</span> ismember(st_datasets{i},{<span class="string">'bmrk3warm'</span>,<span class="string">'bmrk5pain'</span>})
title(sprintf(<span class="string">'Random dataset %d\n(nonpain)\n'</span>, i));
<span class="keyword">else</span>
title(sprintf(<span class="string">'Random dataset %d\n\n'</span>, i));
<span class="keyword">end</span>
<span class="keyword">end</span>
save(<span class="string">'st_datasets.mat'</span>,<span class="string">'st_datasets'</span>,<span class="string">'cverr'</span>,<span class="string">'stats'</span>,<span class="string">'optout'</span>,<span class="string">'obs'</span>,<span class="string">'subject_id'</span>);
p = get(gcf,<span class="string">'Position'</span>);
set(gcf,<span class="string">'Position'</span>,[p(1:2), 1248, 966]);
</pre><pre class="codeoutput">Parallel pool using the 'local' profile is shutting down.
Starting parallel pool (parpool) using the 'local' profile ...
connected to 16 workers.
Source: Romantic Pain data from Tor Wager's single trials Google Drive
____________________________________________________________________________________________________________________________________________
Lopez-Sola, et al. (2019) Pain
____________________________________________________________________________________________________________________________________________
Summary of dataset
______________________________________________________
Images: 480 Nonempty: 480 Complete: 480
Voxels: 328798 Nonempty: 328798 Complete: 323776
Unique data values: 82177956
Min: -44.019 Max: 43.529 Mean: 0.071 Std: 0.742
Percentiles Values
___________ ________
0.1 -4.6006
0.5 -2.3523
1 -1.7967
5 -0.88787
25 -0.22951
50 0.042391
75 0.35992
95 1.1072
99 2.0649
99.5 2.6096
99.9 4.5095
Pain ratings in image_obj.Y
Additional metadata in image_obj.additional_info struct
Loaded images:
Source: NSF data aggregated from Tor Wager's single trials Google Drive
____________________________________________________________________________________________________________________________________________
Wager, et al. (2013) New England Journal of Medicine
Atlas, et al. (2014) Pain
____________________________________________________________________________________________________________________________________________
Summary of dataset
______________________________________________________
Images: 1149 Nonempty: 1149 Complete: 1149
Voxels: 329694 Nonempty: 329694 Complete: 328249
Unique data values: 136162680
Min: -1312.863 Max: 888.306 Mean: -0.351 Std: 21.183
Percentiles Values
___________ __________
0.1 -134.41
0.5 -81.216
1 -63.577
5 -31.933
25 -8.2459
50 3.1861e-06
75 8.286
95 29.963
99 56.493
99.5 70.713
99.9 112.42
Pain ratings in image_obj.Y
Additional metadata in image_obj.additional_info struct
Loaded images:
Source: bmrk3warm img data from Tor Wager's single trials Google Drive. Metadata also from wagerlab/labdata/current/BMRK3 HPC storage
____________________________________________________________________________________________________________________________________________
Wager, et al. (2013) New England Journal of Medicine
Woo et al. (2015) PLoS Biology
____________________________________________________________________________________________________________________________________________
Summary of dataset
______________________________________________________
Images: 1502 Nonempty: 1502 Complete: 1502
Voxels: 328798 Nonempty: 328798 Complete: 327472
Unique data values: 129320822
Min: -81.910 Max: 143.410 Mean: -0.006 Std: 0.497
Percentiles Values
___________ ___________
0.1 -3.0485
0.5 -1.77
1 -1.3678
5 -0.68094
25 -0.19522
50 -0.00068394
75 0.19002
95 0.65406
99 1.275
99.5 1.6349
99.9 2.8324
Warmth ratings in image_obj.Y
Source: bmrk3pain img data from Tor Wager's single trials Google Drive. Metadata also from wagerlab/labdata/current/BMRK3/ HPC storage
____________________________________________________________________________________________________________________________________________
Wager, et al. (2013) New England Journal of Medicine
Woo et al. (2015) PLoS Biology
____________________________________________________________________________________________________________________________________________
Summary of dataset
______________________________________________________
Images: 1699 Nonempty: 1699 Complete: 1699
Voxels: 328798 Nonempty: 328798 Complete: 327472
Unique data values: 135864812
Min: -133.823 Max: 84.093 Mean: -0.006 Std: 0.545
Percentiles Values
___________ ___________