Skip to content

[Release readiness] Stream 1: Data safety #546

Closed

Description

@suraj-ranganath

[Release readiness] Stream 1: Data safety

Context

This issue is one of 11 release-readiness streams for sccn/eegprep. The release goal is EEGLAB parity in the GUI and the numbers for everything except STUDY and third-party plugins (default / bundled plugins only: EEG-BIDS, ICLabel, clean_rawdata, dipfit, firfilt).

The audit (report eegprep_GUI_audit_2026-11-05.pdf, findings F1–F126 in findings.md) was run as a simulated user: hands-on GUI use of eegprep and EEGLAB side by side, with real datasets, plus numerical parity checks against MATLAB EEGLAB. EEGLAB was the pinned tree eeglab-8ac485f6 on the lab MATLAB machine (jamming, path ~/gui-parity/eeglab-8ac485f6), never modified. eegprep was develop at 0bda20da. Where the pinned tree lacked a plugin (Biosig, Fileio, neuroscanio, bva-io, Fieldtrip-lite, viewprops), comparisons against a bench copy are labelled non-pinned.

Of 144 in-scope menu items, 141 were tested hands-on in both GUIs. Not counted in that 141: Quit (not run, ends the session) and the two eegprep-only Plot items "View extended channel/component properties" (pinned EEGLAB has no viewprops; tested in eegprep only as F122).

This stream: Data safety (already running) (size M). Findings assigned: F14, F33, F35, F41, F88, F120.

Files / functions owned (do not edit outside these without coordinating; see fix_streams.md):

menu_actions.py: _saveset (485-518), the pop_delset branch of dispatch (~353), _existing_dataset_filename (1750), _apply_save_metadata (1841); popfunc/pop_saveset.py; popfunc/pop_editeventvals.py; guifunc/qt.py: _navigate_event/_navigate_channel/_navigate_indexed_form (1252-1278) only; adminfunc/pop_delset.py; guifunc/session.py: delete_current (334); popfunc/pop_fileio_brainvision_mat.py

Dependencies / merge order: Merge first. F36 is not in scope: its typed-index overwrite shares the qt.py navigation helper with F35 and is fixed here, but its disabled buttons have a different cause (stream 5).

Suggested tests from the stream plan: Qt tests (resave prompts for a name, Save as error, delete confirmation, typed event index); function tests (md5 of raw file unchanged); BVA .mat against the EEGLAB numbers already recorded (32 ch, 200 Hz, 16 events). MATLAB not needed.

Common datasets used in the audit (copies only; never the originals):

  • eeglab_data.set — continuous tutorial (32 ch, 128 Hz, 30504 pnts)
  • eeglab_data_epochs_ica.set — epoched + ICA (80 epochs)
  • eeglab_data_numerical_events.set — numerical event types
  • BrainVision set (testbva.vhdr / related) — 32 ch, 2112 pnts, 17 events
  • test.bdf / test.edf — Biosemi / EDF samples
  • BIDS oddball sample for import/export
  • Neuroscan .EEG, BVA .mat, MFF folder, HDF5 eeglab_data_hdf5.set where noted
  • Channel location files: eeglab_chan32.locs, standard_1005.elc, standard-10-5-cap385.elp

Already in progress: PR #544 covers F14, F33, F35, F36-navigation, F41, F88, F120. Reference that PR; land leftovers listed below if not already in the PR.

Companion stream issues (together they cover F1–F126):

Stream Issue
1 Data safety #546
2 Dialogs and Edit selection #548
3 Scroll window #547
4 Signal processing #549
5 Channel locations and re-reference #550
6 Rejection numbers #551
7 Plots and plot history #552
8 ICLabel, component properties, DIPFIT #553
9 Importers #554
10 Export and BIDS #555
11 Main window, menus, preferences, help #556

Screenshots: image files for this stream are staged under /workspace/gui-parity/issues/stream-01/ and ready for gh issue edit --attach. Embedding via --attach failed with the current fine-grained GH_TOKEN (HTTP 403 on uploads.github.com). Run attach_screenshots.sh with a classic PAT that can upload user-attachments (or grant the fine-grained token Contents + attachments). Until then, screenshot filenames are listed under each finding.

Findings

Use the checkboxes to track progress. Full audit detail is carried over (not summarised away).

- [x] F14 — critical — File > Resave

Finding (full audit text): Resave on an imported, never-saved dataset OVERWRITES THE ORIGINAL RAW FILE (.vhdr/.edf) with .set content. Repro: cp test.edf /tmp/rs/; import it via From EDF; File > Resave current dataset(s); md5 of /tmp/rs/test.edf changes and the file is now a .set. Cause: _saveset -> _existing_dataset_filename(eeg) accepts the importer's raw filename. In EEGLAB an imported set has an empty filename, so Resave prompts for one. Hit for real: it clobbered sample_data/test_data/testbva.vhdr (restored with git checkout)

