Skip to content

[EEGBrowser] Complete eegplot parity - #111

Merged
arnodelorme merged 88 commits into
developfrom
feature/eegbrowser-completion
Jun 4, 2026
Merged

arnodelorme merged 88 commits into
developfrom
feature/eegbrowser-completion

Conversation

@suraj-ranganath

Copy link
Copy Markdown
Member

Complete EEGBrowser/eegplot parity on top of the STUDY standalone epic. This is stacked on #93 and should not be reviewed or merged until #93 lands in develop. Adds scrolling browser workflows, marking/rejection, pop_eegplot integration, advanced display modes, ICLabel dashboard parity, docs/help, visual parity evidence, and closeout QA.

Closes #94
Closes #95
Closes #96
Closes #97
Closes #98
Closes #99
Closes #100
Closes #101
Closes #108

Implement STUDY metadata and design workflow
…ion' into phase/6a-admin-help-docs

# Conflicts:
#	src/eegprep/resources/help/pop_loadstudy.md
#	src/eegprep/resources/help/pop_savestudy.md
#	src/eegprep/resources/help/pop_study.md
#	src/eegprep/resources/help/pop_studyerp.md
#	src/eegprep/resources/help/pop_studywizard.md
#	tests/test_menu_placeholder_inventory.py
[Study] Add packaged help and menu docs
Phase 6b: public API and plugin packaging
[STUDY] Implement measure precompute workflows
Phase 5c STUDY component clustering
Phase 6c standalone STUDY integration hardening
@claude

claude Bot commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Claude PR Review in progress

Following the github-pr-review workflow for PR #111 (EEGBrowser/eegplot parity).

  • Load github-pr-review skill instructions
  • Set up branch and read PR diff scope
  • Review high-risk files (EEGBrowser, pop_eegplot, eegplot, ICLabel pop_prop_extended)
  • Review STUDY changes (pop_clust, pop_clustedit, std_precomp, std_preclust, etc.)
  • Review console / session / menu_actions changes
  • Post inline comments for concrete findings
  • Post final summary comment

View job run

@suraj-ranganath

Copy link
Copy Markdown
Member Author

🤖 Detailed EEGBrowser epic summary for PR #111

Stacking note: this PR is stacked on PR #93, [STUDY] Complete standalone integration, because feature/eegbrowser-completion was branched from feature/study-standalone-completion. Please do not review, merge, or treat this PR as independently mergeable until #93 lands in develop; otherwise the diff will include the prior STUDY/standalone epic as well as the EEGBrowser work.

Parent epic: #94, Epic: Complete EEGPrep EEGBrowser and eegplot parity.

