41
41
DEFAULT_MEMORY_MIN_GB = 0.01
42
42
43
43
44
- def init_bold_confs_wf (mem_gb , metadata , name = "bold_confs_wf" ):
44
+ def init_bold_confs_wf (mem_gb , metadata , return_all_components = False ,
45
+ spike_criteria = None , name = "bold_confs_wf" ):
45
46
"""
46
47
This workflow calculates confounds for a BOLD series, and aggregates them
47
48
into a :abbr:`TSV (tab-separated value)` file, for use as nuisance
@@ -87,6 +88,15 @@ def init_bold_confs_wf(mem_gb, metadata, name="bold_confs_wf"):
87
88
BIDS metadata for BOLD file
88
89
name : str
89
90
Name of workflow (default: ``bold_confs_wf``)
91
+ return_all_components: bool
92
+ Indicates whether CompCor decompositions should return all
93
+ components instead of the minimal number of components necessary
94
+ to explain 50 percent of the variance in the decomposition mask.
95
+ fd_spike_thr
96
+ Criterion for flagging framewise displacement outliers
97
+ dv_spike_thr
98
+ Criterion for flagging DVARS outliers
99
+
90
100
91
101
**Inputs**
92
102
@@ -144,9 +154,9 @@ def init_bold_confs_wf(mem_gb, metadata, name="bold_confs_wf"):
144
154
The confound time series derived from head motion estimates and global
145
155
signals were expanded with the inclusion of temporal derivatives and
146
156
quadratic terms for each [@confounds_satterthwaite_2013].
147
- Frames that exceeded a threshold of 0.2 mm FD or 20 DVARS were classified
148
- as motion outliers [following @power_fd_dvars] .
149
- """
157
+ Frames that exceeded a threshold of {fd} mm FD or {dv} standardised DVARS
158
+ were classified as motion outliers.
159
+ """ . format ( fd = fd_spike_thr , dv = dv_spike_thr )
150
160
inputnode = pe .Node (niu .IdentityInterface (
151
161
fields = ['bold' , 'bold_mask' , 'movpar_file' , 'skip_vols' ,
152
162
't1_mask' , 't1_tpms' , 't1_bold_xform' ]),
@@ -194,16 +204,23 @@ def init_bold_confs_wf(mem_gb, metadata, name="bold_confs_wf"):
194
204
195
205
tcompcor = pe .Node (
196
206
TCompCor (components_file = 'tcompcor.tsv' , header_prefix = 't_comp_cor_' , pre_filter = 'cosine' ,
197
- save_pre_filter = True , num_components = 'all' , save_metadata = True ,
198
- percentile_threshold = .05 ),
207
+ save_pre_filter = True , save_metadata = True , percentile_threshold = .05 ),
199
208
name = "tcompcor" , mem_gb = mem_gb )
200
209
201
210
acompcor = pe .Node (
202
211
ACompCor (components_file = 'acompcor.tsv' , header_prefix = 'a_comp_cor_' , pre_filter = 'cosine' ,
203
- save_pre_filter = True , num_components = 'all ' , save_metadata = True ,
204
- mask_names = [ 'combined' , 'CSF' , 'WM' ], merge_method = 'none' ),
212
+ save_pre_filter = True , save_metadata = True , mask_names = [ 'combined ' , 'CSF' , 'WM' ] ,
213
+ merge_method = 'none' ),
205
214
name = "acompcor" , mem_gb = mem_gb )
206
215
216
+ # Set number of components
217
+ if return_all_components :
218
+ acompcor .inputs .num_components = 'all'
219
+ tcompcor .inputs .num_components = 'all'
220
+ else :
221
+ acompcor .inputs .variance_threshold = 0.5
222
+ tcompcor .inputs .variance_threshold = 0.5
223
+
207
224
# Set TR if present
208
225
if 'RepetitionTime' in metadata :
209
226
tcompcor .inputs .repetition_time = metadata ['RepetitionTime' ]
@@ -232,7 +249,7 @@ def init_bold_confs_wf(mem_gb, metadata, name="bold_confs_wf"):
232
249
additional_metadata = {'Method' : 'tCompCor' }, enforce_case = True ),
233
250
name = 'tcc_metadata_fmt' )
234
251
acc_metadata_fmt = pe .Node (
235
- TSV2JSON (index_column = 'component' , drop_columns = [ 'mask' ],
252
+ TSV2JSON (index_column = 'component' ,
236
253
additional_metadata = {'Method' : 'aCompCor' }, enforce_case = True ),
237
254
name = 'acc_metadata_fmt' )
238
255
@@ -244,8 +261,8 @@ def init_bold_confs_wf(mem_gb, metadata, name="bold_confs_wf"):
244
261
# Add spike regressors
245
262
spike_regress = pe .Node (SpikeRegressors (
246
263
criteria = {
247
- 'framewise_displacement' : ('>' , 0.2 ),
248
- 'dvars ' : ('>' , 20 )
264
+ 'framewise_displacement' : ('>' , fd_spike_thr ),
265
+ 'std_dvars ' : ('>' , dv_spike_thr )
249
266
}),
250
267
name = 'spike_regressors' )
251
268
0 commit comments