Skip to content

Commit 22c9e4b

Browse files
committed
specification of spike thresholds and decomposition output
1 parent 1e50ae3 commit 22c9e4b

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

fmriprep/workflows/bold/confounds.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
DEFAULT_MEMORY_MIN_GB = 0.01
4242

4343

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"):
4546
"""
4647
This workflow calculates confounds for a BOLD series, and aggregates them
4748
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"):
8788
BIDS metadata for BOLD file
8889
name : str
8990
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+
90100
91101
**Inputs**
92102
@@ -144,9 +154,9 @@ def init_bold_confs_wf(mem_gb, metadata, name="bold_confs_wf"):
144154
The confound time series derived from head motion estimates and global
145155
signals were expanded with the inclusion of temporal derivatives and
146156
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)
150160
inputnode = pe.Node(niu.IdentityInterface(
151161
fields=['bold', 'bold_mask', 'movpar_file', 'skip_vols',
152162
't1_mask', 't1_tpms', 't1_bold_xform']),
@@ -194,16 +204,23 @@ def init_bold_confs_wf(mem_gb, metadata, name="bold_confs_wf"):
194204

195205
tcompcor = pe.Node(
196206
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),
199208
name="tcompcor", mem_gb=mem_gb)
200209

201210
acompcor = pe.Node(
202211
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'),
205214
name="acompcor", mem_gb=mem_gb)
206215

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+
207224
# Set TR if present
208225
if 'RepetitionTime' in metadata:
209226
tcompcor.inputs.repetition_time = metadata['RepetitionTime']
@@ -232,7 +249,7 @@ def init_bold_confs_wf(mem_gb, metadata, name="bold_confs_wf"):
232249
additional_metadata={'Method': 'tCompCor'}, enforce_case=True),
233250
name='tcc_metadata_fmt')
234251
acc_metadata_fmt = pe.Node(
235-
TSV2JSON(index_column='component', drop_columns=['mask'],
252+
TSV2JSON(index_column='component',
236253
additional_metadata={'Method': 'aCompCor'}, enforce_case=True),
237254
name='acc_metadata_fmt')
238255

@@ -244,8 +261,8 @@ def init_bold_confs_wf(mem_gb, metadata, name="bold_confs_wf"):
244261
# Add spike regressors
245262
spike_regress = pe.Node(SpikeRegressors(
246263
criteria={
247-
'framewise_displacement': ('>', 0.2),
248-
'dvars': ('>', 20)
264+
'framewise_displacement': ('>', fd_spike_thr),
265+
'std_dvars': ('>', dv_spike_thr)
249266
}),
250267
name='spike_regressors')
251268

0 commit comments

Comments
 (0)