Skip to content

Commit ba4ebeb

Browse files
authored
Merge pull request #1581 from oesteban/fix/issue-1579
FIX: Support 4D SBRefs when generating the bold reference
2 parents d29902e + 6958253 commit ba4ebeb

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

fmriprep/__about__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
'nilearn',
9090
'nipype>=1.1.6',
9191
'nitime',
92-
'niworkflows<0.9.0a0,>=0.8.1',
92+
'niworkflows',
9393
'numpy',
9494
'pandas',
9595
'psutil>=5.4',
@@ -104,6 +104,8 @@
104104

105105

106106
LINKS_REQUIRES = [
107+
'git+https://github.com/poldracklab/niworkflows.git@'
108+
'b7d111c8fd36a099c74be5e7671677eedb175533#egg=niworkflows',
107109
'git+https://github.com/poldracklab/smriprep.git@'
108110
'423bcc43ab7300177eb3b98da62817b2cad8eb87#egg=smriprep-0.1.0',
109111
]

fmriprep/workflows/bold/base.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,15 +338,16 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
338338
"""
339339

340340
inputnode = pe.Node(niu.IdentityInterface(
341-
fields=['bold_file', 'sbref_file', 'subjects_dir', 'subject_id',
341+
fields=['bold_file', 'subjects_dir', 'subject_id',
342342
't1_preproc', 't1_brain', 't1_mask', 't1_seg', 't1_tpms',
343343
't1_aseg', 't1_aparc',
344344
't1_2_mni_forward_transform', 't1_2_mni_reverse_transform',
345345
't1_2_fsnative_forward_transform', 't1_2_fsnative_reverse_transform']),
346346
name='inputnode')
347347
inputnode.inputs.bold_file = bold_file
348348
if sbref_file is not None:
349-
inputnode.inputs.sbref_file = sbref_file
349+
from niworkflows.interfaces.images import ValidateImage
350+
val_sbref = pe.Node(ValidateImage(in_file=sbref_file), name='val_sbref')
350351

351352
outputnode = pe.Node(niu.IdentityInterface(
352353
fields=['bold_t1', 'bold_t1_ref', 'bold_mask_t1', 'bold_aseg_t1', 'bold_aparc_t1',
@@ -415,6 +416,10 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
415416

416417
# Generate a tentative boldref
417418
bold_reference_wf = init_bold_reference_wf(omp_nthreads=omp_nthreads)
419+
if sbref_file is not None:
420+
workflow.connect([
421+
(val_sbref, bold_reference_wf, [('out_file', 'inputnode.sbref_file')]),
422+
])
418423

419424
# Top-level BOLD splitter
420425
bold_split = pe.Node(FSLSplit(dimension='t'), name='bold_split',
@@ -533,8 +538,7 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
533538
# MAIN WORKFLOW STRUCTURE #######################################################
534539
workflow.connect([
535540
# Generate early reference
536-
(inputnode, bold_reference_wf, [('bold_file', 'inputnode.bold_file'),
537-
('sbref_file', 'inputnode.sbref_file')]),
541+
(inputnode, bold_reference_wf, [('bold_file', 'inputnode.bold_file')]),
538542
# BOLD buffer has slice-time corrected if it was run, original otherwise
539543
(boldbuffer, bold_split, [('bold_file', 'in_file')]),
540544
# HMC

fmriprep/workflows/bold/util.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ def init_bold_reference_wf(omp_nthreads, bold_file=None, pre_mask=False,
115115

116116
gen_ref = pe.Node(EstimateReferenceImage(), name="gen_ref",
117117
mem_gb=1) # OE: 128x128x128x50 * 64 / 8 ~ 900MB.
118-
# Re-run validation; no effect if no sbref; otherwise apply same validation to sbref as bold
119-
validate_ref = pe.Node(ValidateImage(), name='validate_ref', mem_gb=DEFAULT_MEMORY_MIN_GB)
120118
enhance_and_skullstrip_bold_wf = init_enhance_and_skullstrip_bold_wf(
121119
omp_nthreads=omp_nthreads, pre_mask=pre_mask)
122120

@@ -125,12 +123,11 @@ def init_bold_reference_wf(omp_nthreads, bold_file=None, pre_mask=False,
125123
(inputnode, validate, [('bold_file', 'in_file')]),
126124
(inputnode, gen_ref, [('sbref_file', 'sbref_file')]),
127125
(validate, gen_ref, [('out_file', 'in_file')]),
128-
(gen_ref, validate_ref, [('ref_image', 'in_file')]),
129-
(validate_ref, enhance_and_skullstrip_bold_wf, [('out_file', 'inputnode.in_file')]),
126+
(gen_ref, enhance_and_skullstrip_bold_wf, [('ref_image', 'inputnode.in_file')]),
130127
(validate, outputnode, [('out_file', 'bold_file'),
131128
('out_report', 'validation_report')]),
132129
(gen_ref, outputnode, [('n_volumes_to_discard', 'skip_vols')]),
133-
(validate_ref, outputnode, [('out_file', 'raw_ref_image')]),
130+
(gen_ref, outputnode, [('ref_image', 'raw_ref_image')]),
134131
(enhance_and_skullstrip_bold_wf, outputnode, [
135132
('outputnode.bias_corrected_file', 'ref_image'),
136133
('outputnode.mask_file', 'bold_mask'),

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
niworkflows<0.9.0a0,>=0.8.1
1+
git+https://github.com/poldracklab/niworkflows.git@b7d111c8fd36a099c74be5e7671677eedb175533#egg=niworkflows
22
git+https://github.com/poldracklab/smriprep.git@423bcc43ab7300177eb3b98da62817b2cad8eb87#egg=smriprep-0.1.0
33
templateflow<0.2.0a0,>=0.1.3

0 commit comments

Comments
 (0)