Can not read .set file getting 'nodatchans' keyerror

  • MNE version: 1.6.1
  • operating system: Windows 10

:page_facing_up: code:
raw = mne.io.read_raw_eeglab(file, preload = False)

:fountain_pen:Iโ€™m getting this error and donโ€™t know how to solve it. I have tried reinstalling the dependency as given in mne-tools site. but still it gives the below error.

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[13], line 1
----> 1 raw = mne.io.read_raw_eeglab(file, preload = False)

File ~\anaconda3\envs\mneeeglab\Lib\site-packages\mne\io\eeglab\eeglab.py:332, in read_raw_eeglab(input_fname, eog, preload, uint16_codec, montage_units, verbose)
    288 @fill_doc
    289 def read_raw_eeglab(
    290     input_fname,
   (...)
    295     verbose=None,
    296 ):
    297     r"""Read an EEGLAB .set file.
    298 
    299     Parameters
   (...)
    330     .. versionadded:: 0.11.0
    331     """
--> 332     return RawEEGLAB(
    333         input_fname=input_fname,
    334         preload=preload,
    335         eog=eog,
    336         uint16_codec=uint16_codec,
    337         montage_units=montage_units,
    338         verbose=verbose,
    339     )

File <decorator-gen-237>:12, in __init__(self, input_fname, eog, preload, uint16_codec, montage_units, verbose)

File ~\anaconda3\envs\mneeeglab\Lib\site-packages\mne\io\eeglab\eeglab.py:463, in RawEEGLAB.__init__(self, input_fname, eog, preload, uint16_codec, montage_units, verbose)
    456     raise TypeError(
    457         "The number of trials is %d. It must be 1 for raw"
    458         " files. Please use `mne.io.read_epochs_eeglab` if"
    459         " the .set file contains epochs." % eeg.trials
    460     )
    462 last_samps = [eeg.pnts - 1]
--> 463 info, eeg_montage, _ = _get_info(eeg, eog=eog, montage_units=montage_units)
    465 # read the data
    466 if isinstance(eeg.data, str):

File ~\anaconda3\envs\mneeeglab\Lib\site-packages\mne\io\eeglab\eeglab.py:234, in _get_info(eeg, eog, montage_units)
    232 if eeg_has_ch_names_info:
    233     has_pos = _eeg_has_montage_information(eeg)
--> 234     ch_names, ch_types, eeg_montage = _get_montage_information(
    235         eeg, has_pos, montage_units=montage_units
    236     )
    237     update_ch_names = False
    238 else:  # if eeg.chanlocs is empty, we still need default chan names

File ~\anaconda3\envs\mneeeglab\Lib\site-packages\mne\io\eeglab\eeglab.py:169, in _get_montage_information(eeg, get_pos, montage_units)
    158     warn(
    159         "Unknown types found, setting as type EEG:\n"
    160         + "\n".join(
   (...)
    165         )
    166     )
    168 lpa, rpa, nasion = None, None, None
--> 169 if hasattr(eeg, "chaninfo") and isinstance(eeg.chaninfo["nodatchans"], dict):
    170     nodatchans = eeg.chaninfo["nodatchans"]
    171     types = nodatchans.get("type", [])

KeyError: 'nodatchans'

Do you know if EEGLAB can read this file?

Yes. It worked for me in mne version 1.5.1. when I updated the version of mne it gave is error.

1 Like