Skip to content

[GUI] Match the pop_rejtrend dialog to EEGLAB - #911

Merged
arnodelorme merged 3 commits into
developfrom
agent/20261201-fix-910
Dec 1, 2026
Merged

arnodelorme merged 3 commits into
developfrom
agent/20261201-fix-910

Conversation

@claude

@claude claude Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Draw the linear trend rejection dialog with the supergui layout and the geometry, labels and blank checkbox strings of pop_rejtrend.m, so rows sit as close as in EEGLAB and the slope unit and R-square example appear. EEGLAB swaps the slope units between the data and component dialogs; the port copies that literally. GUI only, no numerical change.

Fixes #910

🤖 Generated with Claude Code

Use the supergui layout, EEGLAB's blank geometry row, the full slope and
R-square labels, and blank checkbox strings from pop_rejtrend.m.

Fixes #910

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor Author

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 Author

Claude finished @claude[bot]'s task in 51s —— View job


Code review

  • Overall assessment: The layout part is correct. The supergui switch, geometry, " " checkbox strings and R-square example match the pattern already used by pop_eegthresh and pop_rejspec. One label choice needs a maintainer decision before merge.
  • Highest-risk area: the slope-unit label at pop_rejtrend.py:90-91.
  • Merge recommendation: Needs changes, or an explicit maintainer decision to keep EEGLAB's swapped label.

Blocking

None.

Important

  • pop_rejtrend_dialog_spec copies EEGLAB's swapped slope unit, so the data dialog shows the wrong unit (src/eegprep/functions/popfunc/pop_rejtrend.py:90-91). trend_marks (_rejection.py:218-226) fits slopes to the raw rows and never normalizes them. For channel data, maxslope is in µV per window, yet the dialog now says "std. dev./epoch". A user who sets the threshold from that label would use the wrong scale. The review standard asks EEGPrep to do the correct thing where EEGLAB has a bug, document the difference and lock it with a test. Copying the bug literally goes against that.
    • Fix: use "uV/epoch" if is_data else "std. dev./epoch". Update the changelog entry and the parametrized test, and add a note to resources/help/pop_rejtrend.md.
    • If you keep the literal copy for screenshot parity: at least state the real unit in the help file. Details are in the inline comment.

Nits

None.

Test gaps

None. The new parametrized test covers the geometry, layout and shown strings for both the data and component variants.

EEGLAB parity notes

  • The vendored src/eegprep/eeglab/ checkout is not in this CI checkout. I could not open pop_rejtrend.m to confirm the "line 118" citation or the exact strings, so I checked them for consistency against the sibling rejection dialogs instead.
  • GUI-only change. Nothing in the processing path changed, so no MATLAB reference run is needed.

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

Comment on lines +90 to +91
# pop_rejtrend.m line 118 swaps the units of its fastif: data shows std. dev., components show uV.
slope_unit = "std. dev./epoch" if is_data else "uV/epoch"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Important (needs a maintainer decision): this copies a wrong unit label from EEGLAB into the data dialog.

trend_marks fits slopes to the raw rows and never normalizes them (

for row_index in selected:
windows = np.stack([data[row_index, start : start + winsize, :].T for start in starts], axis=1)
means = np.mean(windows, axis=2, keepdims=True)
slopes = np.tensordot(windows - means, x_centered, axes=([2], [0])) / x_denom
intercepts = means[:, :, 0] - slopes * float(np.mean(x))
fitted = slopes[:, :, np.newaxis] * x + intercepts[:, :, np.newaxis]
sst = np.maximum(np.sum((windows - means) ** 2, axis=2), tolerance)
sse = np.sum((windows - fitted) ** 2, axis=2)
row_marks[row_index, :] = ((np.abs(slopes) >= maxslope) & (1 - sse / sst > min_r)).any(axis=1)
). For channel data, maxslope is therefore in µV per window. A researcher who reads "std. dev./epoch" would pick a threshold on the wrong scale. The review standard says EEGPrep does the correct thing where EEGLAB has a bug, documents the difference and locks it with a test. A literal copy goes against that.

Suggested fix: show the true unit, "uV/epoch" if is_data else "std. dev./epoch" (or just drop the unit from the component label). Then update the changelog entry and the parametrized test, and add a line to resources/help/pop_rejtrend.md saying EEGPrep fixes EEGLAB's swapped label. If the maintainers would rather keep the literal copy for screenshot parity, a short note in the help file would at least tell users the real unit.

