chaohanch
(Chao Han)
April 24, 2025, 4:45pm
1
MNE version: 1.9.0
operating system: macOS 15
Hello,
I was trying to add two reference channels. But it looks like the channel locations are not correctly loaded when I add the two reference channels together by mne.add_reference_channels(raw, ref_channels = ['TP9', 'TP10'])
(both channels show up at the location of TP10
.):
But if I add the two channels sequentially by
mne.add_reference_channels(raw, ref_channels = ['TP9'])
mne.add_reference_channels(raw, ref_channels = ['TP10'])
the channel locations are correct:
I wonder if if itβs a bug or did I miss something?
Thank you!
Here is the code snipeets to reproduce the figures:
# load data
ssvep_folder = mne.datasets.ssvep.data_path()
ssvep_data_raw_path = (
ssvep_folder / "sub-02" / "ses-01" / "eeg" / "sub-02_ses-01_task-ssvep_eeg.vhdr"
)
ssvep_raw = mne.io.read_raw_brainvision(ssvep_data_raw_path, verbose=False, preload=True)
# Apply a template montage directly, without preloading
ssvep_raw.set_montage("easycap-M1")
# remove TP9 and TP10
ssvep_raw.drop_channels(['TP9', 'TP10'])
# add 2 reference channels together
raw1 = mne.add_reference_channels(ssvep_raw, ref_channels = ['TP9', 'TP10'])
raw1.set_montage("easycap-M1")
fig = raw1.plot_sensors(show_names=True)
# add 2 reference channels separately
raw2 = mne.add_reference_channels(ssvep_raw, ref_channels = ['TP9'])
raw2 = mne.add_reference_channels(raw2, ref_channels = ['TP10'])
raw2.set_montage("easycap-M1")
fig = raw2.plot_sensors(show_names=True)
richard
(Richard HΓΆchenberger)
April 25, 2025, 12:44pm
2
Hello @chaohanch and welcome to the forum! This seems like a bug to me β¦ Iβll try to reproduce and report back.
Richard
1 Like
richard
(Richard HΓΆchenberger)
April 25, 2025, 1:04pm
3
Iβve reported the issue on the GitHub issue tracker:
opened 01:03PM - 25 Apr 25 UTC
BUG
### Description of the problem
Reported on the forum:
https://mne.discourse.gro⦠up/t/channel-location-not-correctly-recognized-when-adding-two-reference-channels-using-add-reference-channels/11127
When calling `add_reference_channels()` with two channel names and subsequently setting a montage, both reference channels will be placed in the exact same location (which is only correct for one of the channels):
Doing two separate calls to `add_reference_channels()` instead (i.e., one per channel) yields the expected behavior.
### Steps to reproduce
```Python
# %%
import mne
ssvep_folder = mne.datasets.ssvep.data_path()
ssvep_data_raw_path = (
ssvep_folder / "sub-02" / "ses-01" / "eeg" / "sub-02_ses-01_task-ssvep_eeg.vhdr"
)
ssvep_raw = mne.io.read_raw_brainvision(
ssvep_data_raw_path, preload=True, verbose=False
)
# Add ref channels in single call
ssvep_raw.drop_channels(["TP9", "TP10"])
ssvep_raw.add_reference_channels(["TP9", "TP10"])
ssvep_raw.set_montage("easycap-M1")
fig = ssvep_raw.plot_sensors(show_names=True)
# Add ref channels in separate calls
ssvep_raw.drop_channels(["TP9", "TP10"])
ssvep_raw.add_reference_channels("TP9")
ssvep_raw.add_reference_channels("TP10")
ssvep_raw.set_montage("easycap-M1")
fig = ssvep_raw.plot_sensors(show_names=True)
```
### Link to data
_No response_
### Expected results

### Actual results

### Additional information
Platform macOS-15.4.1-arm64-arm-64bit
Python 3.12.8 (main, Dec 6 2024, 19:42:06) [Clang 18.1.8 ]
Executable /Users/richardhochenberger/Development/mne-python/.venv/bin/python
CPU Apple M2 Pro (10 cores)
Memory 32.0 GiB
Core
ββ mne 1.10.0.dev96+gc18908cb6 (devel, latest release is 1.9.0)
ββ numpy 2.2.5 (unknown linalg bindings)
ββ scipy 1.15.2
ββ matplotlib 3.10.1 (backend=module://matplotlib_inline.backend_inline)
Numerical (optional)
ββ sklearn 1.6.1
ββ numba 0.61.2
ββ nibabel 5.3.2
ββ nilearn 0.11.1
ββ dipy 1.11.0
ββ openmeeg 2.5.15
ββ pandas 2.2.3
ββ h5io 0.2.5
ββ h5py 3.13.0
ββ unavailable cupy
Visualization (optional)
ββ pyvista 0.45.0 (OpenGL 4.1 Metal - 89.4 via Apple M2 Pro)
ββ pyvistaqt 0.11.2
ββ vtk 9.4.2
ββ qtpy 2.4.3 (PyQt6=6.9.0)
ββ ipympl 0.9.7
ββ pyqtgraph 0.13.7
ββ mne-qt-browser 0.7.1
ββ ipywidgets 8.1.6
ββ trame_client 3.8.0
ββ trame_server 3.4.0
ββ trame_vtk 2.8.15
ββ trame_vuetify 3.0.1
Ecosystem (optional)
ββ neo 0.14.1
ββ eeglabio 0.0.3
ββ edfio 0.4.8
ββ mffpy 0.10.0
ββ pybv 0.7.6
ββ unavailable mne-bids, mne-nirs, mne-features, mne-connectivity, mne-icalabel, mne-bids-pipeline
2 Likes
chaohanch
(Chao Han)
April 25, 2025, 3:10pm
4
Thank you for reporting this!
1 Like
system
(system)
Closed
May 2, 2025, 3:10pm
5
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.