Skip to content

[GUI] Match ten dialog functions against recorded EEGLAB calls - #886

Merged
arnodelorme merged 8 commits into
developfrom
agent/issue-875-ten-functions
Dec 1, 2026
Merged

arnodelorme merged 8 commits into
developfrom
agent/issue-875-ten-functions

Conversation

@arnodelorme

@arnodelorme arnodelorme commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

The ten public functions now open dialogs that match the recorded EEGLAB controls across 20 sample cases. The CTF grid converts centimeters to the head model’s declared unit. Both dialog submission and console history recovered the same known source with millimeter and centimeter models.

ICA threshold examples

ICA threshold examples

Unnamed dataset

Unnamed dataset

CTF grid shown to the user

CTF grid shown to the user

Fitted source before and after the CTF conversion

Fitted source before and after the CTF conversion

Row distance for all 20 cases

Row distance for all 20 cases

All 20 cases passed the five visual checks. Maximum vertical offset was 0.69 pixel. For the millimeter model, position error fell from 41.24 mm to zero and residual variance from 11.08% to below 10⁻²⁷%. The centimeter model retained zero position error.

Controls and captures

The regression tests invoke the ten public functions on matched inputs. They compare rows, column shares, labels, defaults, hidden controls and help buttons. The captures show the ICA threshold labels, the empty title for an unnamed ERP dataset and the CTF grid. ICLabel also restores its version tooltip. Native toolkit button shapes and colors differ.

The three-panel images show EEGLAB, EEGPrep before the layout changes at cea86f8f, and EEGPrep at 94398341. The fit table measures submission and history on the same physical source before the numerical fix at 2dc218ef and after at 94398341. Numeric command arguments use the head model’s unit.

Verification on jamming

EEGLAB 5e0be87059098662dc9b50fb378f9002b0ef173a, EEGPrep 94398341344bf51f3711b4ba88a3cc717c1c2627. Both checkouts contained the current develop history. Python imported EEGPrep from the final checkout’s src. All 107 tests in tests/test_gui_geometry.py and tests/test_dipfit_workflows.py passed. The millimeter regression failed on the previous implementation. The broader Linux run passed 3,575 tests with 32 skips, 1,072 deselections and 412 passing subtests in 239 s.

Pinned MATLAB reference suite, final result. On jamming (Linux, MATLAB R2025b Update 7, Python 3.12.13), the whole suite ran on this branch at 94398341 against EEGLAB d0963be9d81acc5b66e84f8d3d7c89e3ce127cc4 and eeglab_tests fec88f9ffe7c225eb1de8924db8b6a3e0d53a4d9: 4,680 passed, 4 failed, 59 skipped, 481 subtests passed, in 3,095.93 seconds (51 minutes 35 seconds). None of the four failures touches the dialogs or the CTF grid of this pull request. Each one comes from the setup of that run.

Failed test Cause Check
test_bids_preproc.py::TestBidsPreproc::test_end2end and ::test_crashability_slow These two tests run only on a few named hosts, jamming among them, and read a data folder inside the checkout. The folder was not there when the run began (it was added 11 minutes later). FileNotFoundError on reference-checkout/data in the log. Not rerun: the second one is the slow stress test over whole studies.
test_bids_load_frombids_helpers.py::test_openneuro_edf_import_matches_matlab_pop_importbids The test compares the samples as single precision. In the full run the MATLAB session returned double precision values, so the exact comparison failed by rounding (93.19735649 against 93.19736). Passed alone with EEGLAB's shipped options (--eeglab-support-path): 1 passed in 6.48 s.
test_fuzz_harness.py::test_replay_20261015_fuzz_mismatches The test stops when there is no EEGLAB options file to restore. There was no ~/eeg_options.m on jamming at that moment of the run (a later test created it). Passed alone with the same options once the file was there: 1 passed in 7.35 s.
Exact command of the full run
cd "$D/reference-checkout"   # D=/mnt/v1/arno/eeglab-eegprep-compare/runs/issue-875-nov30, checkout at 94398341
export TMPDIR="$D/tmp" PYTHONPATH="$PWD/src:$PWD" EEGPREP_OPENNEURO_ROOT="$D/openneuro"
export QT_QPA_PLATFORM=offscreen OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1
export EEGPREP_MATLAB_BATCH_DIR="$D/verified-service"
matlab -batch "addpath('$PWD/tests/matlab'); eegprep_batch_engine_serve('$EEGPREP_MATLAB_BATCH_DIR')" &
"$D/reference-venv/bin/python" -m pytest tests --eeglab-backend=matlab \
  --eeglab-root="$PWD/src/eegprep/eeglab" --eeglab-suite-root="$D/eeglab_tests" \
  --timeout=1200 -q --junitxml="$D/full-reference.xml" > "$D/full-reference.log" 2>&1

