Repository navigation
Closed
Labels
phaseEpic implementation phase
Description
🤖 Phase 3 for the EEGBrowser epic. Target branch: feature/eegbrowser-completion.
Dependency
Start after Phase 1 merges. This can run in parallel with Phase 2, then integrate after Phase 2.
Goal
Implement the user interaction and rejection semantics that make EEGBrowser useful for visual marking and rejection.
Implementation scope
- Mouse drag/click marking and unmarking for continuous data and epoched data.
- Channel/electrode-specific marks in the
winrejtrailing columns. - Color handling for new, old, and superposed marks.
- Python ports of
trial2eegplot,eegplot2event, andeegplot2trial. - Command callback contract for accepting/rejecting marked regions.
- Session-safe cancel/failure behavior.
Acceptance criteria
- Marking behavior matches EEGLAB for continuous regions, whole epochs, reversed drags, duplicate marks, overlapping marks, single-click unmarking, and channel-specific toggles.
- Conversion helpers have MATLAB parity tests.
- Rejected continuous regions flow through
eeg_eegrejwith correct event/urevent/boundary semantics. - Failed/cancelled browser actions do not mutate session or history.
- No runtime code depends on
src/eegprep/eeglab.
Tests and evidence
- Unit tests for
winrej,trial2eegplot,eegplot2event, andeegplot2trialedge cases. - MATLAB parity tests for deterministic helper conversions.
- GUI interaction tests for marking/unmarking and accept/cancel.
- Console/session history tests for accept/reject/cancel paths.
uv run --no-sync ruff check .uv run --no-sync ruff format --check .uv run --no-sync ty check- Focused pytest for changed tests.
/goal prompt
/goal Implement interactive EEGBrowser marking and rejection conversion from this issue. Port winrej, trial2eegplot, eegplot2event, and eegplot2trial semantics from EEGLAB, including continuous/epoched/channel-specific marks and superposed colors. Verify with MATLAB parity tests, sample_data, GUI interaction tests, console/session history tests, ruff/format/ty, and focused pytest.
Required references for every phase
AGENTS.md.agents/skills/eegprep-feature-development/SKILL.md.agents/skills/eeglab-gui-visual-parity/SKILL.mdfor GUI features.agents/skills/gui-agent-flow-qa/SKILL.mdfor end-user flow QA- EEGLAB reference under
src/eegprep/eeglab, used only as development/parity input.
Core EEGLAB references
src/eegprep/eeglab/functions/sigprocfunc/eegplot.msrc/eegprep/eeglab/functions/sigprocfunc/eegplotlegacy.msrc/eegprep/eeglab/functions/sigprocfunc/eegplot2event.msrc/eegprep/eeglab/functions/sigprocfunc/eegplot2trial.msrc/eegprep/eeglab/functions/sigprocfunc/trial2eegplot.msrc/eegprep/eeglab/functions/popfunc/pop_eegplot.msrc/eegprep/eeglab/functions/popfunc/eeg_rejmacro.msrc/eegprep/eeglab/functions/popfunc/eeg_multieegplot.m
Metadata
Metadata
Assignees
Labels
phaseEpic implementation phase
Activity
claude commentedon May 31, 2026
🤖 Plan:
Research
Scope is large (>100 LOC, multi-module:
sigprocfunc,popfunc,guifunc, session/history, MATLAB parity fixtures). Per repo policy I am posting analysis instead of a PR.Blocking dependency. Issue explicitly says "Start after Phase 1 merges". Phase 1 (#95) is still open; the foundation this issue builds on does not exist yet:
eegplot(...)APIwinrejdata modelEEGBrowserwindowsrc/eegprep/functions/sigprocfunc/has noeegplot.pysrc/eegprep/functions/guifunc/has no browser widgetpop_eegplotis intentionally a placeholder withexcluded_reason=\"eegbrowser\"EEGLAB references not vendored locally.
src/eegprep/eeglab/functions/sigprocfunc/is absent in this checkout, so MATLAB ports must be performed againstsccn/eeglabupstream (eegplot.m,eegplot2event.m,eegplot2trial.m,trial2eegplot.m,eeg_rejmacro.m,eeg_multieegplot.m,pop_eegplot.m).Relevant existing code (anchor points for Phase 3, not yet wired to a browser):
src/eegprep/functions/popfunc/eeg_eegrej.py#L272-L319— already accepts 4-column eegplot-style[ch_low ch_high beg end]rows and discards channel cols; this is the downstream sink Phase 3 must feed.src/eegprep/functions/popfunc/eeg_rejsuperpose.py#L12-L77— combines rejection mark families intoEEG.reject.rejglobal/rejglobalE; superposed color logic must agree with this.src/eegprep/functions/popfunc/_rejection.py(406 LOC) — sharedcopy_eeg, mark bookkeeping; reuse, do not duplicate.src/eegprep/functions/guifunc/menu_placeholders.py#L39,L64—pop_eegplotplaceholder + EEGBrowser exclusion message; remove/replace once browser lands.src/eegprep/functions/popfunc/pop_rejmenu.py#L264andsrc/eegprep/plugins/ICLabel/pop_viewprops.py#L99-L100— user-facing strings that disclaim missing browser; update when Phase 3 unblocks them.Proposed Approach (for human review before implementation)
This is a design-change scope, not a bug fix. Recommend gating implementation on Phase 1 merge and splitting Phase 3 into three commits on
feature/eegbrowser-completion:Pure helper ports (no Qt, fully unit-testable). Add to
functions/sigprocfunc/:eegplot2event.py— port ofeegplot2event.m. Convertwinrej(N×(5+nch) —[beg end r g b ch1..chN]) to EEG event rows withtype='rejN', latency=beg, duration=end-beg+1, channel mask in trailing fields. 1-based MATLAB latencies preserved at the EEG-event boundary.eegplot2trial.py— port ofeegplot2trial.m. Convert continuouswinrejrows into per-trial reject vectors usingsrateandpnts.trial2eegplot.py— inverse ofeegplot2trial; buildwinrejrows from per-trial / per-channel mark matrices.tests/matlab/(skipped without MATLAB/Octave viaeeglabcompat), plus pure-Python edge cases (empty, reversed, overlapping, duplicate, channel-specific, boundary-of-window).Interactive marking on the browser widget (
functions/guifunc/eegbrowser.pyfrom Phase 1):ch1..chNcols ofwinrej).pop_*caller, old-marks color fromEEG.reject.rej*color, superposed color via blend matchingeeg_rejmacro.m. Constants at module top.eegplot.mexactly (cross-checked via the helper ports above so logic isn't duplicated).QTestmouse events on a headlessQApplication; assertwinrejstate, not pixel state.Command callback contract & session safety:
pop_*callers pass a callback string (EEGLAB'command'arg). Accept → run callback with currentwinrejmaterialized into globals expected byeeg_rejmacro(TMPREJ, etc.) — in Python, materialize as kwargs intoeeg_eegrej/eeg_rejsuperpose/pop_rejepochdepending on caller.EEGPrepSession(EEG,ALLEEG,CURRENTSET,LASTCOM,ALLCOM). Exception in callback → restore pre-action snapshot, leaveLASTCOMuntouched, surface the error.tests/test_console_workspace.pygets accept/cancel/error coverage per AGENTS.mdGUI And Console Workspacesection.Open questions for the issue author before any code lands:
phase/3-interactive-marking) offfeature/eegbrowser-completion, opened as draft until Phase 1 merges? Or wait entirely?.notes/implementation-notes.html?eeg_rejmacroin MATLAB relies onevalin('base', ...)globals. The Python equivalent presumably routes throughEEGPrepSessionrather than re-implementing a global namespace dance — confirm?winrej[:, 5:]columns and theelectrodesfield surface ineegplot, but who owns rendering them as colored row segments — Phase 2 or Phase 3?Stopping here pending Phase 1 merge and answers to the above.