Repository navigation
Closed
Labels
Description
Describe the bug
When reading file with an HydroCel Geodesic Sensor Net montage, set_montage() returns an error if the electrodes are not correctly named. Unfortunately, the indicated error message is incorrect and does not help to fix the naming scheme.
Steps to reproduce
I'm using MAMEM EEG dataset 1 for SSVEP, a publicly available data. The example code below download 60 MB of data and try to apply the expected naming scheme. It generates an error.
import wfdb
from mne import create_info
from mne.channels import make_standard_montage
from mne.io import RawArray
from mne.datasets.utils import _get_path
import glob
import os
import numpy as np
subj = "dataset1/S001a"
wfdb.io.dl_database('mssvepdb', './', [subj],
annotators='win', overwrite=False)
record = wfdb.rdrecord(subj)
data = record.p_signal.T
n_samples, n_channels, n_trials = record.sig_len, 256, 23
ch_types = ['eeg']*256
sfreq = 250
ch_names = ["{}-{}".format(s, i) if s == "EEG" else s
for i, s in enumerate(record.sig_name)]
info = create_info(ch_names, sfreq, ch_types)
raw = RawArray(data, info, verbose=False)
montage = make_standard_montage('GSN-HydroCel-256')
try:
# Raise an error
raw.set_montage(montage)
except ValueError as err:
# Point out missing channels: ['EEG-0', 'F8', 'EEG-2', 'EEG-3', ...
# even if they are correctly defined
print("Channels are: ", ch_names)
raise(err)
# in fact, this montage requires channels named ['E1', 'E2', 'E3', ...
ch_names = ["E{}".format(i+1) for i in range(0, 256)]
raw.set_montage(montage)
Expected results
The montage should work with the following naming scheme: ch_names = ['EEG-0', 'F8', 'EEG-2', 'EEG-3', 'EEG-4', 'EEG-5', 'EEG-6', ...
Actual results
The montage works with a different naming scheme: ch_names = ['E1', 'E2', 'E3', 'E4', 'E5', 'E6', 'E7', 'E8', 'E9', ... that is not easy to find.
Additional information
Platform: macOS-10.16-x86_64-i386-64bit
Python: 3.6.10 |Anaconda, Inc.| (default, Mar 25 2020, 18:53:43) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
Executable: /Users/sylchev/anaconda3/bin/python
CPU: i386: 4 cores
Memory: 8.0 GB
mne: 0.22.0
numpy: 1.18.1 {blas=mkl_rt, lapack=mkl_rt}
scipy: 1.4.1
matplotlib: 3.1.3 {backend=Qt5Agg}
sklearn: 0.22.1
numba: 0.51.2
nibabel: Not found
nilearn: Not found
dipy: Not found
cupy: Not found
pandas: 1.1.3
mayavi: Not found
pyvista: Not found
vtk: Not found
Activity
agramfort commentedon Feb 3, 2021
sylvchev commentedon Feb 3, 2021
On this MAMEM dataset, the channels are named : `['EEG', 'F8', 'EEG', 'EEG', 'EEG', 'EEG', 'EEG', ...]
when trying to apply the GSN-256 montage, I have the following error :
So I figured I just have to rename the 'EEG' channels into 'EEG-X', with 0 <= X <=255. There are some channels that are named explicitly (F8, Fz, NAS, ...) and that are in the same index in my
ch_namesand in the error message list. Hence the list comprehension you mentioned: I append an integer only the 'EEG' channels, not for the named channels. When doing that, and complying to the naming scheme indicated in the error message, I still encounter the same error message.The
make_standard_montage('GSN-HydroCel-256').ch_namesindicates that the channels should be['E1', 'E2', 'E3', 'E4', 'E5', 'E6', 'E7', 'E8', 'E9', ...], without any explicit named channels (there is no F8, Fz or NAS in this list). When renaming the channels E1 to E256, I could apply the montage successfully.There is an inconsistency between the ch_names in the 'GSN-HydroCel-256' montage and the ch_names mentioned in the error message. Those mentioned in the error message are closer to the names I found in the MAMEM datasets.
agramfort commentedon Feb 3, 2021