6
6
from niworkflows .engine .workflows import LiterateWorkflow as Workflow
7
7
8
8
9
- def init_unwarp_wf (omp_nthreads = 1 , debug = False , name = "unwarp_wf" ):
9
+ def init_unwarp_wf (omp_nthreads = 1 , debug = False , name = "unwarp_wf" , mask = True ):
10
10
"""
11
11
Set up a workflow that unwarps the input :abbr:`EPI (echo-planar imaging)` dataset.
12
12
@@ -24,6 +24,10 @@ def init_unwarp_wf(omp_nthreads=1, debug=False, name="unwarp_wf"):
24
24
Maximum number of threads an individual process may use.
25
25
name : :obj:`str`
26
26
Unique name of this workflow.
27
+ debug : :obj:`bool`
28
+ Whether to run in *sloppy* mode.
29
+ mask : obj:`bool`
30
+ Generate a quick mask.
27
31
28
32
Inputs
29
33
------
@@ -41,7 +45,7 @@ def init_unwarp_wf(omp_nthreads=1, debug=False, name="unwarp_wf"):
41
45
42
46
"""
43
47
from niworkflows .interfaces .fixes import FixHeaderApplyTransforms as ApplyTransforms
44
- from ...interfaces .epi import GetReadoutTime
48
+ from ...interfaces .epi import GetReadoutTime , EPIMask
45
49
from ...interfaces .bspline import Coefficients2Warp
46
50
47
51
workflow = Workflow (name = name )
@@ -50,7 +54,8 @@ def init_unwarp_wf(omp_nthreads=1, debug=False, name="unwarp_wf"):
50
54
name = "inputnode" ,
51
55
)
52
56
outputnode = pe .Node (
53
- niu .IdentityInterface (fields = ["corrected" , "fieldmap" ]), name = "outputnode"
57
+ niu .IdentityInterface (fields = ["corrected" , "fieldmap" , "corrected_mask" ]),
58
+ name = "outputnode" ,
54
59
)
55
60
56
61
rotime = pe .Node (GetReadoutTime (), name = "rotime" )
@@ -75,4 +80,16 @@ def init_unwarp_wf(omp_nthreads=1, debug=False, name="unwarp_wf"):
75
80
(unwarp , outputnode , [("output_image" , "corrected" )]),
76
81
])
77
82
# fmt:on
83
+
84
+ if not mask :
85
+ return workflow
86
+
87
+ epi_mask = pe .Node (EPIMask (), name = "epi_mask" )
88
+
89
+ # fmt:off
90
+ workflow .connect ([
91
+ (unwarp , epi_mask , [("output_image" , "in_file" )]),
92
+ (epi_mask , outputnode , [("out_file" , "corrected_mask" )]),
93
+ ])
94
+ # fmt:on
78
95
return workflow
0 commit comments