I am running into problem when I try to select more than one label simultaneously from a parcellation while keeping them as label objects. I need to keep the labels as label objects since they will be used to select sources for a simulation (i.e. mne.label.select.sources() does not accept list objects). All the 11 labels that I want are read from the parcellation but only the first (in this case caudalmiddlefrontal_1-lh) is kept in selected_labels_A (see code below). Sorry for this trivial question, I have searched the forum but only found solutions for when you want the selected labels to be a list.
Kind regards
Marika
selected_labels_A = mne.read_labels_from_annot(
subject, parc= "aparc_sub", hemi="both", regexp="caudalmiddlefrontal", subjects_dir=subjects_dir,
)[0]
location = "center" # Use the center of the region as a seed.
extent = 10.0 # Extent in mm of the region.
labels_A = mne.label.select_sources(
subject, selected_labels_A, location=location, extent=extent, grow_outside=False, subjects_dir=subjects_dir
)
Reading labels from parcellation…
read 6 labels from /Users/marist1/mne_data/MNE-sample-data/subjects/sample/label/lh.aparc_sub_subj.annot
read 5 labels from /Users/marist1/mne_data/MNE-sample-data/subjects/sample/label/rh.aparc_sub_subj.annot
You have a [0] at the end of your command mne.read_labels_from_annot. So this is just going to read the first item in the list of 11. If you take away that [0], you should get the full list of labels that have been printed out during the reading operation.
However it does not solve my problem. I found that if I remove [0], selected_label_A will be a list object instead of a label object. I have tried to figure out why this is so but so far been unsuccessful. I need the selected labels to be label objects in order to be accepted by mne.label.selected_sources(). Or is there some way to make mne.label.selected_sources() accept a list instead of label object?