Skip to content

[Release readiness] Stream 4: Signal processing #549

Closed

Description

@suraj-ranganath

[Release readiness] Stream 4: Signal processing

Context

This issue is one of 11 release-readiness streams for sccn/eegprep. The release goal is EEGLAB parity in the GUI and the numbers for everything except STUDY and third-party plugins (default / bundled plugins only: EEG-BIDS, ICLabel, clean_rawdata, dipfit, firfilt).

The audit (report eegprep_GUI_audit_2026-11-05.pdf, findings F1–F126 in findings.md) was run as a simulated user: hands-on GUI use of eegprep and EEGLAB side by side, with real datasets, plus numerical parity checks against MATLAB EEGLAB. EEGLAB was the pinned tree eeglab-8ac485f6 on the lab MATLAB machine (jamming, path ~/gui-parity/eeglab-8ac485f6), never modified. eegprep was develop at 0bda20da. Where the pinned tree lacked a plugin (Biosig, Fileio, neuroscanio, bva-io, Fieldtrip-lite, viewprops), comparisons against a bench copy are labelled non-pinned.

Of 144 in-scope menu items, 141 were tested hands-on in both GUIs. Not counted in that 141: Quit (not run, ends the session) and the two eegprep-only Plot items "View extended channel/component properties" (pinned EEGLAB has no viewprops; tested in eegprep only as F122).

This stream: Signal-processing numerics (filter, ICA, interpolation, time-frequency) (size L). Findings assigned: F58, F59, F60, F69, F91, F92, F126.

Files / functions owned (do not edit outside these without coordinating; see fix_streams.md):

plugins/firfilt/plotfresp.py; popfunc/eeg_interp.py, pop_interp.py; sigprocfunc/runica.py (and pop_runica.py seeding only); timefreqfunc/newtimef.py (+ timefreq helpers); popfunc/pop_newtimef.py, pop_newcrossf.py, newcrossf

Dependencies / merge order: Independent. Owns pop_newtimef/pop_newcrossf, so S7 must not edit them. pop_interp index base (part of F70) is aligned here, not in S5.

Suggested tests from the stream plan: Function tests plus MATLAB parity on jamming (runica with rndreset 'no', newtimef explicit args, newcrossf defaults, interpolation full/partial range). F60: a test that records the intended difference, citing pop_interp.m:61.

Common datasets used in the audit (copies only; never the originals):

  • eeglab_data.set — continuous tutorial (32 ch, 128 Hz, 30504 pnts)
  • eeglab_data_epochs_ica.set — epoched + ICA (80 epochs)
  • eeglab_data_numerical_events.set — numerical event types
  • BrainVision set (testbva.vhdr / related) — 32 ch, 2112 pnts, 17 events
  • test.bdf / test.edf — Biosemi / EDF samples
  • BIDS oddball sample for import/export
  • Neuroscan .EEG, BVA .mat, MFF folder, HDF5 eeglab_data_hdf5.set where noted
  • Channel location files: eeglab_chan32.locs, standard_1005.elc, standard-10-5-cap385.elp

Companion stream issues (together they cover F1–F126):

Stream Issue
1 Data safety #546
2 Dialogs and Edit selection #548
3 Scroll window #547
4 Signal processing #549
5 Channel locations and re-reference #550
6 Rejection numbers #551
7 Plots and plot history #552
8 ICLabel, component properties, DIPFIT #553
9 Importers #554
10 Export and BIDS #555
11 Main window, menus, preferences, help #556

Screenshots: image files for this stream are staged under /workspace/gui-parity/issues/stream-04/ and ready for gh issue edit --attach. Embedding via --attach failed with the current fine-grained GH_TOKEN (HTTP 403 on uploads.github.com). Run attach_screenshots.sh with a classic PAT that can upload user-attachments (or grant the fine-grained token Contents + attachments). Until then, screenshot filenames are listed under each finding.

Findings

Use the checkboxes to track progress. Full audit detail is carried over (not summarised away).

- [ ] F58 — critical — Tools > Filter the data > Basic FIR filter (new, default)

Finding (full audit text): With the default "Plot frequency response" checked, every design (HP 1 Hz, LP, BP, notch) fails with "Onepass-zerophase filtering is only allowed for linear-phase FIR filters". Cause: plotfresp.py:76 uses an exact float symmetry test on the windowed-sinc coefficients. Unchecking the plot works and matches EEGLAB exactly. EEGLAB shows the response plot.

Evidence / screenshots: F58_eegprep_filter_freqresp_error.png, F58_eeglab_freqresp_ok_20261105_015946.png

What needs fixing: Resolve the behaviour so eegprep matches EEGLAB for this item (GUI and numbers), unless EEGLAB is the buggy side — then keep the correct behaviour, document the difference, and lock it with a test. Add a regression test. Keep existing tolerances.

Screenshots (filenames; attach pending):

  • F58_eeglab_freqresp_ok_20261105_015800.png — F58: EEGLAB
  • F58_eeglab_freqresp_ok_20261105_015946.png — F58: EEGLAB
  • F58_eegprep_filter_freqresp_error.png — F58: eegprep

