can't import my set file using read_epochs_eeglab()

import os
import mne
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
os.chdir("D:/222experiment_material/EEG_DATA")
print(os.getcwd())
file_path = './practice/hulike/data/MC_H01.set'
raw = mne.read_epochs_eeglab(file_path)
print(raw.info)
TypeError                                 Traceback (most recent call last)
Cell In[4], line 2
      1 
----> 2 raw = mne.read_epochs_eeglab(file_path)

File D:\Python\Anaconda3\lib\site-packages\mne\io\eeglab\eeglab.py:337, in read_epochs_eeglab(input_fname, events, event_id, eog, uint16_codec, montage_units, verbose)
    288 @fill_doc
    289 def read_epochs_eeglab(input_fname, events=None, event_id=None,
    290                        eog=(), *, uint16_codec=None, montage_units='mm',
    291                        verbose=None):
    292     r"""Reader function for EEGLAB epochs files.
    293 
    294     Parameters
   (...)
    335     .. versionadded:: 0.11.0
    336     """
--> 337     epochs = EpochsEEGLAB(input_fname=input_fname, events=events, eog=eog,
    338                           event_id=event_id, uint16_codec=uint16_codec,
    339                           montage_units=montage_units, verbose=verbose)
    340     return epochs

File <decorator-gen-296>:12, in __init__(self, input_fname, events, event_id, tmin, baseline, reject, flat, reject_tmin, reject_tmax, eog, uint16_codec, montage_units, verbose)

File D:\Python\Anaconda3\lib\site-packages\mne\io\eeglab\eeglab.py:569, in EpochsEEGLAB.__init__(self, input_fname, events, event_id, tmin, baseline, reject, flat, reject_tmin, reject_tmax, eog, uint16_codec, montage_units, verbose)
    567 logger.info('Extracting parameters from %s...' % input_fname)
    568 scale_units = _handle_montage_units(montage_units)
--> 569 info, eeg_montage, _ = _get_info(eeg, eog=eog, scale_units=scale_units)
    571 for key, val in event_id.items():
    572     if val not in events[:, 2]:

File D:\Python\Anaconda3\lib\site-packages\mne\io\eeglab\eeglab.py:199, in _get_info(eeg, eog, scale_units)
    196 if eeg_has_ch_names_info:
    197     has_pos = _eeg_has_montage_information(eeg)
    198     ch_names, ch_types, eeg_montage = \
--> 199         _get_montage_information(eeg, has_pos, scale_units=scale_units)
    200     update_ch_names = False
    201 else:  # if eeg.chanlocs is empty, we still need default chan names

File D:\Python\Anaconda3\lib\site-packages\mne\io\eeglab\eeglab.py:150, in _get_montage_information(eeg, get_pos, scale_units)
    148 lpa, rpa, nasion = None, None, None
    149 if hasattr(eeg, "chaninfo") and len(eeg.chaninfo.get('nodatchans', [])):
--> 150     for item in list(zip(*eeg.chaninfo['nodatchans'].values())):
    151         d = dict(zip(eeg.chaninfo['nodatchans'].keys(), item))
    152         if d.get("type", None) != 'FID':


TypeError: 'int' object is not iterable

My document can be read in MATLAB without any issues, it is likely that there are no problems with it.

1 Like

I also can’t run my code in this error, do you have solved this error?If you solve it, I want to learn with you !
best,

1 Like

I do have this problem too!!! and the message is also TypeError: ‘int’ object is not iterable when I try to use the mne.io.read_epochs_eeglab() to load my .set file generated by eeglab.
and my OS is MacOS 12.5.1, the python version is 3.9.16, mne version is 1.3.1.
At first, I thought it might be my M1 pro problem, but when I use the window10 as OS, it also produces this wrong message.
If You have solved this problem, I want to learn it too!
Best regards,

@richard hi! This seems like a big issue for multiple users. Any opinions?

2 Likes

I’m not familiar with EEGLAB file reading.

I suppose an example file would be required for debugging…

3 Likes

yes, I also have the problem too!!

1 Like

Hi, I have the .set file with problems, If you need it, I can send it to you. by email or some other way.

I won’t have time to look into this, but maybe someone else will :+1:

@Eliteria I think the issue was already reported a couple of days before.
You can follow the following post for more updates:

best,
Dip

4 Likes

Hello everyone,

I also get an error when I try to read a .set EEGLAB file using the mne.io.read_epochs_eeglab() reader. However, the error message I get differs from the one @HSUkin, @lucas, and @Eliteria face.

