@@ -52,9 +52,10 @@ def init_anat_segmentations_wf(
52
52
name = "inputnode" ,
53
53
)
54
54
outputnode = pe .Node (
55
- niu .IdentityInterface (fields = ["anat_aseg" , "anat_mcrib_aseg" , " anat_dseg" , "anat_tpms" ]),
55
+ niu .IdentityInterface (fields = ["anat_aseg" , "anat_dseg" , "anat_tpms" ]),
56
56
name = "outputnode" ,
57
57
)
58
+ buffernode = niu .IdentityInterface (fields = ["final_aseg" ], name = 'buffernode' )
58
59
59
60
wf .__desc__ = """Brain tissue segmentation of cerebrospinal fluid (CSF),
60
61
white-matter (WM) and gray-matter (GM) was performed on """
@@ -160,74 +161,27 @@ def init_anat_segmentations_wf(
160
161
(apply_atlas , jointfusion , [('output_image' , 'atlas_image' )]),
161
162
(apply_seg , jointfusion , [('output_image' , 'atlas_segmentation_image' )]),
162
163
(jointfusion , jf_label , [('out_label_fusion' , 'in_file' )]),
164
+ (jf_label , buffernode , [('out_file' , 'final_aseg' )]),
163
165
])
164
166
# fmt:on
165
167
166
168
elif precomp_aseg :
167
169
wf .__desc__ += "a pre-computed segmentation."
168
- from niworkflows .interfaces .header import ValidateImage
169
170
170
- inputnode .inputs .anat_aseg = precomp_aseg
171
- validate_aseg = pe .Node (ValidateImage (), name = "validate_aseg" )
172
- wf .connect (inputnode , "anat_aseg" , validate_aseg , "in_file" )
171
+ wf .connect (inputnode , "anat_aseg" , buffernode , "final_aseg" )
173
172
174
173
# Otherwise, the final aseg will be split into three tissue classes
175
174
# regardless if it was precomputed or generated via JLF
176
175
lut_anat_dseg .inputs .lut = _aseg_to_three ()
177
176
split_seg = pe .Node (niu .Function (function = _split_segments ), name = "split_seg" )
178
- out_aseg = validate_aseg if precomp_aseg else jf_label
179
-
180
- wf .__desc__ += """Segmentation volume label indices were remapped
181
- from FreeSurfer to M-CRIB-compatible format. """
182
-
183
- # dictionary to map labels from aseg to mcrib
184
- aseg2mcrib = {
185
- 2 : 51 ,
186
- 3 : 21 ,
187
- 4 : 49 ,
188
- 5 : 0 ,
189
- 7 : 17 ,
190
- 8 : 17 ,
191
- 10 : 43 ,
192
- 11 : 41 ,
193
- 12 : 47 ,
194
- 13 : 47 ,
195
- 14 : 0 ,
196
- 15 : 0 ,
197
- 16 : 19 ,
198
- 17 : 1 ,
199
- 18 : 3 ,
200
- 26 : 41 ,
201
- 28 : 45 ,
202
- 31 : 49 ,
203
- 41 : 52 ,
204
- 42 : 20 ,
205
- 43 : 50 ,
206
- 44 : 0 ,
207
- 46 : 18 ,
208
- 47 : 18 ,
209
- 49 : 42 ,
210
- 50 : 40 ,
211
- 51 : 46 ,
212
- 52 : 46 ,
213
- 53 : 2 ,
214
- 54 : 4 ,
215
- 58 : 40 ,
216
- 60 : 44 ,
217
- 63 : 50 ,
218
- 253 : 48 ,
219
- }
220
- map_labels = pe .Node (MapLabels (mappings = aseg2mcrib ), name = "map_labels" )
221
177
222
178
# fmt: off
223
179
wf .connect ([
224
- (out_aseg , outputnode , [('out_file ' , 'anat_aseg' )]),
225
- (out_aseg , lut_anat_dseg , [('out_file ' , 'in_dseg' )]),
180
+ (buffernode , outputnode , [('final_aseg ' , 'anat_aseg' )]),
181
+ (buffernode , lut_anat_dseg , [('final_aseg ' , 'in_dseg' )]),
226
182
(lut_anat_dseg , outputnode , [('out' , 'anat_dseg' )]),
227
183
(lut_anat_dseg , split_seg , [('out' , 'in_file' )]),
228
184
(split_seg , outputnode , [('out' , 'anat_tpms' )]),
229
- (out_aseg , map_labels , [("out_file" , "in_file" )]),
230
- (map_labels , outputnode , [("out_file" , "anat_mcrib_aseg" )]),
231
185
])
232
186
# fmt: on
233
187
0 commit comments