28
28
)
29
29
from niworkflows .interfaces .segmentation import ICA_AROMARPT
30
30
from niworkflows .interfaces .utils import (
31
- TPM2ROI , AddTPMs , AddTSVHeader
31
+ TPM2ROI , AddTPMs , AddTSVHeader , TSV2JSON
32
32
)
33
33
34
34
from ...interfaces import (
@@ -131,23 +131,28 @@ def init_bold_confs_wf(mem_gb, metadata, name="bold_confs_wf"):
131
131
*preprocessed BOLD* time-series (using a discrete cosine filter with
132
132
128s cut-off) for the two *CompCor* variants: temporal (tCompCor)
133
133
and anatomical (aCompCor).
134
- Six tCompCor components are then calculated from the top 5% variable
134
+ tCompCor components are then calculated from the top 5% variable
135
135
voxels within a mask covering the subcortical regions.
136
136
This subcortical mask is obtained by heavily eroding the brain mask,
137
137
which ensures it does not include cortical GM regions.
138
- For aCompCor, six components are calculated within the intersection of
138
+ For aCompCor, components are calculated within the intersection of
139
139
the aforementioned mask and the union of CSF and WM masks calculated
140
140
in T1w space, after their projection to the native space of each
141
141
functional run (using the inverse BOLD-to-T1w transformation).
142
142
The head-motion estimates calculated in the correction step were also
143
143
placed within the corresponding confounds file.
144
+ The confound time series derived from head motion estimates and global
145
+ signals were expanded with the inclusion of temporal derivatives and
146
+ quadratic terms for each [@satterthwaite].
147
+ Frames that exceeded a threshold of 0.2 mm FD or 20 DVARS were classified
148
+ as motion outliers [following @power_fd_dvars].
144
149
"""
145
150
inputnode = pe .Node (niu .IdentityInterface (
146
151
fields = ['bold' , 'bold_mask' , 'movpar_file' , 'skip_vols' ,
147
152
't1_mask' , 't1_tpms' , 't1_bold_xform' ]),
148
153
name = 'inputnode' )
149
154
outputnode = pe .Node (niu .IdentityInterface (
150
- fields = ['confounds_file' ]),
155
+ fields = ['confounds_file' , 'tcompcor_metadata' , 'acompcor_metadata' ]),
151
156
name = 'outputnode' )
152
157
153
158
# Get masks ready in T1w space
@@ -218,6 +223,29 @@ def init_bold_confs_wf(mem_gb, metadata, name="bold_confs_wf"):
218
223
name = "add_motion_headers" , mem_gb = 0.01 , run_without_submitting = True )
219
224
concat = pe .Node (GatherConfounds (), name = "concat" , mem_gb = 0.01 , run_without_submitting = True )
220
225
226
+ # CompCor metadata
227
+ tcc_metadata_fmt = pe .Node (
228
+ TSV2JSON (index_column = 'component' , drop_columns = ['mask' ],
229
+ additional_metadata = {'Method' : 'tCompCor' }, enforce_case = True ),
230
+ name = 'tcc_metadata_fmt' )
231
+ acc_metadata_fmt = pe .Node (
232
+ TSV2JSON (index_column = 'component' , drop_columns = ['mask' ],
233
+ additional_metadata = {'Method' : 'aCompCor' }, enforce_case = True ),
234
+ name = 'acc_metadata_fmt' )
235
+
236
+ # Expand model to include derivatives and quadratics
237
+ model_expand = pe .Node (ExpandModel (
238
+ model_formula = '(dd1(rps + wm + csf + gsr))^^2 + others' ),
239
+ name = 'model_expansion' )
240
+
241
+ # Add spike regressors
242
+ spike_regress = pe .Node (SpikeRegressors (
243
+ criteria = {
244
+ 'framewise_displacement' : ('>' , 0.2 ),
245
+ 'dvars' : ('>' , 20 )
246
+ }),
247
+ name = 'spike_regressors' )
248
+
221
249
# Generate reportlet (ROIs)
222
250
mrg_compcor = pe .Node (niu .Merge (2 ), name = 'merge_compcor' , run_without_submitting = True )
223
251
rois_plot = pe .Node (ROIsPlot (colors = ['b' , 'magenta' ], generate_report = True ),
@@ -231,37 +259,24 @@ def init_bold_confs_wf(mem_gb, metadata, name="bold_confs_wf"):
231
259
# Generate reportlet (CompCor)
232
260
mrg_cc_metadata = pe .Node (niu .Merge (2 ), name = 'merge_compcor_metadata' ,
233
261
run_without_submitting = True )
234
- compcor_plot = pe .Node (CompCorVariancePlot (
235
- variance_thresholds = (0.5 , 0.7 , 0.9 ),
236
- metadata_sources = ['tCompCor' , 'aCompCor' ]),
262
+ compcor_plot = pe .Node (
263
+ CompCorVariancePlot ( variance_thresholds = (0.5 , 0.7 , 0.9 ),
264
+ metadata_sources = ['tCompCor' , 'aCompCor' ]),
237
265
name = 'compcor_plot' )
238
266
ds_report_compcor = pe .Node (
239
267
DerivativesDataSink (suffix = 'compcor' ),
240
268
name = 'ds_report_compcor' , run_without_submitting = True ,
241
269
mem_gb = DEFAULT_MEMORY_MIN_GB )
242
270
243
271
# Generate reportlet (Confound correlation)
244
- conf_corr_plot = pe .Node (ConfoundsCorrelationPlot (
245
- reference_column = 'global_signal' ),
272
+ conf_corr_plot = pe .Node (
273
+ ConfoundsCorrelationPlot ( reference_column = 'global_signal' , max_dim = 70 ),
246
274
name = 'conf_corr_plot' )
247
275
ds_report_conf_corr = pe .Node (
248
276
DerivativesDataSink (suffix = 'confounds_correlation' ),
249
277
name = 'ds_report_conf_corr' , run_without_submitting = True ,
250
278
mem_gb = DEFAULT_MEMORY_MIN_GB )
251
279
252
- # Expand model to include derivatives and quadratics
253
- model_expand = pe .Node (ExpandModel (
254
- model_formula = '(dd1(rps + wm + csf + gsr))^^2 + others' ),
255
- name = 'model_expansion' )
256
-
257
- # Add spike regressors
258
- spike_regress = pe .Node (SpikeRegressors (
259
- criteria = {
260
- 'framewise_displacement' : ('>' , 0.2 ),
261
- 'dvars' : ('>' , 20 )
262
- }),
263
- name = 'spike_regressors' )
264
-
265
280
def _pick_csf (files ):
266
281
return files [0 ]
267
282
@@ -334,12 +349,18 @@ def _pick_wm(files):
334
349
(add_dvars_header , concat , [('out_file' , 'dvars' )]),
335
350
(add_std_dvars_header , concat , [('out_file' , 'std_dvars' )]),
336
351
352
+ # Confounds metadata
353
+ (tcompcor , tcc_metadata_fmt , [('metadata_file' , 'in_file' )]),
354
+ (acompcor , acc_metadata_fmt , [('metadata_file' , 'in_file' )]),
355
+
337
356
# Expand the model with derivatives, quadratics, and spikes
338
357
(concat , model_expand , [('confounds_file' , 'confounds_file' )]),
339
358
(model_expand , spike_regress , [('confounds_file' , 'confounds_file' )]),
340
359
341
360
# Set outputs
342
361
(spike_regress , outputnode , [('confounds_file' , 'confounds_file' )]),
362
+ (tcc_metadata_fmt , outputnode , [('out_file' , 'tcompcor_metadata' )]),
363
+ (acc_metadata_fmt , outputnode , [('out_file' , 'acompcor_metadata' )]),
343
364
(inputnode , rois_plot , [('bold' , 'in_file' ),
344
365
('bold_mask' , 'in_mask' )]),
345
366
(tcompcor , mrg_compcor , [('high_variance_masks' , 'in1' )]),
0 commit comments