Skip to content

Commit 829d762

Browse files
committed
Replace MCFLIRT with 3dVolReg
2 parents 682e60d + eb7e4a5 commit 829d762

File tree

6 files changed

+45
-9
lines changed

6 files changed

+45
-9
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ RUN apt-get update && \
2222
apt-get update
2323

2424
# Installing freesurfer
25-
RUN curl -sSL https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/6.0.1/freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.1-f53a55a.tar.gz | tar zxv --no-same-owner -C /opt \
25+
RUN curl -sSL https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/6.0.1/freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.1.tar.gz | tar zxv --no-same-owner -C /opt \
2626
--exclude='freesurfer/trctrain' \
2727
--exclude='freesurfer/subjects/fsaverage_sym' \
2828
--exclude='freesurfer/subjects/fsaverage3' \

docs/workflows.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,9 @@ BOLD reference image estimation
294294

295295
This workflow estimates a reference image for a
296296
:abbr:`BOLD (blood-oxygen level-dependent)` series.
297+
If a single-band reference ("sbref") image associated with the BOLD series is
298+
available, then it is used directly.
299+
If not, a reference image is estimated from the BOLD series as follows:
297300
When T1-saturation effects ("dummy scans" or non-steady state volumes) are
298301
detected, they are averaged and used as reference due to their
299302
superior tissue contrast.

fmriprep/cli/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def get_parser():
107107
g_conf = parser.add_argument_group('Workflow configuration')
108108
g_conf.add_argument(
109109
'--ignore', required=False, action='store', nargs="+", default=[],
110-
choices=['fieldmaps', 'slicetiming'],
110+
choices=['fieldmaps', 'slicetiming', 'sbref'],
111111
help='ignore selected aspects of the input dataset to disable corresponding '
112112
'parts of the workflow (a space delimited list)')
113113
g_conf.add_argument(

fmriprep/workflows/bold/base.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
243243
'Memory resampled/largemem=%.2f/%.2f GB.'),
244244
ref_file, mem_gb['filesize'], bold_tlen, mem_gb['resampled'], mem_gb['largemem'])
245245

246+
sbref_file = None
246247
# For doc building purposes
247248
if layout is None or bold_file == 'bold_preprocesing':
248249
LOGGER.log(25, 'No valid layout: building empty workflow.')
@@ -260,6 +261,28 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
260261
run_stc = True
261262
multiecho = False
262263
else:
264+
# Find associated sbref, if possible
265+
entities = layout.parse_file_entities(ref_file)
266+
entities['type'] = 'sbref'
267+
files = layout.get(**entities)
268+
refbase = os.path.basename(ref_file)
269+
if 'sbref' in ignore:
270+
LOGGER.info("Single-band reference files ignored.")
271+
elif files and multiecho:
272+
LOGGER.warning("Single-band reference found, but not supported in "
273+
"multi-echo workflows at this time. Ignoring.")
274+
elif files:
275+
sbref_file = files[0].filename
276+
sbbase = os.path.basename(sbref_file)
277+
if len(files) > 1:
278+
LOGGER.warning(
279+
"Multiple single-band reference files found for {}; using "
280+
"{}".format(refbase, sbbase))
281+
else:
282+
LOGGER.log(25, "Using single-band reference file {}".format(sbbase))
283+
else:
284+
LOGGER.log(25, "No single-band-reference found for {}".format(refbase))
285+
263286
metadata = layout.get_metadata(ref_file)
264287

