mne-tools / mne-tools/mne-python

Missing event information when reading EEGLAB file and exporting raw to .set files

Open
#10,482 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

BUG
Dominant language
Python
Stars
3.5k
Forks
1.6k
Avg merge
1d 6h
Merged PRs (30d)
100

Description

Describe the bug

When reading an EEGLAB file with mne.io.read_raw_eeglab(), the events information seems oversimplified.

In EEGLAB, the set file event structure contains the following:

>> EEG_set.event

ans = 

  1×2670 struct array with fields:

    description
    begintime
    classid
    code
    duration
    label
    relativebegintime
    sourcedevice
    name
    tracktype
    latency
    type
    mffkeys
    mffkey_gidx
    mffkeysbackup
    mffkey_age_
    mffkey_exp_
    mffkey_hand
    mffkey_sex_
    mffkey_subj
    mffkey_cel
    mffkey_obs
    mffkey_spc
    mffkey_pos
    mffkey_argu
    mffkey_rsp
    mffkey_eval
    mffkey_rtim
    mffkey_trl
    mffkey_blk1

However, after reading the SET file with mne.io.read_raw_eeglab(), I can only see annotations with onset, duration, description and orig_time information:

>>> raw.annotations
<Annotations | 2670 segments: CELL (4), DIN2 (666), SESS (1), TRSP (666), ...>
>>> raw.annotations[0]
OrderedDict([('onset', 0.255321), ('duration', 2.0), ('description', 'SESS'), ('orig_time', None)])
>>> 
>>> raw.annotations[1]
OrderedDict([('onset', 0.46732), ('duration', 2.0), ('description', 'CELL'), ('orig_time', None)])

And when I export the raw structure into a new SET file, the event structure of the file is as follows:

>> EEG_new_set.event

ans = 

  1×2670 struct array with fields:

    type
    latency
    duration

Is there a way to keep the same events structure as the original SET file?

Steps to reproduce
raw = mne.io.read_raw_eeglab(input_fname=<FILE PATH>, preload=False, verbose=True)
mne.export.export_raw(
    fname=<NEW FILE PATH>,
    raw=raw,
    fmt='eeglab',
    overwrite=True
)
Additional information
>>> mne.sys_info()
Platform:         macOS-11.3-x86_64-i386-64bit
Python:           3.9.12 (main, Mar 26 2022, 15:52:10)  [Clang 13.0.0 (clang-1300.0.29.30)]
Executable:       /Users/cmadjar/Development/python_venv/python_intel_3.9.4/eeg2bids_py3.9.12/bin/python
CPU:              i386: 8 cores
Memory:           Unavailable (requires "psutil" package)
mne:              1.0.0
numpy:            1.21.5 {blas=openblas, lapack=openblas}
scipy:            1.8.0
matplotlib:       3.5.1 {backend=MacOSX}

sklearn:          1.0.2
numba:            0.55.1
nibabel:          Not found
nilearn:          Not found
dipy:             Not found
cupy:             Not found
pandas:           1.4.1
pyvista:          Not found
pyvistaqt:        Not found
ipyvtklink:       Not found
vtk:              Not found
PyQt5:            Not found
ipympl:           Not found
pooch:            v1.6.0

mne_bids:         0.10
mne_nirs:         Not found
mne_features:     0.2
mne_qt_browser:   Not found
mne_connectivity: Not found

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the mne.io.read_raw_eeglab() and mne.export.export_raw() entry points and reproduce the reported loss of EEGLAB event fields with the supplied commands. Compare the original event structure with raw.annotations and the exported .set event structure, then determine which event information should round-trip and verify that behavior with an equivalent regression check.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.