Evidence / screenshots: out/clobbered_testbva.vhdr.set; screenshots/F14_eegprep_before.png, F14_eegprep.png, F14_evidence.png (re-run on a copy at 01:01 PST Nov 5: md5 changed, .vhdr is now a 599 KB MAT file)

What needs fixing: Resolve the behaviour so eegprep matches EEGLAB for this item (GUI and numbers), unless EEGLAB is the buggy side — then keep the correct behaviour, document the difference, and lock it with a test. Add a regression test. Keep existing tolerances.

Screenshots (filenames; attach pending):

  • F14_evidence.png — F14: evidence
  • F14_eegprep.png — F14: eegprep
  • F14_eegprep_before.png — F14: eegprep

- [x] F33 — high — File > Save as

Finding (full audit text): Save as to a folder that doesn't exist (/workspace/gui-parity/nodir/x.set) fails SILENTLY. No file is written and no error appears, yet the main window shows Filename .../nodir/x.set and the history records EEG = pop_saveset(EEG, '/workspace/gui-parity/nodir/x.set');. The user believes the data is saved (data-loss risk)

Evidence / screenshots: ep_saveas_nodir_20261104_231825.png; ls nodir -> no such directory; screenshots/F33_eegprep.png

What needs fixing: Resolve the behaviour so eegprep matches EEGLAB for this item (GUI and numbers), unless EEGLAB is the buggy side — then keep the correct behaviour, document the difference, and lock it with a test. Add a regression test. Keep existing tolerances.

Screenshots (filenames; attach pending):

  • F33_eegprep.png — F33: eegprep
  • ep_saveas_nodir_20261104_231825.png — F33: ep_saveas_nodir_20261104_231825

- [x] F35 — critical — Edit > Event values

Finding (full audit text): DATA CORRUPTION. Typing an Event Num and pressing Enter does not move to that event; the fields still show event 1. Pressing Ok then writes event 1's values into event N. Repro: eeglab_data copy, Event values, type 5 + Enter, change Type to zz, Ok -> event 5 (rt) becomes zz at latency 129 samples (event 1's latency). Typing 999 gives "list index out of range". Moving with < > drops unsaved edits without a warning. EEGLAB: the numval callback is pop_editeventvals('goto',0), so typing 5 + Enter jumps to rt, 5.1482 s; 999 is ignored

Evidence / screenshots: F35_eegprep.png, F35b_eegprep_999.png, F35_eeglab.png, eout/ep_eventvals_F35.set

What needs fixing: Resolve the behaviour so eegprep matches EEGLAB for this item (GUI and numbers), unless EEGLAB is the buggy side — then keep the correct behaviour, document the difference, and lock it with a test. Add a regression test. Keep existing tolerances.

Screenshots (filenames; attach pending):

  • F35_eeglab.png — F35: EEGLAB
  • F35_eegprep.png — F35: eegprep
  • F35b_eegprep_999.png — F35: eegprep

- [x] F41 — high — Edit > Delete dataset(s)

Finding (full audit text): Deletes the current dataset immediately with no dialog and no confirmation (ALLEEG = pop_delset( ALLEEG, [15] );); this can't be undone. EEGLAB shows "Delete dataset -- pop_delset()" ("Dataset(s) to delete:", default current, Cancel/Ok). With only 1 set loaded, EEGLAB refuses ("Cannot delete dataset when there is only one of them...")

Evidence / screenshots: F41_eegprep.png, F41_eegprep_dialog.png, F41_eeglab.png, F41_eeglab_onlyone.png

What needs fixing: Resolve the behaviour so eegprep matches EEGLAB for this item (GUI and numbers), unless EEGLAB is the buggy side — then keep the correct behaviour, document the difference, and lock it with a test. Add a regression test. Keep existing tolerances.

Screenshots (filenames; attach pending):

  • F41_eeglab.png — F41: EEGLAB
  • F41_eeglab_onlyone.png — F41: EEGLAB
  • F41_eegprep.png — F41: eegprep
  • F41_eegprep_dialog.png — F41: eegprep

- [x] F88 — medium (re-confirms F41/F29, now with EEGLAB pair) — Datasets/File > Delete dataset(s)

Finding (full audit text): eegprep deletes immediately with no prompt. EEGLAB opens the "Delete dataset -- pop_delset()" input dialog with the dataset index prefilled ("2"); its history is ALLEEG = pop_delset( ALLEEG, [2] );.

Evidence / screenshots: F88_delete_dataset_sbs.png, D_delete_first_eegprep_20261105_041207.png, P_D_delete_eeglab_20261105_043556.png