Phase map and merged phase PRs:

  1. Phase 1, Phase 1: Browser data model, rendering foundation, and eegplot API #95, PR [EEGBrowser] Implement eegplot browser foundation #102: Browser data model, rendering foundation, and eegplot API. Added the standalone EEGPrep browser model, EEGLAB-compatible option parsing, continuous/epoched/component data normalization, event and winrej state, visible-window state, channel-label/scale/grid state, large-data decimation, conversion helpers, and the first public eegplot surface without runtime dependency on the vendored EEGLAB checkout.

  2. Phase 2, Phase 2: Core browser UI, navigation, menus, and visual shell parity #96, PR Implement EEGBrowser Phase 2 UI shell #104: Core browser UI, navigation, menus, and visual shell parity. Added the Qt/pyqtgraph browser shell with EEGLAB-familiar plot geometry, navigation controls, displayed-channel controls, scale controls, grid/label/event menu behavior, keyboard navigation, and visual parity cases for continuous, epoched, event, labels, and grid states.

  3. Phase 3, Phase 3: Interactive marking, winrej, and rejection conversion parity #97, PR [EEGBrowser] Add marking and rejection callbacks #103: Interactive marking, winrej, and rejection conversion parity. Implemented continuous and epoched mark/unmark behavior, channel-specific mark masks, trial2eegplot, eegplot2event, eegplot2trial, accept/cancel callback semantics, and regression coverage for edge cases like reversed drags, overlapping marks, whole-epoch marks, and failed/cancelled actions.

  4. Phase 4, Phase 4: pop_eegplot menu workflows and session-console integration #98, PR Implement pop_eegplot menu session workflows #105: pop_eegplot menu workflows and session-console integration. Replaced browser placeholders with real pop_eegplot flows for scrolling data, inspecting/rejecting data by eye, component activation browsing, accepted mark propagation, return_com=True, valid command/history strings, EEGPrepSession updates, and mixed GUI plus eegprep-console synchronization.

  5. Phase 5, Phase 5: Browser integration for rejection and cleaning workflows #99, PR [EEGBrowser] Integrate rejection workflows #107: Browser integration for rejection and cleaning workflows. Re-enabled browser-backed rejection paths in existing rejection/selection/cleaning surfaces, including continuous and epoched rejection review flows, rejection mark display, reject-on-close behavior, cancel/no-op behavior, and preservation of existing non-browser behavior when display is off.

  6. Phase 6, Phase 6: Advanced display modes, linked windows, component views, and property flows #100, PR Implement advanced EEGBrowser display modes #106: Advanced display modes, linked windows, component views, and property flows. Added component activity scrolling, data2 before/after overlays, linked child windows, publication/noui-style mode, spectral/frequency-axis mode, eeg_multieegplot, browser-backed component/property workflows, and pop_subcomp browser confirmation support.

  7. Phase 8, Phase 8: Full ICLabel pop_prop_extended dashboard parity #108, PR Phase 8: ICLabel extended properties dashboard #109: Full ICLabel pop_prop_extended dashboard parity. Added the ICLabel extended component-property dashboard, component navigation, event/activity panels, rejection controls, callback/session integration, DIPFIT MRI slice resources packaged for standalone runtime use, and visual evidence for dashboard, DIPFIT MRI, and rejection-control parity. Phase 8 was intentionally done before closeout because it extends the component/property browser surface.

  8. Phase 7, Phase 7: Docs, help, performance, cross-platform QA, and epic closeout #101, PR [EEGBrowser] Complete Phase 7 closeout #110: Docs, help, performance, cross-platform QA, and epic closeout. Removed stale EEGBrowser exclusion language, added EEGPrep-owned browser docs/help, tightened menu placeholder inventory, added large-data decimation smoke coverage, expanded visual parity coverage, ran mixed GUI plus eegprep-console QA, and attached browser visual evidence.

Post-closeout integration fixes on the epic branch:

  1. e077613 Fix EEGBrowser integration test gaps: fixed the MATLAB parity wrapper so nargout is treated as a Python wrapper control instead of a MATLAB argument, and made GUI tests skip cleanly for partial GUI installs missing pyqtgraph.

  2. 923a078 Respect EEGBrowser displayed channel count: fixed an autoreview-found parity bug where the browser drew dispchans + 2 channels even though EEGLAB and the UI requested exactly dispchans; added regression assertions for visible-channel state.

User-facing feature summary:

  • EEGPrep now has a standalone EEGLAB-style scrolling browser for continuous, epoched, component, overlay, and spectral/frequency-style views.
  • Users can scroll, scale, change displayed channels, toggle grids/labels/events, inspect event overlays, and use keyboard/mouse navigation in a UI that stays familiar to EEGLAB users.
  • Users can mark/reject continuous regions, whole epochs, and channel-specific regions with EEGLAB-style winrej semantics.
  • pop_eegplot and browser-backed main-window menu paths now update the shared EEGPrepSession, GUI state, LASTCOM, ALLCOM, and eegprep-console workspace consistently.
  • Rejection and cleaning workflows that previously had browser exclusions now use the browser where appropriate while preserving non-browser programmatic paths.
  • Component browsing, data2 overlays, linked windows, eeg_multieegplot, pop_subcomp confirmation, and ICLabel extended component-property workflows are now implemented as EEGPrep-owned standalone functionality.
  • Browser docs/help are packaged under EEGPrep resources instead of falling back to the vendored EEGLAB checkout.

Integration evidence from the final epic branch:

  • OC autoreview pass 1 found one concrete displayed-channel-count parity bug; fixed in 923a078.
  • OC autoreview pass 2: autoreview clean: no accepted/actionable findings reported.
  • Focused EEGBrowser tests: 88 passed for tests/test_eegplot_gui.py tests/test_eegplot.py tests/test_visual_parity.py.
  • Broader browser integration suite before closeout push: 220 passed across EEGBrowser, rejection workflow, placeholder inventory, public examples, console workspace, and visual registration tests.
  • MATLAB browser conversion parity: tests/test_eegplot.py::test_eegplot_conversion_helpers_match_matlab passed locally with MATLAB Engine available.
  • Lint/type: uv run --no-sync ruff check ., uv run --no-sync ruff format --check ., and uv run --no-sync ty check passed.
  • Full non-slow suite after final fixes: 1576 passed, 203 skipped, 11 deselected with EEGPREP_SKIP_MATLAB=1 uv run --no-sync pytest -m "not slow".
  • Full live EEGBrowser visual parity capture/compare completed for 12 browser cases after rerunning one MATLAB capture timeout with a longer timeout.

Visual evidence:

  • I am attaching the final 12 EEGBrowser side-by-side captures to this PR as GitHub user attachments in a separate comment.
  • Phase 8 ICLabel dashboard visual evidence remains on PR Phase 8: ICLabel extended properties dashboard #109, including the dashboard, DIPFIT MRI slice, and rejection-control side-by-side captures.

@suraj-ranganath

Copy link
Copy Markdown
Member Author

Attachments

🤖 EEGBrowser visual parity side-by-side captures

eegbrowser_component_activity_side_by_side.png eegbrowser_continuous_marked_side_by_side.png
eegbrowser_component_activity_side_by_side.png eegbrowser_continuous_marked_side_by_side.png
eegbrowser_continuous_side_by_side.png eegbrowser_data2_overlay_side_by_side.png
eegbrowser_continuous_side_by_side.png eegbrowser_data2_overlay_side_by_side.png
eegbrowser_epoched_marked_side_by_side.png eegbrowser_epoched_side_by_side.png
eegbrowser_epoched_marked_side_by_side.png eegbrowser_epoched_side_by_side.png
eegbrowser_events_side_by_side.png eegbrowser_grid_off_side_by_side.png
eegbrowser_events_side_by_side.png eegbrowser_grid_off_side_by_side.png
eegbrowser_labels_side_by_side.png eegbrowser_pop_eegplot_reject_data_side_by_side.png
eegbrowser_labels_side_by_side.png eegbrowser_pop_eegplot_reject_data_side_by_side.png
eegbrowser_rejcont_continuous_side_by_side.png eegbrowser_rejection_epochs_side_by_side.png
eegbrowser_rejcont_continuous_side_by_side.png eegbrowser_rejection_epochs_side_by_side.png

@suraj-ranganath
suraj-ranganath marked this pull request as draft June 1, 2026 18:28
@suraj-ranganath

Copy link
Copy Markdown
Member Author

@claude review this

@claude

claude Bot commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @suraj-ranganath's task in 6m 7s —— View job