Log and JUnit file: $D/full-reference.log and $D/full-reference.xml. The reruns: $D/precision-retry.log and $D/fuzz-retry.log (script $D/fuzz-retry.sh).

Part of #875.

EEGLAB reference run (December 1, 2026)

Workflow EEGLAB reference (.github/workflows/eeglab-reference.yml, real MATLAB backend) on commit 41cbe141, the head after merging develop: https://github.com/sccn/eegprep/actions/runs/46603716218
EEGLAB d0963be9, eeglab_tests fec88f9f. Runtime 1 hour 25 minutes, most of it waiting in the queue.

Shard Passed Failed Skipped Time
core 3485 4 (and 2 teardown errors) 17 19 min 51 s
study 341 0 27 14 min 06 s
misc 688 0 8 7 min 28 s
stats 257 0 0 1 min 46 s
parity 10 0 2 22 min 05 s
hybrid 143 0 4 42 s
heavy 3 0 0 8 min 57 s

The four failures are on develop and not from this pull request. Two are tests/test_stream11_datasets.py::test_f42_merge_opens_newset_and_cancel_preserves_datasets (failing since #904 gave the pop_mergeset dialog an empty title). Two are the pop_newtimef cases of tests/test_gui_geometry.py::test_drawn_dialog_has_matlab_rows_and_aligned_edit_boxes, which fail on GitHub's Ubuntu runner since #994 (repair in #1059). Develop's own Tests run shows the same four: https://github.com/sccn/eegprep/actions/runs/46606001709

Deliberate difference with EEGLAB. A CTF grid submitted in the dialog is converted to the head model's declared unit (Arno's choice of November 29). For a millimetre head model EEGLAB passes the centimetre grid unchanged. The help page documents it and test_ctf_grid_dialog_and_history_locate_the_same_source locks it.

@arnodelorme

Copy link
Copy Markdown
Collaborator Author

Arno chose option (a) on November 29, 2026: the CTF search grid is converted using the head model's declared unit inside this pull request, with tests for millimeter and centimeter head models, dialog submission and history replay. The instruction was sent to the Codex Astra session that owns this pull request.

— orchestrator

@arnodelorme
arnodelorme marked this pull request as ready for review November 30, 2026 22:44

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@claude

claude Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @arnodelorme's task in 1m 43s —— View job


Code review

  • Overall assessment: Needs changes. I found no bugs in the dialog changes or the CTF grid conversion. The one gap is process: the PR body is missing the EEGLAB reference run that AGENTS.md requires.
  • Highest-risk area: the CTF grid conversion in pop_dipfit_gridsearch (src/eegprep/plugins/dipfit/pop_dipfit_gridsearch.py:67-77).
  • Merge recommendation: Needs changes. Add the reference-run evidence and get Arno's approval of the numerical change (he chose option (a) on Nov 29); then it is safe to merge.

Blocking

None.

Important

  • The EEGLAB reference run is missing from the PR description (pop_dipfit_gridsearch.py, ft_dipolefitting.py). This PR changes dipfit code that EEGLAB also has. When a CTF/MEG grid is submitted through the dialog, the fitted positions now differ from EEGLAB's. For a millimetre head model, EEGLAB passes the centimetre grid straight to the model. AGENTS.md requires: "Before merging a PR that changes core function implementations … trigger .github/workflows/eeglab-reference.yml … Put that run in the PR description: the exact command or workflow run, the EEGLAB and eeglab_tests commits, pass/fail/skip counts, runtime." It also says "A numerical change compared with EEGLAB, even a tiny one, is never merged without Arno Delorme's explicit approval." The body only reports the 107 tests in test_gui_geometry.py and test_dipfit_workflows.py.
    • Fix: dispatch the EEGLAB reference workflow on this branch and add its results to the body.
    • Fix: state in the body that this is a deliberate deviation from EEGLAB for millimetre models. The help page documents it and test_ctf_grid_dialog_and_history_locate_the_same_source locks it.

