Skip to content

eegplot issue #129

Closed
Closed

Activity

  1. claude commented on Jun 4, 2026

    @claude
    Contributor

    🤖 Plan:

    • Read AGENTS.md, fix-issue, pull-request skills
    • Actionability check
    • Duplicate-work preflight (open PR [EEGBrowser] Complete eegplot parity #111 owns this surface)
    • Audit eegbrowser channel-count and epoched x-axis vs MATLAB eegplot.m
    • Post research + proposed fix (analysis only, no parallel PR)

    Research

    Both bugs live on feature/eegbrowser-completion and belong in PR #111 ([EEGBrowser] Complete eegplot parity), not a parallel PR. Both demo cases use data=zeros(8,...) with dispchans=6, so EEGLAB shows 7 visible channels (chans 2–8) — its ylim=[elecoffset*spacing, (elecoffset+dispchans+1)*spacing] deliberately spans dispchans+1 rows so the bottom channel sits at 1*spacing and chan 1 is hidden at the top by default. The Python canvas was changed to draw exactly dispchans channels in commit 923a078 ("Respect EEGBrowser displayed channel count"), which is what drops channels 7–8 from eegbrowser_pop_eegplot_reject_data and eegbrowser_rejection_epochs.

    The "x-axis depart" in eegbrowser_rejection_epochs is the epoched case (pnts=250, trials=3, winlength=3). Python only renders epoch-number ticks at sample-0 of each epoch — there is no second axis showing time-within-epoch and no trial-boundary dashed lines. EEGLAB renders two x axes for epoched data: ax0 (background) carries the epoch number centered between dashed trial boundaries, and ax1 (main) carries in-epoch latency labels computed by eeg_point2lat. The current Python path collapses both into a single tick row, so the labels and the box edge no longer line up the way they do in MATLAB.

    Relevant code

    • src/eegprep/functions/guifunc/eegbrowser.py#L947-L950 — _plot_channel_count returns min(remaining, dispchans); needs dispchans + 1 to match MATLAB ylim.
    • commit 923a078 — regression that flipped dispchans + 2 to dispchans; both visual-parity cases broke here.
    • src/eegprep/functions/guifunc/eegbrowser.py#L726-L741 — _configure_axes sets YRange=[-0.5, plot_channel_count-0.5] and emits one tick row; needs the extra row plus epoched two-tier x ticks.
    • src/eegprep/functions/guifunc/eegbrowser.py#L978-L996 — _x_ticks for epoched data emits one label per epoch start; MATLAB equivalent at eegplot.m#L1602-L1666 draws trial boundaries on ax0 and in-epoch latencies on ax1.
    • src/eegprep/eeglab/functions/sigprocfunc/eegplot.m#L1426 and #L519-L528 — the dispchans+1 ylim trick and the 0:spacing:chans*spacing YTicks with a leading blank label.
    • tests/test_eegplot_gui.py#L259-L274 — currently locks _visible_channels() to exactly dispchans; must be updated when the count changes.

    Proposed Fix (apply in PR #111, not as a separate PR)

    Bug 1 — channels 7/8 missing. Revert the intent of 923a078 to dispchans + 1 (matches MATLAB exactly; dispchans + 2 over-draws). Tighten _configure_axes so YRange = [-1.0, dispchans - 0.5] reserves the extra row at the bottom and the existing labels stay at integer screen indices, and update the slider page step / maximum_offset to max(0, n_channels - dispchans - 1) so the extra row does not break scrolling. Update tests/test_eegplot_gui.py::test_gui_displayed_channels_and_vertical_slider_update_visible_state (and any other _visible_channels() parity tests) to expect the extra row.

    Bug 2 — epoched x-axis. Extend _x_ticks so the epoched branch returns two tick sets: trial-boundary positions (dashed grid + epoch-number labels centered between boundaries, matching MATLAB ax0) and in-epoch latency labels at eeg_point2lat-equivalent positions inside each epoch. The simplest container is a second AxisItem (or TextItem overlay) anchored to the plot box so the in-epoch labels sit inside the frame instead of "departing" below it. Re-capture both visual-parity cases and the existing eegbrowser_epoched / eegbrowser_epoched_marked cases to confirm parity.

    This is multi-module work (eegbrowser.py, eegplot.py, tests, visual-parity captures, GUI tests) and belongs in PR #111. No separate PR opened.

    Duplicate-work preflight: PR #111 (feature/eegbrowser-completion) is the canonical home for this work. No other open PR or issue covers the same regression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions