def get_volume_labels_from_aseg(mgz_fname):
    import nibabel as nib

    # Read the mgz file using nibabel
    mgz_data = nib.load(mgz_fname).get_data()

    # Get the unique label names
    lut = _get_lut()
    label_names = [lut[lut['id'] == ii]['name'][0].decode('utf-8')
                   for ii in np.unique(mgz_data)]
    label_names = sorted(label_names, key=lambda n: n.lower())
    return label_names
Returns a list of names of segmented volumes.
dataset/ETHPy150Open mne-tools/mne-python/mne/source_space.py/get_volume_labels_from_aseg