Nits

  • The changelog does not mention the unit conversion (docs/source/changelog.rst:29-33). It says pop_dipfit_gridsearch "proposes grids in centimeters". The change users will notice is that a submitted dialog grid is now converted to the head model's unit, and that history records the result in head-model coordinates. Add a sentence saying so, as interactive_pop_workflows.rst already does.
  • Extra blank lines in an import block (pop_dipfit_gridsearch.py:21-28). The new import is set off by blank lines inside one block of first-party imports. Join it to the block to match local style.
  • The new error does not say how to fix it (pop_dipfit_gridsearch.py:70-72). The message "set the head model's length unit" does not say where. Name the field, for example "set EEG['dipfit']['vol']['unit'] (or the unit field of the hdmfile) to 'mm' or 'cm'". This only applies when a user-supplied vol, or a .mat BEM file, has no unit.

Test gaps

None. The parametrized mm/cm test covers dialog submission and history replay on a known source. POP_CALLS now opens dialogs through the public pop_* functions rather than the *_dialog_spec helpers, and test_every_recorded_case_is_compared keeps the cases and POP_CALLS in sync.

EEGLAB parity notes

  • The pop_eegthresh ICA labels, including EEGLAB's double space in std. dev, Ex, match the recorded cases/pop_eegthresh.ica.json. The CTF defaults linspace(-8.5,8.5,24) / linspace(0,8.5,12) match cases/pop_dipfit_gridsearch.ctf.json.
  • Console calls with explicit grids are still read in head-model units, as in EEGLAB. Only the dialog path converts.
  • Reading unit from a packaged .npz does not change ordinary fits. prepare_headmodel_sens still sets vol["unit"] = "mm" (ft_dipolefitting.py:142), so the unit only feeds the new dialog conversion.
  • pop_plottopo with an empty title still falls back to "Channel ERPs" when plotting (pop_plottopo.py:56). Only the dialog's initial value changed, which matches the recorded EEGLAB case.