# Conflicts:
#	docs/source/changelog.rst
#	src/eegprep/functions/popfunc/pop_rejtrend.py
@arnodelorme

Copy link
Copy Markdown
Collaborator

🤖 Second round on the review above (commit cd698135). The branch now includes develop.

  • The slope label keeps EEGLAB's wording, and the help now states the real unit. EEGLAB's pop_rejtrend.m line 118 is fastif(icacomp, '... (std. dev./epoch)', '... (uV/epoch)'), so its data dialog reads "std. dev./epoch" although its own help says the opposite. Develop already draws this literal label, and the recorded MATLAB case compares it. resources/help/pop_rejtrend.md now says that the threshold is in data units (µV) per window for channels and in activation units per window for components, and that the label follows EEGLAB's swapped wording.
  • Open for Arno: whether EEGPrep should show the correct unit and differ from EEGLAB's label (the recorded case would then need an exception), and whether the swap should be fixed in EEGLAB.
  • What is left of this pull request: the dialog code is identical to develop's. It adds the help note, the changelog line and the test of the shown strings.

@arnodelorme arnodelorme left a comment

Copy link
Copy Markdown
Collaborator

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: Safe to merge. PR #927 (8e2a9db3) already landed the pop_rejtrend_dialog_spec changes on develop, and the remaining changelog.rst and pop_rejtrend.md additions in this branch are accurate, with one optional duplicate test nit.
  • Highest-risk area: Slope unit explanation in src/eegprep/resources/help/pop_rejtrend.md.
  • Merge recommendation: Safe to merge.

Blocking

None.

Important

None.

Nits

  • Duplicate dialog spec test in tests/test_stream6_rejection_numbers.py (test_pop_rejtrend_dialog_matches_eeglab_uilist, lines 777 to 806): After merging origin/develop (c263758b), src/eegprep/functions/popfunc/pop_rejtrend.py has no diff against develop because PR #927 (8e2a9db3) already updated pop_rejtrend_dialog_spec and added pop_rejtrend and pop_rejtrend.ica to tests/test_gui_geometry.py. test_pop_dialog_has_the_geometry_eeglab_passes_to_inputgui already checks layout, geometry, title, help_text, and every control style, string, and default value on eeglab_data_epochs_ica.set against the recorded MATLAB uilist files (tools/gui_geometry/cases/pop_rejtrend.json and pop_rejtrend.ica.json). Keeping a second hardcoded copy of those control strings in tests/test_stream6_rejection_numbers.py duplicates that coverage (AGENTS.md, Testing: only add a test that catches a real bug existing tests miss).
    Suggested fix: Remove the pop_rejtrend_dialog_spec import and test_pop_rejtrend_dialog_matches_eeglab_uilist from tests/test_stream6_rejection_numbers.py so this PR carries only the docs/source/changelog.rst entry and src/eegprep/resources/help/pop_rejtrend.md unit note missing from #927, or merge as is if the extra unit test is wanted.

Test gaps

None.

EEGLAB parity notes

  • Slope unit note verified: Checked src/eegprep/resources/help/pop_rejtrend.md and docs/source/changelog.rst against pop_rejtrend.m (header lines 15 to 18 vs fastif at line 118), rejtrend.m (lines 76 to 83), and src/eegprep/functions/popfunc/_rejection.py (trend_marks, lines 219 to 232). Because rejtrend fits against linspace(1 / winsize, 1, winsize) on unnormalized channel rows (µV) or raw ICA activations, maxslope is in data units (µV) per window of winsize points for channels and component activation units per window for ICA, while the dialog keeps EEGLAB's swapped uilist strings for GUI geometry parity.
  • No numerical change: The diff against develop touches only documentation, help text, and tests, so no MATLAB reference run is needed.

Tests run: Ran .venv/bin/python -m pytest tests/test_stream6_rejection_numbers.py tests/test_guifunc_pophelp_chansel.py tests/test_gui_geometry.py -k "not layout_places_controls or rejtrend" on commit cd6981351316e9a2520a8cb1bcd40fd5355dd7be in a detached worktree: 120 passed, 67 skipped (Linux MATLAB reference pixel checks on macOS), 74 deselected in 15.04s.

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.

[GUI] Match the pop_rejtrend dialog to EEGLAB

1 participant