@@ -228,6 +228,78 @@ def tissue_types():
228
228
return labels
229
229
230
230
231
+ def nonlateral_aseg_recoder (include_lesions = False ):
232
+ """
233
+ Returns a recoding table that converts default brain labels to the
234
+ corresponding tissue-type.
235
+
236
+ Returns:
237
+ RecodingLookupTable: .
238
+ """
239
+ include_list = [
240
+ "Unknown" ,
241
+ "Left-Cerebral-White-Matter" ,
242
+ "Left-Cerebral-Cortex" ,
243
+ "Left-Cerebellum-White-Matter" ,
244
+ "Left-Cerebellum-Cortex" ,
245
+ "Left-Thalamus" ,
246
+ "Left-Caudate" ,
247
+ "Left-Putamen" ,
248
+ "Left-Pallidum" ,
249
+ "3rd-Ventricle" ,
250
+ "4th-Ventricle" ,
251
+ "Brain-Stem" ,
252
+ "Left-Hippocampus" ,
253
+ "Left-Amygdala" ,
254
+ "CSF" ,
255
+ "Left-Lesion" ,
256
+ "Left-Accumbens-area" ,
257
+ "Left-VentralDC" ,
258
+ "Left-Choroid-Plexus"
259
+ ]
260
+ aseg = labels ()
261
+ source_lut = labels ()
262
+ target_lut = LabelLookup ()
263
+ mapping = {}
264
+ for key in source_lut .keys ():
265
+ if (key >= 1000 and key < 3000 ) or \
266
+ (key > 11000 and key < 13000 ): # destrieux labels
267
+ name = 'Left-Cerebral-Cortex'
268
+ elif (key >= 3000 and key < 5000 ) or (key >= 13000 and key < 15000 ) or (key >= 250 and key <= 255 ):
269
+ name = 'Left-Cerebral-White-Matter'
270
+ elif (key >= 7000 and key <= 7020 ):
271
+ name = 'Left-Amygdala'
272
+ elif (key >= 8000 and key < 9000 ):
273
+ name = 'Left-Thalamus'
274
+ elif key < 100 :
275
+ name = source_lut [key ].name
276
+ if name .startswith ('Right-' ):
277
+ name = name .replace ('Right-' , 'Left-' )
278
+ if (name .find ('Vent' ) >= 0 and name .find ('entral' ) < 0 ):
279
+ name = 'CSF'
280
+ if name .find ('ypoint' ) >= 0 or name .find ('esion' ) >= 0 or \
281
+ name .find ('wmsa' ) >= 0 :
282
+ name = 'Left-Lesion'
283
+ else :
284
+ continue ;
285
+
286
+ if name not in include_list :
287
+ continue
288
+
289
+ source_key = key
290
+ target_list = target_lut .search (name )
291
+
292
+ if len (target_list ) == 0 : # not already
293
+ target_key = len (target_lut )
294
+ target_lut [target_key ] = (name , source_lut [key ].color )
295
+ else :
296
+ target_key = target_list [0 ]
297
+
298
+ mapping [source_key ] = target_key
299
+
300
+ return LabelRecoder (mapping , target = target_lut )
301
+
302
+
231
303
def tissue_type_recoder (extra = False , lesions = False ):
232
304
"""
233
305
Return a recoding lookup that converts default brain labels to the
0 commit comments