diff --git a/.maint/developers.json b/.maint/developers.json index 5529971b..c19f031d 100644 --- a/.maint/developers.json +++ b/.maint/developers.json @@ -22,6 +22,11 @@ "name": "Lerma-Usabiaga, Garikoitz", "orcid": "0000-0001-9800-4816" }, + { + "affiliation": "The Centre for Addiction and Mental Health", + "name": "Mansour, Salim", + "orcid": "0000-0002-1092-1650" + }, { "affiliation": "Department of Psychology, University of Texas at Austin, TX, USA", "name": "Pisner, Derek", diff --git a/dmriprep/cli/parser.py b/dmriprep/cli/parser.py index 0d6458b4..96acce0e 100644 --- a/dmriprep/cli/parser.py +++ b/dmriprep/cli/parser.py @@ -191,7 +191,7 @@ def _bids_filter(value): action="store", nargs="+", default=[], - choices=["fieldmaps", "slicetiming", "sbref"], + choices=["fieldmaps", "sbref"], help="ignore selected aspects of the input dataset to disable corresponding " "parts of the workflow (a space delimited list)", ) @@ -219,6 +219,14 @@ def _bids_filter(value): https://www.nipreps.org/dmriprep/en/%s/spaces.html""" % (currentv.base_version if is_release else "latest"), ) + g_conf.add_argument( + "--dwi2t1w-init", + action="store", + default="register", + choices=["register", "header"], + help='Either "register" (the default) to initialize volumes at center or "header"' + " to use the header information when coregistering DWI to T1w images.", + ) # ANTs options g_ants = parser.add_argument_group("Specific options for ANTs registrations") diff --git a/dmriprep/config/__init__.py b/dmriprep/config/__init__.py index 0f8ca8bb..45ccdaa4 100644 --- a/dmriprep/config/__init__.py +++ b/dmriprep/config/__init__.py @@ -425,6 +425,9 @@ class workflow(_Config): anat_only = False """Execute the anatomical preprocessing only.""" + dwi2t1w_init = "register" + """Whether to use standard coregistration ('register') or to initialize coregistration from the + DWI header ('header').""" fmap_bspline = None """Regularize fieldmaps with a field of B-Spline basis.""" fmap_demean = None diff --git a/dmriprep/config/reports-spec.yml b/dmriprep/config/reports-spec.yml index 8beea1db..fd188eeb 100644 --- a/dmriprep/config/reports-spec.yml +++ b/dmriprep/config/reports-spec.yml @@ -49,6 +49,23 @@ sections: all b=0 found in the dataset, after accounting for signal drift. The red contour shows the brain mask calculated using this reference b=0. subtitle: Reference b=0 and brain mask + - bids: {datatype: figures, desc: coreg, suffix: dwi} + caption: Diffusion-weighted data and anatomical data (EPI-space and T1w-space) + were aligned with mri_coreg (FreeSurfer). + WARNING - bbregister refinement rejected. + description: Note that nearest-neighbor interpolation is used in this reportlet + in order to highlight potential slice Inhomogeneities and other artifacts, whereas + the final images are resampled using cubic B-Spline interpolation. + static: false + subtitle: Alignment of functional and anatomical MRI data (volume based) + - bids: {datatype: figures, desc: bbregister, suffix: dwi} + caption: Diffusion-weighted data and anatomical data (EPI-space and T1w-space) + were aligned with bbregister (FreeSurfer). + description: Note that nearest-neighbor interpolation is used in this reportlet + in order to highlight potential slice Inhomogeneities and other artifacts, whereas + the final images are resampled using cubic B-Spline interpolation. + static: false + subtitle: Alignment of functional and anatomical MRI data (surface driven) - name: About reportlets: - bids: {datatype: figures, desc: about, suffix: T1w} diff --git a/dmriprep/workflows/base.py b/dmriprep/workflows/base.py index ce6e9cb8..4df5de88 100755 --- a/dmriprep/workflows/base.py +++ b/dmriprep/workflows/base.py @@ -12,6 +12,7 @@ from niworkflows.utils.misc import fix_multi_T1w_source_name from niworkflows.utils.spaces import Reference from smriprep.workflows.anatomical import init_anat_preproc_wf +from fmriprep.workflows.bold.registration import init_bbreg_wf from ..interfaces import DerivativesDataSink, BIDSDataGrabber from ..interfaces.reports import SubjectSummary, AboutSummary @@ -287,7 +288,7 @@ def init_single_subject_wf(subject_id): return workflow # Append the dMRI section to the existing anatomical excerpt - # That way we do not need to stream down the number of bold datasets + # That way we do not need to stream down the number of DWI datasets anat_preproc_wf.__postdesc__ = ( (anat_preproc_wf.__postdesc__ or "") + f""" @@ -354,6 +355,53 @@ def init_single_subject_wf(subject_id): ]) # fmt:on + if config.workflow.run_reconall: + from niworkflows.interfaces.nibabel import ApplyMask + + # Mask the T1w + t1w_brain = pe.Node(ApplyMask(), name="t1w_brain") + + bbr_wf = init_bbreg_wf( + bold2t1w_dof=6, + bold2t1w_init=config.workflow.dwi2t1w_init, + omp_nthreads=config.nipype.omp_nthreads, + use_bbr=True, + ) + + ds_report_reg = pe.Node( + DerivativesDataSink(base_directory=str(output_dir), datatype="figures",), + name="ds_report_reg", + run_without_submitting=True, + ) + + def _bold_reg_suffix(fallback): + return "coreg" if fallback else "bbregister" + + # fmt:off + workflow.connect([ + # T1w Mask + (anat_preproc_wf, t1w_brain, [ + ("outputnode.t1w_preproc", "in_file"), + ("outputnode.t1w_mask", "in_mask"), + ]), + # BBRegister + (early_b0ref_wf, bbr_wf, [ + ("outputnode.dwi_reference", "inputnode.in_file") + ]), + (t1w_brain, bbr_wf, [("out_file", "inputnode.t1w_brain")]), + (anat_preproc_wf, bbr_wf, [("outputnode.t1w_dseg", "inputnode.t1w_dseg")]), + (fsinputnode, bbr_wf, [("subjects_dir", "inputnode.subjects_dir")]), + (bids_info, bbr_wf, [(("subject", _prefix), "inputnode.subject_id")]), + (anat_preproc_wf, bbr_wf, [ + ("outputnode.fsnative2t1w_xfm", "inputnode.fsnative2t1w_xfm") + ]), + (split_info, ds_report_reg, [("dwi_file", "source_file")]), + (bbr_wf, ds_report_reg, [ + ('outputnode.out_report', 'in_file'), + (('outputnode.fallback', _bold_reg_suffix), 'desc')]), + ]) + # fmt:on + fmap_estimation_wf = init_fmap_estimation_wf( subject_data["dwi"], debug=config.execution.debug ) diff --git a/docs/requirements.txt b/docs/requirements.txt index beb81f5e..3604c366 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,5 +1,6 @@ git+https://github.com/AleksandarPetrov/napoleon.git@0dc3f28a309ad602be5f44a9049785a1026451b3#egg=sphinxcontrib-napoleon git+https://github.com/rwblair/sphinxcontrib-versioning.git@39b40b0b84bf872fc398feff05344051bbce0f63#egg=sphinxcontrib-versioning +fmriprep nbsphinx nipype ~= 1.4 git+https://github.com/nipreps/niworkflows.git@master#egg=niworkflows diff --git a/setup.cfg b/setup.cfg index aee34daf..2d9d56e1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,6 +33,7 @@ install_requires = smriprep ~= 0.7.0 templateflow ~= 0.6 toml + fmriprep ~= 20.2 setup_requires = setuptools >= 40.8.0 test_requires =