Repository navigation
Closed
Labels
phaseEpic implementation phase
Description
🤖 Phase 1 for the EEGBrowser epic. Target branch: feature/eegbrowser-completion.
Goal
Build the standalone browser foundation under EEGPrep conventions. This phase defines the shared data model, state model, rendering foundation, and public eegplot(...) API used by later phases.
Implementation scope
- Add the Python
eegplot(...)surface in the locally appropriate split betweenfunctions/sigprocfuncandfunctions/guifunc. - Add data normalization for continuous, epoched, component, spectral, and overlay inputs.
- Add
winrejdata model support, visible-window state, event overlay state, scaling state, channel-label state, and decimation for large datasets. - Use PySide6/QPainter or Qt-native painting first; do not add a rendering dependency unless implementation proves Qt-native rendering cannot meet responsiveness requirements.
- Add packaged help resource
src/eegprep/resources/help/eegplot.md. - Maintain
.notes/implementation-notes.htmlwith parity decisions and open questions.
Acceptance criteria
eegplot(data, key=value, ...)accepts EEGLAB-compatible core options:srate,spacing,limits,winlength,time,dispchans,title,plottitle,xgrid,ygrid,data2,winrej,events,submean,eloc_file,scale, andcolor.- Basic viewer opens without mutating EEG data.
- Headless tests cover option parsing, data normalization, window bounds, event/time conversion, and decimation.
- GUI tests verify a nonblank rendered browser with
sample_data/eeglab_data.set. - No runtime code depends on
src/eegprep/eeglab.
Tests and evidence
- Focused unit tests for model/state/parsing helpers.
- GUI smoke tests for nonblank render and no mutation.
- Sample-data test using
sample_data/eeglab_data.set. 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 the EEGPrep EEGBrowser/eegplot foundation from this issue, using EEGLAB eegplot.m/eegplotlegacy.m as parity references. Build the data model, rendering foundation, and public eegplot API without runtime EEGLAB dependency. Verify with unit tests, GUI smoke tests, sample_data, ruff/format/ty, and focused pytest. Maintain .notes/implementation-notes.html with parity decisions and open questions.
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:
Scope decision. This is the Phase-1 foundation for an entire scrolling-browser subsystem (data model + Qt renderer + public API + parsing + tests + help). The sibling merged phases (#68, #74, #75, etc.) each added 1k–10k LOC. Per the agent instructions, anything >100 LOC gets an analysis comment, not a drive-by PR. No open PR targets
feature/eegbrowser-completionfor browser work yet — that branch currently only carries STUDY work from #93. Sibling phases #96–#101 depend on this one.Research
EEGPrep currently has no
eegplotPython surface.pop_eegplotis registered as a permanent placeholder withexcluded_reason=\"eegbrowser\"(src/eegprep/functions/guifunc/menu_placeholders.py#L39), andplaceholder_messageemits an EEGLAB-style "outside parity scope" string (#L62-L66). That exclusion must be lifted as part of this phase so menu actions can route to the new viewer instead of the coming-soon dialog.The vendored EEGLAB tree at `src/eegprep/eeglab/` is empty in this checkout (it is a submodule populated by contributors, not by CI). The issue's reference list (`eegplot.m`, `eegplotlegacy.m`, `pop_eegplot.m`, `eeg_rejmacro.m`, `eeg_multieegplot.m`, `eegplot2event.m`, `eegplot2trial.m`, `trial2eegplot.m`) is therefore a parity oracle the implementer must check out locally; AGENTS.md forbids the runtime package from depending on it (see AGENTS.md §EEGLAB Parity).
Relevant code
src/eegprep/functions/guifunc/menu_placeholders.py#L39-L66— placeholder + "eegbrowser" exclusion to unwiresrc/eegprep/functions/sigprocfunc/— target dir foreegplot.pycore (parallel totopoplot.py,erpimage.py)src/eegprep/functions/guifunc/qt.pyandspec.py— existing PySide6 infrastructure to reuse for the window/painter widgetsrc/eegprep/functions/popfunc/eeg_eegrej.py— existingwinrej-shaped rejection-region applier; defines the row schema this phase must producesample_data/eeglab_data.set— required dataset for the GUI smoke test in the acceptance criteriaProposed Approach
This is a design-change comment (feature port), not a bug fix. Splitting Phase 1 along the structural boundary called out in the issue:
1. Package layout. Two new modules — keep public API in
sigprocfunc, keep Qt widgets inguifunc, mirroring howtopoplot.py(compute) lives next to its Qt host.src/eegprep/functions/sigprocfunc/eegplot.py— argument parser, data normalizer, state object, decimation, and the publiceegplot(data, **kwargs)entry that constructs and shows the viewer.src/eegprep/functions/guifunc/eegbrowser.py(new) —EEGBrowserWindow(QMainWindow) +EEGBrowserCanvas(QWidget withpaintEventdoing the trace draw). No matplotlib, no pyqtgraph in Phase 1.2. Data model. Single immutable
BrowserDatadataclass that normalizes the five input modes into channel-major(nchan, npts, ntrials)withntrials=1for continuous:(nchan, npts)→ trials=1(nchan, npts, ntrials)→ passed throughicaact/icawinvand tagged so axis labels switch to "Comp N"data2with shared time/x-griddata2) — same shape constraints as primaryReject (a) jagged inputs, (b)
nbchanmismatch witheloc_file, (c)winrejrows whose[start,end]lie outside[0, pnts*trials]. Fail fast withValueError, no silent reshape.3. State. Mutable
BrowserStatedataclass holdingsrate,spacing,winlength,time(window-start sec),dispchans,xgrid,ygrid,submean,scale, color theme, currentwinrejlist, and theeventsoverlay table. Time↔sample conversion goes through one helper (time_to_sample(state, t) -> int) so MATLAB 1-based latency boundaries are handled in exactly one place — covered by a dedicated test forxmin,xmin+1/srate, and the last sample.4. Rendering. QPainter-based draw in
paintEvent:QPainterPathof(x_px, y_px)pairs. Per-channel offset =(idx - dispchans/2) * spacing.pnts_in_window > widget_width_px * 2, downsample by min/max pair per pixel column (the standard responsiveness pattern; matches EEGLAB's redraw cadence). Threshold lives as a single top-level constant.QRectFtable for later phases.winrejrectangles: translucent fill behind traces, color taken from row columns 3-5 like EEGLAB.5. Public API.
eegplot(data, *, srate=1, spacing=None, limits=(0,0), winlength=5, time=0, dispchans=None, title='', plottitle='', xgrid='off', ygrid='off', data2=None, winrej=None, events=None, submean='off', eloc_file=None, scale='on', color='off')returning the window so callers can.show()/.close(). Does not mutate EEG dicts — accepts annp.ndarrayor an EEG dict and copies what it needs.6. Acceptance-criteria mapping.
tests/test_eegplot_parser.py(headless, no Qt import).tests/test_eegplot_state.py.2 * widget_width_px, first/last sample preserved.tests/test_eegplot_gui.pymarked@pytest.mark.gui, usesQApplication, callswidget.grab(), asserts non-uniform pixel std.sample_data/eeglab_data.setand asserts no-mutation on the source EEG dict.7. Help + notes.
src/eegprep/resources/help/eegplot.md— EEGLAB-parity option table..notes/eegplot-phase1.html(issue saysimplementation-notes.html) — record parity decisions, esp. anywhere we deviate fromeegplot.m.8. Lift the placeholder. Replace the
pop_eegplotentry inmenu_placeholders.pywith a stubpop_eegplot.pythat calls into the neweegplotand returns(EEG, com). Updatetests/test_menu_placeholder_inventory.py.Open Questions for Human Review
eloc_fileand channel-label state but not explicit component-mode rendering. Treat component activations as a labeled channel array (no scalp inset) in Phase 1, defer the inset to Phase 6?eeg_multieegplot/eegplot2event/eegplot2trial/trial2eegplot. Issue lists them as references but they are conversion utilities feeding marking/rejection workflows (Phase 3). Scope them out of Phase 1 — agreed?.notes/filename. Issue saysimplementation-notes.html; sibling phases used per-phase filenames. Use.notes/eegplot-phase1.htmlto avoid collisions, or stick to the literal name from the issue?feature/eegbrowser-completion(currently STUDY-only) or directly againstdevelop?Will not open a PR until these are settled.