Skip to content

[GUI] Restore the EEGLAB geometry of the event value editor - #844

Closed
arnodelorme wants to merge 6 commits into
developfrom
agent/issue-823
Closed

arnodelorme wants to merge 6 commits into
developfrom
agent/issue-823

Conversation

@arnodelorme

@arnodelorme arnodelorme commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

The event value editor now uses EEGLAB’s spacer and button rows. The field buttons carry a capital first letter, as EEGLAB's supergui gives them (Type, Position, Latency (ms), Epoch), and show the units used for latency and duration. All captions fit, including Append event.

EEGLAB, EEGPrep on develop, the first version of this pull request, and EEGPrep now

The four panels above are EEGLAB, EEGPrep before this pull request, the first version of this pull request (lower-case captions) and the current version. The EEGPrep panels use the native Mac style, drawn by Qt without showing the window, so they have no title bar. The earlier Linux capture is kept below. Its "EEGPrep after" panel is the first version, before the capital letters.

The change in the shared dialog code does not move the two other windows that use the same option, pop_importepoch and pop_chanevent: every control keeps its position and width (measured in the review of this pull request).

EEGLAB, EEGPrep before, and EEGPrep after on Linux

Editable Word report · PDF report

Cause and change

The event editor omitted a spacer row and supplied its own margins, spacing and height. The control list now follows the MATLAB geometry. The button captions follow lines 387 to 398 of supergui.m: capital first letter and the rest in lower case, unless the caption already starts with a capital followed by a lower-case letter. In the shared Qt renderer, equal weighted columns give repeated field buttons one minimum width so a longer caption cannot shift one row. The sample window keeps its width.

Verification

After the caption change (c42b8ff): the two event editor test files and the shared dialog tests pass on the Mac (26 passed, 2 deselected), Ruff passes. No numerical code changed, so no EEGLAB parity run is needed. The Word and PDF reports linked above now hold the capitalized captions (Mac style for the current version, since it was not captured again on Linux). An independent review by Codex is in the comments. Earlier checks: 164 GUI, event editor and importer tests passed, with 138 subtests and six deselected MATLAB reference cases. Ruff, ty and pre-commit passed. Windows CI previously measured field-button starts at 239 and 242 px. A long custom field reproduced a 41 px offset locally. The regression now passes with both buttons at the same x and the original window width. The final Xvfb recapture matched the attached PNG and all control coordinates byte for byte. The four sample edit boxes start at x = 377 px and the 135 px Append event caption fits. A separate one-pixel Windows row-height check is tracked in #834 and its proposed fix. CI for the final branch.

Fixes #823
Fixes #859
Part of #725

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

Copy link
Copy Markdown
Contributor

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


Code review

  • Overall assessment: Looks correct. No blocking problems. I checked the dialog spec's control and geometry counts, the field-button labels, the qt.py size-policy change and its other users, the removed hard-coded margins and row spacing, and the tests.
  • Highest-risk area: the shared renderer change in src/eegprep/functions/guifunc/qt.py:255-260.
  • Merge recommendation: Safe to merge once the test nit below is addressed or deliberately waived.

Blocking

None.

Important

None.

Nits

  • tests/test_pop_editeventvals_current.py:43-53: the new Qt layout test is in the file that holds the EEGLAB current-suite ports. The other Qt tests for this dialog are in tests/test_pop_editeventvals.py, so this one belongs there too. It also asserts spec.geometry[-4] == (1,), which only reads back the tuple the spec just built (AGENTS.md: no tests that "only assert ... implementation details"). Instead, check that the navigation row is rendered at least one row below the last field row, or drop that assertion. Details are in the inline comment.

Test gaps

None. The epoched latency (ms) label is covered by test_epoched_latency_display_matches_ms_label, and the button-fit check covers the clipped Append event caption.

EEGLAB parity notes

  • The controls and geometry now line up. The extra spacer goes with the new (1,) row, and the two navigation rows each have 7 controls for their 7 weights (1.2, 0.6, 0.6, 1, 0.6, 0.6, 1.2). The final (2, 1, 2) row has spacer / blank original text / spacer.
  • Field buttons now show the raw field name, with units for latency and duration (latency (sec) / latency (ms)). Other fields are no longer capitalized.
  • The qt.py change only takes effect when a dialog sets fit_weighted_labels=True. That flag is also set in pop_importepoch (its Browse button) and pop_chanevent. In those dialogs, pushbuttons in weighted rows now keep at least their natural width instead of shrinking to their column share. That looks intended, but it's worth a quick visual check of those two dialogs.
  • I couldn't open the EEGLAB pop_editeventvals.m source because src/eegprep/eeglab/ isn't checked out in this runner. The parity notes above compare the diff with the PR description and the dialog's own structure. This PR only changes GUI layout and no core numerics, so the MATLAB reference run isn't needed.

