@@ -1170,11 +1170,11 @@ def init_hcp_morphometrics_wf(
1170
1170
def init_segs_to_native_wf (
1171
1171
* ,
1172
1172
image_type : ty .Literal ['T1w' , 'T2w' ] = 'T1w' ,
1173
- segmentation : ty .Literal ['aseg' , 'aparc_aseg' , 'wmparc' ] = 'aseg' ,
1173
+ segmentation : ty .Literal ['aseg' , 'aparc_aseg' , 'aparc_a2009s' , 'aparc_dkt' ] | str = 'aseg' ,
1174
1174
name : str = 'segs_to_native_wf' ,
1175
1175
) -> Workflow :
1176
1176
"""
1177
- Get a segmentation from FreeSurfer conformed space into native T1w space.
1177
+ Get a segmentation from FreeSurfer conformed space into native anatomical space.
1178
1178
1179
1179
Workflow Graph
1180
1180
.. workflow::
@@ -1219,30 +1219,27 @@ def init_segs_to_native_wf(
1219
1219
1220
1220
lta = pe .Node (ConcatenateXFMs (out_fmt = 'fs' ), name = 'lta' , run_without_submitting = True )
1221
1221
1222
- # Resample from T1.mgz to T1w.nii.gz , applying any offset in fsnative2anat_xfm,
1222
+ # Resample from Freesurfer anat to native anat , applying any offset in fsnative2anat_xfm,
1223
1223
# and convert to NIfTI while we're at it
1224
1224
resample = pe .Node (
1225
1225
fs .ApplyVolTransform (transformed_file = 'seg.nii.gz' , interp = 'nearest' ),
1226
1226
name = 'resample' ,
1227
1227
)
1228
1228
1229
- if segmentation .startswith ('aparc' ):
1230
- if segmentation == 'aparc_aseg' :
1229
+ seg_mapping = {'aparc_aseg' : 'aparc+' , 'aparc_a2009s' : 'a2009s+' , 'aparc_dkt' : 'DKTatlas+' }
1230
+ if segmentation in seg_mapping :
1231
+ name = seg_mapping [segmentation ]
1231
1232
1232
- def _sel (x ):
1233
- return [parc for parc in x if 'aparc+' in parc ][0 ] # noqa
1233
+ def _sel (files , name = name ):
1234
+ if isinstance (files , str ):
1235
+ return files
1234
1236
1235
- elif segmentation == 'aparc_a2009s' :
1237
+ for fl in files :
1238
+ if name in fl :
1239
+ return fl
1240
+ raise FileNotFoundError
1236
1241
1237
- def _sel (x ):
1238
- return [parc for parc in x if 'a2009s+' in parc ][0 ] # noqa
1239
-
1240
- elif segmentation == 'aparc_dkt' :
1241
-
1242
- def _sel (x ):
1243
- return [parc for parc in x if 'DKTatlas+' in parc ][0 ] # noqa
1244
-
1245
- segmentation = (segmentation , _sel )
1242
+ segmentation = (segmentation , _sel ) # type: ignore
1246
1243
1247
1244
anat = 'T2' if image_type == 'T2w' else 'T1'
1248
1245
0 commit comments