Claude PR Review — EEGBrowser/eegplot parity (PR #111)

  • Set up branch + read PR diff scope
  • Review browser core (eegbrowser.py, eegplot.py)
  • Review pop_eegplot.py + _eegplot_rejection.py + rejection wrappers
  • Review ICLabel pop_prop_extended.py + property browser (visual code only, no deep audit)
  • Review session / menu_actions / console changes (sampled)
  • Skim STUDY-stacked changes (PR [STUDY] Complete standalone integration #93 is the substantive owner)
  • Post review summary

Scope note

This PR is stacked on #93, so the origin/develop…HEAD diff includes the STUDY/standalone work. I limited the deep review to the EEGBrowser/eegplot surface that is genuinely new in this PR (eegbrowser.py, eegplot.py, pop_eegplot.py, _eegplot_rejection.py, pop_prop_extended.py, the rejection wrappers, and the menu/session glue). Please re-trigger a review after #93 lands and the diff narrows, if you want a fuller pass on STUDY.

The visual parity captures in the comments are convincing for the rendering layer; the findings below are about semantics that the screenshots cannot prove.

Findings

1. pop_eegplot(return_com=True) returns stale EEG without waiting for Accept — high impact

src/eegprep/functions/popfunc/pop_eegplot.py:88-99

if show:
    options["command_callback"] = _accept
...
window = eegplot(EEG, *args, show=show, **options)
command = history_command("pop_eegplot", icacomp, superpose, reject)
return (EEG, command) if return_com else window

eegplot() is opened non-blocking, so pop_eegplot returns immediately. The _accept closure runs only later, inside the Qt event loop, and mutates a local out = copy_eeg(EEG) it then forwards to accept_callback. With return_com=True and no command_callback argument (the normal case for eegprep-console bare calls like pop_eegplot(EEG)), the caller receives the unmodified input EEG plus a history command claiming a rejection was applied — the user's marks have nowhere to flow. EEGLAB's pop_eegplot.m blocks via uiwait so the returned EEG reflects the user's choice.

This breaks the contract that EEGPrepSession relies on (per AGENTS.md) for bare console calls auto-storing via (EEG, com).

Suggested fix: either drive a QEventLoop/uiwait-equivalent until the Accept/Cancel callback resolves and then return the resolved EEG, or document that return_com=True requires command_callback and refuse to return a stale command.

Fix this →

2. trial2eegplot writes 0-based sample ranges — diverges from EEGLAB trial2eegplot.m

src/eegprep/functions/sigprocfunc/eegplot.py:408-434

rows[:, 0] = marked * int(pnts)
rows[:, 1] = (marked + 1) * int(pnts) - 1

The docstring asserts this is what EEGLAB stores ([(trial-1)*pnts, trial*pnts-1]), but EEGLAB's trial2eegplot.m returns 1-based ranges [(trial-1)*pnts+1, trial*pnts]. The internal round-trip with eegplot2trial works (because the ==1, 0 compensation never fires here), but any winrej loaded from a MATLAB session (or saved out for downstream MATLAB processing) is off by 1 at both edges. The legacy rows[rows[:, 0] == 1, 0] = 0 at eegplot.py:470 is now dead code — that's a tell that the convention drifted. Please verify against the vendored trial2eegplot.m and either fix the offsets here or remove the docstring claim and the legacy ==1 compensation.

3. toggle_winrej_at_sample uses strict <, so clicks exactly on the boundary never toggle

src/eegprep/functions/sigprocfunc/eegplot.py:493

if not (float(region.start) < sample_value < float(region.end)):
    continue

add_winrej_region rounds to integer frames; a single-frame mark [s, s+1) is never toggleable by clicking at s or s+1. Use <= on both sides (or at least at start) to match EEGLAB's behavior.

4. _model_options crashes when caller passes spacing=[] (MATLAB "use default")

src/eegprep/functions/sigprocfunc/eegplot.py:629

if options["spacing"] is None or float(options["spacing"]) == 0:

float([]) → TypeError. EEGLAB callers commonly pass [] to mean "use the default", and other places in this file already use _is_empty for that. Replace with options["spacing"] is None or _is_empty(options["spacing"]) or float(options["spacing"]) == 0.

5. Continuous vs epoched mark sample indexing is silently inconsistent

src/eegprep/functions/guifunc/eegbrowser.py:1002-1014

elif self.model.data.epoched:
    sample = int(round(x_value))                            # 0-based
    max_sample = self.model.data.total_samples - 1
else:
    sample = int(round(x_value * float(self.model.state.srate))) + 1   # 1-based
    max_sample = self.model.data.total_samples

The +1 is intentional (continuous winrej is 1-based downstream), but the two branches share _event_sample and feed mark_samples/add_winrej_region/toggle_winrej_at_sample without recording which convention each region was authored in. This is fragile (every future maintainer has to re-derive it) and combines with finding #3 to produce off-by-one toggle behavior at exact integer frame boundaries on continuous data. At minimum, please add a comment explaining the +1 and the asymmetric max_sample clamp.

6. Default spacing factor and epoched limits — EEGLAB parity drift

  • eegplot.py:698/:700 — default spacing is mean(std) * 3.0; EEGLAB's eegplot.m uses a different factor (commonly 5×). Worth verifying against MATLAB and updating either the code or the parity claim in the PR description.
  • eegplot.py:710-713 / browser_window_duration returns trials for epoched, so the x-axis is in epoch units, not epoch-local time in ms. EEGLAB's eegplot.m honors the limits arg for epoched x-axis ticks. The visual parity capture cases pass because both renderings show indices, but a power-user comparing tick labels against MATLAB will see the difference.

7. eegplot2event column convention is internally consistent but not EEGLAB-shaped

src/eegprep/functions/sigprocfunc/eegplot.py:447-451

events[:, 0] = float(event_type)
events[:, 1] = 1.0
events[:, 2:4] = np.rint(rows[:, 0:2])

This codebase's eeg_eegrej (src/eegprep/functions/popfunc/eeg_eegrej.py:296-303) explicitly reads cols 2:4 as [beg, end], so the round-trip inside eegprep works. EEGLAB's eegplot2event.m packs [type 0 latency duration r g b] (col 1 = 0, col 3 = latency, col 4 = duration). This is fine for internal use, but please add a comment noting the deliberate column-layout divergence so anyone exporting these rows back to MATLAB doesn't mis-feed them to EEGLAB's eeg_eegrej.

8. pop_eegplot raises _require_ica for component browsing of empty datasets, but silently returns None for empty data-channel browsing

pop_eegplot.py:55-60 returns (None, "") for EEG is None but later raises for missing ICA. EEGLAB's pop_eegplot.m errors on empty datasets. Minor; pick one behavior.

Not findings, just observations

  • No runtime imports of src/eegprep/eeglab/ in any of the audited modules. ✅
  • The visual parity registration loop and 12 attached side-by-side captures are convincing for the render path.
  • _eegplot_rejection.py color-filter family routing is OK at current DEFAULT_REJECTION_COLORS precision (2-decimal rounding doesn't collide); just noting that future custom palettes could collide.
  • ICLabel pop_prop_extended.py is 1376 lines and I only skimmed it. The pop_viewprops refactor looks clean. Worth a dedicated review pass given its size; I'd want to verify component navigation, the rejection toggle, and DIPFIT MRI slicing against EEGLAB before signing off — but those are out of scope for a generalist PR review at this size.

Suggested priority for fixes before merge

  1. Finding 1 (return_com semantics) — directly impacts the EEGPrepSession console contract called out in AGENTS.md.
  2. Finding 2 (trial2eegplot offset) — silent MATLAB interop break.
  3. Findings 3, 4, 5 — small, localized, but real bugs.
  4. Findings 6, 7 — parity polish; can be follow-ups.

Testing notes

I did not run the test suite for this review — read-only audit per the trigger comment. The PR description reports 1576 passed/203 skipped under EEGPREP_SKIP_MATLAB=1 pytest -m "not slow" and 88 passed for the focused EEGBrowser tests; if those numbers still hold after addressing findings 1–5, that's a good baseline. I'd recommend adding a regression test for finding 1 that calls pop_eegplot(EEG, return_com=True) programmatically and asserts the returned EEG reflects an Accept that the test drove via command_callback.
| branch: feature/eegbrowser-completion

@suraj-ranganath
suraj-ranganath marked this pull request as ready for review June 2, 2026 09:26
@claude

claude Bot commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @suraj-ranganath's task in 4m 55s —— View job


Claude PR Review — EEGBrowser/eegplot parity (PR #111)

  • Set up branch and read PR scope
  • Identify high-risk EEGBrowser/eegplot surface
  • Verify candidate findings against current code
  • Validate findings for false positives
  • Post inline comments for validated issues
  • Post final summary review

Code review

  • Overall assessment: needs changes (small, localized)
  • Highest-risk area: pop_eegplot return contract under return_com=True
  • Merge recommendation: address Finding 1 or document the constraint; the other two are localized polish

Scope note: this PR is stacked on #93 so origin/develop…HEAD includes STUDY work. I limited deep review to the EEGBrowser/eegplot surface that is genuinely new here (eegbrowser.py, eegplot.py, pop_eegplot.py, the rejection wrappers, _event_sample plumbing). The 12 attached side-by-side captures are convincing for the render path; the findings below are semantic issues a screenshot cannot prove.

I did re-verify the previously-flagged candidate findings against the current branch SHA a8abadd and dropped four where I could not confirm them with high confidence (notes in "Not flagged" below).

Blocking

None.

Important

  • pop_eegplot(return_com=True) returns the unmodified input EEG plus a misleading history command. open_eegbrowser is non-blocking (eegbrowser.py:114-121); the _accept closure in pop_eegplot.py:76-86 runs later inside the Qt event loop and forwards the modified EEG only via accept_callback. The console flow works only because ConsolePopFunction.__call__ injects a command_callback (adminfunc/console.py:169-185); any non-console programmatic caller using return_com=True gets (EEG_input, "EEG = pop_eegplot(...)") — history claims a rejection ran on data that was never touched. Fix: either block on Accept/Cancel via a nested QEventLoop and return the resolved EEG, or refuse return_com=True without command_callback and document apply_eegplot_rejections as the programmatic API. Inline comment posted.

  • _model_options crashes when spacing=[] (eegplot.py:629). float([]) raises TypeError. The rest of this file accepts [] as "use default" via _is_empty(...) for command, data2, etc.; spacing is the odd one out and the EEGLAB convention is to pass [] for defaults. One-line fix using the existing _is_empty helper. Inline comment posted.

Nits

  • _event_sample (eegbrowser.py:1002-1014) silently mixes 1-based continuous (+ 1, clamp to total_samples) and 0-based epoched (clamp to total_samples - 1) sample conventions, then passes the bare int into mark_samples/add_winrej_region/toggle_winrej_at_sample. The asymmetry is intentional (continuous winrej → eeg_eegrej is 1-based; epoched winrej → trial2eegplot is 0-based) but undocumented. Add a one-line comment to each branch explaining the convention. Inline comment posted.

Test gaps

  • No regression test exercises pop_eegplot(EEG, return_com=True) end-to-end (drive Accept via callback and verify the returned tuple's EEG actually reflects the modification). Adding one would lock down the contract before/after the Finding 1 fix.

EEGLAB parity notes

  • Default spacing factor (eegplot.py:698/:700) uses mean(stds)*3.0, which matches eegplot.m's mean(sig(...))*3. (Re-checked against EEGLAB; the prior review's "5" claim looks incorrect — not flagging.)
  • eegplot2event packs [type 1 latency_start latency_end r g b] (eegplot.py:447-451) while EEGLAB's eegplot2event.m uses [type 0 latency duration r g b]. The round-trip is internally consistent with this codebase's eeg_eegrej (eeg_eegrej.py:296-303 reads cols 2:4 as [beg end]), so it is not a correctness bug today, but anyone exporting these rows back to MATLAB will mis-feed them. A short comment on eegplot2event noting the deliberate column-layout divergence would prevent future confusion.

Not flagged (verified down from prior candidate list)

  • trial2eegplot 0-based vs EEGLAB 1-based: the MATLAB parity test test_eegplot_conversion_helpers_match_matlab asserts assert_allclose(rows, matlab_rows) (tests/test_eegplot.py:256) and PR notes report it passing locally with MATLAB Engine, so I cannot confirm a divergence without violating the skill's "no web fetch" rule.
  • toggle_winrej_at_sample strict <: edge case only at exact integer-frame boundaries; existing tests pass and practical click coordinates are floats unlikely to land precisely on boundaries.
  • pop_eegplot empty-EEG return vs raise asymmetry: cosmetic.

Checked: EEGBrowser rendering/marking surface, pop_eegplot flow, _eegplot_rejection.py, pop_rejcont browser path, eeg_multieegplot, DIPFIT MRI slice helper, session/console glue. Did not deeply audit pop_prop_extended.py (1376 lines) or the STUDY-stacked changes — those are best reviewed against #93 once the diff narrows.
| branch: feature/eegbrowser-completion

@suraj-ranganath

Copy link
Copy Markdown
Member Author

@claude review this

@claude

claude Bot commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @suraj-ranganath's task in 4m 46s —— View job


Claude PR Review — EEGBrowser/eegplot parity (PR #111)

  • Set up branch and confirm scope
  • Re-check prior findings (return_com contract, spacing=[] crash, _event_sample comment)
  • Audit new/changed surface that prior passes flagged but did not deep-review
  • Spot-check pop_prop_extended.py (deferred in earlier pass)
  • Spot-check rejection-wrapper browser hooks (_eegplot_rejection.py, pop_rejcont)
  • Spot-check STUDY changes only for cross-cutting risks
  • Post final review

Code review

  • Overall assessment: looks good to merge (after [STUDY] Complete standalone integration #93 lands; this PR is stacked)
  • Merge recommendation: approve — all earlier important findings are resolved
  • Reviewed @ commit c18bb02 against earlier review SHA a8abadd

Scope note: this PR is stacked on #93 so origin/develop…HEAD still contains 561 commits / STUDY work. I limited this pass to verifying the three fix-commits made since my previous review (0cbfc65, a746558, c18bb02) and spot-checking adjacent integration points.

Verification of previously-flagged findings

All three "important/nit" findings from the prior review pass were addressed in the new commits. I verified each fix against the current code on this branch:

✅ Finding 1 — pop_eegplot(return_com=True) stale-EEG contract (was important)

src/eegprep/functions/popfunc/pop_eegplot.py:88-105 now:

  • Raises ValueError when return_com=True + show=True + no command_callback. Tested in test_pop_eegplot_return_com_requires_callback_for_nonblocking_browser.
  • Returns (None, command) when a callback is supplied — explicitly signaling "result is deferred; consume via callback." Tested in test_pop_eegplot_return_com_with_callback_does_not_return_stale_eeg.

src/eegprep/functions/adminfunc/console.py:209-213 paired matching logic to the console wrapper: when _eeg is None and command, the workspace adds history once via add_history(command) and returns ConsolePopResult(session.EEG, command, updated=False) ("no EEG change"). The accept callback later mutates state via _store_eeg and uses the recorded_commands dedupe to avoid double-history. test_console_pop_eegplot_accept_callback_refreshes_session_after_browser_accept exercises both branches and asserts session.ALLCOM == [command] (single entry) and refresh.assert_called_once() (sane refresh cadence).

Cross-verified that all in-tree callers behave correctly with the new contract:

  • src/eegprep/functions/guifunc/menu_actions.py:1049-1062 already passes command_callback=accept_eegplot and extracts out[1] for history. ✅
  • src/eegprep/functions/guifunc/qt.py:774-780 calls without return_com=True. ✅
  • src/eegprep/functions/popfunc/pop_rejmenu.py:91 is a matlab_callback string (not a Python call). ✅

✅ Finding 2 — _event_sample indexing-convention comments (was nit)

src/eegprep/functions/guifunc/eegbrowser.py:1009,1013 now has the convention comments on both branches:

# 0-based: epoched winrej rows follow trial2eegplot sample offsets.
# 1-based: continuous winrej rows feed eeg_eegrej latency ranges.

✅ Finding 3 — _model_options crash on spacing=[] (was important)

src/eegprep/functions/sigprocfunc/eegplot.py:633 now treats [] as "use default" via the existing _is_empty(...) helper, consistent with other option handling in this module. test_empty_spacing_uses_eeglab_default_spacing exercises the path.

✅ Finding 4 — eegplot2event row layout (was parity note)

Docstring at src/eegprep/functions/sigprocfunc/eegplot.py:443-447 now explicitly documents the deliberate divergence from MATLAB's eegplot2event.m:

"EEGPrep stores start/end latencies in columns 2:4 for direct consumption by its eeg_eegrej port. EEGLAB's MATLAB helper uses latency/duration there."

New, small changes since last review

toggle_winrej_at_sample: strict < → <= at both ends

src/eegprep/functions/sigprocfunc/eegplot.py:497. Verified safety against region merge behavior:

  • _merge_continuous_regions (eegplot.py:889-905) merges any regions where the new region's start <= merged[-1].end, so two regions cannot share an exact boundary in normal flow. A boundary click cannot accidentally toggle two regions.
  • _add_epoched_winrej (eegplot.py:848-886) uses [epoch*pnts, (epoch+1)*pnts-1] so adjacent epochs have a 1-sample gap. Also safe.
  • Test test_single_click_toggles_marks_at_region_boundaries locks down the new boundary behavior.

pop_eegplot(EEG=None): (None, "") → raises ValueError

pop_eegplot.py:55-56. Behavior change in the right direction. Grepped for callers: only tests/test_eegplot.py:326 (the new regression test) passes None. ✅

Items intentionally not re-flagged

  • trial2eegplot 0-based offsets: I could not independently verify divergence from EEGLAB's trial2eegplot.m. The MATLAB parity test test_eegplot_conversion_helpers_match_matlab (tests/test_eegplot.py:256) asserts assert_allclose(rows, matlab_rows), which the PR description reports passing locally with MATLAB Engine. Trust the parity test.
  • Default spacing factor (*3.0): matches EEGLAB eegplot.m's mean(sig(...))*3. Re-verified in the previous pass.
  • pop_prop_extended.py (1376 lines): not deep-audited (out of scope for a generalist re-review at this size). Visual evidence on PR Phase 8: ICLabel extended properties dashboard #109 covers the dashboard/DIPFIT/rejection paths. If you want me to do a dedicated audit, ping me.

CI

Tests run is still in progress at review time (id 26812010882); Documentation Build passed. The PR description reports 1576 passed, 203 skipped, 11 deselected under EEGPREP_SKIP_MATLAB=1 pytest -m "not slow" on the previous SHA. The three new commits add four new tests and tighten one assertion; they exercise small targeted code paths and should not regress the prior baseline.

Summary

All previously-flagged important findings are resolved with code changes that are minimal, on-style, and accompanied by regression tests. Nothing new to flag. Once #93 lands and origin/develop…HEAD narrows to the genuinely-new EEGBrowser surface, this PR is in good shape to merge.
| branch: feature/eegbrowser-completion

@arnodelorme

Copy link
Copy Markdown
Collaborator

@claude claude Bot mentioned this pull request Jun 4, 2026
@arnodelorme
arnodelorme merged commit a9e6125 into develop Jun 4, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment