Skip to content

Commit 15f48fd

Browse files
committed
actually generate references
1 parent b8c897f commit 15f48fd

File tree

3 files changed

+43
-18
lines changed

3 files changed

+43
-18
lines changed

fmriprep/workflows/bold/base.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,10 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
347347
inputnode.inputs.sbref_file = sbref_file
348348

349349
outputnode = pe.Node(niu.IdentityInterface(
350-
fields=['bold_t1', 'bold_mask_t1', 'bold_aseg_t1', 'bold_aparc_t1', 'cifti_variant',
351-
'bold_mni', 'bold_mask_mni', 'bold_cifti', 'confounds', 'surfaces',
352-
't2s_map', 'aroma_noise_ics', 'melodic_mix', 'nonaggr_denoised_file',
353-
'cifti_variant_key']),
350+
fields=['bold_t1', 'bold_t1_ref', 'bold_mask_t1', 'bold_aseg_t1', 'bold_aparc_t1',
351+
'bold_mni', 'bold_mni_ref' 'bold_mask_mni', 'bold_cifti',
352+
'cifti_variant', 'cifti_variant_key', 'confounds', 'surfaces',
353+
't2s_map', 'aroma_noise_ics', 'melodic_mix', 'nonaggr_denoised_file']),
354354
name='outputnode')
355355

356356
# BOLD buffer: an identity used as a pointer to either the original BOLD
@@ -376,10 +376,12 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
376376
(inputnode, func_derivatives_wf, [('bold_file', 'inputnode.source_file')]),
377377
(outputnode, func_derivatives_wf, [
378378
('bold_t1', 'inputnode.bold_t1'),
379+
('bold_t1_ref', 'inputnode.bold_t1_ref'),
379380
('bold_aseg_t1', 'inputnode.bold_aseg_t1'),
380381
('bold_aparc_t1', 'inputnode.bold_aparc_t1'),
381382
('bold_mask_t1', 'inputnode.bold_mask_t1'),
382383
('bold_mni', 'inputnode.bold_mni'),
384+
('bold_mni_ref', 'inputnode.bold_mni_ref'),
383385
('bold_mask_mni', 'inputnode.bold_mask_mni'),
384386
('confounds', 'inputnode.confounds'),
385387
('surfaces', 'inputnode.surfaces'),
@@ -501,6 +503,7 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
501503
(bold_reg_wf, bold_t1_trans_wf, [
502504
('outputnode.itk_bold_to_t1', 'inputnode.itk_bold_to_t1')]),
503505
(bold_t1_trans_wf, outputnode, [('outputnode.bold_t1', 'bold_t1'),
506+
('outputnode.bold_t1_ref', 'bold_t1_ref'),
504507
('outputnode.bold_aseg_t1', 'bold_aseg_t1'),
505508
('outputnode.bold_aparc_t1', 'bold_aparc_t1')]),
506509
(bold_reg_wf, summary, [('outputnode.fallback', 'fallback')]),
@@ -676,6 +679,7 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
676679
(bold_sdc_wf, bold_mni_trans_wf, [
677680
('outputnode.out_warp', 'inputnode.fieldwarp')]),
678681
(bold_mni_trans_wf, outputnode, [('outputnode.bold_mni', 'bold_mni'),
682+
('outputnode.bold_mni_ref', 'bold_mni_ref'),
679683
('outputnode.bold_mask_mni', 'bold_mask_mni')]),
680684
(bold_bold_trans_wf, carpetplot_wf, [
681685
('outputnode.bold', 'inputnode.bold'),
@@ -811,7 +815,9 @@ def init_func_derivatives_wf(output_dir, output_spaces, template, freesurfer,
811815

812816
inputnode = pe.Node(
813817
niu.IdentityInterface(
814-
fields=['source_file', 'bold_t1', 'bold_mask_t1', 'bold_mni', 'bold_mask_mni',
818+
fields=['source_file',
819+
'bold_t1', 'bold_t1_ref', 'bold_mask_t1',
820+
'bold_mni', 'bold_mni_ref', 'bold_mask_mni',
815821
'bold_aseg_t1', 'bold_aparc_t1', 'cifti_variant_key',
816822
'confounds', 'surfaces', 'aroma_noise_ics', 'melodic_mix',
817823
'nonaggr_denoised_file', 'bold_cifti', 'cifti_variant']),
@@ -847,6 +853,8 @@ def init_func_derivatives_wf(output_dir, output_spaces, template, freesurfer,
847853
workflow.connect([
848854
(inputnode, ds_bold_t1, [('source_file', 'source_file'),
849855
('bold_t1', 'in_file')]),
856+
(inputnode, ds_bold_t1_ref, [('source_file', 'source_file'),
857+
('bold_t1_ref', 'in_file')]),
850858
(inputnode, ds_bold_mask_t1, [('source_file', 'source_file'),
851859
('bold_mask_t1', 'in_file')]),
852860
])
@@ -869,6 +877,8 @@ def init_func_derivatives_wf(output_dir, output_spaces, template, freesurfer,
869877
workflow.connect([
870878
(inputnode, ds_bold_mni, [('source_file', 'source_file'),
871879
('bold_mni', 'in_file')]),
880+
(inputnode, ds_bold_mni_ref, [('source_file', 'source_file'),
881+
('bold_mni_ref', 'in_file')]),
872882
(inputnode, ds_bold_mask_mni, [('source_file', 'source_file'),
873883
('bold_mask_mni', 'in_file')]),
874884
])

fmriprep/workflows/bold/registration.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ def init_bold_reg_wf(freesurfer, use_bbr, bold2t1w_dof, mem_gb, omp_nthreads,
112112
113113
**Subworkflows**
114114
115-
* :py:func:`~fmriprep.workflows.util.init_bbreg_wf`
116-
* :py:func:`~fmriprep.workflows.util.init_fsl_bbr_wf`
115+
* :py:func:`~fmriprep.workflows.bold.registration.init_bbreg_wf`
116+
* :py:func:`~fmriprep.workflows.bold.registration.init_fsl_bbr_wf`
117117
118118
"""
119119
workflow = Workflow(name=name)
@@ -232,6 +232,8 @@ def init_bold_t1_trans_wf(freesurfer, mem_gb, omp_nthreads, use_fieldwarp=False,
232232
233233
bold_t1
234234
Motion-corrected BOLD series in T1 space
235+
bold_t1_ref
236+
Reference, contrast-enhanced summary of the motion-corrected BOLD series in T1w space
235237
bold_mask_t1
236238
BOLD mask in T1 space
237239
bold_aseg_t1
@@ -244,10 +246,11 @@ def init_bold_t1_trans_wf(freesurfer, mem_gb, omp_nthreads, use_fieldwarp=False,
244246
245247
**Subworkflows**
246248
247-
* :py:func:`~fmriprep.workflows.util.init_bbreg_wf`
248-
* :py:func:`~fmriprep.workflows.util.init_fsl_bbr_wf`
249+
* :py:func:`~fmriprep.workflows.bold.registration.init_bbreg_wf`
250+
* :py:func:`~fmriprep.workflows.bold.registration.init_fsl_bbr_wf`
249251
250252
"""
253+
from ..util import init_bold_reference_wf
251254
workflow = Workflow(name=name)
252255
inputnode = pe.Node(
253256
niu.IdentityInterface(
@@ -260,7 +263,7 @@ def init_bold_t1_trans_wf(freesurfer, mem_gb, omp_nthreads, use_fieldwarp=False,
260263

261264
outputnode = pe.Node(
262265
niu.IdentityInterface(fields=[
263-
'bold_t1', 'bold_mask_t1',
266+
'bold_t1', 'bold_t1_ref', 'bold_mask_t1',
264267
'bold_aseg_t1', 'bold_aparc_t1']),
265268
name='outputnode'
266269
)
@@ -320,14 +323,19 @@ def init_bold_t1_trans_wf(freesurfer, mem_gb, omp_nthreads, use_fieldwarp=False,
320323

321324
merge = pe.Node(Merge(compress=use_compression), name='merge', mem_gb=mem_gb)
322325

326+
# Generate a reference on the target T1w space
327+
gen_final_ref = init_bold_reference_wf(omp_nthreads)
328+
323329
workflow.connect([
324330
(inputnode, merge_xforms, [('itk_bold_to_t1', 'in1')]),
325331
(merge_xforms, bold_to_t1w_transform, [('out', 'transforms')]),
326332
(inputnode, merge, [('name_source', 'header_source')]),
327333
(inputnode, bold_to_t1w_transform, [('bold_split', 'input_image')]),
328334
(gen_ref, bold_to_t1w_transform, [('out_file', 'reference_image')]),
329335
(bold_to_t1w_transform, merge, [('out_files', 'in_files')]),
336+
(merge, gen_final_ref, [('out_file', 'inputnode.bold_file')]),
330337
(merge, outputnode, [('out_file', 'bold_t1')]),
338+
(gen_final_ref, outputnode, [('outputnode.ref_image', 'bold_t1_ref')]),
331339
])
332340

333341
return workflow
@@ -338,7 +346,7 @@ def init_bbreg_wf(use_bbr, bold2t1w_dof, omp_nthreads, name='bbreg_wf'):
338346
This workflow uses FreeSurfer's ``bbregister`` to register a BOLD image to
339347
a T1-weighted structural image.
340348
341-
It is a counterpart to :py:func:`~fmriprep.workflows.util.init_fsl_bbr_wf`,
349+
It is a counterpart to :py:func:`~fmriprep.workflows.bold.registration.init_fsl_bbr_wf`,
342350
which performs the same task using FSL's FLIRT with a BBR cost function.
343351
344352
The ``use_bbr`` option permits a high degree of control over registration.
@@ -381,9 +389,9 @@ def init_bbreg_wf(use_bbr, bold2t1w_dof, omp_nthreads, name='bbreg_wf'):
381389
subject_id
382390
FreeSurfer subject ID (must have folder in SUBJECTS_DIR)
383391
t1_brain
384-
Unused (see :py:func:`~fmriprep.workflows.util.init_fsl_bbr_wf`)
392+
Unused (see :py:func:`~fmriprep.workflows.bold.registration.init_fsl_bbr_wf`)
385393
t1_seg
386-
Unused (see :py:func:`~fmriprep.workflows.util.init_fsl_bbr_wf`)
394+
Unused (see :py:func:`~fmriprep.workflows.bold.registration.init_fsl_bbr_wf`)
387395
388396
389397
Outputs
@@ -556,17 +564,17 @@ def init_fsl_bbr_wf(use_bbr, bold2t1w_dof, name='fsl_bbr_wf'):
556564
t1_seg
557565
FAST segmentation of ``t1_brain``
558566
t1_2_fsnative_reverse_transform
559-
Unused (see :py:func:`~fmriprep.workflows.util.init_bbreg_wf`)
567+
Unused (see :py:func:`~fmriprep.workflows.bold.registration.init_bbreg_wf`)
560568
subjects_dir
561-
Unused (see :py:func:`~fmriprep.workflows.util.init_bbreg_wf`)
569+
Unused (see :py:func:`~fmriprep.workflows.bold.registration.init_bbreg_wf`)
562570
subject_id
563-
Unused (see :py:func:`~fmriprep.workflows.util.init_bbreg_wf`)
571+
Unused (see :py:func:`~fmriprep.workflows.bold.registration.init_bbreg_wf`)
564572
565573
566574
Outputs
567575
568576
itk_bold_to_t1
569-
Affine transform from ``ref_bold_brain`` to T1 space (ITK format)
577+
Affine transform from ``ref_bold_brain`` to T1w space (ITK format)
570578
itk_t1_to_bold
571579
Affine transform from T1 space to BOLD space (ITK format)
572580
out_report

fmriprep/workflows/bold/resampling.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ def init_bold_mni_trans_wf(template, mem_gb, omp_nthreads,
227227
228228
bold_mni
229229
BOLD series, resampled to template space
230+
bold_mni_ref
231+
Reference, contrast-enhanced summary of the BOLD series, resampled to template space
230232
bold_mask_mni
231233
BOLD series mask in template space
232234
@@ -251,7 +253,7 @@ def init_bold_mni_trans_wf(template, mem_gb, omp_nthreads,
251253
)
252254

253255
outputnode = pe.Node(
254-
niu.IdentityInterface(fields=['bold_mni', 'bold_mask_mni']),
256+
niu.IdentityInterface(fields=['bold_mni', 'bold_mni_ref', 'bold_mask_mni']),
255257
name='outputnode')
256258

257259
def _aslist(in_value):
@@ -298,14 +300,19 @@ def _aslist(in_value):
298300
merge = pe.Node(Merge(compress=use_compression), name='merge',
299301
mem_gb=mem_gb * 3)
300302

303+
# Generate a reference on the target T1w space
304+
gen_final_ref = init_bold_reference_wf(omp_nthreads)
305+
301306
workflow.connect([
302307
(inputnode, merge_xforms, [('t1_2_mni_forward_transform', 'in1'),
303308
(('itk_bold_to_t1', _aslist), 'in2')]),
304309
(merge_xforms, bold_to_mni_transform, [('out', 'transforms')]),
305310
(inputnode, merge, [('name_source', 'header_source')]),
306311
(inputnode, bold_to_mni_transform, [('bold_split', 'input_image')]),
307312
(bold_to_mni_transform, merge, [('out_files', 'in_files')]),
313+
(merge, gen_final_ref, [('out_file', 'inputnode.bold_file')]),
308314
(merge, outputnode, [('out_file', 'bold_mni')]),
315+
(gen_final_ref, outputnode, [('outputnode.ref_image', 'bold_mni_ref')]),
309316
])
310317

311318
if template_out_grid == 'native':

0 commit comments

Comments
 (0)