6
6
from niworkflows .engine .workflows import LiterateWorkflow
7
7
from niworkflows .interfaces .freesurfer import PatchedLTAConvert as LTAConvert
8
8
from niworkflows .interfaces .freesurfer import PatchedRobustRegister as RobustRegister
9
+ from niworkflows .utils .connections import pop_file
9
10
from smriprep .workflows .surfaces import init_gifti_surface_wf
10
11
12
+ from ...config import DEFAULT_MEMORY_MIN_GB
13
+
11
14
SURFACE_INPUTS = [
12
15
"subjects_dir" ,
13
16
"subject_id" ,
30
33
]
31
34
32
35
33
- def init_mcribs_surface_recon_wf (* , use_aseg , mcribs_dir = None , name = "mcribs_surface_recon_wf" ):
36
+ def init_mcribs_surface_recon_wf (
37
+ * , use_aseg : bool , mcribs_dir : str = None , name : str = "mcribs_surface_recon_wf"
38
+ ):
34
39
"""
35
40
Reconstruct cortical surfaces using the M-CRIB-S pipeline.
36
41
@@ -41,6 +46,11 @@ def init_mcribs_surface_recon_wf(*, use_aseg, mcribs_dir=None, name="mcribs_surf
41
46
42
47
from ...interfaces .mcribs import MCRIBReconAll
43
48
49
+ if not use_aseg :
50
+ raise NotImplementedError (
51
+ "A previously computed segmentation is required for the M-CRIB-S workflow."
52
+ )
53
+
44
54
inputnode = pe .Node (niu .IdentityInterface (fields = SURFACE_INPUTS ), name = 'inputnode' )
45
55
outputnode = pe .Node (niu .IdentityInterface (fields = SURFACE_OUTPUTS ), name = 'outputnode' )
46
56
@@ -100,6 +110,7 @@ def init_mcribs_surface_recon_wf(*, use_aseg, mcribs_dir=None, name="mcribs_surf
100
110
101
111
fssource = pe .Node (nio .FreeSurferSource (), name = 'fssource' , run_without_submitting = True )
102
112
norm2nii = pe .Node (fs .MRIConvert (out_type = "niigz" ), name = "norm2nii" )
113
+ aparc2nii = pe .Node (fs .MRIConvert (out_type = "niigz" ), name = "aparc2nii" )
103
114
104
115
fsnative2t1w_xfm = pe .Node (
105
116
RobustRegister (auto_sens = True , est_int_scale = True ),
@@ -115,42 +126,40 @@ def init_mcribs_surface_recon_wf(*, use_aseg, mcribs_dir=None, name="mcribs_surf
115
126
# fmt:off
116
127
wf .connect ([
117
128
(inputnode , t2w_las , [("t2w" , "in_file" )]),
118
- (inputnode , map_labels , [("ants_segs" , "in_file" )])
129
+ (inputnode , map_labels , [("ants_segs" , "in_file" )]),
130
+ (inputnode , outputnode , [("ants_segs" , "out_aseg" )]), # Input segs are final
119
131
(map_labels , seg_las , [("out_file" , "in_file" )]),
120
132
(inputnode , mcribs_recon , [
121
133
("subjects_dir" , "subjects_dir" ),
122
134
("subject_id" , "subject_id" )]),
123
135
(t2w_las , mcribs_recon , [("out_file" , "t2w_file" )]),
124
136
(seg_las , mcribs_recon , [("out_file" , "segmentation_file" )]),
125
- (map_labels , outputnode , [("out_file" , "out_aseg" )]),
137
+ (inputnode , fssource , [("subject_id" , "subject_id" )]),
138
+ (mcribs_recon , fssource , [("subjects_dir" , "subjects_dir" )]),
139
+ (mcribs_recon , outputnode , [("subjects_dir" , "subjects_dir" )]),
140
+ (inputnode , outputnode , [("subject_id" , "subject_id" )]),
126
141
127
- # copied from infantFS workflow
128
142
(inputnode , fsnative2t1w_xfm , [('skullstripped_t1' , 'target_file' )]),
129
143
(fssource , norm2nii , [('norm' , 'in_file' )]),
144
+ (fssource , aparc2nii , [(('aparc_aseg' , pop_file ), 'in_file' )]),
145
+ (aparc2nii , outputnode , [('out_file' , 'out_aparc' )]),
130
146
(norm2nii , fsnative2t1w_xfm , [('out_file' , 'source_file' )]),
131
147
(fsnative2t1w_xfm , t1w2fsnative_xfm , [('out_reg_file' , 'in_lta' )]),
132
148
(inputnode , gifti_surface_wf , [
133
- ("subjects_dir" , "subjects_dir" ),
134
- ("subject_id" , "subject_id" )]),
149
+ ("subjects_dir" , "inputnode. subjects_dir" ),
150
+ ("subject_id" , "inputnode. subject_id" )]),
135
151
(fsnative2t1w_xfm , gifti_surface_wf , [
136
152
('out_reg_file' , 'inputnode.fsnative2t1w_xfm' )]),
153
+ (fsnative2t1w_xfm , outputnode , [('out_reg_file' , 'fsnative2t1w_xfm' )]),
154
+ (t1w2fsnative_xfm , outputnode , [('out_lta' , 't1w2fsnative_xfm' )]),
137
155
(gifti_surface_wf , outputnode , [
138
156
('outputnode.surfaces' , 'surfaces' ),
139
- ('outputnode.morphometrics' , 'morphometrics' ),
140
- ]),
157
+ ('outputnode.morphometrics' , 'morphometrics' )]),
141
158
])
142
159
# fmt:on
143
160
return wf
144
161
145
162
146
- from nipype .interfaces import fsl
147
- from nipype .interfaces import utility as niu
148
- from nipype .pipeline import engine as pe
149
-
150
- from ...config import DEFAULT_MEMORY_MIN_GB
151
- from ...interfaces .workbench import CreateSignedDistanceVolume
152
-
153
-
154
163
def init_infantfs_surface_recon_wf (
155
164
* , age_months , use_aseg = False , name = "infantfs_surface_recon_wf"
156
165
):
@@ -251,6 +260,10 @@ def init_infantfs_surface_recon_wf(
251
260
252
261
253
262
def init_anat_ribbon_wf (name = "anat_ribbon_wf" ):
263
+ from nipype .interfaces import fsl
264
+
265
+ from nibabies .interfaces .workbench import CreateSignedDistanceVolume
266
+
254
267
# 0, 1 = wm; 2, 3 = pial; 6, 7 = mid
255
268
# note that order of lh / rh within each surf type is not guaranteed due to use
256
269
# of unsorted glob by FreeSurferSource prior, but we can do a sort
0 commit comments