-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBMSWinningComparision.m
More file actions
162 lines (138 loc) · 6.53 KB
/
BMSWinningComparision.m
File metadata and controls
162 lines (138 loc) · 6.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
% Translational Neuromodeling Project, ETH Zurich
% 'Decoding moral judgements from neurotypical individuals compared to
% individuals with ASD'
%--------------------------------------------------------------------------
% authors: Stephan Boner, Alexander Hess, Nina Stumpf
% date: 2019-05-30
% version: 1.0
%--------------------------------------------------------------------------
% This file is used to compare the 2 winning models from the 'BMS_runner.m'
% separately. The 2 winning models (for ASD & NT subjects are hard coded in
% this file and can be specified in line 19 & 20).
%==========================================================================
pathBase = what('TNproject');
pathBase = pathBase.path;
dataPath = fullfile(pathBase, 'data');
winningModelASD = 15;
winningModelNT = 14;
specs = helperReadParticipantSpecs();
clear matlabbatch;
outputPath = fullfile(dataPath, 'BMSandBMA');
mkdir(outputPath);
outputPathNT = fullfile(outputPath, 'NT_WinnerComparison');
mkdir(outputPathNT);
outputPathASD = fullfile(outputPath, 'ASD_WinnerComparison');
mkdir(outputPathASD);
outputPathOverall = fullfile(outputPath, 'Overall_WinnerComparison');
mkdir(outputPathOverall);
outputPathsNT = cell(0,0);
outputPathsASD = cell(0,0);
for n=1:2
tmpPathNT = fullfile(outputPathNT,num2str(n,'%02d'));
outputPathsNT(n) = {tmpPathNT};
mkdir(tmpPathNT);
tmpPathASD = fullfile(outputPathASD,num2str(n,'%02d'));
outputPathsASD(n) = {tmpPathASD};
mkdir(tmpPathASD);
tmpPathOverall = fullfile(outputPathOverall,num2str(n,'%02d'));
outputPathsOverall(n) = {tmpPathOverall};
mkdir(tmpPathOverall);
end
matlabbatch{1}.spm.dcm.bms.inference.dir = outputPathsNT(1);
matlabbatch{2}.spm.dcm.bms.inference.dir = outputPathsNT(2);
matlabbatch{3}.spm.dcm.bms.inference.dir = outputPathsASD(1);
matlabbatch{4}.spm.dcm.bms.inference.dir = outputPathsASD(2);
matlabbatch{5}.spm.dcm.bms.inference.dir = outputPathsOverall(1);
matlabbatch{6}.spm.dcm.bms.inference.dir = outputPathsOverall(2);
subjects = dir(fullfile(dataPath, 'sub*'));
asdCount = 0;
ntCount = 0;
for subject = 1:numel(subjects)
subj = subjects(subject);
subjectPath = fullfile(subj.folder, subj.name);
dcmTaskFolders = dir(fullfile(subjectPath, 'DCM', 'sub*'));
for task = 1:numel(dcmTaskFolders)
taskFolder = fullfile(dcmTaskFolders(task).folder, dcmTaskFolders(task).name);
dcms = dir(fullfile(taskFolder, 'DCM_estimated*'));
dcmmat = cell(2, 1);
dcmDirASD = dcms(winningModelASD);
dcmmat{1} = fullfile(dcmDirASD.folder, dcmDirASD.name);
dcmDirNT = dcms(winningModelNT);
dcmmat{2} = fullfile(dcmDirNT.folder, dcmDirNT.name);
if ismember(subj.name, specs.ASD_names)
if task == 1
asdCount = asdCount + 1;
end
matlabbatch{3}.spm.dcm.bms.inference.sess_dcm{asdCount}(task).dcmmat = dcmmat;
matlabbatch{4}.spm.dcm.bms.inference.sess_dcm{asdCount}(task).dcmmat = dcmmat;
matlabbatch{5}.spm.dcm.bms.inference.sess_dcm{asdCount+ntCount}(task).dcmmat = dcmmat;
matlabbatch{6}.spm.dcm.bms.inference.sess_dcm{asdCount+ntCount}(task).dcmmat = dcmmat;
elseif ismember(subj.name, specs.NT_names)
if task == 1
ntCount = ntCount + 1;
end
matlabbatch{1}.spm.dcm.bms.inference.sess_dcm{ntCount}(task).dcmmat = dcmmat;
matlabbatch{2}.spm.dcm.bms.inference.sess_dcm{ntCount}(task).dcmmat = dcmmat;
matlabbatch{5}.spm.dcm.bms.inference.sess_dcm{asdCount+ntCount}(task).dcmmat = dcmmat;
matlabbatch{6}.spm.dcm.bms.inference.sess_dcm{asdCount+ntCount}(task).dcmmat = dcmmat;
else
sprintf("Error!")
end
end
end
matlabbatch{1}.spm.dcm.bms.inference.model_sp = {''};
matlabbatch{1}.spm.dcm.bms.inference.load_f = {''};
matlabbatch{1}.spm.dcm.bms.inference.method = 'FFX';
matlabbatch{1}.spm.dcm.bms.inference.family_level.family_file = {''};
matlabbatch{1}.spm.dcm.bms.inference.bma.bma_yes.bma_famwin = 'famwin';
matlabbatch{1}.spm.dcm.bms.inference.verify_id = 1;
matlabbatch{2}.spm.dcm.bms.inference.model_sp = {''};
matlabbatch{2}.spm.dcm.bms.inference.load_f = {''};
matlabbatch{2}.spm.dcm.bms.inference.method = 'RFX';
matlabbatch{2}.spm.dcm.bms.inference.family_level.family_file = {''};
matlabbatch{2}.spm.dcm.bms.inference.bma.bma_yes.bma_famwin = 'famwin';
matlabbatch{2}.spm.dcm.bms.inference.verify_id = 1;
matlabbatch{3}.spm.dcm.bms.inference.model_sp = {''};
matlabbatch{3}.spm.dcm.bms.inference.load_f = {''};
matlabbatch{3}.spm.dcm.bms.inference.method = 'FFX';
matlabbatch{3}.spm.dcm.bms.inference.family_level.family_file = {''};
matlabbatch{3}.spm.dcm.bms.inference.bma.bma_yes.bma_famwin = 'famwin';
matlabbatch{3}.spm.dcm.bms.inference.verify_id = 1;
matlabbatch{4}.spm.dcm.bms.inference.model_sp = {''};
matlabbatch{4}.spm.dcm.bms.inference.load_f = {''};
matlabbatch{4}.spm.dcm.bms.inference.method = 'RFX';
matlabbatch{4}.spm.dcm.bms.inference.family_level.family_file = {''};
matlabbatch{4}.spm.dcm.bms.inference.bma.bma_yes.bma_famwin = 'famwin';
matlabbatch{4}.spm.dcm.bms.inference.verify_id = 1;
matlabbatch{5}.spm.dcm.bms.inference.model_sp = {''};
matlabbatch{5}.spm.dcm.bms.inference.load_f = {''};
matlabbatch{5}.spm.dcm.bms.inference.method = 'FFX';
matlabbatch{5}.spm.dcm.bms.inference.family_level.family_file = {''};
matlabbatch{5}.spm.dcm.bms.inference.bma.bma_yes.bma_famwin = 'famwin';
matlabbatch{5}.spm.dcm.bms.inference.verify_id = 1;
matlabbatch{6}.spm.dcm.bms.inference.model_sp = {''};
matlabbatch{6}.spm.dcm.bms.inference.load_f = {''};
matlabbatch{6}.spm.dcm.bms.inference.method = 'RFX';
matlabbatch{6}.spm.dcm.bms.inference.family_level.family_file = {''};
matlabbatch{6}.spm.dcm.bms.inference.bma.bma_yes.bma_famwin = 'famwin';
matlabbatch{6}.spm.dcm.bms.inference.verify_id = 1;
for n=1:numel(matlabbatch)
spm_jobman('run', matlabbatch(n));
saveDir = matlabbatch{n}.spm.dcm.bms.inference.dir{:};
nPlots = 0;
figures = findall(0,'type','figure');
for m=1:numel(figures)
if strcmp(figures(m).Tag,'Graphics')
nPlots = nPlots + 1;
saveas(figures(m),fullfile(saveDir,['resultsPlot_',num2str(nPlots),'.fig']));
end
end
spm_dcm_bma_results(fullfile(saveDir,'BMS.mat'),lower(matlabbatch{n}.spm.dcm.bms.inference.method));
figures = findall(0,'type','figure');
for m=1:numel(figures)
if strcmp(figures(m).Tag,'Graphics')
nPlots = nPlots + 1;
saveas(figures(m),fullfile(saveDir,['resultsPlot_',num2str(nPlots),'.fig']));
end
end
end