Comment thread tests/test_pop_editeventvals_current.py Outdated
Comment on lines +43 to +53
def test_event_editor_leaves_one_row_between_fields_and_navigation(qt_dialogs):
eeg = {"event": [{"latency": 1, "type": "A"}], "srate": 100, "trials": 1}
spec = pop_editeventvals_dialog_spec(eeg)
widgets = qt_dialogs.build(spec)
dialog = qt_dialogs.dialogs[-1]
dialog.show()
assert widgets["desc_latency"].text() == "latency (sec)"
assert spec.geometry[-4] == (1,)
assert widgets["desc_latency"].x() == widgets["desc_type"].x()
button = widgets["append_button"]
assert button.width() >= button.sizeHint().width()

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.

Nit (test placement / implementation detail): This Qt layout test went into test_pop_editeventvals_current.py, which otherwise holds the @eeglab_test "current suite" ports. The other Qt renderer tests for this dialog (test_qt_renderer_navigation_updates_eventnum_and_fields and others) are in tests/test_pop_editeventvals.py. AGENTS.md says "Extend the closest existing test first".

Also, assert spec.geometry[-4] == (1,) reads back the geometry tuple the spec function just built, which is the kind of check AGENTS.md calls out ("Do not write tautological tests that only assert ... implementation details"). The rendered widgets already show the behavior: check that the navigation row sits at least one row height below the last field row, e.g. widgets["back1"].mapTo(dialog, QPoint()).y() - widgets["field_type"].mapTo(dialog, QPoint()).y() exceeds roughly twice the field row height. You could also drop that assertion and keep the label, alignment and button-width checks.

Suggested fix: move this test to tests/test_pop_editeventvals.py and replace the geometry-tuple assertion with a check on the rendered layout.

@arnodelorme

Copy link
Copy Markdown
Collaborator Author

Review (Claude Fable): needs more work

  • Button captions do not match EEGLAB yet. EEGLAB shows Type, Position, Latency (ms), Epoch. This branch shows type, position, latency (ms), epoch. The capture in this pull request shows the difference. The fix makes the diff smaller (keep _display_field_label as it is on develop).
  • The geometry itself is right: rows, control counts, blank original text and content-based height all match pop_editeventvals.m.
  • The shared qt.py change does not move pop_importepoch or pop_chanevent (measured, every widget identical). The body should say so.
  • CI is not green yet: macOS failed on a test unrelated to this branch, Ubuntu and Windows were still pending at review time.
Details

Reviewed at f175ace.

1. Captions (to fix). supergui.m lines 387 to 398 put a capital on the first letter of every push button and lower the rest. pop_editeventvals.m lines 527 to 532 pass the raw field name, and supergui then turns it into Type or Latency (ms). On develop, _display_field_label already returned Latency (ms), Latency (sec), Duration (ms) and field.capitalize(). This branch rewrites it to lower case and edits tests/test_pop_editeventvals.py to expect latency (ms). Suggested change: revert both of those edits and keep only the one-word change field to label on the button. Then expect Latency (sec) in the new test. That removes about 12 changed lines and matches the EEGLAB capture. Porting the supergui capital rule into guifunc/qt.py for all windows would be the shared fix (rule 34), but it touches every dialog, so it belongs in its own issue.

2. Shared renderer change (_width_fitting_weighted_labels). I rendered four dialogs with develop's helper and with this branch's helper (offscreen Qt on a Mac, same specs).

Dialog Result
pop_importepoch every widget x and width identical
pop_chanevent every widget x and width identical
event editor, sample fields Append event 113 to 123 px (caption needs 123), Delete event 109 to 113 px
event editor, long field name field buttons 139 to 263 px, edit boxes 139 to 102 px, all rows still aligned

So the change does what it claims and the other two windows that use fit_weighted_labels do not move. One side effect, not blocking: the navigation row no longer follows its weights exactly. Insert event is 111 px and Append event is 123 px for the same weight 1.2, and the event number box sits 6 px left of the Event Num label above it (centre 334 against 340). The capture shows the unequal buttons. If equal weights matter more than the window width, the alternative is one line: count QPushButton with QLabel and QCheckBox in the existing widening test, so the window grows (about 680 to 740 px with this font) and every column keeps EEGLAB's share. Also a small naming point: the helper is named as a getter and now sets minimum widths.

3. Tests. Local run of the two touched files: 15 passed, 1 deselected. In the new test, the assertion that the three field buttons share one x also passes with develop's helper (x = 194 in both cases), so it does not guard the qt.py change. Only the Append event assertion does (113 < 123 with develop's helper). spec.geometry[-4] == (1,) reads back the tuple the spec just built, and the test name promises a row between fields and navigation that nothing measures. The earlier automated nit is still open: move the test to tests/test_pop_editeventvals.py and replace the tuple check with a rendered gap check, or drop it.

4. Docs. The new paragraph is appended under "Quality Control Checklist" in preprocessing_pipeline.rst, where it does not belong. Move it to the help file src/eegprep/resources/help/pop_editeventvals.md or to a page that describes the editor, or drop it.