- [ ] F59 — medium — Tools > Interpolate electrodes (empty time range)

Finding (full audit text): Second-to-last sample (1-based 30503) keeps the original value (7.24 µV off EEGLAB at that one sample; rest 1.5e-4). Cause: pop_interp _gui_t_range returns list [xmin, xmax], eeg_interp.py:163 compares to a tuple so the "restore outside range" branch always runs.

Evidence / screenshots: F59_eegprep_interp_done_20261105_021216.png, F59_eegprep_vs_eeglab_diffplot.png, ml_interp_20261105_015653.png

What needs fixing: Resolve the behaviour so eegprep matches EEGLAB for this item (GUI and numbers), unless EEGLAB is the buggy side — then keep the correct behaviour, document the difference, and lock it with a test. Add a regression test. Keep existing tolerances.

Additional eegprep bug to fix in this stream (time-range endpoint): eeg_interp restores original data only up to floor(xmax*srate), so the final sample of a partial time range stays interpolated and the exact range end is excluded. Fix by using EEG.times with inclusive endpoints, matching the upstream fix direction in sccn/eeglab#980.

Screenshots (filenames; attach pending):

  • F59_eegprep_vs_eeglab_diffplot.png — F59: F59_eegprep_vs_eeglab_diffplot
  • F59_eegprep_interp_done_20261105_021216.png — F59: eegprep
  • ml_interp_20261105_015653.png — F59: ml_interp_20261105_015653

- [ ] F60 — medium (EEGLAB bug; eegprep correct) — Interpolate with time range [10 20]

Finding (full audit text): eegprep interpolates only 10–20 s; EEGLAB output equals full interpolation. Verdict: EEGLAB bug. Pinned 8ac485f6 functions/popfunc/pop_interp.m:58-61: function [EEG com] = pop_interp(EEG, bad_elec, method, t_range) then line 61 t_range = ''; unconditionally discards the 4th argument, so any scripted pop_interp(EEG, chans, method, [t1 t2]) passes '' to eeg_interp, and eeg_interp.m:317 if ~isempty(t_range) skips the restore-outside-range step. The GUI path (pop_interp.m:128-136, if nargin < 4 ... t_range = res{2}) does honor a typed range, but the history string (pop_interp.m:150, sprintf('EEG = pop_interp(EEG, %s, ''%s'');', ...)) drops it, so replaying GUI history also interpolates everything. Documented behavior (pop_interp.m:20 / eeg_interp.m:19 t_range - time interval of the data to interpolate) matches eegprep. Side note: eeg_interp.m:322 restores [1:floor(t_start*srate), floor(t_end*srate):floor(xmax*srate)], which skips the final sample (index pnts) and is off by one at both boundaries relative to 0-based times. No fix made. Verified on the box: ml_interp_range.set equals ml_interp_sph.set exactly (maxabs 0) on the interpolated channels.

Evidence / screenshots: logs/compare_tools.txt (interp_range), /tmp/f60.py output in progress.log

What needs fixing: Resolve the behaviour so eegprep matches EEGLAB for this item (GUI and numbers), unless EEGLAB is the buggy side — then keep the correct behaviour, document the difference, and lock it with a test. Add a regression test. Keep existing tolerances.

EEGLAB-side bug (keep eegprep behaviour): EEGLAB pop_interp.m:61 sets t_range = '', discarding a scripted time range; the GUI history also drops the range. Fix is upstream in sccn/eeglab#980. eegprep already honours the range (as pop_interp help describes). Do not change eegprep to match the buggy EEGLAB behaviour. Document the difference and lock it with a documented-difference test citing pop_interp.m:61.

- [ ] F69 — high — Tools > Decompose data by ICA (runica)

Finding (full audit text): Identical input, rndreset 'no' + pythoncompat: decompositions differ (W maxabs 1.36; matched-component abs(r) min 0.66, median 0.94; end-to-end min 0.68, median 0.91). Downstream ICLabel flag differs (eegprep [25], EEGLAB none). EEGLAB ICLabel on eegprep's ICA also flags [25], so ICLabel is at parity; ICA seeding is not.

Evidence / screenshots: F69_eegprep_vs_eeglab_runica.png

What needs fixing: Resolve the behaviour so eegprep matches EEGLAB for this item (GUI and numbers), unless EEGLAB is the buggy side — then keep the correct behaviour, document the difference, and lock it with a test. Add a regression test. Keep existing tolerances.

Screenshots (filenames; attach pending):

  • F69_eegprep_vs_eeglab_runica.png — F69: F69_eegprep_vs_eeglab_runica

- [ ] F91 — medium — Plot > Channel/Component cross-coherence (pop_newcrossf, all menus)

Finding (full audit text): With default frequencies, eegprep covers 6-64 Hz (30x200) and EEGLAB covers 6-50 Hz (23x200); eegprep coherence is about 1 above 52 Hz. On the shared bins, channels differ by at most 0.063 (correlation 0.998) and components by at most 0.057 (0.998). Means are eegprep 0.6383/0.1977 vs EEGLAB 0.6384/0.1977.

