Labelling source space points when visualizing with mne.viz.plot_bem

Hello all,

I have set up a volume source space (using mne.setup_volume_source_space) with discrete source locations (only 10 points) that are given through a dictionary (set with pos[β€˜rr’] and pos[β€˜nn’]). I am then visualizing said sources in the brain through mne.viz.plot_bem; however, I would like to be able to see which source space point corresponds to which value in the pos dict. Is there a way to customize how source points are labelled in plot_bem? Alternatively, would anyone have a suggestion for a better function that might take care of this?

Many thanks!

Unfortunately, there isn’t.

Well, you could use the plotting function of the source object itself and then manually add annotations to that:

import mne
import pyvista

# Grab a volumetric source space
subjects_dir = mne.datasets.sample.data_path() / 'subjects'
src = mne.read_source_spaces(subjects_dir / 'sample' / 'bem' / 'volume-7mm-src.fif')

# Plot it, make sure to keep the figure handle
fig = src.plot(subjects_dir=subjects_dir)

# Generally, a source space defines more points than that are actually used as
# sources. Grab the source points that are actually used.
rr = src[0]['rr'][src[0]['inuse'].astype(bool)]

# Manually add three source points to the plot in different colors.
fig.plotter.add_mesh(pyvista.PolyData(rr[[1000]]), color='red', point_size=20)
fig.plotter.add_mesh(pyvista.PolyData(rr[[2000]]), color='green', point_size=20)
fig.plotter.add_mesh(pyvista.PolyData(rr[[3000]]), color='blue', point_size=20)

Screenshot 2023-01-25 115248

2 Likes