forked from nipreps/sdcflows
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: Refactor fieldmap-unwarping flows, more homogeneous interface
This PR closes nipreps#19, reorganizing the unwarping tools for fieldmap-based solutions: - [x] Separate the displacements field generation from actual unwarping (i.e., applying the nonlinear transform). By doing this, we are not only addressing nipreps#19 directly, we are also readying the ground for tackling nipreps#21 since now all the unwarping paths (pepolar, fieldmaps/phases/phasediff, or syn) have more consistent interfaces. - [x] Update the root workflow to reflect these changes. - [x] Unloaded ``unwarp.py`` of the workflow to write reports, which has been moved to a new module called ``outputs.py`` following some of the latest *fMRIPrep* non-written standards. - [x] Polished some minor documentation and stylistic issues within the scope of the proposed changes.
- Loading branch information
Showing
6 changed files
with
270 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- | ||
# vi: set ft=python sts=4 ts=4 sw=4 et: | ||
"""Writing out outputs.""" | ||
from nipype.pipeline import engine as pe | ||
from nipype.interfaces import utility as niu | ||
from niworkflows.interfaces.bids import DerivativesDataSink | ||
|
||
|
||
def init_sdc_unwarp_report_wf(name='sdc_unwarp_report_wf', forcedsyn=False): | ||
""" | ||
Save a reportlet showing how SDC unwarping performed. | ||
This workflow generates and saves a reportlet showing the effect of fieldmap | ||
unwarping a BOLD image. | ||
.. workflow:: | ||
:graph2use: orig | ||
:simple_form: yes | ||
from sdcflows.workflows.outputs import init_sdc_unwarp_report_wf | ||
wf = init_sdc_unwarp_report_wf() | ||
Parameters | ||
---------- | ||
name : str, optional | ||
Workflow name (default: ``sdc_unwarp_report_wf``) | ||
forcedsyn : bool, optional | ||
Whether SyN-SDC was forced. | ||
Inputs | ||
------ | ||
in_pre | ||
Reference image, before unwarping | ||
in_post | ||
Reference image, after unwarping | ||
in_seg | ||
Segmentation of preprocessed structural image, including | ||
gray-matter (GM), white-matter (WM) and cerebrospinal fluid (CSF) | ||
in_xfm | ||
Affine transform from T1 space to BOLD space (ITK format) | ||
""" | ||
from niworkflows.interfaces import SimpleBeforeAfter | ||
from niworkflows.interfaces.fixes import FixHeaderApplyTransforms as ApplyTransforms | ||
from niworkflows.interfaces.images import extract_wm | ||
|
||
DEFAULT_MEMORY_MIN_GB = 0.01 | ||
|
||
workflow = pe.Workflow(name=name) | ||
|
||
inputnode = pe.Node(niu.IdentityInterface( | ||
fields=['in_pre', 'in_post', 'in_seg', 'in_xfm']), name='inputnode') | ||
|
||
map_seg = pe.Node(ApplyTransforms( | ||
dimension=3, float=True, interpolation='MultiLabel'), | ||
name='map_seg', mem_gb=0.3) | ||
|
||
sel_wm = pe.Node(niu.Function(function=extract_wm), name='sel_wm', | ||
mem_gb=DEFAULT_MEMORY_MIN_GB) | ||
|
||
bold_rpt = pe.Node(SimpleBeforeAfter(), name='bold_rpt', | ||
mem_gb=0.1) | ||
ds_report_sdc = pe.Node( | ||
DerivativesDataSink(desc='sdc' if not forcedsyn else 'forcedsyn', | ||
suffix='bold'), name='ds_report_sdc', | ||
mem_gb=DEFAULT_MEMORY_MIN_GB, run_without_submitting=True | ||
) | ||
|
||
workflow.connect([ | ||
(inputnode, bold_rpt, [('in_post', 'after'), | ||
('in_pre', 'before')]), | ||
(bold_rpt, ds_report_sdc, [('out_report', 'in_file')]), | ||
(inputnode, map_seg, [('in_post', 'reference_image'), | ||
('in_seg', 'input_image'), | ||
('in_xfm', 'transforms')]), | ||
(map_seg, sel_wm, [('output_image', 'in_seg')]), | ||
(sel_wm, bold_rpt, [('out', 'wm_seg')]), | ||
]) | ||
|
||
return workflow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.