Skip to content

ValueError: Could not find EEG array in the .set file. #8864

Closed

Description

@MSA8D8

Describe the bug

Dear MNE developers
Thank you for developing this wonderful tool.

I am faced with the error when I tried to use read_raw_eeglab() to load the .set file made by EEGLAB
What I did in EEGLAB is just loading the data by Quick 30 and save it in '.set(with '.fdt')' format only.
I think this is very weird, so I guess this is bug.

The script I made is below.

subject_name = 'DA'
script_path = os.path.abspath('./Python/EEG_analysis')
data_path = os.path.abspath('./output_play/' + subject_name) 
os.path.exists(data_path + '/'+ subject_name + '.set') # The print out result is 'True'
raw = mne.io.read_raw_eeglab(input_fname = data_path + '/'+ subject_name + '.set')

Actual results

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-17-1519c0d84577> in <module>
----> 1 raw = mne.io.read_epochs_eeglab(input_fname = data_path + '/'+ subject_name + '_play_merged.set')

~/.pyenv/versions/anaconda3-5.3.1/lib/python3.7/site-packages/mne/io/eeglab/eeglab.py in read_epochs_eeglab(input_fname, events, event_id, eog, verbose, uint16_codec)
    277     epochs = EpochsEEGLAB(input_fname=input_fname, events=events, eog=eog,
    278                           event_id=event_id, verbose=verbose,
--> 279                           uint16_codec=uint16_codec)
    280     return epochs
    281 

<decorator-gen-198> in __init__(self, input_fname, events, event_id, tmin, baseline, reject, flat, reject_tmin, reject_tmax, montage, eog, verbose, uint16_codec)

~/.pyenv/versions/anaconda3-5.3.1/lib/python3.7/site-packages/mne/io/eeglab/eeglab.py in __init__(self, input_fname, events, event_id, tmin, baseline, reject, flat, reject_tmin, reject_tmax, montage, eog, verbose, uint16_codec)
    449                  uint16_codec=None):  # noqa: D102
    450         eeg = _check_load_mat(input_fname, uint16_codec)
--> 451 
    452         if not ((events is None and event_id is None) or
    453                 (events is not None and event_id is not None)):

~/.pyenv/versions/anaconda3-5.3.1/lib/python3.7/site-packages/mne/io/eeglab/eeglab.py in _check_load_mat(fname, uint16_codec)
     63             'mne-python developers for more information.')
     64     if 'EEG' not in eeg:
---> 65         raise ValueError('Could not find EEG array in the .set file.')
     66     else:
     67         eeg = eeg['EEG']

ValueError: Could not find EEG array in the .set file.

Additional information

I am using the latest version of EEGLAB(2021), so there might be some minor change in the .set file. This might be why I am faced with this error.

Thank you in advance.

