-
Notifications
You must be signed in to change notification settings - Fork 0
/
tbx_cfg_tfce.m
187 lines (171 loc) · 8.46 KB
/
tbx_cfg_tfce.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
function tfce_estimate = tbx_cfg_tfce
% SPM Configuration file for TFCE estimate
% ______________________________________________________________________
%
% Christian Gaser
% Structural Brain Mapping Group (https://neuro-jena.github.io)
% Departments of Neurology and Psychiatry
% Jena University Hospital
% ______________________________________________________________________
addpath(fileparts(which(mfilename)));
% try to estimate number of processor cores
try
if strcmpi(spm_check_version,'octave')
numcores = nproc;
else
numcores = feature('numcores');
end
% because of poor memory management use only half of the cores for windows
if ispc
numcores = round(numcores/2);
end
numcores = max(numcores,1);
catch
numcores = 0;
end
% force running in the foreground if only one processor was found or for compiled version
% or for Octave
if numcores == 1 || isdeployed || strcmpi(spm_check_version,'octave'), numcores = 0; end
%_______________________________________________________________________
nproc = cfg_entry;
nproc.tag = 'nproc';
nproc.name = 'Split job into separate processes';
nproc.strtype = 'w';
nproc.val = {numcores};
nproc.num = [1 1];
nproc.hidden = numcores <= 1 || isdeployed;
nproc.help = {
'In order to use multi-threading the TFCE job with multiple SPM.mat files can be split into separate processes that run in the background. If you do not want to run processes in the background then set this value to 0.'
''
'Keep in mind that each process might need a large amount of RAM, which should be considered to choose the appropriate number of processes.'
''
'Please further note that additional modules in the batch can now be used because the processes are checked every minute.'
};
% ---------------------------------------------------------------------
% data Select SPM.mat
% ---------------------------------------------------------------------
data = cfg_files;
data.tag = 'data';
data.name = 'Select (v)SPM.mat';
data.help = {'Select the (v)SPM.mat files that contain the design specification from a previous (parametric) estimation, where all required contrasts are already specified.'};
data.filter = 'mat';
data.ufilter = 'SPM\.mat$';
data.num = [1 Inf];
% ---------------------------------------------------------------------
% mask Select mask to restrict analysis
% ---------------------------------------------------------------------
mask = cfg_files;
mask.tag = 'mask';
mask.name = 'Select additional mask';
mask.help = {'Select an additional mask image or surface to restrict your analysis. As default the mask in the analysis folder is used. Here you can select a mask to additionally restrict the analysis to regions of interest (i.e. small volume/surface correction).'};
if strcmp(spm('ver'),'SPM12')
mask.filter = {'image','mesh'};
else
mask.filter = {'image'};
end
mask.val = {''};
mask.ufilter = '.*';
mask.num = [0 1];
% ---------------------------------------------------------------------
% titlestr Results Title
% ---------------------------------------------------------------------
titlestr = cfg_entry;
titlestr.tag = 'titlestr';
titlestr.name = 'Results title';
titlestr.help = {'Heading on results page - determined automatically if left empty'};
titlestr.val = {''};
titlestr.strtype = 's';
titlestr.num = [0 Inf];
% ---------------------------------------------------------------------
% contrasts Contrast
% ---------------------------------------------------------------------
contrasts = cfg_entry;
contrasts.tag = 'contrasts';
contrasts.name = 'Contrast index';
contrasts.help = {'Index(es) of contrast according to the contrast manager.'
''
'Each contrast in SPM is indicated by a sequential number that is displayed in the first column of the contrast manager.'
''
'You can enter one or more contrasts. If only one number is entered, and this number is "Inf", you can select one or more contrasts interactively using the contrast manager.'
''
'Do not define here the contrast itself. This should be done in the contrast manager, that is automatically called if "Inf" is kept as entry.'
}';
contrasts.strtype = 'e';
contrasts.val = {Inf};
contrasts.num = [1 Inf];
% ---------------------------------------------------------------------
% number of permutations
% ---------------------------------------------------------------------
n_perm = cfg_entry;
n_perm.tag = 'n_perm';
n_perm.name = 'Number of permutations';
n_perm.help = {'In order to obtain reliable estimates you need about 5000-10000 permutations.'
''
'There is also an option to interrrupt the permutation process and to save the results at this step to take a first look on your results.'
''
'If the number of maximal possible permutations is smaller, then this number is used resulting in an exact permutation test.'
''
'Please note, that a tail approximation is finally used to estimate the corrected p-values. Thus, there is no dependency anymore between the lowest achievable p-value and the number of permutations as in previous versions.'
}';
n_perm.strtype = 'e';
n_perm.val = {5000};
n_perm.num = [1 Inf];
% ---------------------------------------------------------------------
% two-dimensional processing
% ---------------------------------------------------------------------
tbss = cfg_menu;
tbss.tag = 'tbss';
tbss.name = 'TBSS data';
tbss.labels = {'yes','no'};
tbss.values = {1 0};
tbss.val = {0};
tbss.help = {[...
'Use 2D optimization (e.g. for TBSS DTI data) with internal TFCE parameters H=2, E=1.']};
% ---------------------------------------------------------------------
% method to deal with nuisance variables
% ---------------------------------------------------------------------
nuisance_method = cfg_menu;
nuisance_method.tag = 'nuisance_method';
nuisance_method.name = 'Permutation method to deal with nuisance variables';
nuisance_method.labels = {'Draper-Stoneman','Smith','Freedman-Lane (experimental)'};
nuisance_method.values = {0 2 1};
nuisance_method.val = {2};
nuisance_method.help = {'A number of methods are available to obtain parameter estimates and construct a reference distribution in the presence of nuisance variables. Smith permutation method is used if any nuisance variables exist and is selected by default. If no nuisance variables were found in the model then Draper-Stoneman method is automatically used. '
''
'Freedman-Lane is another permutation method to deal with nuisance parameters. However, behaviour of that method was found to be strange under some circumstances and you have to apply this method very carefully. '
''
'It is only necessary to change the permutation method if a large discrepancy between parametric and non-parametric statistic was found, which is indicated at the Matlab command line. '
}';
% ---------------------------------------------------------------------
% conspec Contrast query
% ---------------------------------------------------------------------
conspec = cfg_branch;
conspec.tag = 'conspec';
conspec.name = 'Contrast query';
conspec.val = {titlestr contrasts n_perm};
conspec.help = {''};
% ---------------------------------------------------------------------
% multithreading
% ---------------------------------------------------------------------
singlethreaded = cfg_menu;
singlethreaded.tag = 'singlethreaded';
singlethreaded.name = 'Use multi-threading to speed up calculations';
singlethreaded.labels = {'yes','no'};
singlethreaded.values = {0 1};
if ispc
singlethreaded.val = {1};
else
singlethreaded.val = {0};
end
singlethreaded.help = {[...
'Multithreading can be used to distribute calculations to multiple processors. ',...
'This will minimize calculation time by a large amount, but makes trouble on Windows machines, where it is deselected by default. ']};
% ---------------------------------------------------------------------
% results Results Report
% ---------------------------------------------------------------------
tfce_estimate = cfg_exbranch;
tfce_estimate.tag = 'tfce_estimate';
tfce_estimate.name = 'Estimate TFCE';
tfce_estimate.val = {data nproc mask conspec nuisance_method tbss singlethreaded};
tfce_estimate.help = {''};
tfce_estimate.prog = @tfce_estimate_stat;