Skip to content

File > Load existing dataset fails when a dataset has an empty name (setname loads as an empty array) #767

Done

Description

@arnodelorme

Arno could not load a dataset from the menu File > Load existing dataset on November 27, 2026 (EEGPrep develop at 11743a2, started with uv run --no-sync eegprep-console --full --window-menu-bar): a warning window "pop_loadset: could not read the selected data file" appears and the dataset never shows in the main window.

  • Where it stands: reproduced without the window. A dataset saved with an empty name (EEG.setname = '' in MATLAB) loads with setname as an empty 0 by 0 array, and the Datasets menu then fails on dataset.get("setname") or "(no dataset name)" (session.py, line 738).
  • What is wrong twice: pop_loadset (or eeg_checkset) should return an empty text field as '', as EEGLAB does, and the warning names the wrong cause (the file was read correctly, the failure is in the menu refresh).
  • Not yet explained: the three files of EEGLAB's own sample_data folder load correctly in a fresh session here, so either the file he picked has no name, or an earlier dataset of that session had none. To be confirmed with him.
  • Next step: fix at the load (one place), guard the menu line, add a test on a real nameless file, and check the 86 other places that use the same get(...) or pattern on text fields.
  • Waits on: the eegprep worker.
How to reproduce and what was measured

Files of sample_data in the EEGPrep repository that load with setname as an empty array: FlankerTest.set, EmotionValence.set, eeglab_data_tmp.set. The fields subject, group, condition and session come back as empty 0 by 0 arrays for every sample file, including EEGLAB's three.

from eegprep import pop_loadset
from eegprep.functions.guifunc.session import EEGPrepSession
sess = EEGPrepSession()
sess.store_current(pop_loadset("sample_data/eeglab_data_tmp.set"), new=True, command="EEG = pop_loadset(...);")
sess.dataset_summaries()
# ValueError: The truth value of an empty array is ambiguous. Use `array.size > 0` to check that an array is not empty.

The same pattern, EEG.get("<text field>") or <default>, appears 86 times under src/eegprep for setname, filename, filepath, subject, group, condition, session and comments (for example pop_newset.py lines 80 and 160, pop_runica.py line 746, pop_headplot.py line 670). Each of them fails the same way on such a dataset, which is why the fix belongs at the load.

The line of session.py dates from May 2026, so the menu line itself is not a recent change.

Arno's message and traceback

"More importantly, it seems I cannot load a file in the EEGPrep version. I type uv run --no-sync eegprep-console --full --window-menu-bar. Then select a dataset file in the menu: "Load dataset." And then get warning and error. I tried the sample dataset file in the sample data folder of EEGLAB."

INFO (eegprep.functions.adminfunc.eeg_checkset) Scaling components to RMS microvolt
INFO (eegprep.functions.adminfunc.eeg_checkset) Scaling components to RMS microvolt
ERROR (eegprep.functions.guifunc.menu_actions) EEGPrep GUI menu action failed: pop_loadset
  File ".../guifunc/menu_actions.py", line 598, in _loadset
    self._refresh()
  File ".../guifunc/main_window.py", line 316, in _dataset_menu_items
    summaries = self.session.dataset_summaries()
  File ".../guifunc/session.py", line 738, in dataset_summaries
    setname = str(dataset.get("setname") or "(no dataset name)")
ValueError: The truth value of an empty array is ambiguous. Use `array.size > 0` to check that an array is not empty.

Part of the File menu test, issue #696.

— orchestrator

Activity

  1. added
    bug
    gui-parity
    on Nov 27, 2026
  2. claude commented on Nov 27, 2026

    @claude
    Contributor

    🤖 Plan:

    • Write a failing test: a v7 .set with setname = '', then EEGPrepSession.dataset_summaries()
    • Fix at the load: pop_loadset returns empty text fields as ''
    • pre-commit + pytest, open PR

    Research

    The v7 reader keeps MATLAB '' as a 0x0 <U1 array (matlab_empty), so EEG.get("setname") or ... raises. The v7.3 reader already returns '' for these fields (see sample_data/eeglab_data_hdf5.set).

    • src/eegprep/functions/popfunc/_matlab_fields.py matlab_empty: keeps an empty char as a 0x0 array
    • src/eegprep/functions/popfunc/pop_loadset.py#L77: v7 load path
    • src/eegprep/functions/guifunc/session.py#L738: the menu line that fails

    Proposed Fix

    In pop_loadset, set the EEGLAB text fields (setname, subject, group, condition, comments) to '' when they load as an empty array. session stays [], as in eeg_emptyset.m.

  3. arnodelorme commented on Nov 27, 2026

    @arnodelorme
    CollaboratorAuthor

    🤖 Fix ready in pull request #768 (opened by the automatic agent, reviewed, one commit added by the eegprep worker).

    • At the load: pop_loadset returns empty text fields as ''.
    • Menu line: guarded, a name that is not text shows as (no dataset name).
    • Warning: it no longer says the file could not be read when a later step failed.
    • Which file Arno loaded: the three files of EEGLAB's sample_data have a name and load in a fresh session. On develop, once one nameless dataset is in memory (for example eeglab_data_tmp.set, FlankerTest.set or EmotionValence.set of the EEGPrep sample_data folder of his clone), every later load shows the same warning, EEGLAB's samples included. Reproduced in the real menu on jamming, capture in [EEG] Load empty text fields as empty strings in pop_loadset #768. So the likely cause is a nameless file loaded earlier in the same session. To confirm with him.
    • Not changed: the 86 other places that use get(...) or on text fields. They are safe for datasets that come from pop_loadset now.
    • Merge order: [CI] Add the blank line ruff format expects in the BDF tests #766 first (develop fails the format check), then [EEG] Load empty text fields as empty strings in pop_loadset #768.
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

    buggui-parity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions