- 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