I could not open the EEGLAB .m sources because the vendored src/eegprep/eeglab/ checkout is not in this CI workspace, so parity was checked against the recorded tools/gui_geometry/cases/*.json. I did not run ruff or the tests either, because those commands need approval in this environment.

@arnodelorme

Copy link
Copy Markdown
Collaborator Author

🤖 The ten dialogs passed the visual comparison on jamming in all 20 cases. The largest row offset was 0.69 pixel. The report includes the captures, the distance histogram and the CTF results before and after the fix.

PR 886 now converts the displayed CTF coordinates using the head model’s declared unit. Entering (1, −2, 4) cm recovered (10, −20, 40) mm in both the dialog and its replayed history for millimeter and centimeter models. Before the fix, the millimeter model missed the source by 41.24 mm. All 107 targeted tests passed. The broader Linux run passed 3,575 tests with 32 skips.
#886
#875

PR 885 now targets develop and includes Arno’s merged PR 884. The Windows run passed all 14 tests in the event editor file, including the long-field-name regression for issue 859.
#885
#884
#823
#859
https://github.com/sccn/eegprep/actions/runs/46528608530/job/142236610304

At the report cutoff, 22:48 UTC, PR 885 had six successful checks, one skip and five pending. PR 886 had six successful checks, four skips and six pending. Both PRs are open for Arno’s review. The remaining dialogs need migration and comparison by menu. The next batch covers the FIR filter dialogs.

@arnodelorme

Copy link
Copy Markdown
Collaborator Author

🤖 All 99 inventory functions have native MATLAB and Qt captures on jamming. The report contains the 41 previously different dialogs, 40 previously uncompared entries, and 18 earlier matches.

Of 307 paired output checks, 289 met tolerance and 18 exceeded it across nine functions. Five other cases could not be scored: two ICLabel network variants, MRI segmentation, eLORETA, and one component spectrum whose array dimensions differ. Of 152 geometry comparisons, 146 passed. The six remaining differences are the three BIDS editors, BioSig, EGI, and the multiline input dialog. Two accepted reader-specific workflows have captures but no comparable geometry measure.

Each function page links its issue and PR and names the required branch base. The newest File changes are #1054 (base #1052) and #1056 (base #1034). The stacked PRs are ready for your review. GitHub only runs the full Tests workflow on its configured base branches; the report distinguishes the jamming checks. PR #885 targets develop, and its Windows job passed all 14 event-editor tests, including #859.

Project tracker files for the team: full PDF, editable Word, base branch of every linked PR, and measured distances. The project tracker requires access. Individual function captures are public on the linked PRs.

# Conflicts:
#	docs/source/api/interactive_pop_workflows.rst
#	tests/test_gui_geometry.py
#	tools/gui_geometry/draw_geometry.py
#	tools/gui_geometry/matlab/record_geometry.m

@arnodelorme arnodelorme left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review was written by an AI assistant during a nightly check, not by Arno.

Code review

  • Overall assessment: Looks good.
  • Highest-risk area: CTF centimeter to head model unit conversion in src/eegprep/plugins/dipfit/pop_dipfit_gridsearch.py and src/eegprep/plugins/dipfit/ft_dipolefitting.py.
  • Merge recommendation: Safe to merge after human approval of the core dipfit change per AGENTS.md.

Blocking

None.

Important

None.

Nits

None.

Test gaps

None.

EEGLAB parity notes

  • CTF dialog unit conversion (pop_dipfit_gridsearch.py, ft_dipolefitting.py): On dialog submission with coordformat == 'CTF' or MEG channels, EEGPrep converts the centimeter grid into the head model's declared unit (mm, cm, m, dm, or um), whereas EEGLAB (pop_dipfit_gridsearch.m, lines 79 to 110) evaluates the centimeter linspace expression directly without scaling to vol.unit. Explicit command arguments and recorded history remain in head model coordinates, matching EEGLAB. This intentional deviation for millimeter head models is documented in pop_dipfit_gridsearch.md, interactive_pop_workflows.rst, and changelog.rst, and covered by test_ctf_grid_dialog_and_history_locate_the_same_source. The PR description includes the pinned MATLAB reference run required by AGENTS.md.
  • Dialog specifications (pop_eegthresh.py, pop_plottopo.py, pop_iclabel.py, draw_geometry.py): Checked against pop_eegthresh.m (lines 113 to 142), pop_plottopo.m (lines 64 to 76), and pop_iclabel.m (lines 35 to 43). The ICA threshold prompts preserve EEGLAB's examples and spacing, unnamed datasets open pop_plottopo with an empty title field while plotting still falls back to 'Channel ERPs' when left blank, pop_iclabel restores the version popup tooltip (with EEGLAB's repoducibility typo corrected), and draw_geometry.py preserves dotted variant suffixes when saving .png and .json outputs.

Tests and checks run locally on commit 4be45a013690150cb0bb5a5357e1ba326b45664a (detached worktree):

  • .venv-arm/bin/python -m pytest tests/test_gui_geometry.py tests/test_dipfit_workflows.py -q: 199 passed, 67 skipped (Linux reference position checks skipped on macOS). Note: running the same command under the older Python 3.11 .venv without onnxruntime failed only on test_pop_function_opens_the_dialog_eeglab_passes_to_inputgui[pop_iclabel] because pop_iclabel checks onnxruntime (included in the dev dependency group) before opening its dialog.
  • EEGPREP_SKIP_MATLAB=1 .venv-arm/bin/python -m pytest tests/test_iclabel.py tests/test_console_workspace.py -k "not test_installed_wheels_open_both_sample_recordings_from_eegprep_sample_data" -q: 139 passed, 3 skipped.
  • .venv-arm/bin/python pre-commit.py --changed-from origin/develop, ruff check, ruff format --check, and ty check on the modified Python files: passed with zero diagnostics on changed files.

Checked for correctness bugs, EEGLAB parity, data structure compatibility, tests for changed behavior, and CLAUDE.md/AGENTS.md compliance.

@arnodelorme
arnodelorme merged commit 068ad17 into develop Dec 1, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant