Issue with mne.io.read_raw_eeglab in EEGLAB File Loading

I’m encountering an issue while trying to load an EEGLAB .set file using mne.io.read_raw_eeglab. Here’s the relevant code snippet:

import mne

file_path = "s01_061102n.set"
raw = mne.io.read_raw_eeglab(file_path, preload=True)

When I run this, I receive the following error:

Traceback (most recent call last):
  File "main.py", line 8, in <module>
    raw = mne.io.read_raw_eeglab(file_path, preload=True)
  File "...\site-packages\mne\io\eeglab\eeglab.py", line 328, in read_raw_eeglab
    return RawEEGLAB(
  File "<decorator-gen-267>", line 12, in __init__
  File "...\site-packages\mne\io\eeglab\eeglab.py", line 459, in __init__
    info, eeg_montage, _ = _get_info(eeg, eog=eog, montage_units=montage_units)
  File "...\site-packages\mne\io\eeglab\eeglab.py", line 230, in _get_info
    ch_names, ch_types, eeg_montage = _get_montage_information(
  File "...\site-packages\mne\io\eeglab\eeglab.py", line 165, in _get_montage_information
    if hasattr(eeg, "chaninfo") and isinstance(eeg.chaninfo["nodatchans"], dict):
KeyError: 'nodatchans'

Process finished with exit code 1

The error seems to be caused by the absence of the chaninfo["nodatchans"] key in the data structure. May I know if there is a way to bypass or handle the missing chaninfo["nodatchans"] key to successfully load the file?

The dataset I’m working with includes EEG signals obtained using the Scan SynAmps2 Express system (Compumedics Ltd., VIC, Australia). The signals were recorded using a wired EEG cap with 32 Ag/AgCl electrodes, including 30 EEG electrodes and 2 reference electrodes (opposite lateral mastoids). These details are provided in the dataset’s README file.

The specific file used in this example can be downloaded here: figshare.

It seems like you’re hitting an issue that I thought had been resolved (but apparently it still exists), see some discussion here. There’s another forum post with the same problem, which states that importing used to work with MNE 1.5.1 (and we never followed up on that unfortunately). @larsoner @drammock do you remember if we fixed that issue, or should we open a new one?

That line appears to exist:

We probably need to adjust the check. Worth opening a new issue I think!

1 Like

Thanks @larsoner! I agree it might be worth doing e.g. isinstance(eeg.chaninfo.get("nodatchans"), dict) or similar instead, but @balandongiv can you post the output of mne.sys_info() just in case?

Thanks for the response @cbrnr ,

May I know if I should open new issue in "Github`?

as requested, here is the output for mne.sys_info()



 + mne               1.9.0 (latest release)
 + numpy             2.2.1 (OpenBLAS 0.3.28 with 24 threads)
 + scipy             1.15.1
 + matplotlib        3.10.0 (backend=tkagg)

Numerical (optional)
 + sklearn           1.6.1
 + pandas            2.2.3
 - unavailable       numba, nibabel, nilearn, dipy, openmeeg, cupy, h5io, h5py

Visualization (optional)
 - unavailable       pyvista, pyvistaqt, vtk, qtpy, ipympl, pyqtgraph, mne-qt-browser, ipywidgets, trame_client, trame_server, trame_vtk, trame_vuetify

Ecosystem (optional)
 - unavailable       mne-bids, mne-nirs, mne-features, mne-connectivity, mne-icalabel, mne-bids-pipeline, neo, eeglabio, edfio, mffpy, pybv
None

Thanks @balandongiv. Yes, please open an issue, and if possible, share the problematic file with us there.

1 Like

Done log the bug.

Thanks for your time responding on this thread.

1 Like

This has been fixed in the MNE-Python development version and will be included in the next release.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.