Hello,
I’m new to MNE and EEG-analysis in general, and would appreciate your help
I’m working with the EEGEyeNet dataset, a publicly available dataset with co-registered EEG and Eye Tracking data. The dataset was preprocessed using matlab’s EEG-Eye toolbox, and I’m trying to convert its data structure to MNE objects.
The conversion itself works well, but when I’m attempting to visualize the data, for example by generating a PSD and calling spectrum.plot()
, the visualization hangs indefinitely. I tried using different matplotlib backends (TkAgg
and QT5Agg
), but the issue persists. I also applied the same steps to MNE’s sample
dataset and here the visualization didn’t hang.
I’m wondering if there’s something inherently wrong with the EEGEyeNet dataset that prevents it from working with MNE (doubtful) or if I’m doing something wrong in my loading/preprocessing (probably).
The following script should run after you download a file subset of the EEGEyeNet dataset, which is available here:
import os
import numpy as np
import pandas as pd
import mne
from pymatreader import read_mat
import matplotlib
matplotlib.use('QT5Agg') # or 'TkAgg'
_BASE_PATH = r'path-to-data\dots_data\sunchronised_min'
_FILE_PATH = r'EP10\EP10_DOTS3_EEG.mat'
FULL_PATH = os.path.join(_BASE_PATH, _FILE_PATH)
def channel_type(chan: str):
if chan.startswith('E') and chan[1:].isdigit():
return 'eeg'
if chan == 'Cz':
return 'eeg'
if 'GAZE' in chan:
return 'eyegaze'
if 'AREA' in chan:
return 'pupil'
return 'misc'
mat = read_mat(FULL_PATH)['sEEG']
sfreq = mat['srate']
data = mat['data']
labels = mat['chanlocs']['labels']
types = list(map(lambda chan: channel_type(chan), labels))
data[np.array(types) == 'eeg'] *= 1e-6 # convert uV to V on EEG channels
info = mne.create_info(ch_names=labels, ch_types=types, sfreq=sfreq, verbose=False)
raw = mne.io.RawArray(data, info, verbose=False).crop(tmax=60)
raw.filter(1, 40.0, verbose=False)
raw.set_eeg_reference("average", verbose=False)
spectrum = raw.copy().compute_psd(picks='eeg', n_fft=512, verbose=False)
print((spectrum.data.min(), spectrum.data.max()))
spectrum.plot(average=False, picks=['eeg'])
Here, the last line opens a new window, but immediately it is classified as “not responding” and the code just hangs. Conversely, the following script runs smoothly:
from mne.datasets import sample
from mne.io import read_raw_fif
import matplotlib
matplotlib.use('TkAgg') # or 'Qt5Agg'
EEG_REF = "EEG 010"
fname = sample.data_path() / "MEG" / "sample" / "sample_audvis_raw.fif"
raw = read_raw_fif(fname, preload=False)
raw.crop(0, 60).pick("eeg")
raw.load_data()
raw.filter(1., 40.)
raw.set_eeg_reference(ref_channels=[EEG_REF])
spectrum = raw.copy().compute_psd(n_fft=512, verbose=False, exclude=[EEG_REF])
print((spectrum.data.min(), spectrum.data.max()))
spectrum.plot(average=False, picks=['eeg', 'eog'])
any thoughts on the difference between the two datasets?