Skip to content

[GUI] Initialize the ERP and scalp-map plot dialog from the dataset - #1014

Merged
arnodelorme merged 4 commits into
developfrom
agent/issue-875-plot-timtopo
Dec 1, 2026
Merged

arnodelorme merged 4 commits into
developfrom
agent/issue-875-plot-timtopo

Conversation

@arnodelorme

@arnodelorme arnodelorme commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Initialize the ERP and scalp-map plot dialog from the dataset. The continuous window measured 221 px high in MATLAB, 329 px before the fix and 221 px afterward. Stack base is #1012.

Continuous

Epoched

Displacement

Peak amplitude across drawn erp traces

Across 2 native openings, the largest vertical control offset was 0.62 px (target 1 px). Numerical comparison of peak amplitude across drawn erp traces: 2/2 measured cases within tolerance.

EEGLAB 5e0be870, EEGPrep after 336cd6b1, clean Linux checkouts. Part of #875.

Fixes #1015.

Full inventory report for the project team. pop_timtopo (p. 38). PDF · Editable Word.

@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 Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

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


Code review

  • Overall assessment: The runtime change is correct and matches EEGLAB's pop_timtopo.m initialization. One developer-tooling caller was missed.
  • Highest-risk area: Defaults moved out of pop_timtopo_dialog_spec into _run_gui initial_values
  • Merge recommendation: Safe to merge after the visual-capture fix below. It is small and does not block runtime behavior.

Blocking

None.

Important

  • tools/visual_parity/visual_capture.py:969-975 (capture_pop_timtopo_dialog) now renders empty time-range and title boxes. The PR moves the dataset-derived values out of pop_timtopo_dialog_spec and into initial_values in _run_gui (src/eegprep/functions/popfunc/pop_timtopo.py:139-144). That keeps tests/test_gui_geometry.py happy, because it checks against the recorded uilist where these strings are "". However, capture_pop_timtopo_dialog still builds the dialog straight from pop_timtopo_dialog_spec(eeg). The EEGPrep side of the tools/visual_parity comparison will now show blank "Plotting time range" and "Plot title" fields, while the MATLAB capture shows the filled values. The visual parity loop will report a difference that isn't real.
    Fix: have the capture use the real entry point. Move the initial_values construction into a small helper in pop_timtopo.py and use it in both _run_gui and the capture. Alternatively, drive pop_timtopo(eeg, renderer=...) with a capturing renderer, the same way PUBLIC_CALLS does in tests/test_gui_geometry.py.
    Fix this →

Nits

None.

Test gaps

None. The two new PUBLIC_CALLS entries run the dialog through the real pop_timtopo(EEG) entry point for both epoched and continuous data, and the recorded references cover both cases.

EEGLAB parity notes

  • The title matches EEGLAB's 'ERP data and scalp maps' fastif(~isempty(EEG.setname), [' of ' EEG.setname], ''). The time range uses dialog_time_range, which reproduces MATLAB num2str(EEG.xmin*1000) / num2str(EEG.xmax*1000) formatting.
  • Setting the dialog title to "" is correct, because the recorded inputgui call has an empty title. tools/visual_parity/capture.py already fills in EEGPREP_VISUAL_DIALOG_TITLE for empty-title MATLAB dialogs, so the MATLAB capture still works.
  • The recorded tag is topotime, while EEGPrep uses plottimes. The geometry test doesn't compare tags and the tag isn't user-visible, so this is fine.

@arnodelorme
arnodelorme changed the base branch from agent/issue-875-plot-envtopo to develop December 1, 2026 07:09

@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: Implementation matches EEGLAB, though automated tests do not yet check the initial dialog values computed from the dataset.
  • Highest-risk area: Dialog field initialization in src/eegprep/functions/popfunc/pop_timtopo.py (pop_timtopo_initial_values and _run_gui).
  • Merge recommendation: Safe to merge once a unit test covers pop_timtopo_initial_values and _run_gui.

Blocking

None.

Important

None.

Nits

None.

Test gaps

  • Severity: important
    Location: src/eegprep/functions/popfunc/pop_timtopo.py (pop_timtopo_initial_values, _run_gui) and tests/test_gui_geometry.py (PUBLIC_CALLS, _CancelledDialog)
    Why it matters: pop_timtopo_dialog_spec now leaves timerange and title empty ("") so the spec matches the raw EEGLAB uilist, while pop_timtopo_initial_values(EEG) supplies the time limits and default plot title (including omitting " of <setname>" when setname is empty). In tests/test_gui_geometry.py, _CancelledDialog.run(self, spec, initial_values=None) records only self.spec, ignores initial_values, and cancels immediately. No other test in tests/ calls pop_timtopo_initial_values or drives pop_timtopo through gui=True, so if initial_values were dropped or misformatted, the entire test suite would still pass.
    Suggested fix: Add a unit test in tests/test_phase4_plot_wrappers.py (or tests/test_stream7_plots.py) that invokes pop_timtopo(eeg, renderer=..., plot="off", return_com=True) with a stub renderer that merges initial_values over spec.controls defaults, asserting both the formatted timerange and the generated title for a named dataset ("ERP data and scalp maps of ...") and an untitled dataset (setname="" producing "ERP data and scalp maps").

EEGLAB parity notes

  • Checked against functions/popfunc/pop_timtopo.m lines 62 to 76: the supergui geometry (5 rows of [2 1]), empty window title, uilist defaults, and evalstr initialization of timerange ([num2str(EEG.xmin*1000) ' ' num2str(EEG.xmax*1000)] via dialog_time_range) and title ('ERP data and scalp maps' plus optional ' of ' EEG.setname) match EEGLAB.
  • tools/visual_parity/visual_capture.py (capture_pop_timtopo_dialog) passes pop_timtopo_initial_values(eeg) into renderer.build_dialog, keeping visual capture aligned with _run_gui.
  • Tests run on commit 294fbe17e62040e9c94ff06ab64b35c4233969ed in a detached worktree:
    • PYTHONPATH=<worktree>/src:<worktree> .venv/bin/python -m pytest <worktree>/tests/test_gui_geometry.py: 169 passed, 80 skipped (Linux pixel comparison skipped on macOS).
    • PYTHONPATH=<worktree>/src:<worktree> .venv/bin/python -m pytest <worktree>/tests/test_phase4_plot_wrappers.py -k timtopo: 3 passed.
    • uv run --no-sync ruff check on the three modified Python files: passed.
    • Offscreen QtDialogRenderer().build_dialog and mock renderer check on eeglab_data.set, eeglab_data_epochs_ica.set, and an empty setname copy: verified expected timerange, title, and history command output.

@arnodelorme

Copy link
Copy Markdown
Collaborator Author

🤖 The test the second review asked for is added (commit 430801fc). test_pop_timtopo_gui_starts_from_the_dataset_limits_and_title drives pop_timtopo through its dialog with a renderer that receives initial_values. It checks the time limits of the dataset, the title for a named dataset ("ERP data and scalp maps of named set") and for a dataset with no name ("ERP data and scalp maps"), and that the title reaches the history command. The test fails if _run_gui stops passing the initial values. The same review found no blocking or important problem in the code.

@arnodelorme
arnodelorme merged commit 0c20e55 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.

pop_timtopo: Initialize the ERP and scalp-map plot dialog from the dataset

1 participant