My script:

import mne
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

filepath = "C:\Dev\DATA\Data_Marseille_RECOGNISENS_EPOCHED\ECV10\ECV10_WM_0.5_prepline_dessins_BR_clean_FIX.set"
EOG_channels = ("EXG1", "EXG2", "EXG4", "EXG5")
excluded_channels = ("EXG3", "EXG8", "EXG6", "EXG7")
test = mne.io.read_epochs_eeglab(filepath, eog=EOG_channels, verbose=True)

The error message I get:

In [3]: runcell(1, 'C:/Dev/Python/Renorm/PyRenorm_Biosemi64_Marseille_WholeBrain_EPOCHEDdata.py')
Traceback (most recent call last):

  File C:\ProgramData\Anaconda3\envs\mne\lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
    exec(code, globals, locals)

  File c:\dev\python\renorm\pyrenorm_biosemi64_marseille_wholebrain_epocheddata.py:79
    test = mne.io.read_epochs_eeglab(filepath, eog=EOG_channels, verbose=True)

  File C:\ProgramData\Anaconda3\envs\mne\lib\site-packages\mne\io\eeglab\eeglab.py:377 in read_epochs_eeglab
    epochs = EpochsEEGLAB(

  File <decorator-gen-306>:10 in __init__

  File C:\ProgramData\Anaconda3\envs\mne\lib\site-packages\mne\io\eeglab\eeglab.py:644 in __init__
    events[idx, 0] = event_latencies[idx]

IndexError: list index out of range

A sample of the “eeglab.py” file around line 644:

            # now fill up the event array
            events = np.zeros((eeg.trials, 3), dtype=int)
            for idx in range(0, eeg.trials):
                if idx == 0:
                    prev_stim = 0
                elif idx > 0 and event_latencies[idx] - event_latencies[idx - 1] == 1:
                    prev_stim = event_id[event_name[idx - 1]]
                events[idx, 0] = event_latencies[idx]
                events[idx, 1] = prev_stim
                events[idx, 2] = event_id[event_name[idx]]
        elif isinstance(events, (str, Path, PathLike)):
            events = read_events(events)

Unfortunately, I cannot share with everyone the data I am working with. if @richard or anyone else has some time to look into this, I can temporarily share my .set file by email with them.
Thank you for your time.

  • MNE version: 1.4.0
  • OS: Windows 11

Best regards,
Valentin

Hello,
I had a similar issue because of the way EEGLAB deals with events. Listing some troubleshooting options

  1. Open the set file in EEGLAB and see if EEG.event is empty
  2. Such situations can happen when you epoch in EEGLAB avoiding the marker time point, say

EEG = pop_epoch( EEG, {‘S101’}, …
[5 55], …
‘newname’, ‘eeg_data_epochs’, ‘epochinfo’, ‘yes’);

I circumvented this issue by creating dummy EEG.event and EEG.epoch. I traced out the error by running eeg_checkset(EEG) and realised the EEG.event was missing an epoch field as well.
You may also look up this issue

Thanks!
But I would like to confirm if this is considered as EEG.event being empty?

It seems you do have event structure. Could you please check if there is a label called epoch inside the EEG.event structure?
You can also do a eeg_checkset(EEG) in MATLAB and see if you catch any errors

I was getting an error because the EEG.event was not having epoch field. I wrote a small script to update the EEG.event and EEG.epoch and then saved the .set epoched files and those opened without any errors on MNE.

You can also epoch with timings 0 200 and see if same issue is happening. It should not since you have the marker

I just used eeg_checkset(EEG) and it seems there are no errors.

And, I guess there should be no problem with EEG.event

1 Like

It seems like there are multiple different problems regarding reading epoched EEGLAB data. To make it easier for developers track down and fix them, please open separate issues for each problem in our GitHub repository. Note that without specific files that demonstrate the problems, it will be very difficult to solve these issues, so please try and share some small dataset that cannot be imported with MNE.

1 Like

Not a small dataset, but it’s easy to download one example for demonstration (eg.: sub-008): OpenNeuro

as @cbrnr said above, please open separate issues for each problem in our GitHub repository. If there is a problem with ds003655 subject 008, please open a GitHub issue with a link to that file and a description of what goes wrong when you try to open it, and complete sample code that will recreate the error for anyone trying to replicate it.

1 Like

There is an existing issue (unfortunetly no progress since April)

1 Like