Skip to content

Commit 250b6f0

Browse files
authored
Merge pull request #1278 from emdupre/split_reg_wf
[RF] Split BOLD-T1w registration into calculation/application workflows
2 parents eb7e4a5 + 7b09fab commit 250b6f0

File tree

5 files changed

+171
-88
lines changed

5 files changed

+171
-88
lines changed

Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ RUN conda install -y mkl=2018.0.3 mkl-service; sync &&\
114114
pandas=0.23.0 \
115115
libxml2=2.9.4 \
116116
libxslt=1.1.29 \
117+
graphviz=2.40.1 \
117118
traits=4.6.0; sync && \
118119
chmod -R a+rX /usr/local/miniconda; sync && \
119120
chmod +x /usr/local/miniconda/bin/*; sync && \
@@ -127,8 +128,7 @@ RUN python -c "from matplotlib import font_manager" && \
127128
# Installing Ubuntu packages and cleaning up
128129
RUN apt-get update && \
129130
apt-get install -y --no-install-recommends \
130-
git=1:2.7.4-0ubuntu1 \
131-
graphviz=2.38.0-12ubuntu2 && \
131+
git=1:2.7.4-0ubuntu1 && \
132132
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
133133

134134
# Install latest pandoc
@@ -183,4 +183,3 @@ LABEL org.label-schema.build-date=$BUILD_DATE \
183183
org.label-schema.vcs-url="https://github.com/poldracklab/fmriprep" \
184184
org.label-schema.version=$VERSION \
185185
org.label-schema.schema-version="1.0"
186-

docs/workflows.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ to be run through ``fmriprep``.
128128

129129
Longitudinal processing
130130
~~~~~~~~~~~~~~~~~~~~~~~
131-
In the case of multiple T1w images (across sessions and/or runs), T1w images are
131+
In the case of multiple T1w images (across sessions and/or runs), T1w images are
132132
merged into a single template image using FreeSurfer's `mri_robust_template`_.
133133
This template may be *unbiased*, or equidistant from all source images, or
134134
aligned to the first image (determined lexicographically by session label).
@@ -448,9 +448,9 @@ EPI to T1w registration
448448
use_bbr=True,
449449
bold2t1w_dof=9)
450450

451-
The reference :abbr:`EPI (echo-planar imaging)` image of each run is aligned
452-
by the ``bbregister`` routine to the reconstructed subject using the gray/white
453-
matter boundary (FreeSurfer's ``?h.white`` surfaces).
451+
The alignment between the reference :abbr:`EPI (echo-planar imaging)` image
452+
of each run and the reconstructed subject using the gray/white matter boundary
453+
(FreeSurfer's ``?h.white`` surfaces) is calculated by the ``bbregister`` routine.
454454

455455
.. figure:: _static/EPIT1Normalization.svg
456456
:scale: 100%
@@ -459,7 +459,9 @@ matter boundary (FreeSurfer's ``?h.white`` surfaces).
459459

460460
If FreeSurfer processing is disabled, FSL ``flirt`` is run with the
461461
:abbr:`BBR (boundary-based registration)` cost function, using the
462-
``fast`` segmentation to establish the gray/white matter boundary. After :abbr:`BBR (boundary-based registration)` is run, the resulting affine transform will be compared to the initial transform found by FLIRT. Excessive deviation will result in rejecting the BBR refinement and accepting the original, affine registration.
462+
``fast`` segmentation to establish the gray/white matter boundary.
463+
After :abbr:`BBR (boundary-based registration)` is run, the resulting affine transform will be compared to the initial transform found by FLIRT.
464+
Excessive deviation will result in rejecting the BBR refinement and accepting the original, affine registration.
463465

464466
EPI to MNI transformation
465467
~~~~~~~~~~~~~~~~~~~~~~~~~

fmriprep/workflows/bold/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
from .hmc import init_bold_hmc_wf
2525
from .stc import init_bold_stc_wf
2626
from .t2s import init_bold_t2s_wf
27-
from .registration import init_bold_reg_wf
27+
from .registration import (
28+
init_bold_t1_trans_wf,
29+
init_bold_reg_wf,
30+
)
2831
from .resampling import (
2932
init_bold_mni_trans_wf,
3033
init_bold_surf_wf,

fmriprep/workflows/bold/base.py

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from .hmc import init_bold_hmc_wf
3535
from .stc import init_bold_stc_wf
3636
from .t2s import init_bold_t2s_wf
37-
from .registration import init_bold_reg_wf
37+
from .registration import init_bold_t1_trans_wf, init_bold_reg_wf
3838
from .resampling import (
3939
init_bold_surf_wf,
4040
init_bold_mni_trans_wf,
@@ -211,6 +211,7 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
211211
* :py:func:`~fmriprep.workflows.bold.stc.init_bold_stc_wf`
212212
* :py:func:`~fmriprep.workflows.bold.hmc.init_bold_hmc_wf`
213213
* :py:func:`~fmriprep.workflows.bold.t2s.init_bold_t2s_wf`
214+
* :py:func:`~fmriprep.workflows.bold.registration.init_bold_t1_trans_wf`
214215
* :py:func:`~fmriprep.workflows.bold.registration.init_bold_reg_wf`
215216
* :py:func:`~fmriprep.workflows.bold.confounds.init_bold_confounds_wf`
216217
* :py:func:`~fmriprep.workflows.bold.confounds.init_ica_aroma_wf`
@@ -404,15 +405,22 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
404405
mem_gb=mem_gb['filesize'],
405406
omp_nthreads=omp_nthreads)
406407

407-
# mean BOLD registration to T1w
408+
# calculate BOLD registration to T1w
408409
bold_reg_wf = init_bold_reg_wf(name='bold_reg_wf',
409410
freesurfer=freesurfer,
410411
use_bbr=use_bbr,
411412
bold2t1w_dof=bold2t1w_dof,
412413
mem_gb=mem_gb['resampled'],
413414
omp_nthreads=omp_nthreads,
414-
use_compression=False,
415-
use_fieldwarp=(fmaps is not None or use_syn))
415+
use_compression=False)
416+
417+
# apply BOLD registration to T1w
418+
bold_t1_trans_wf = init_bold_t1_trans_wf(name='bold_t1_trans_wf',
419+
freesurfer=freesurfer,
420+
use_fieldwarp=(fmaps is not None or use_syn),
421+
mem_gb=mem_gb['resampled'],
422+
omp_nthreads=omp_nthreads,
423+
use_compression=False)
416424

417425
# get confounds
418426
bold_confounds_wf = init_bold_confs_wf(
@@ -476,22 +484,25 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
476484
('outputnode.bold_file', 'inputnode.bold_file')]),
477485
# EPI-T1 registration workflow
478486
(inputnode, bold_reg_wf, [
479-
('bold_file', 'inputnode.name_source'),
480-
('t1_preproc', 'inputnode.t1_preproc'),
481487
('t1_brain', 'inputnode.t1_brain'),
482-
('t1_mask', 'inputnode.t1_mask'),
483488
('t1_seg', 'inputnode.t1_seg'),
484-
('t1_aseg', 'inputnode.t1_aseg'),
485-
('t1_aparc', 'inputnode.t1_aparc'),
486489
# Undefined if --no-freesurfer, but this is safe
487490
('subjects_dir', 'inputnode.subjects_dir'),
488491
('subject_id', 'inputnode.subject_id'),
489492
('t1_2_fsnative_reverse_transform', 'inputnode.t1_2_fsnative_reverse_transform')]),
490-
(bold_split, bold_reg_wf, [('out_files', 'inputnode.bold_split')]),
491-
(bold_hmc_wf, bold_reg_wf, [('outputnode.xforms', 'inputnode.hmc_xforms')]),
492-
(bold_reg_wf, outputnode, [('outputnode.bold_t1', 'bold_t1'),
493-
('outputnode.bold_aseg_t1', 'bold_aseg_t1'),
494-
('outputnode.bold_aparc_t1', 'bold_aparc_t1')]),
493+
(inputnode, bold_t1_trans_wf, [
494+
('bold_file', 'inputnode.name_source'),
495+
('t1_brain', 'inputnode.t1_brain'),
496+
('t1_mask', 'inputnode.t1_mask'),
497+
('t1_aseg', 'inputnode.t1_aseg'),
498+
('t1_aparc', 'inputnode.t1_aparc')]),
499+
(bold_split, bold_t1_trans_wf, [('out_files', 'inputnode.bold_split')]),
500+
(bold_hmc_wf, bold_t1_trans_wf, [('outputnode.xforms', 'inputnode.hmc_xforms')]),
501+
(bold_reg_wf, bold_t1_trans_wf, [
502+
('outputnode.itk_bold_to_t1', 'inputnode.itk_bold_to_t1')]),
503+
(bold_t1_trans_wf, outputnode, [('outputnode.bold_t1', 'bold_t1'),
504+
('outputnode.bold_aseg_t1', 'bold_aseg_t1'),
505+
('outputnode.bold_aparc_t1', 'bold_aparc_t1')]),
495506
(bold_reg_wf, summary, [('outputnode.fallback', 'fallback')]),
496507
# SDC (or pass-through workflow)
497508
(inputnode, bold_sdc_wf, [
@@ -502,6 +513,8 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
502513
('outputnode.ref_image_brain', 'inputnode.bold_ref_brain'),
503514
('outputnode.bold_mask', 'inputnode.bold_mask')]),
504515
(bold_sdc_wf, bold_reg_wf, [
516+
('outputnode.bold_ref_brain', 'inputnode.ref_bold_brain')]),
517+
(bold_sdc_wf, bold_t1_trans_wf, [
505518
('outputnode.bold_ref_brain', 'inputnode.ref_bold_brain'),
506519
('outputnode.bold_mask', 'inputnode.ref_bold_mask'),
507520
('outputnode.out_warp', 'inputnode.fieldwarp')]),
@@ -598,14 +611,14 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
598611

599612
# Replace EPI-to-T1w registration inputs
600613
workflow.disconnect([
601-
(bold_sdc_wf, bold_reg_wf, [
614+
(bold_sdc_wf, bold_t1_trans_wf, [
602615
('outputnode.bold_ref_brain', 'inputnode.ref_bold_brain'),
603616
('outputnode.bold_mask', 'inputnode.ref_bold_mask')]),
604617
])
605618
workflow.connect([
606619
(bold_hmc_wf, bold_t2s_wf, [
607620
('outputnode.xforms', 'inputnode.hmc_xforms')]),
608-
(bold_t2s_wf, bold_reg_wf, [
621+
(bold_t2s_wf, bold_t1_trans_wf, [
609622
('outputnode.t2s_map', 'inputnode.ref_bold_brain'),
610623
('outputnode.oc_mask', 'inputnode.ref_bold_mask')]),
611624
])
@@ -624,8 +637,9 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
624637
(bold_bold_trans_wf, boldmask_to_t1w, [
625638
('outputnode.bold_mask', 'input_image')]),
626639
(bold_reg_wf, boldmask_to_t1w, [
627-
('outputnode.bold_mask_t1', 'reference_image'),
628640
('outputnode.itk_bold_to_t1', 'transforms')]),
641+
(bold_t1_trans_wf, boldmask_to_t1w, [
642+
('outputnode.bold_mask_t1', 'reference_image')]),
629643
(boldmask_to_t1w, outputnode, [
630644
('output_image', 'bold_mask_t1')]),
631645
])
@@ -736,7 +750,7 @@ def init_func_preproc_wf(bold_file, ignore, freesurfer,
736750
('subjects_dir', 'inputnode.subjects_dir'),
737751
('subject_id', 'inputnode.subject_id'),
738752
('t1_2_fsnative_forward_transform', 'inputnode.t1_2_fsnative_forward_transform')]),
739-
(bold_reg_wf, bold_surf_wf, [('outputnode.bold_t1', 'inputnode.source_file')]),
753+
(bold_t1_trans_wf, bold_surf_wf, [('outputnode.bold_t1', 'inputnode.source_file')]),
740754
(bold_surf_wf, outputnode, [('outputnode.surfaces', 'surfaces')]),
741755
])
742756

0 commit comments

Comments
 (0)