@@ -1170,11 +1170,11 @@ def init_hcp_morphometrics_wf(
11701170def init_segs_to_native_wf (
11711171 * ,
11721172 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' ,
11741174 name : str = 'segs_to_native_wf' ,
11751175) -> Workflow :
11761176 """
1177- Get a segmentation from FreeSurfer conformed space into native T1w space.
1177+ Get a segmentation from FreeSurfer conformed space into native anatomical space.
11781178
11791179 Workflow Graph
11801180 .. workflow::
@@ -1219,30 +1219,27 @@ def init_segs_to_native_wf(
12191219
12201220 lta = pe .Node (ConcatenateXFMs (out_fmt = 'fs' ), name = 'lta' , run_without_submitting = True )
12211221
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,
12231223 # and convert to NIfTI while we're at it
12241224 resample = pe .Node (
12251225 fs .ApplyVolTransform (transformed_file = 'seg.nii.gz' , interp = 'nearest' ),
12261226 name = 'resample' ,
12271227 )
12281228
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 ]
12311232
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
12341236
1235- elif segmentation == 'aparc_a2009s' :
1237+ for fl in files :
1238+ if name in fl :
1239+ return fl
1240+ raise FileNotFoundError
12361241
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
12461243
12471244 anat = 'T2' if image_type == 'T2w' else 'T1'
12481245
0 commit comments