Skip to content

Commit 9afb9f5

Browse files
authored
Merge pull request #1130 from oesteban/fix/1127
[FIX] Non-invertible transforms bringing parcellation to BOLD
2 parents 13f7654 + 5f55944 commit 9afb9f5

File tree

3 files changed

+58
-19
lines changed

3 files changed

+58
-19
lines changed

fmriprep/workflows/bold/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,8 +610,10 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
610610
(bold_bold_trans_wf, carpetplot_wf, [
611611
('outputnode.bold', 'inputnode.bold'),
612612
('outputnode.bold_mask', 'inputnode.bold_mask')]),
613-
(bold_mni_trans_wf, carpetplot_wf, [
614-
('outputnode.bold_mni_transforms', 'inputnode.bold_mni_transforms')]),
613+
(inputnode, carpetplot_wf, [
614+
('t1_2_mni_reverse_transform', 'inputnode.t1_2_mni_reverse_transform')]),
615+
(bold_reg_wf, carpetplot_wf, [
616+
('outputnode.itk_t1_to_bold', 'inputnode.t1_bold_xform')]),
615617
(bold_confounds_wf, carpetplot_wf, [
616618
('outputnode.confounds_file', 'inputnode.confounds_file')]),
617619
])

fmriprep/workflows/bold/confounds.py

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ def init_bold_confs_wf(mem_gb, metadata, name="bold_confs_wf"):
7979
the FoV
8080
metadata : dict
8181
BIDS metadata for BOLD file
82+
name : str
83+
Name of workflow (default: ``bold_confs_wf``)
8284
8385
**Inputs**
8486
@@ -270,12 +272,55 @@ def _pick_wm(files):
270272
return workflow
271273

272274

273-
def init_carpetplot_wf(mem_gb, metadata, name="bold_confs_wf"):
275+
def init_carpetplot_wf(mem_gb, metadata, name="bold_carpet_wf"):
276+
"""
277+
278+
Resamples the MNI parcellation (ad-hoc parcellation derived from the
279+
Harvard-Oxford template and others).
280+
281+
**Parameters**
282+
283+
mem_gb : float
284+
Size of BOLD file in GB - please note that this size
285+
should be calculated after resamplings that may extend
286+
the FoV
287+
metadata : dict
288+
BIDS metadata for BOLD file
289+
name : str
290+
Name of workflow (default: ``bold_carpet_wf``)
291+
292+
**Inputs**
293+
294+
bold
295+
BOLD image, after the prescribed corrections (STC, HMC and SDC)
296+
when available.
297+
bold_mask
298+
BOLD series mask
299+
confounds_file
300+
TSV of all aggregated confounds
301+
t1_bold_xform
302+
Affine matrix that maps the T1w space into alignment with
303+
the native BOLD space
304+
t1_2_mni_reverse_transform
305+
ANTs-compatible affine-and-warp transform file
306+
307+
**Outputs**
308+
309+
out_carpetplot
310+
Path of the generated SVG file
274311
312+
"""
275313
inputnode = pe.Node(niu.IdentityInterface(
276-
fields=['bold', 'bold_mask', 'confounds_file', 'bold_mni_transforms']),
314+
fields=['bold', 'bold_mask', 'confounds_file',
315+
't1_bold_xform', 't1_2_mni_reverse_transform']),
277316
name='inputnode')
278317

318+
outputnode = pe.Node(niu.IdentityInterface(
319+
fields=['out_carpetplot']), name='outputnode')
320+
321+
# List transforms
322+
mrg_xfms = pe.Node(niu.Merge(2), name='mrg_xfms')
323+
279324
# Warp segmentation into EPI space
280325
resample_parc = pe.Node(ApplyTransforms(
281326
float=True,
@@ -299,26 +344,20 @@ def init_carpetplot_wf(mem_gb, metadata, name="bold_confs_wf"):
299344
name='ds_report_bold_conf', run_without_submitting=True,
300345
mem_gb=DEFAULT_MEMORY_MIN_GB)
301346

302-
def _reversed(inlist):
303-
return list(reversed(inlist))
304-
305-
def _flags(inlist):
306-
return [True] * len(inlist)
307-
308347
workflow = pe.Workflow(name=name)
309348
workflow.connect([
310-
(inputnode, resample_parc, [
311-
('bold_mask', 'reference_image'),
312-
(('bold_mni_transforms', _reversed), 'transforms'),
313-
(('bold_mni_transforms', _flags), 'invert_transform_flags')]),
349+
(inputnode, mrg_xfms, [('t1_bold_xform', 'in1'),
350+
('t1_2_mni_reverse_transform', 'in2')]),
351+
(inputnode, resample_parc, [('bold_mask', 'reference_image')]),
352+
(mrg_xfms, resample_parc, [('out', 'transforms')]),
314353
# Carpetplot
315354
(inputnode, conf_plot, [
316355
('bold', 'in_func'),
317356
('bold_mask', 'in_mask'),
318357
('confounds_file', 'confounds_file')]),
319358
(resample_parc, conf_plot, [('output_image', 'in_segm')]),
320359
(conf_plot, ds_report_bold_conf, [('out_file', 'in_file')]),
321-
360+
(conf_plot, outputnode, [('out_file', 'out_carpetplot')]),
322361
])
323362
return workflow
324363

fmriprep/workflows/bold/resampling.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,7 @@ def init_bold_mni_trans_wf(template, mem_gb, omp_nthreads,
237237
)
238238

239239
outputnode = pe.Node(
240-
niu.IdentityInterface(fields=[
241-
'bold_mni', 'bold_mask_mni', 'bold_mni_transforms']),
240+
niu.IdentityInterface(fields=['bold_mni', 'bold_mask_mni']),
242241
name='outputnode')
243242

244243
def _aslist(in_value):
@@ -271,11 +270,10 @@ def _aslist(in_value):
271270

272271
workflow.connect([
273272
(inputnode, gen_ref, [(('bold_split', _first), 'moving_image')]),
273+
(inputnode, mask_mni_tfm, [('bold_mask', 'input_image')]),
274274
(inputnode, mask_merge_tfms, [('t1_2_mni_forward_transform', 'in1'),
275275
(('itk_bold_to_t1', _aslist), 'in2')]),
276276
(mask_merge_tfms, mask_mni_tfm, [('out', 'transforms')]),
277-
(inputnode, mask_mni_tfm, [('bold_mask', 'input_image')]),
278-
(mask_merge_tfms, outputnode, [('out', 'bold_mni_transforms')]),
279277
(mask_mni_tfm, outputnode, [('output_image', 'bold_mask_mni')]),
280278
])
281279

0 commit comments

Comments
 (0)