1
1
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
2
2
# vi: set ft=python sts=4 ts=4 sw=4 et:
3
- """
4
- .. _sdc_unwarp :
5
-
6
- Unwarping
7
- ~~~~~~~~~
8
-
9
- .. topic :: Abbreviations
10
-
11
- fmap
12
- fieldmap
13
- VSM
14
- voxel-shift map -- a 3D nifti where displacements are in pixels (not mm)
15
- DFM
16
- displacements field map -- a nifti warp file compatible with ANTs (mm)
17
-
18
- """
3
+ """Apply the estimated fieldmap to perform susceptibility-derived distortion correction."""
19
4
from nipype .pipeline import engine as pe
20
- from nipype .interfaces import fsl , utility as niu
5
+ from nipype .interfaces import utility as niu
21
6
from niworkflows .engine .workflows import LiterateWorkflow as Workflow
22
- from niworkflows .interfaces .images import FilledImageLike
23
7
from niworkflows .interfaces .registration import ANTSApplyTransformsRPT
24
8
from niworkflows .func .util import init_enhance_and_skullstrip_bold_wf
25
9
@@ -31,10 +15,8 @@ def init_sdc_unwarp_wf(omp_nthreads, debug, name='sdc_unwarp_wf'):
31
15
This workflow takes in a displacements field through which the
32
16
input reference can be corrected for susceptibility-derived distortion.
33
17
34
- It also calculates a new mask for the input dataset, which takes into
35
- account the (corrected) distortions.
36
- The mask is restricted to the field of view of the fieldmap since outside
37
- of it corrections could not be performed.
18
+ It also calculates a new mask for the input dataset, after the distortions
19
+ have been accounted for.
38
20
39
21
.. workflow ::
40
22
:graph2use: orig
@@ -58,26 +40,26 @@ def init_sdc_unwarp_wf(omp_nthreads, debug, name='sdc_unwarp_wf'):
58
40
in_warp : os.pathlike
59
41
The :abbr:`DFM (displacements field map)` that corrects for
60
42
susceptibility-derived distortions estimated elsewhere.
61
- in_reference
43
+ in_reference : os.pathlike
62
44
the reference image to be unwarped.
63
- in_reference_brain
64
- a skull-stripped version corresponding to the ``in_reference``.
45
+ in_reference_mask : os.pathlike
46
+ the reference image mask to be unwarped
65
47
66
48
Outputs
67
49
-------
68
- out_reference
50
+ out_reference : str
69
51
the ``in_reference`` after unwarping
70
- out_reference_brain
52
+ out_reference_brain : str
71
53
the ``in_reference`` after unwarping and skullstripping
72
- out_warp
54
+ out_warp : str
73
55
the ``in_warp`` field is forwarded for compatibility
74
- out_mask
56
+ out_mask : str
75
57
mask of the unwarped input file
76
58
77
59
"""
78
60
workflow = Workflow (name = name )
79
61
inputnode = pe .Node (niu .IdentityInterface (
80
- fields = ['in_warp' , 'in_reference' , 'in_reference_brain ' ]),
62
+ fields = ['in_warp' , 'in_reference' , 'in_reference_mask ' ]),
81
63
name = 'inputnode' )
82
64
outputnode = pe .Node (niu .IdentityInterface (
83
65
fields = ['out_reference' , 'out_reference_brain' , 'out_warp' , 'out_mask' ]),
@@ -89,30 +71,29 @@ def init_sdc_unwarp_wf(omp_nthreads, debug, name='sdc_unwarp_wf'):
89
71
interpolation = 'LanczosWindowedSinc' ),
90
72
name = 'unwarp_reference' )
91
73
92
- fieldmap_fov_mask = pe .Node (FilledImageLike (dtype = 'uint8' ), name = 'fieldmap_fov_mask' )
93
- fmap_fov2ref_apply = pe .Node (ANTSApplyTransformsRPT (
94
- generate_report = False , dimension = 3 , interpolation = 'NearestNeighbor' ,
95
- float = True ),
96
- name = 'fmap_fov2ref_apply' )
74
+ unwarp_mask = pe .Node (ANTSApplyTransformsRPT (
75
+ dimension = 3 , generate_report = False , float = True ,
76
+ interpolation = 'NearestNeighbor' ), name = 'unwarp_mask' )
97
77
98
- apply_fov_mask = pe .Node (fsl .ApplyMask (), name = "apply_fov_mask" )
99
78
enhance_and_skullstrip_bold_wf = init_enhance_and_skullstrip_bold_wf (omp_nthreads = omp_nthreads ,
100
79
pre_mask = True )
101
80
workflow .connect ([
102
81
(inputnode , unwarp_reference , [
103
82
('in_warp' , 'transforms' ),
104
83
('in_reference' , 'reference_image' ),
105
84
('in_reference' , 'input_image' )]),
106
- (inputnode , fieldmap_fov_mask , [('in_warp' , 'in_file' )]),
107
- (fieldmap_fov_mask , fmap_fov2ref_apply , [('out_file' , 'input_image' )]),
108
- (inputnode , fmap_fov2ref_apply , [('in_reference' , 'reference_image' )]),
109
- (fmap_fov2ref_apply , apply_fov_mask , [('output_image' , 'mask_file' )]),
110
- (unwarp_reference , apply_fov_mask , [('output_image' , 'in_file' )]),
111
- (apply_fov_mask , enhance_and_skullstrip_bold_wf , [('out_file' , 'inputnode.in_file' )]),
112
- (apply_fov_mask , outputnode , [('out_file' , 'out_reference' )]),
85
+ (inputnode , unwarp_mask , [
86
+ ('in_warp' , 'transforms' ),
87
+ ('in_reference_mask' , 'reference_image' ),
88
+ ('in_reference_mask' , 'input_image' )]),
89
+ (unwarp_reference , enhance_and_skullstrip_bold_wf , [
90
+ ('output_image' , 'inputnode.in_file' )]),
91
+ (unwarp_mask , enhance_and_skullstrip_bold_wf , [
92
+ ('output_image' , 'inputnode.pre_mask' )]),
93
+ (inputnode , outputnode , [('in_warp' , 'out_warp' )]),
94
+ (unwarp_reference , outputnode , [('output_image' , 'out_reference' )]),
113
95
(enhance_and_skullstrip_bold_wf , outputnode , [
114
96
('outputnode.mask_file' , 'out_mask' ),
115
97
('outputnode.skull_stripped_file' , 'out_reference_brain' )]),
116
- (inputnode , outputnode , [('in_warp' , 'out_warp' )]),
117
98
])
118
99
return workflow
0 commit comments