What needs fixing: Resolve the behaviour so eegprep matches EEGLAB for this item (GUI and numbers), unless EEGLAB is the buggy side — then keep the correct behaviour, document the difference, and lock it with a test. Add a regression test. Keep existing tolerances.

Screenshots (filenames; attach pending):

  • F88_delete_dataset_sbs.png — F88: EEGLAB vs eegprep side-by-side
  • P_D_delete_eeglab_20261105_043556.png — F88: EEGLAB
  • D_delete_first_eegprep_20261105_041207.png — F88: eegprep

- [x] F120 — high (silent data corruption) — File > Import data > Brain Vision Analyzer .mat

Finding (full audit text): pop_fileio_brainvision_mat misparses without warning. raw_data loads as 1 ch x 2112 @ 1 Hz with 0 events; the file has 32 ch, 200 Hz and 17 markers, and EEGLAB pop_loadbva (non-pinned) gives 32 ch / 2112 / 200 Hz / 16 events. The segmentation file loads as 10 ch x 200 with 1 trial instead of 32 x 200 x 10 (EEGLAB 15 events). The history name isn't EEGLAB's.

Evidence / screenshots: F120bvamat_eegprep_20261105_051521.png, F120bvamat_raw_data_eegprep_20261105_051037.png, F120bvamatseg_eegprep_20261105_051539.png, F120bvamat_segmentation_eegprep_20261105_051045.png

What needs fixing: Resolve the behaviour so eegprep matches EEGLAB for this item (GUI and numbers), unless EEGLAB is the buggy side — then keep the correct behaviour, document the difference, and lock it with a test. Add a regression test. Keep existing tolerances.

Cosmetic leftover (include if touching the reader): after the misparse fix, BVA .mat chanlocs may still lack the empty ref and type fields EEGLAB appends — track under leftover item below if not fixed here.

Screenshots (filenames; attach pending):

  • F120bvamat_eegprep_20261105_051521.png — F120: eegprep
  • F120bvamat_raw_data_eegprep_20261105_051037.png — F120: eegprep
  • F120bvamat_segmentation_eegprep_20261105_051045.png — F120: eegprep
  • F120bvamatseg_eegprep_20261105_051539.png — F120: eegprep

