Description of the problem
There appears to be a limitation with the mne.viz.plot_topomap function. When using the names parameter to display channel labels, the mask parameter affects which labels are shown, even in cases where it shouldn't. This behavior is inconsistent with the expected functionality of the mask parameter.
Steps to reproduce
- Install MNE-Python and its dependencies.
- Run the following code:
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)
Link to data
No response
Expected results
- Case 1: All channel labels should be displayed.
- Case 2: All channel labels should be displayed (equivalent to Case 1).
- Case 3: All channel labels should be displayed, with "EEG 001" highlighted or emphasized due to the
True value in the mask.
Actual results
- Case 1: All channel labels are displayed correctly.
- Case 2: No channel labels are displayed, despite the mask being all False (which according to the documentation is equivalent to the default
None)
- Case 3: Only the "EEG 001" label is displayed, corresponding to the True value in the mask. The other labels are missing.
Additional information
Platform Linux-6.11.3-arch1-1-x86_64-with-glibc2.40
Python 3.12.7 (main, Oct 1 2024, 11:15:50) [GCC 14.2.1 20240910]
Executable /home/richard/Projekte/mne/.venv3/bin/python
CPU (12 cores)
Memory 15.0 GB
Core
├☑ mne 1.8.0 (latest release)
├☑ numpy 2.1.2 (OpenBLAS 0.3.27 with 12 threads)
├☑ scipy 1.14.1
└☑ matplotlib 3.9.2 (backend=qtagg)
Numerical (optional)
├☑ sklearn 1.5.2
├☑ nibabel 5.3.0
├☑ pandas 2.2.3
├☑ h5io 0.2.4
├☑ h5py 3.12.1
└☐ unavailable numba, nilearn, dipy, openmeeg, cupy
Visualization (optional)
├☑ pyvista 0.44.1 (OpenGL 4.6 (Core Profile) Mesa 24.2.5-arch1.1 via AMD Radeon Graphics (radeonsi, renoir, LLVM 18.1.8, DRM 3.59, 6.11.3-arch1-1))
├☑ pyvistaqt 0.11.1
├☑ vtk 9.3.1
├☑ qtpy 2.4.1 (PySide6=6.7.2)
├☑ pyqtgraph 0.13.7
├☑ mne-qt-browser 0.6.3
└☐ unavailable ipympl, ipywidgets, trame_client, trame_server, trame_vtk, trame_vuetify
Ecosystem (optional)
├☑ mne-bids 0.15.0
├☑ mne-bids-pipeline 1.9.0
├☑ eeglabio 0.0.2-4
├☑ edfio 0.4.4
├☑ pybv 0.7.5
└☐ unavailable mne-nirs, mne-features, mne-connectivity, mne-icalabel, neo, mffpy
Description of the problem
There appears to be a limitation with the mne.viz.plot_topomap function. When using the names parameter to display channel labels, the mask parameter affects which labels are shown, even in cases where it shouldn't. This behavior is inconsistent with the expected functionality of the mask parameter.
Steps to reproduce
Link to data
No response
Expected results
Truevalue in the mask.Actual results
None)Additional information