Skip to content

pop_loadset of MATLAB v7.3 .set files returns 1-character labels and event types, and crashes on empty events #497

Closed

Description

@suraj-ranganath

EEGLAB writes v7.3 (HDF5) .set files when asked, and falls back to v7.3 automatically for files too large for v6 (pop_saveset.m:262-268 at the 8ac485f6 pin). EEGPrep's v7.3 reader decodes them incorrectly.

Evidence (develop ef8ac13, MATLAB R2025b)

  • The committed sample_data/eeglab_data_hdf5.set loads with channel labels [uint16(70), uint16(69), …] instead of ['FPz', 'EOG1', …], and event type 115 instead of 'square'.
  • Every MATLAB-written v7.3 set with no events fails to load with TypeError: argument of type 'numpy.uint64' is not iterable. This happens for 1 or 2 channels, with or without channel locations, and for sample_data with its events cleared.

Root causes in src/eegprep/functions/popfunc/pop_loadset_h5.py

  • read_ref (lines 62-65) returns arr.reshape(-1)[0], so a string or vector keeps only its first element.
  • The MATLAB_empty marker MATLAB writes for empty arrays isn't recognised. event=[] becomes array([0, 0], uint64) (line 215) and then crashes at _file_io.py:45.
  • The struct element count uses squeeze (line 82), which breaks for single-element structs.
  • Data orientation is guessed (lines 261-271), which goes wrong when nbchan == pnts or nbchan == trials.

Why the tests miss it

tests/test_pop_loadset_h5.py:68-78 calls eeg_compare, which only returns a summary string. Nothing asserts on it.

Expected

Loading a v7.3 set gives the same EEG structure as loading the v7 save of the same dataset, and the same structure MATLAB's pop_loadset returns.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions