You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
can’t import my set file using read_epochs_eeglab() #11641
I get the error: “TypeError: ‘int’ object is not iterable”.I am not sure where I could be making a mistake.
Steps to reproduce
thesearemycodes:
importmneimportnumpyasnpimportmatplotlib.pyplotaspltfromscipyimportstatsimportpickleimportpymatreaderimportmffpy#single sub evokedeeg1=mne.io.read_epochs_eeglab(‘1_LH.set’)
Link to data
No response
Expected results
how to solve the problem
Actual results
eeg1 = mne.io.read_epochs_eeglab('1_LH.set')
Extracting parameters from E:\code\EEG ML code\EEG\part2\2_extra_features\Example_data\1_LH.set...
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Temp/ipykernel_17044/1102068857.py", line 1, in
eeg1 = mne.io.read_epochs_eeglab('1_LH.set')
File "C:\ProgramData\Anaconda3\lib\site-packages\mne\io\eeglab\eeglab.py", line 337, in read_epochs_eeglab
epochs = EpochsEEGLAB(input_fname=input_fname, events=events, eog=eog,
File "", line 12, in init
File "C:\ProgramData\Anaconda3\lib\site-packages\mne\io\eeglab\eeglab.py", line 569, in init
info, eeg_montage, _ = _get_info(eeg, eog=eog, scale_units=scale_units)
File "C:\ProgramData\Anaconda3\lib\site-packages\mne\io\eeglab\eeglab.py", line 199, in _get_info
_get_montage_information(eeg, has_pos, scale_units=scale_units)
File "C:\ProgramData\Anaconda3\lib\site-packages\mne\io\eeglab\eeglab.py", line 150, in _get_montage_information
for item in list(zip(*eeg.chaninfo['nodatchans'].values())):
your file is inconsistent:
here is what eeg.chaninfo['nodatchans'].keys() contains:
dict_values(['VEO', array([], dtype='<U1'), array([], dtype=uint8),
array([], dtype=uint8), array([], dtype=uint8), array([], dtype=uint8),
array([], dtype=uint8), array([], dtype=uint8), array([], dtype=uint8),
array([], dtype=uint8), 32, 'VEO', 0])
the structure of this file has been updated manually and broke the format.
I don't think we can really fix this in the mne reader.
can you load the data in matlab and use the eeglab checkset function to see
if you can fix it?
your file is inconsistent: here is what eeg.chaninfo['nodatchans'].keys() contains: dict_values(['VEO', array([], dtype='<U1'), array([], dtype=uint8), array([], dtype=uint8), array([], dtype=uint8), array([], dtype=uint8), array([], dtype=uint8), array([], dtype=uint8), array([], dtype=uint8), array([], dtype=uint8), 32, 'VEO', 0]) the structure of this file has been updated manually and broke the format. I don't think we can really fix this in the mne reader. can you load the data in matlab and use the eeglab checkset function to see if you can fix it? …
Message ID: @.***>
what does eeg.chaninfo.nodatchans give you in matlab? can you check that the values correct and consistent across channels? …
Message ID: @.***>
Can you load this data on eeglab and check if it is correct? I checked it on eeglab and I think it is error-free. But when I load it on mne, this error cannot be solved. I tried different data and the error is almost the same (TypeError: ‘int’ objecr is not interable) or (‘float’ object is not iterable). I tried to solve it and looked at many similar questions and answers, but this problem keeps appearing. Others have encountered it but have not been able to solve it. If it cannot be solved, it will affect the later feature extraction and other work. Or do you have a better way to read it? I look forward to your reply, thank you
The workaround is to load the data in EEGLAB and export as some other format besides .set (such as EDF). I'm sorry, I know that's not a very satisfactory answer, but we (MNE-Python maintainers) are not all EEGLAB users (much less experts) and those that are have limited time.
I am one of the non-EEGLAB experts and I just spent ~45 minutes in the python debugger, reading EEGLAB source code, loading the file in Octave, etc. I can tell you that the reason for the error is that eeg.chaninfo['nodatchans']['datachan'] = 0 and our code expects all entries in eeg.chaninfo['nodatchans'] to be iterables (lists or arrays). But I have little idea what the value represents so I can't propose a reasonable fix to the code. maybe @cbrnr or @agramfort or @smathot has some ideas?
I also can't find any information about the meaning of the data in eeg.chaninfo['nodatchans']. But it has seemingly no relationship with the currently implemented code.
The code which uses eeg.chaninfo['nodatchans'] seems to fill three variable which have None-s for default value. If someone needs a workaround then I propose a simple iterator check after line 168. So we simply keep the default variable values if the check fails. Example (tested on my files): all_iterable = all(isinstance(v, (list, tuple, np.ndarray)) for v in eeg.chaninfo["nodatchans"].values())
I'm also just guessing here, but apparently eeg.chaninfo['nodatchans'] can contain information on fiducials. I am not quite sure what eeg.chaninfo['nodatchans']['datachan'] refers to, but 0 might indicate that this channel is not part of the data array (because MATLAB is 1-indexed, so 0 means it is not present). If this is true, then we can safely special-case 0 to mean "not present".
I would like to see an example of a file where this field has some value other than 0 though.
Activity
welcome commentedon Apr 21, 2023
Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴
drammock commentedon Apr 21, 2023
please provide a download link to the problematic file. Without that it is very hard to guess what might be going wrong.
Cross-ref to forum posts:
INRING commentedon Apr 23, 2023
This is my data, please check. Thanks!
https://github.com/INRING/data/blob/7e5f3a386e2b3d8dec4e807cb5bce04178eef06a/1_LH.zip
agramfort commentedon Apr 23, 2023
INRING commentedon Apr 23, 2023
I also run other data , the data is: https://github.com/INRING/data/blob/e2eaf48bcf223fd207794b16379f6d36502ad3e5/4.23.1.zip
and I also use the eeglab checkset function ,my matlab code is:
for i = [1:2];
setname = [num2str(i) '.set'];
EEG = pop_loadset('filename',setname,'filepath','E:\loss aversion\duyan\loss aversion\EEG\geti data\4.23');
EEG = eeg_checkset( EEG );
EEG = pop_saveset( EEG, 'filename',setname,'filepath','E:\loss aversion\duyan\loss aversion\EEG\geti data\4.23.1');
end
but I also have the same problem.
agramfort commentedon Apr 23, 2023
INRING commentedon Apr 23, 2023
Can you load this data on eeglab and check if it is correct? I checked it on eeglab and I think it is error-free. But when I load it on mne, this error cannot be solved. I tried different data and the error is almost the same (TypeError: ‘int’ objecr is not interable) or (‘float’ object is not iterable). I tried to solve it and looked at many similar questions and answers, but this problem keeps appearing. Others have encountered it but have not been able to solve it. If it cannot be solved, it will affect the later feature extraction and other work. Or do you have a better way to read it? I look forward to your reply, thank you
agramfort commentedon Apr 23, 2023
Yangdudua commentedon May 26, 2023
Have you solved this problem
gergo-szabo commentedon Nov 1, 2023
Please provide a quick fix or workaround. There are multiple public dataset which have this issue.
Example: https://openneuro.org/datasets/ds003655
drammock commentedon Nov 1, 2023
The workaround is to load the data in EEGLAB and export as some other format besides
.set(such as EDF). I'm sorry, I know that's not a very satisfactory answer, but we (MNE-Python maintainers) are not all EEGLAB users (much less experts) and those that are have limited time.I am one of the non-EEGLAB experts and I just spent ~45 minutes in the python debugger, reading EEGLAB source code, loading the file in Octave, etc. I can tell you that the reason for the error is that
eeg.chaninfo['nodatchans']['datachan'] = 0and our code expects all entries ineeg.chaninfo['nodatchans']to be iterables (lists or arrays). But I have little idea what the value represents so I can't propose a reasonable fix to the code. maybe @cbrnr or @agramfort or @smathot has some ideas?drammock commentedon Nov 1, 2023
here's a reproducer, for the next person:
gergo-szabo commentedon Nov 1, 2023
I also can't find any information about the meaning of the data in
eeg.chaninfo['nodatchans']. But it has seemingly no relationship with the currently implemented code.eeg.chaninfo['nodatchans']value in example recording:{'labels': '[A1A2]', 'ref': '[A1A2]', 'theta': array([], dtype=uint8), 'radius': array([], dtype=uint8), 'X': array([], dtype=uint8), 'Y': array([], dtype=uint8), 'Z': array([], dtype=uint8), 'sph_theta': array([], dtype=uint8), 'sph_phi': array([], dtype=uint8), 'sph_radius': array([], dtype=uint8), 'type': array([], dtype='<U1'), 'urchan': array([], dtype=uint8), 'datachan': 0}Processing code segment:
https://github.com/mne-tools/mne-python/blob/a4d4c10c6546bd53fa01f7b81ca87c6d2c0f155a/mne/io/eeglab/eeglab.py#L167C5-L178C57
The code which uses
eeg.chaninfo['nodatchans']seems to fill three variable which have None-s for default value. If someone needs a workaround then I propose a simple iterator check after line 168. So we simply keep the default variable values if the check fails. Example (tested on my files):all_iterable = all(isinstance(v, (list, tuple, np.ndarray)) for v in eeg.chaninfo["nodatchans"].values())cbrnr commentedon Nov 2, 2023
I'm also just guessing here, but apparently
eeg.chaninfo['nodatchans']can contain information on fiducials. I am not quite sure whateeg.chaninfo['nodatchans']['datachan']refers to, but0might indicate that this channel is not part of the data array (because MATLAB is1-indexed, so0means it is not present). If this is true, then we can safely special-case0to mean "not present".I would like to see an example of a file where this field has some value other than
0though.And maybe @arnodelorme can help us out here?
arnodelorme commentedon Nov 2, 2023
Yes,
eeg.chaninfo['nodatchans']['datachan']is always 0.cbrnr commentedon Nov 2, 2023
Great, thanks!