Evidence / screenshots: F91_crossf_sbs.png, mlout/dh_crossf.mat

What needs fixing: Resolve the behaviour so eegprep matches EEGLAB for this item (GUI and numbers), unless EEGLAB is the buggy side — then keep the correct behaviour, document the difference, and lock it with a test. Add a regression test. Keep existing tolerances.

Screenshots (filenames; attach pending):

  • F91_crossf_sbs.png — F91: EEGLAB vs eegprep side-by-side

- [ ] F92 — low — Cross-coherence dialog

Finding (full audit text): The default time range is "-1000 1992.19" in eegprep and "-1000 1992" in EEGLAB.

Evidence / screenshots: F92_crossf_dlg_sbs.png

What needs fixing: Resolve the behaviour so eegprep matches EEGLAB for this item (GUI and numbers), unless EEGLAB is the buggy side — then keep the correct behaviour, document the difference, and lock it with a test. Add a regression test. Keep existing tolerances.

Screenshots (filenames; attach pending):

  • F92_crossf_dlg_sbs.png — F92: EEGLAB vs eegprep side-by-side

- [ ] F126 — medium (numeric) — Plot > Time-frequency > Channel time-frequency (explicit args)

Finding (full audit text): With tlimits [-1000 1992], cycles [3 0.8], padratio 1, baseline 0, ERSP max is 7.218061 (EEGLAB 7.250184) and ITC max 0.491775 (0.488446). The earlier default-argument run agreed to 1e-6. The baseline argument had no visible effect in eegprep. Needs element-wise root-causing.

Evidence / screenshots: F126_newtimef_sbs.png, E2Ec_newtimef_eegprep_20261105_055104.png, E2Ec_newtimef_eeglab_20261105_053634.png

What needs fixing: Resolve the behaviour so eegprep matches EEGLAB for this item (GUI and numbers), unless EEGLAB is the buggy side — then keep the correct behaviour, document the difference, and lock it with a test. Add a regression test. Keep existing tolerances.

Definition of done

  • Every finding checkbox in this issue is fixed (or explicitly documented as intentional / EEGLAB-only with a locked test).
  • A regression test exists for each finding (Qt offscreen and/or function test as appropriate for the stream).
  • Where numbers are involved: a numerical parity test against pinned EEGLAB eeglab-8ac485f6 on jamming. Do not loosen any existing tolerance — only Suraj or Arno may change tolerances; fix root causes instead.
  • Where EEGLAB itself is buggy: eegprep does the right thing; the difference is documented and locked with a test (documented-difference style).
  • Error messages state what is wrong, which function hit it, and the exact fix (e.g. the pip install eegprep[...] command).
  • No code comments that restate code or justify workarounds.
  • Changelog entry for the stream.
  • One PR against develop, CI green (ignore the known-broken Claude review check).
  • Before merge, retest the same way as the audit: each finding's GUI flow is re-run hands-on in both eegprep and EEGLAB side by side, with before/after screenshots, plus the MATLAB parity / reference checks where this stream requires them; post the results on the PR.
  • Merging requires Suraj's explicit approval (squash merge).

Dependencies and overlaps

Independent. Owns pop_newtimef/pop_newcrossf, so S7 must not edit them. pop_interp index base (part of F70) is aligned here, not in S5.

Shared hotspots (from fix_streams.md):

  • menu_actions.py is split by method — only edit this stream's named methods.
  • tests/eeglab_python_backend_xfails.py and tests/parity_expected/: each stream adds/removes only its own entries.
  • Suggested merge order overall: S1 → S2/S9/S11 → S5; S7 → S8; S3/S4/S6/S10 independent.

References

  • Audit PDF: eegprep_GUI_audit_2026-11-05.pdf (Suraj / Arno)

  • Findings log: findings.md (F1–F126)

  • Stream plan: fix_streams.md

  • Pinned EEGLAB: eeglab-8ac485f6

Screenshots (filenames; attach pending):

  • F126_newtimef_sbs.png — F126: EEGLAB vs eegprep side-by-side
  • E2Ec_newtimef_eeglab_20261105_053634.png — F126: EEGLAB
  • E2Ec_newtimef_eegprep_20261105_055104.png — F126: eegprep

Activity

  1. added
    bug
    epic
    on Nov 5, 2026
  2. suraj-ranganath commented on Nov 7, 2026

    @suraj-ranganath
    MemberAuthor

    Closing. Stream 4 landed in develop as squash cdbe303d via #560. That PR said Refs #549 rather than Fixes #549, so GitHub didn't close this automatically.

    What's fixed:

    • F58, F59, F60, F69, F91, F92 and F126.
    • The pop_interp 1-based half of F70.

    All of it is in the changelog and covered by tests/test_stream4_signal_processing.py and tests/test_linspace.py. MATLAB parity was checked on a7334bf8 against EEGLAB d0963be9.

    The deliberate differences from EEGLAB stay documented and tested: the scripted t_range, the inclusive end in pop_newcrossf, the epoched restore, and plotfresp's allclose check.

    Follow-ups that aren't part of this stream:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugepic

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions