Confusion between freesurfer parcellation and segmentation

  • MNE version: e.g. 0.24.0
  • operating system: Ubuntu 18.04

Dear MNE community,

I am currently facing an issue that most probably stems from my lack of experience with FreeSurfer. I am currently working with intracranial recordings data and I would like to produce a vizualization of how many electrodes I have per region of interest with color coding. I am therefore trying to extract the label from each electrode in my data set using the function get_montage_volume_labels from the Destrieux Atlas. I am then trying to count how many electrodes I have in each regions of interest of the said atlas.

In order to do so, I am trying to do something like this:


subjects_dir = Path(mne.datasets.sample.data_path(), 'subjects')
# Get the labels from the Destrieux parcellation:
labels = mne.read_labels_from_annot('fsaverage', parc="aparc.a2009s", subjects_dir=subjects_dir)
# Prepare a dictionary to store the counts per Destrieux regions:
counts_per_roi = {label.name: 0 for label in labels}
# Looping through each of them to get the labels of each electrode:
for sub in subjects_list:
    # Creating the bids path object:
    bids_path = BIDSPath(root=bids_root, subject=sub,
                                         session=session,
                                         datatype=data_type,
                                         task=task_name)
    # Read the data:
    raw = read_raw_bids(bids_path=bids_path, verbose=True)
    # Extract the labels from each electrodes:
    labels, _ = mne.get_montage_volume_labels(
    raw.get_montage(), "sub-" + sub, subjects_dir=fs_dir, aseg="aparc.a2009s+aseg")
    # Looping through each label retrieved from read_labels_from_annot:
    for label_names in counts_per_roi.keys():
         # Preparing list to hold the electrodes that are found in this label:
         roi_channels = []
         # Looping through each electrode labels to find those in the current label:
         for channel in labels.keys():
             if label_names in labels[channel]:
                 roi_channels.append(channel)
          counts_per_roi[label_names] += len(roi_channels)

Unfortunately, when doing so, it turns out that the names of the labels retrieved from the function read_labels_from_annot differs from the names of the channels labels obtained with get_montage_volume_labels.

The function read_labels_from_annot retrieves labels names like so:
'G_Ins_lg_and_S_cent_ins-lh', 'G_Ins_lg_and_S_cent_ins-rh', 'G_and_S_cingul-Ant-lh', 'G_and_S_cingul-Ant-rh', 'G_and_S_cingul-Mid-Ant-lh'
Whereas get_montage_volume_labels retrieves names like so:
['Unknown', 'ctx_rh_G_front_inf-Opercular'], ['Unknown', 'ctx_rh_G_precentral'], ['Unknown', 'ctx_rh_G_precentral']

I am quite confused by this mismatch and I am a bit uncertain about how to achieve what I want to do. Ideally, I would like the rough snippet posted above to return for each labels retrieved from read_labels_from_annot with the Destrieux atlas a count of how many electrodes I have in there.

Would anyone know how to achieve this? Maybe there is an easy way to map the two different outputs? Or maybe different functions than the ones I am using to retrieve consistent names?

Thanks in advance for the support,

Kind regards,

Alex

Hello @AlexLepauvre, did you manage to resolve this confusion? :slight_smile:

Hello Richard,

Thanks for following up on this :slight_smile:

I have indeed managed to figure out the confusion. In case anyone ever faces something similar, here is an explanation:
When using the function

mne.get_montage_volume_labels(
    raw.get_montage(), "sub-" + sub, subjects_dir=fs_dir, aseg="aparc.a2009s+aseg")

to retrieve an electrode ROI according to a specific atlas, the aseg file from freesurfer is accessed, which contains the labels in volume space. However, when using:

labels = mne.read_labels_from_annot('fsaverage', parc="aparc.a2009s", subjects_dir=subjects_dir)

the aparc.a2009s.annot file is accessed, containing the labels in surface space, hence the name discrepancies.

The roi list I was provided was in surface space. For intracranial however (especially stereo channels), surface labels do not make much sense, we indeed want the volume ones to be retrieved by get_montage_volume_labels. In order to convert the list I was provided with in volume space, I used the function freesurfer function mri_annotation2label to transform the aparc.a2009s.annot into volume labels:

mri_annotation2label --hemi lh --subject fsaverage --annotation ./label/lh.aparc.a2009s.annot --seg ~/destrieux_labels.mgz --segbase ./mri/aparc-lh

As it turned out, the labels names contained in the retrieved destrieux_labels.mgz were not consistent with the ones found in aparc.a2009s.annot but with the ones found in the aparc.a2009s+aseg.mgz. In other words, when performing the Destrieux atlas mapping, the surface labels are automatically converted into volume labels and stored in the mgz file. There is therefore a 1 to 1 mapping between the surface and volume labels from the Destrieux, the naming discrepancy is just introduced when doing the conversion from surface to volume labels with freesurfer. I wrote a little function to convert the names from one to the other:

def convert_surf_to_vol(surf_labels):
    renamed_surf_labels = []
    for label in surf_labels:
        if "lh" in label.name:
            new_label_name = label.name.replace("-lh", "")
            new_label_name = "ctx_lh_" + new_label_name
        elif "rh" in label.name:
            new_label_name = label.name.replace("-rh", "")
            new_label_name = "ctx_rh_" + new_label_name
        else:
            new_label_name = label.name
        label.name = new_label_name
        renamed_surf_labels.append(label)
    return renamed_surf_labels

Hope this helps,

Kind regards,

Alex

PS: note that while for each surface label found in aparc.a2009s.annot you have a corresponding volume label in aparc.a2009s+aseg.mgz, the reverse is not true. Some of the volume labels found in aparc.a2009s+aseg.mgz are not found in aparc.a2009s.annot as these are depth structures.