Skip to content

Potential bug in eeglabio exporting #13535

Closed

Description

@Andesha

Description of the problem

When exporting an epochs object via eeglabio, all events when loaded into MATLAB are marked as dummy events, or fails to pass checkset.

Steps to reproduce

# This requires my data file of course

epochs = mne.read_epochs('working_mne.fif')
epochs.export('problematic_eeglab.set', overwrite=True)

# Then load via pop_loadset in latest matlab/eeglab

Link to data

https://drive.google.com/file/d/1U3HptLod9yCUd7YebKnGSaWK8RqfUmkh/view?usp=sharing

Expected results

Replicating the event names in MATLAB.

Image

Actual results

See screenshot.

Image

Additional information

Platform Linux-6.14.0-36-generic-x86_64-with-glibc2.39
Python 3.12.3 (main, Nov 6 2025, 13:44:16) [GCC 13.3.0]
Executable /home/tyler/.cache/uv/builds-v0/.tmpV89SPU/bin/python
CPU Intel(R) Core(TM) Ultra 7 155U (14 cores)
Memory 30.9 GiB

Core
├☑ mne 1.11.0 (latest release)
├☑ numpy 1.26.4 (OpenBLAS 0.3.23.dev with 14 threads)
├☑ scipy 1.16.3
└☑ matplotlib 3.10.7 (backend=module://matplotlib_inline.backend_inline)

Numerical (optional)
├☑ sklearn 1.7.2
├☑ pandas 2.3.3
└☐ unavailable numba, nibabel, nilearn, dipy, openmeeg, cupy, h5io, h5py

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

Ecosystem (optional)
├☑ mne-bids 0.17.0
├☑ mne-icalabel 0.8.1
├☑ eeglabio 0.1.2
├☑ edfio 0.4.11
├☑ defusedxml 0.7.1

Activity

  1. welcome commented on Dec 8, 2025

    @welcome

    Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴

  2. scott-huberty commented on Dec 8, 2025

    @scott-huberty
    Contributor

    Hey @Andesha !

    Do you have any hypotheses about where things are going wrong? I wonder if it has something to do with these warnings which are generated when I export the file you shared, particularly the last warning message...

    import mne
    
    ep_bug = mne.read_epochs("/path/to/mne-bug/working_mne.fif")
    ep_bug.export("foo.set")
    /Users/scotterik/devel/repos/eeglabio/eeglabio/epochs.py:125 EEGLABIO: WARNING: Invalid event latencies, ignored for export.
    /Users/scotterik/devel/repos/eeglabio/eeglabio/epochs.py:162 EEGLABIO: WARNING: Events doesn't meet the requirement of at least one event per epoch, adding dummy events
    
  3. Andesha commented on Dec 8, 2025

    @Andesha
    Author

    I did poke around in that part of the code but it didn't illuminate anything for me.

    These files are the result of merged files at one point but I don't think that should change anything,

  4. Andesha commented on Dec 18, 2025

    @Andesha
    Author

    any news or any support I can give on this?

  5. larsoner commented on Dec 19, 2025

    @larsoner
    Member

    I have not had a chance to check -- @scott-huberty do you have time to look into the potential fix here? If not I can get to it but maybe not until after holidays

  6. added this to the 1.12 milestone on Dec 19, 2025
  7. scott-huberty commented on Dec 22, 2025

    @scott-huberty
    Contributor

    @Andesha given you have the time, if you are able to 1) identify the cause of the bug (likely a line in the eeglabio codebase), just let us know so that we know what to fix, or 2) you can open a PR with a fix and we can iterate from there!

    If not, I can also take a closer look but I also am unlikely to get to it until after the holidays.

  8. drammock commented on Jan 7, 2026

    @drammock
    Member

    @Andesha is there something unusual about your file, or does it still fail with this? (sorry, no MATLAB so I can't test myself)

    import mne
    
    fname = mne.datasets.kiloword.data_path() / "kword_metadata-epo.fif"
    epo = mne.read_epochs(fname)
    epo.export('problematic_eeglab.set')
  9. Andesha commented on Jan 7, 2026

    @Andesha
    Author

    that sample works just fine @drammock . No warnings and it looks okay in MATLAB. I wonder if this is something to do with rejected/bad events and then the event counts being off?

  10. PragnyaKhandelwal commented on Mar 25, 2026

    @PragnyaKhandelwal
    Contributor

    I’ve been digging into this locally with the dataset provided to see if I could reproduce the issue.
    https://drive.google.com/file/d/1U3HptLod9yCUd7YebKnGSaWK8RqfUmkh/view?usp=sharing
    I found two things that might be causing the trouble:

    First, I hit a MemoryError when trying to export the full file. The process tried to allocate over 2GB of RAM at once and crashed. I could only get it to finish by exporting a smaller subset of epochs, so it looks like we might need some better data chunking for files this large.

    Second, I noticed a mismatch in the indexing. In this dataset, we have 3388 epochs, but the maximum index in epochs.selection is 3511—likely because some trials were dropped earlier. This seems to be what's tripping up eeglabio. Since the mapping finds indices that 'don't exist' in the current object, it discards the latencies and falls back to those dummy events.

  11. removed this from the 1.12 milestone on Apr 3, 2026
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