Skip to content

Phase 2: Signal conditioning, filtering, baseline, and cleaning #62

Closed

Description

@suraj-ranganath

🤖 Phase issue for the EEGLAB completion epic.

Goal

Complete parity for signal conditioning, filtering, baseline removal, boundary-aware data transforms, and bundled cleaning workflows.

Target branch and PR flow

  • Create the phase branch from feature/eeglab-completion.
  • Open the phase PR back into feature/eeglab-completion.
  • The phase PR should close this issue.

Parallelization

Can run in parallel with Phases 1, 3, and 4. Coordinate shared helpers for event, urevent, boundary, epoch, and ICA invalidation semantics.

In scope

  • Legacy and new FIR filtering workflows and firfilt menu actions.
  • Baseline removal and low-level rmbase parity.
  • Continuous and epoched boundary handling.
  • Epoch-to-continuous and time-interpolation helpers needed by EEGLAB parity.
  • Rerejection-support helpers that do not require EEGBrowser.
  • clean_rawdata parity gaps already represented in this repo.
  • GUI dialogs, help Markdown, console commands, history strings, and menu dispatch for implemented workflows.

Out of scope

  • EEGBrowser/eegplot scrolling viewers.
  • External plugins not vendored in this repo.

Acceptance criteria

  • Tools filtering/baseline/cleaning actions operate on continuous and epoched EEG like EEGLAB.
  • Boundary events, ICA invalidation/reactivation, urevent, epoch, times, and history behavior match EEGLAB expectations.
  • Numerical tests include MATLAB parity, sample_data, small synthetic data, edge sampling rates, boundary events, and invalid parameters.
  • GUI dialogs match EEGLAB layout and remain responsive from eegprep-console.
  • Successful expected workflows do not emit noisy warnings unless EEGLAB-equivalent behavior requires them.
  • Required lint/type/test commands pass.

/goal prompt

/goal Complete EEGPrep parity for signal conditioning, filtering, baseline removal, and bundled cleaning workflows. Use EEGLAB source as oracle, preserve standalone runtime behavior, verify with MATLAB parity tests, sample_data integration tests, GUI visual parity where dialogs exist, console/GUI workspace tests, ruff/format/ty, and non-slow pytest. Continue until all category placeholders are either implemented or documented as explicit browser/external exclusions.

Activity

  1. added
    phase
    on May 27, 2026
  2. claude commented on May 27, 2026

    @claude
    Contributor

    🤖 Plan:

    • Read issue, AGENTS.md, fix-issue and pull-request skills
    • Inventory existing Phase 2 modules and gaps
    • Confirm scope (epic, multi-module, >>100 LOC) → no PR; post analysis only
    • Await human direction on per-subphase PR breakdown

    Research

    Phase 2 is an EEGLAB-completion epic, not a bug fix. It spans Tools→Filter, Tools→Remove baseline, continuous/epoch boundary semantics, epoch↔continuous helpers, and clean_rawdata parity gaps. Implementing it as one PR would be thousands of LOC across popfunc/, sigprocfunc/, plugins/firfilt/, plugins/clean_rawdata/, guifunc/, resources/help/, MATLAB parity tests, and console wrappers — out of scope for an automated single-PR fix.

    Current state vs. scope

    • Filter family: plugins/firfilt/menu.py dispatches to pop_eegfiltnew, pop_firws, pop_firpm, pop_firma; all four (plus legacy pop_eegfilt, pop_iirfilt) are still in functions/popfunc/_coming_soon.py PLACEHOLDER_ACTIONS. Only firws/firwsord ports exist under plugins/firfilt/. No pop_* wrappers, no GUI dialogs, no help md.
    • Baseline: functions/popfunc/pop_rmbase.py is partially implemented (boundary-aware _normalize_pointrange) but pop_rmbase is still listed in PLACEHOLDER_ACTIONS and has no help md, no console/GUI wiring audit, no MATLAB parity test confirmed.
    • Boundary / epoching helpers: eeg_findboundaries, eeg_lat2point, eeg_point2lat, eeg_eegrej, pop_epoch present. Missing per EEGLAB: eeg_regepochs, epoch2continuous, pop_eegrej user-facing wrapper, and a documented invariant pass for urevent/epoch/times/history after boundary rejection.
    • Rerejection helpers (non-EEGBrowser): pop_rejcont, pop_eegthresh, pop_jointprob, pop_rejkurt, pop_rejtrend, pop_rejspec, pop_rejepoch all in PLACEHOLDER_ACTIONS. (Note: most overlap Phase 3 ICA-rejection — needs an explicit boundary with Phase 3: ICA, component, rejection, ICLabel, and DIPFIT workflows #63.)
    • clean_rawdata: clean_artifacts, clean_asr, clean_channels, clean_channels_nolocs, clean_drifts, clean_flatlines, clean_windows, pop_clean_rawdata all ported. Gaps are in MATLAB parity coverage on boundary-aware continuous data, edge sample rates, and history string format — not in missing modules.
    • Help md present: pop_clean_rawdata.md, clean_artifacts.md, pop_epoch.md, pop_resample.md, pop_select.md, pop_reref.md, reref.md, pop_interp.md. Missing for everything else in this phase.

    Relevant code

    Branch + duplicate-work preflight

    Proposed Approach (design change — needs human review before any PR)

    Break Phase 2 into 5 reviewable PRs against feature/eeglab-completion. Each is independently testable, fits well under 500 LOC excluding tests/help, and removes the matching entries from PLACEHOLDER_ACTIONS only as ports land. Suggested order matches dependency direction:

    1. pop_rmbase finalize. Audit current implementation against eeglab/functions/popfunc/pop_rmbase.m, confirm boundary-aware behavior on continuous and epoched data, add MATLAB parity test, add resources/help/pop_rmbase.md, wire console+GUI dialog, drop from PLACEHOLDER_ACTIONS. Depends on nothing.
    2. firfilt filter family. Implement pop_eegfiltnew (default), then pop_firws, pop_firpm, pop_firma. Use existing plugins/firfilt/firws.py/firwsord.py for kernels; share a private _apply_fir.py helper for boundary-aware filtfilt across continuous and epoched data. One PR per pop function to keep diffs small. Each PR ships GUI dialog (visual parity vs EEGLAB screenshot), help md, console wrapper test, MATLAB parity test on sample_data, removal from PLACEHOLDER_ACTIONS. Skip pop_eegfilt legacy and pop_iirfilt unless explicitly requested — EEGLAB defaults to pop_eegfiltnew.
    3. Boundary + epoch↔continuous helpers. Port eeg_regepochs and epoch2continuous, add pop_eegrej wrapper over existing eeg_eegrej. Establish a single internal invariant helper for urevent/event/epoch/times/history/icaact updates post-boundary that every Phase 2 mutator calls. Parity tests must cover first/last sample, repeated boundaries, and ICA invalidation/reactivation.
    4. clean_rawdata parity hardening. No new modules — add MATLAB parity tests for clean_artifacts, clean_asr, clean_channels, clean_drifts, clean_flatlines, clean_windows on boundary-aware continuous data and edge sampling rates; tighten history strings to match EEGLAB. Help md additions where missing.
    5. Rerejection helpers without EEGBrowser. Scope explicitly to pop_rejcont and pop_rejepoch (continuous and epoch-level marking that does not need a scrolling viewer). Defer pop_eegthresh/pop_jointprob/pop_rejkurt/pop_rejtrend/pop_rejspec to Phase 3 (Phase 3: ICA, component, rejection, ICLabel, and DIPFIT workflows #63) since they sit on the ICA component-rejection axis and the boundary is ambiguous in this issue.

    Open questions for the human before implementation

    1. Is the breakdown above the right granularity, or do you want each pop_* filter as its own issue rather than chained PRs under Phase 2: Signal conditioning, filtering, baseline, and cleaning #62?
    2. For boundary-aware filtering, EEGLAB applies filtfilt per continuous segment between boundary events. Confirm we mirror exactly that semantic (vs. naive whole-recording filtfilt).
    3. Should this phase add pop_eegfilt (legacy) and pop_iirfilt at all? EEGLAB still ships them but defaults to pop_eegfiltnew; leaving them as placeholders matches the "out of scope: external plugins not vendored" clause.
    4. Confirm rejection helper boundary with Phase 3: ICA, component, rejection, ICLabel, and DIPFIT workflows #63: pop_rejcont + pop_rejepoch here, everything ICA-driven there.
    5. GUI visual parity: is screenshot-based parity required for each new filter dialog (per .agents/skills/eeglab-gui-visual-parity/SKILL.md), or layout-equivalent acceptable?

    No PR opened. Awaiting direction on (1)-(5) before starting subphase 1.

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

Metadata

Metadata

Labels

phase

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions