Hi everyone,
I believe I’ve encountered a limitation with the mne.viz.plot_topomap
function. When using the names
parameter to display channel labels, I’ve noticed that the mask
parameter affects which labels are shown, even when it shouldn’t.
Here’s a minimal example to demonstrate the issue:
import mne
import numpy as np
# Create a sample raw object
sample_data_folder = mne.datasets.sample.data_path()
sample_data_raw_file = (sample_data_folder / 'MEG' / 'sample' /
'sample_audvis_raw.fif')
raw = mne.io.read_raw_fif(sample_data_raw_file, preload=True)
# Select only EEG channels
raw.pick_types(meg=False, eeg=True)
# Create dummy data for visualization
data = np.random.rand(len(raw.ch_names))
# Case 1: No mask (all labels shown)
mne.viz.plot_topomap(data, raw.info, names=raw.ch_names)
# Case 2: Mask with all False (should be equivalent to mask=None)
mask = np.zeros(len(raw.ch_names), dtype=bool)
mne.viz.plot_topomap(data, raw.info, names=raw.ch_names, mask=mask)
# Case 3: Mask with some True values
mask[0] = True # Set "EEG 001" to True
mne.viz.plot_topomap(data, raw.info, names=raw.ch_names, mask=mask)