5. Parity checked and fine. Geometry [2 0.5], one [1 1 1 1] per field, [1], two rows [1.2 0.6 0.6 1 0.6 0.6 1.2], [2 1 2], with 1 + 7 + 7 + 3 controls, as in pop_editeventvals.m lines 515 to 575. The original text starts blank as on line 575. Removing the hand-set height, margins and row spacing follows rule 26. Units follow EEG.trials.

6. Not from this branch, for #725. No code fills the original text on navigation (EEGLAB writes originally N, lines 197 to 203). EEGLAB centres the text of the edit boxes. position shows 2.0 against 2.

7. CI. macOS failed on tests/test_package_help.py::test_every_public_optional_path_carries_its_marker (pop_mneio marker). That comes from develop commits made after this branch point and the file pop_mneio.py does not exist on this branch, so it is unrelated. Build Documentation and Ruff and ty pass. The Ubuntu and Windows jobs were still pending, so the Windows alignment that #859 is about is not yet confirmed on the final commit.

8. Other open pull requests. Merges cleanly with develop, #846, #848 and #851. #835 and #778 conflict, but both already conflict with develop alone (changelog.rst, qt.py), so this branch is not the cause.

9. What the pull request shows. Capture of EEGLAB, before and after is visible, the Word and PDF reports exist, and no histogram is needed since no numbers change. Missing: a line saying the two other windows were checked (rule 15), a mention of the capital letter difference, and the Mac capture (rule 29, to be added at night).

— orchestrator review

@arnodelorme

Copy link
Copy Markdown
Collaborator Author

Code review

Independent review by Codex (OpenAI, model gpt-6.1-terra), run read-only on commit 1b43573 with the diff against develop. Its text follows unchanged, apart from local file links turned into plain file names.

Overall assessment

Needs changes. The geometry and ordinary captions follow the MATLAB control list, but the original event index is never displayed. The shared sizing change also needs a test for long field names. I could not run the Qt tests because PySide6 is unavailable. GitHub access was unavailable, so I could not verify the live PR head.

Blocking

None.

Important

The original event index remains blank. The changed control at pop_editeventvals.py:146 has no text, and no code updates its original tag. EEGLAB initializes the dialog with goto and displays originally N when the current event’s urevent differs from its position (pop_editeventvals.m:197, line 587). Populate it initially and update it during navigation and event structure edits.

Nits

None.

Test gaps

The Qt test checks visible captions, alignment, spacing, and an unclipped Append button. It would fail on the base version because its captions and row spacing differ. The helper test checks capitalization, but does not establish what the user sees (test_pop_editeventvals.py:371).

Add a GUI test for urevent initially and after navigation. Also test a long field caption: qt.py:1072 sets a button minimum but does not include button widths in its calculated window width. Check that the caption and edit remain usable. The helper also affects the Browse button in pop_importepoch.py:288. The other existing caller, pop_chanevent, has no content push buttons, so this change does not alter its button widths.

EEGLAB parity notes

For ordinary and unusual names, the capitalization rule matches the reference: type becomes Type, TTL becomes Ttl, EventType stays unchanged, STATS stays uppercase, and a single lowercase x stays lowercase. MATLAB passes the field name with units for latency and duration, then supergui transforms it (pop_editeventvals.m:526, supergui.m:387).

The row weights and control order match (Python, MATLAB). The help claim that every field button starts with a capital is therefore inaccurate for x (help:10). The PR also lacks the required matching Sphinx update.


What was done with these findings

The review found nothing blocking. I fixed three of its points in commit c42b8ff. The help page no longer says that every button starts with a capital, since a one-letter field name stays as it is, in EEGLAB too. The matching sentence is now in the Sphinx migration notes (eeglab_migration.rst), which the repository rules ask for. The window test now also checks that a long field caption fits its button and leaves a usable edit box beside it.

I left the blank "original" text. It is true that EEGLAB writes "originally N" there, but no code filled it before this pull request either, and filling it on navigation and after insert, append and delete is new behaviour that belongs in its own small pull request under #725, not in a geometry fix. I also left the navigation row as it is: "Insert event" and "Append event" keep slightly different widths for the same weight, a point of the earlier review that is a design choice and was not part of this request.

The two event editor test files and the shared dialog tests pass on the Mac (26 passed, 2 deselected). No numerical code changed, so no EEGLAB parity run is needed. Codex could not run the Qt tests in its sandbox.

— orchestrator

@arnodelorme

Copy link
Copy Markdown
Collaborator Author

Closed at Arno's request (email of November 29, 2026). Instead of fixing the geometry of pop_editeventvals on the earlier layout, pop_editeventvals will be moved to the new supergui layout merged in #878 with the Edit menu. The work is tracked in #823.

— orchestrator

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_editeventvals: keep field buttons aligned under Windows and with longer event names pop_editeventvals: rebuild the layout from EEGLAB's geometry

1 participant