- [x] Leftover: BVA .mat chanlocs missing empty ref / type (cosmetic) (fixed in #557, b293f74)

After F120, chanlocs may still omit empty ref and type fields that EEGLAB pop_loadbva appends for unknown channels. Cosmetic; fix if editing the reader.

Definition of done

  • Every finding checkbox in this issue is fixed (or explicitly documented as intentional / EEGLAB-only with a locked test).
  • A regression test exists for each finding (Qt offscreen and/or function test as appropriate for the stream).
  • Where numbers are involved: a numerical parity test against pinned EEGLAB eeglab-8ac485f6 on jamming. Do not loosen any existing tolerance — only Suraj or Arno may change tolerances; fix root causes instead.
  • Where EEGLAB itself is buggy: eegprep does the right thing; the difference is documented and locked with a test (documented-difference style).
  • Error messages state what is wrong, which function hit it, and the exact fix (e.g. the pip install eegprep[...] command).
  • No code comments that restate code or justify workarounds.
  • Changelog entry for the stream.
  • One PR against develop, CI green (ignore the known-broken Claude review check).
  • Before merge, retest the same way as the audit: each finding's GUI flow is re-run hands-on in both eegprep and EEGLAB side by side, with before/after screenshots, plus the MATLAB parity / reference checks where this stream requires them; post the results on the PR.
  • Merging requires Suraj's explicit approval (squash merge).

Dependencies and overlaps

Merge first. F36 is not in scope: its typed-index overwrite shares the qt.py navigation helper with F35 and is fixed here, but its disabled buttons have a different cause (stream 5).

Shared hotspots (from fix_streams.md):

  • menu_actions.py is split by method — only edit this stream's named methods.
  • tests/eeglab_python_backend_xfails.py and tests/parity_expected/: each stream adds/removes only its own entries.
  • Suggested merge order overall: S1 → S2/S9/S11 → S5; S7 → S8; S3/S4/S6/S10 independent.

References

  • Audit PDF: eegprep_GUI_audit_2026-11-05.pdf (Suraj / Arno)

  • Findings log: findings.md (F1–F126)

  • Stream plan: fix_streams.md

  • Pinned EEGLAB: eeglab-8ac485f6

Activity

  1. added
    bug
    epic
    on Nov 5, 2026
  2. suraj-ranganath commented on Nov 5, 2026

    @suraj-ranganath
    MemberAuthor

    Post-merge verification on develop @ 89eb4112 (PR #544)

    Checked every finding against the merged tree: code + targeted pytest, then re-ran the audit-style eegprep GUI flows with the /workspace/gui-parity ctl harness on DISPLAY=:3 at this commit. Screenshots: /workspace/gui-parity/screenshots/S1_recheck_* (America/Los_Angeles, 2026-11-05).

    Item Status Evidence
    F14 Resave must not clobber raw done-and-verified pop_saveset.py resave requires .set; menu opens Save as. GUI: Resave on imported test.edf → dialog Save current dataset as (filter *.set); md5 unchanged fd267ef9…. Tests: TestPopSaveset::test_resave_refuses_to_overwrite_a_raw_source_file, MenuActionDispatcherTests::test_resave_of_imported_raw_file_prompts_and_does_not_overwrite_source. Shot: S1_recheck_F14_resave_prompt_w9.png
    F33 Save as silent fail done-and-verified Missing parent is created (hardening); non-directory parent errors and does not mark saved. GUI: /tmp/…/nodir/x.set written; /tmp/…/not_a_dir/x.set → pop_saveset could not write … Choose a .set file…. Tests: test_saveset_creates_a_missing_parent_directory, test_saveset_refuses_a_parent_that_is_not_a_directory, test_save_as_creates_missing_folder_and_failed_save_is_not_recorded. Shots: S1_recheck_F33_created_folder_w18.png, S1_recheck_F33_bad_parent_error_w7.png
    F35 Event values wrong target done-and-verified qt.py _bind_index_navigation / _navigate_indexed_form; editingFinished goto. GUI: Event Num 5 → type rt @ 5.148 s; edit zz + Ok → event 5 only (changefield', {5 'type' 'zz'}); 999 clamps to 154. Tests: test_event_number_enter_loads_that_event_and_ok_keeps_the_edit, test_leaving_an_event_keeps_the_edit_for_ok, test_event_number_out_of_range_is_clamped_and_non_numeric_is_restored. Shot: S1_recheck_F35_at5_zz_w64.png
    F41 / F88 Delete confirmation done-and-verified menu_actions.py _delete_datasets (~484–516). GUI: dialog Delete dataset -- pop_delset() with Dataset(s) to delete: prefilled; Cancel keeps sets; Ok → ALLEEG = pop_delset( ALLEEG, [2] );; only-one → pop_delset cannot delete the only loaded dataset…. Tests: test_delete_dataset_asks_for_confirmation_and_can_cancel, test_delete_dataset_refuses_the_only_loaded_dataset, test_delete_dataset_dialog_has_help_cancel_and_ok. Shots: S1_recheck_F41_confirm_dialog_w27.png, S1_recheck_F41_only_one_w13.png
    F120 BVA .mat misparse done-and-verified (shapes/events) pop_fileio_brainvision_mat.py. GUI/dispatcher: raw 32×2112 @ 200 Hz / 16 events; seg 32×200×10 / 15 events; filename/filepath empty. Tests: full tests/test_pop_fileio_brainvision_mat.py (37 passed + suite parity with --eeglab-suite-root). Shots: S1_recheck_F120_raw_ok_w22.png, S1_recheck_F120_seg_ok_w29.png
    Leftover empty ref/type on BVA chanlocs not done eegprep keys lack ref/type. EEGLAB pop_loadbva (bench bva-io + pin functions on jamming) fields include ref,type as empty char. Fix brief: /workspace/gui-parity/issues/stream-01/remaining_brief.md
    pop_chanedit history cell form out of scope here Listed on #550 (Stream 5 / F49 leftover), not on this issue

    Pytest: EEGPREP_SKIP_MATLAB=1 QT_QPA_PLATFORM=offscreen uv run pytest on the S1 selection above → 37 passed, 1 skipped (suite fixture without root; re-run with --eeglab-suite-root → parity passed).

    DoD checkboxes: ticked regression tests, numerics, documented EEGLAB differences, helpful errors, no restating comments, changelog, merged PR #544, pre-merge/post-merge retest, Suraj squash approval. Left unticked: leftover; “every finding checkbox” (blocked on leftover).

    GUI flows not re-driven as live EEGLAB GUI this pass: EEGLAB side-by-side pixel pairs for F14/F33/F35/F41 (covered in the original audit and the pre-merge #544 hands-on on c0054bdf). This pass used the eegprep ctl harness + one jamming MATLAB batch for BVA chanloc fields only (pinned tree untouched). Nested QAction.trigger() on From Brain Vis. Anal. Matlab file did not raise the file dialog in the harness; the same MenuActionDispatcher.dispatch('pop_fileio_brainvision_mat') path was used instead (identical importer).

    Issue left open for the BVA ref/type leftover.

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

    bugepic

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions