Cannot use `evoked.animate_topomap()` on CSD data
michalrzak opened this issue · comments
Description of the problem
When computing CSD from an EEG dataset, the animate_topomap
method does not to run. This is most likely a bug, as plot_topomap
has no such restrictions.
The problem is relatively easy to fix by just adding "csd" here.
The bigger question I suppose is why the checks in plot_tomap
and animate_topomap
are different and whether they should be merged to the same. This would account to changing the line here to ch_type = _get_plot_ch_type(evoked, ch_type)
such as in the plot_topomap method.
Steps to reproduce
This FAILS:
import mne
from mne.datasets import sample
# load data
data_path = sample.data_path()
meg_path = data_path / "MEG" / "sample"
raw = mne.io.read_raw_fif(meg_path / "sample_audvis_raw.fif")
raw.drop_channels(raw.info["bads"])
# find events
events = mne.find_events(raw)
event_id = {
"auditory/left": 1,
"auditory/right": 2,
"visual/left": 3,
"visual/right": 4,
"smiley": 5,
"button": 32,
}
# only compute with eeg data
raw.pick(["eeg"])
# compute CSD
epochs = mne.Epochs(raw, events, event_id=event_id, tmin=-0.2, tmax=0.5, preload=True)
evoked = epochs["auditory"].average()
evoked_csd = mne.preprocessing.compute_current_source_density(evoked)
# animate topomap
evoked_csd.animate_topomap(times=[-0.1, 0, 0.1])
This DOES NOT fail
...
evoked_csd.plot_topomap(times=[-0.1, 0, 0.1])
Link to data
No response
Expected results
The animated topomap is shown.
Actual results
Channel type not supported. Supported channel types include 'mag', 'grad', 'eeg'. 'hbo', 'hbr', 'fnirs_cw_amplitude', and 'fnirs_od'.
Additional information
Platform Linux-6.8.6-100.fc38.x86_64-x86_64-with-glibc2.37
Python 3.12.2 (main, Feb 21 2024, 00:00:00) [GCC 13.2.1 20231011 (Red Hat 13.2.1-4)]
Executable /home/zakm00/git/auditory-stimulation-data-analysis/.venv/bin/python
CPU (16 cores)
Memory 15.3 GB
Core
├☒ mne 1.6.1 (outdated, release 1.7.0 is available!)
├☑ numpy 1.26.4 (unknown linalg bindings (threadpoolctl module not found: No module named 'threadpoolctl'))
├☑ scipy 1.13.0
├☑ matplotlib 3.8.3 (backend=module://matplotlib_inline.backend_inline)
├☑ pooch 1.8.1
└☑ jinja2 3.1.3
Numerical (optional)
└☐ unavailable sklearn, numba, nibabel, nilearn, dipy, openmeeg, cupy, pandas
Visualization (optional)
├☑ pyvista 0.43.5 (OpenGL 4.6 (Core Profile) Mesa 23.1.9 via Mesa Intel(R) Graphics (ADL GT2))
├☑ pyvistaqt 0.11.0
├☑ vtk 9.3.0
├☑ qtpy 2.4.1 (PyQt6=6.6.1)
├☑ ipympl 0.9.4
├☑ pyqtgraph 0.13.6
├☑ mne-qt-browser 0.6.2
├☑ ipywidgets 8.1.2
└☐ unavailable trame_client, trame_server, trame_vtk, trame_vuetify
Ecosystem (optional)
└☐ unavailable mne-bids, mne-nirs, mne-features, mne-connectivity, mne-icalabel, mne-bids-pipeline
To update to the latest supported release version to get bugfixes and improvements, visit https://mne.tools/stable/install/updating.html
Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