Activity

  1. cbrnr commented on Feb 12, 2021

    @cbrnr
    Contributor

    Could you share a small example file?

  2. MSA8D8 commented on Feb 12, 2021

    @MSA8D8
    Author

    @cbrnr Thank you for your quick reply.
    Here is the link for the sample data.

    I will give you the access permission of the link when you download them.

    I made this sample in the same way as before (just loading the data by Quick 30 and save it in '.set(with '.fdt')' format only).
    The EEGLAB version is 2021.0 and MNE is v0.22.0.

    Thank you for your help.

  3. cbrnr commented on Feb 12, 2021

    @cbrnr
    Contributor

    Usually, the .set file (which is just a .mat file) contains an EEG key with all relevant data. Your file does not have this EEG key, but all fields are directly in the root of the .mat file.

    Can you please double-check that you can load this file with EEGLAB? If they changed the format we need to adapt our reader, but I want to make sure that this is a valid EEG file.

  4. cbrnr commented on Feb 12, 2021

    @cbrnr
    Contributor

    @MSA8D8 can you please also post the output of eeghist so that we can see how you exported the data from EEGLAB?

  5. MSA8D8 commented on Feb 12, 2021

    @MSA8D8
    Author

    @cbrnr Thank you for your quick reply.

    Can you please double-check that you can load this file with EEGLAB?

    Here is the Matlab output of loading the sample data and checking the history of it.
    I am sure that this is a valid EEG file.

    Thank you for your help.

    >> eeglab
    Some menus items hidden. Use Preference menu to show them all.
    eeglab: options file is ~/eeg_options.m
    Retrieving plugin versions from server...
    Retreiving download statistics...
    EEGLAB: adding "Fieldtrip-lite" to the path; subfolders (if any) might be missing from the path
    EEGLAB: adding "Fileio" to the path; subfolders (if any) might be missing from the path
    EEGLAB: adding "ICLabel" v1.3 (see >> help eegplugin_iclabel)
    EEGLAB: adding "Viewprops" v1.5.4 (see >> help eegplugin_viewprops)
    EEGLAB: adding "bva-io" v1.7 (see >> help eegplugin_bva_io)
    EEGLAB: adding "clean_rawdata" v2.3 (see >> help eegplugin_clean_rawdata)
    EEGLAB: adding "dipfit" v3.7 (see >> help eegplugin_dipfit)
    EEGLAB: adding "firfilt" v2.4 (see >> help eegplugin_firfilt)
    You are using the latest version of EEGLAB.
    pop_loadset(): loading file /Users/masarusasaki/Documents/GitHub/Script/demo/Sample.set ...
    Reading float file '/Users/masarusasaki/Documents/GitHub/Script/demo/Sample.fdt'...
    Creating a new ALLEEG dataset 1
    Done.
    >> EEG
    
    EEG = 
    
      フィールドをもつ struct:
    
                 setname: 'Sample'
                filename: 'Sample.set'
                filepath: '/Users/masarusasaki/Documents/GitHub/Script/demo/'
                 subject: ''
                   group: ''
               condition: ''
                 session: []
                comments: 'Original file: sasakitest20200610arest.eeg'
                  nbchan: 29
                  trials: 1
                    pnts: 154624
                   srate: 500
                    xmin: 0
                    xmax: 309.2460
                   times: [1×154624 double]
                    data: [29×154624 single]
                  icaact: []
                 icawinv: []
               icasphere: []
              icaweights: []
             icachansind: []
                chanlocs: [1×29 struct]
              urchanlocs: []
                chaninfo: [1×1 struct]
                     ref: 'common'
                   event: []
                 urevent: []
        eventdescription: {}
                   epoch: []
        epochdescription: {}
                  reject: [1×1 struct]
                   stats: [1×1 struct]
                specdata: []
              specicaact: []
              splinefile: ''
           icasplinefile: ''
                  dipfit: []
                 history: '↵EEG.etc.eeglabvers = '2021.0'; % this tracks which version of EEGLAB is being used, you may ignore it↵EEG = pop_loadbv('/Users/masarusasaki/Documents/GitHub/Script/demo/sasakidata/raw/2020-6-10/', 'sasakitest20200610arest.vhdr', [1 154624], [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29]);↵EEG.setname='Sample';↵EEG = eeg_checkset( EEG );↵EEG = eeg_checkset( EEG );'
                   saved: 'yes'
                     etc: [1×1 struct]
                     run: []
                 datfile: 'Sample.fdt'
    
  6. cbrnr commented on Feb 12, 2021

    @cbrnr
    Contributor

    @agramfort @hoechenberger @mmagnuski @larsoner the fix is relatively simple (instead of raising an error here just continue because we already have all the fields that are otherwise contained within EEG), but before fixing this I'd like to hear what you think.

  7. hoechenberger commented on Feb 12, 2021

    @hoechenberger
    Member

    Seems this is a change that was introduced with EEGLAB 2021:
    https://eeglab.org/others/EEGLAB_revision_history.html#eeglab-version-20210

    I wonder if we should explicitly check for the existence of all required fields before proceeding?

  8. cbrnr commented on Feb 12, 2021

    @cbrnr
    Contributor

    Hmm, where do you see this change? It says "Now saving all EEGLAB datasets in a single file instead of two (fully backward compatible)", but it doesn't mention dropping the EEG struct. Also, the example data set still consists of two files.

    If we're sure this is a (new) valid format I'd not bother and check all fields, for one because I haven't found any official description of the format. Also, if a required field is missing it will fail at some point anyway.

  9. hoechenberger commented on Feb 12, 2021

    @hoechenberger
    Member

    Hmm, where do you see this change? It says "Now saving all EEGLAB datasets in a single file instead of two (fully backward compatible)", but it doesn't mention dropping the EEG struct.

    Yeah I just assumed that since they changed something, and since @MSA8D8's dataset was created using EEGLAB 2021, this could be related.

  10. cbrnr commented on Feb 15, 2021

    @cbrnr
    Contributor

    @arnodelorme sorry to bother you again, but could you confirm if EEGLAB now saves .set/.fdt data fields in the root instead of within an EEG struct? All of our test files contain the EEG struct, but @MSA8D8 has data (created with the latest EEGLAB version) where this is not the case.

  11. arnodelorme commented on Feb 15, 2021

    @arnodelorme

    This is correct.

  12. arnodelorme commented on Feb 15, 2021

    @arnodelorme

    This is because, when saving in the root, it is possible to ignore some fields (such as "data"). In that case, we can load the metadata without loading the data, so there is no need to save 2 files anymore (.set and .fdt). We can just save one file. Simpler for users. EEGLAB in 2004 used to save files in this way as well so all versions of EEGLAB are already compatible with this format.

  13. cbrnr commented on Feb 15, 2021

    @cbrnr
    Contributor

    Thanks @arnodelorme! I'll prepare a fix for our reader!

  14. jeangillain commented on Mar 3, 2021

    @jeangillain

    Hello,

    I was wondering if you fixed the problem, because when I try to load .set files on mne, I still have the same problem.
    Thanks a lot for everything you do,

    Jean Gillain

  15. hoechenberger commented on Mar 3, 2021

    @hoechenberger
    Member

    Hello @jeangillain,

    this has been fixed in our development and 0.22 maintenance branches; but there hasn't been an official release since this fix was added. You can install the latest version of the (unreleased) 0.22 maintenance branch (which will eventually become 0.22.1) by running:

    pip install -U https://github.com/mne-tools/mne-python/archive/maint/0.22.zip

    I hope this helps!

  16. MSA8D8 commented on Mar 30, 2021

    @MSA8D8
    Author

    Hello. @cbrnr @hoechenberger

    I still have this problem even after installing the latest version of mne as @hoechenberger suggested.

    The version of mne I can install is 0.22.0

    Thank you in advance.

  17. cbrnr commented on Mar 30, 2021

    @cbrnr
    Contributor

    Can you share a small example file again? I can't find the link you posted previously.

  18. reopened this on Mar 30, 2021
  19. MSA8D8 commented on Mar 30, 2021

    @MSA8D8
    Author

    @cbrnr
    I deleted the folder in the drive, so I re-uploaded it again.
    Here is the new link for the same data I shared with you before.
    https://drive.google.com/drive/folders/1rQAyEMYBxiBgNHQSbphIsb_spFmmXwY-?usp=sharing
    Thank you for your help.

  20. cbrnr commented on Mar 30, 2021

    @cbrnr
    Contributor

    It works for me with the current maint branch (linked above). Maybe you still have the 0.22 release? Unfortunately, the version shows 0.22 in both the latest release and the WIP maint branch, so I don't know how to determine if you have installed it correctly.

    In any case, I think it's time for an official release of 0.22.1 - @hoechenberger @larsoner what are our plans?

  21. agramfort commented on Mar 30, 2021

    @agramfort
    SponsorMember
  22. hoechenberger commented on Mar 30, 2021

    @hoechenberger
    Member

    Yes +10 from me for 0.22.1 sooner than later!!

  23. MSA8D8 commented on Mar 30, 2021

    @MSA8D8
    Author

    @cbrnr
    I uninstalled mne and install it again as @hoechenberger suggested.
    Then, the problem was finally solved !!!

    Thank you for everything !!
    I really appriciate all of your kindly help !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions