mne-python
mne-python copied to clipboard
Bug with plot_topomap and coordinate transformations following #11081
Description of the problem
Following #11081, topomaps created with digitization points provided as Info
don't look the same.
It has to do with dev_head_t
(I think). Now that info
is not None, sphere
value is replaced from None
to 'auto'
here https://github.com/mne-tools/mne-python/blob/4310c92b85fa7dcc77ffe322501037e5ad82372d/mne/utils/check.py#L848-L857
which means that we now enter this statement https://github.com/mne-tools/mne-python/blob/4310c92b85fa7dcc77ffe322501037e5ad82372d/mne/utils/check.py#L859-L869
Steps to reproduce
from mne.datasets import testing
from mne.io import read_raw_fif
from mne.viz import plot_topomap
directory = testing.data_path() / "MEG" / "sample"
fname = directory / "sample_audvis_trunc_raw.fif"
raw = read_raw_fif(fname, preload=False)
raw = raw.crop(0, 10).pick("eeg").load_data().apply_proj()
plot_topomap(raw.get_data()[:, 101], raw.info)
Expected results
On mne-stable 1.1.1
, a nice looking topographic map:
Actual results
On mne-main 1.2
, a weird looking topographic map:
Can you share the info?
It's the MNE sample dataset "MEG" from which I picked only the EEG sensors. In the example above, I used the testing
dataset instead of sample
, but it's the same. e.g.
from mne.datasets import sample
directory = sample.data_path() / "MEG" / "sample"
fname = directory / "sample_audvis_filt-0-40_raw.fif"
With the filtered file above, the info representation is:
<Info | 15 non-empty values
bads: 1 items (EEG 053)
ch_names: EEG 001, EEG 002, EEG 003, EEG 004, EEG 005, EEG 006, EEG 007, ...
chs: 60 EEG
custom_ref_applied: False
dev_head_t: MEG device -> head transform
dig: 146 items (3 Cardinal, 4 HPI, 61 EEG, 78 Extra)
file_id: 4 items (dict)
highpass: 0.1 Hz
hpi_meas: 1 item (list)
hpi_results: 1 item (list)
lowpass: 40.0 Hz
meas_date: 2002-12-03 19:01:10 UTC
meas_id: 4 items (dict)
nchan: 60
projs: Average EEG reference: on
sfreq: 150.2 Hz
>
@mscheltienne I am lost. I see a PR in pycrostates.
what is the bug to fix?
Sorry, if that was not clear. Let's start over ;)
A while ago, I fixed a bug in mne-python
, sphere='eeglab'
was not working. PR: https://github.com/mne-tools/mne-python/pull/11081 But that PR had a side-effect that we did not notice at the time, namely, it messed up how the plot looks (c.f. the 2 screenshots and the code snippet with the MNE sample dataset in the first post).
I noticed this visualization issue because the CI testing pycrostates
against mne-main
started failing. As far as this CI is concerned, there are 2 issues: one in pycrostates
(an oversight that I'll fix) and one in mne-python
, the visualization issue I described here. Thus the x-ref since pycrostates
fix depends on this one as well.
I did not dig up enough yet to figure out why the topoplot is messed up now that https://github.com/mne-tools/mne-python/pull/11081 has been merged.
ok I'll let you look into it.
Message ID: @.***>