You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Activity
claude commentedon Jun 4, 2026
🤖 Plan:
eegplot.mResearch
Both bugs live on
feature/eegbrowser-completionand belong in PR #111 ([EEGBrowser] Complete eegplot parity), not a parallel PR. Both demo cases usedata=zeros(8,...)withdispchans=6, so EEGLAB shows 7 visible channels (chans 2–8) — itsylim=[elecoffset*spacing, (elecoffset+dispchans+1)*spacing]deliberately spansdispchans+1rows so the bottom channel sits at1*spacingand chan 1 is hidden at the top by default. The Python canvas was changed to draw exactlydispchanschannels in commit923a078("Respect EEGBrowser displayed channel count"), which is what drops channels 7–8 fromeegbrowser_pop_eegplot_reject_dataandeegbrowser_rejection_epochs.The "x-axis depart" in
eegbrowser_rejection_epochsis 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, andax1(main) carries in-epoch latency labels computed byeeg_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_countreturnsmin(remaining, dispchans); needsdispchans + 1to match MATLABylim.923a078— regression that flippeddispchans + 2todispchans; both visual-parity cases broke here.src/eegprep/functions/guifunc/eegbrowser.py#L726-L741—_configure_axessetsYRange=[-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_ticksfor epoched data emits one label per epoch start; MATLAB equivalent ateegplot.m#L1602-L1666draws trial boundaries onax0and in-epoch latencies onax1.src/eegprep/eeglab/functions/sigprocfunc/eegplot.m#L1426and#L519-L528— thedispchans+1ylim trick and the0:spacing:chans*spacingYTicks with a leading blank label.tests/test_eegplot_gui.py#L259-L274— currently locks_visible_channels()to exactlydispchans; 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
923a078todispchans + 1(matches MATLAB exactly;dispchans + 2over-draws). Tighten_configure_axessoYRange = [-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_offsettomax(0, n_channels - dispchans - 1)so the extra row does not break scrolling. Updatetests/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_ticksso the epoched branch returns two tick sets: trial-boundary positions (dashed grid + epoch-number labels centered between boundaries, matching MATLABax0) and in-epoch latency labels ateeg_point2lat-equivalent positions inside each epoch. The simplest container is a secondAxisItem(orTextItemoverlay) 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 existingeegbrowser_epoched/eegbrowser_epoched_markedcases 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.