265288
# Find fieldmaps. Options: (phase1|phase2|phasediff|epi|fieldmap|syn)
@@ -313,13 +336,15 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
313336
"""
314337

315338
inputnode = pe.Node(niu.IdentityInterface(
316-
fields=['bold_file', 'subjects_dir', 'subject_id',
339+
fields=['bold_file', 'sbref_file', 'subjects_dir', 'subject_id',
317340
't1_preproc', 't1_brain', 't1_mask', 't1_seg', 't1_tpms',
318341
't1_aseg', 't1_aparc',
319342
't1_2_mni_forward_transform', 't1_2_mni_reverse_transform',
320343
't1_2_fsnative_forward_transform', 't1_2_fsnative_reverse_transform']),
321344
name='inputnode')
322345
inputnode.inputs.bold_file = bold_file
346+
if sbref_file is not None:
347+
inputnode.inputs.sbref_file = sbref_file
323348

324349
outputnode = pe.Node(niu.IdentityInterface(
325350
fields=['bold_t1', 'bold_mask_t1', 'bold_aseg_t1', 'bold_aparc_t1', 'cifti_variant',
@@ -443,7 +468,8 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
443468
# MAIN WORKFLOW STRUCTURE #######################################################
444469
workflow.connect([
445470
# Generate early reference
446-
(inputnode, bold_reference_wf, [('bold_file', 'inputnode.bold_file')]),
471+
(inputnode, bold_reference_wf, [('bold_file', 'inputnode.bold_file'),
472+
('sbref_file', 'inputnode.sbref_file')]),
447473
# BOLD buffer has slice-time corrected if it was run, original otherwise
448474
(boldbuffer, bold_split, [('bold_file', 'in_file')]),
449475
# HMC
@@ -551,7 +577,8 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
551577
# Replace reference with the echo selected with FirstEcho
552578
workflow.disconnect([
553579
(inputnode, bold_reference_wf, [
554-
('bold_file', 'inputnode.bold_file')]),
580+
('bold_file', 'inputnode.bold_file'),
581+
('sbref_file', 'inputnode.sbref_file')]),
555582
(bold_reference_wf, boldbuffer, [
556583
('outputnode.bold_file', 'bold_file')]),
557584
])

fmriprep/workflows/bold/util.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ def init_bold_reference_wf(omp_nthreads, bold_file=None, name='bold_reference_wf
8787
First, a reference volume and its skull-stripped version were generated
8888
using a custom methodology of *fMRIPrep*.
8989
"""
90-
inputnode = pe.Node(niu.IdentityInterface(fields=['bold_file']), name='inputnode')
90+
inputnode = pe.Node(niu.IdentityInterface(fields=['bold_file', 'sbref_file']),
91+
name='inputnode')
9192
outputnode = pe.Node(
9293
niu.IdentityInterface(fields=['bold_file', 'raw_ref_image', 'skip_vols', 'ref_image',
9394
'ref_image_brain', 'bold_mask', 'validation_report',
@@ -103,17 +104,20 @@ def init_bold_reference_wf(omp_nthreads, bold_file=None, name='bold_reference_wf
103104
gen_ref = pe.Node(EstimateReferenceImage(), name="gen_ref",
104105
mem_gb=1) # OE: 128x128x128x50 * 64 / 8 ~ 900MB.
105106
deoblique = pe.Node(afni.Refit(deoblique=True), name='deoblique')
107+
# Re-run validation; no effect if no sbref; otherwise apply same validation to sbref as bold
108+
validate_ref = pe.Node(ValidateImage(), name='validate_ref', mem_gb=DEFAULT_MEMORY_MIN_GB)
106109
enhance_and_skullstrip_bold_wf = init_enhance_and_skullstrip_bold_wf(omp_nthreads=omp_nthreads)
107110

108111
workflow.connect([
109112
(inputnode, validate, [('bold_file', 'in_file')]),
113+
(inputnode, gen_ref, [('sbref_file', 'sbref_file')]),
110114
(validate, gen_ref, [('out_file', 'in_file')]),
111-
(gen_ref, deoblique, [('ref_image', 'in_file')]),
112-
(deoblique, enhance_and_skullstrip_bold_wf, [('out_file', 'inputnode.in_file')]),
115+
(gen_ref, validate_ref, [('ref_image', 'in_file')]),
116+
(validate_ref, enhance_and_skullstrip_bold_wf, [('out_file', 'inputnode.in_file')]),
113117
(validate, outputnode, [('out_file', 'bold_file'),
114118
('out_report', 'validation_report')]),
115-
(deoblique, outputnode, [('out_file', 'raw_ref_image')]),
116119
(gen_ref, outputnode, [('n_volumes_to_discard', 'skip_vols')]),
120+
(validate_ref, outputnode, [('out_file', 'raw_ref_image')]),
117121
(enhance_and_skullstrip_bold_wf, outputnode, [
118122
('outputnode.bias_corrected_file', 'ref_image'),
119123
('outputnode.mask_file', 'bold_mask'),

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
niworkflows>=0.4.3
2+
grabbit==0.2.3
3+
pybids==0.6.5
24
versioneer

0 commit comments

Comments
 (0)