def get_volume_labels_from_aseg(mgz_fname, return_colors=False):
 import nibabel as nib
 mgz_data = nib.load(mgz_fname).get_data()
 lut = _get_lut()
 label_names = [lut[(lut['id'] == ii)]['name'][0].decode('utf-8') for ii in np.unique(mgz_data)]
 label_colors = [[lut[(lut['id'] == ii)]['R'][0], lut[(lut['id'] == ii)]['G'][0], lut[(lut['id'] == ii)]['B'][0], lut[(lut['id'] == ii)]['A'][0]] for ii in np.unique(mgz_data)]
 order = np.argsort(label_names)
 label_names = [label_names[k] for k in order]
 label_colors = [label_colors[k] for k in order]
 if return_colors:
  return (label_names, label_colors)
 else:
  return label_names

def get_volume_labels_from_aseg ( mgz_fname , return_colors = False ) : import nibabel as nib mgz_data = nib . load ( mgz_fname ) . get_data ( ) lut = _get_lut ( ) label_names = [ lut [ ( lut [ 'id' ] == ii ) ] [ 'name' ] [ 0 ] . decode ( 'utf-8' ) for ii in np . unique ( mgz_data ) ] label_colors = [ [ lut [ ( lut [ 'id' ] == ii ) ] [ 'R' ] [ 0 ] , lut [ ( lut [ 'id' ] == ii ) ] [ 'G' ] [ 0 ] , lut [ ( lut [ 'id' ] == ii ) ] [ 'B' ] [ 0 ] , lut [ ( lut [ 'id' ] == ii ) ] [ 'A' ] [ 0 ] ] for ii in np . unique ( mgz_data ) ] order = np . argsort ( label_names ) label_names = [ label_names [ k ] for k in order ] label_colors = [ label_colors [ k ] for k in order ] if return_colors : return ( label_names , label_colors ) else : return label_names
return a list of names and colors of segmented volumes .