Skip to content

Phase 4: Time-frequency internals and legacy time-frequency entry points #135

Closed

Description

@suraj-ranganath

🤖

Phase 4: Time-Frequency Internals And Legacy Time-Frequency Entry Points

Summary

Complete the useful EEGLAB time-frequency stack and related legacy entry points. This phase should make current pop_newtimef and pop_newcrossf behavior meaningfully closer to EEGLAB while keeping EEGPrep standalone.

Can start after Phase 1 merges. Can run in parallel with Phases 2 and 3.

Scope

Prioritize:

  • timefreq, timef, crossf, bootstat, correct_mc, newtimefbaseln
  • wavelet/DFT helpers needed by current newtimef and newcrossf
  • bootstrap/significance paths for pop_newtimef and pop_newcrossf
  • pop_timef and pop_crossf only if documented/user-facing and not stale

Do not port MATLAB-only plotting internals if a simpler EEGPrep-native matplotlib/Qt implementation preserves user-facing behavior better.

Acceptance Criteria

  • Existing pop_newtimef and pop_newcrossf unsupported options are either implemented or reclassified with defensible rationale.
  • Numerical outputs have MATLAB parity tests with documented tolerances.
  • Plot outputs work headlessly where possible and fail clearly when display is required.
  • GUI option dialogs match EEGLAB for implemented paths and include side-by-side attachments.
  • User-facing commands support valid Python history, return_com=True, and mixed GUI/console behavior.
  • No package runtime path depends on src/eegprep/eeglab.
  • Matrix rows touched by this phase are updated.

Verification

Run focused time-frequency tests, MATLAB parity tests, GUI visual parity captures where dialogs change, then:

  • uv run --no-sync ruff check .
  • uv run --no-sync ruff format --check .
  • uv run --no-sync ty check
  • relevant plotting/headless tests

/goal Prompt

/goal Complete EEGPrep time-frequency internals and useful legacy time-frequency entry points. Implement EEGLAB-compatible numerical behavior, bootstrap/significance support, and related pop_* options where in scope; verify with MATLAB parity, sample_data, plotting tests, GUI visual parity where dialogs change, valid console history, full lint/type/focused pytest checks, and parity matrix updates.

Activity

  1. added
    phase
    on Jun 5, 2026
  2. claude commented on Jun 5, 2026

    @claude
    Contributor

    🤖 Plan:

    Research

    Phase 4 is a multi-module port spanning EEGLAB's timefreqfunc/ stack plus legacy pop_* entry points; it depends on Phase 1 (#132) which is still open, so the porting contracts and parity-matrix rows this work must update do not yet exist. Current EEGPrep ships only a deterministic ERSP/ITC core in newtimef and a phase-coherence-only newcrossf; all EEGLAB-style significance, baseline normalization, time-warp, curve plots, and the lower-level timefreq/bootstat/correct_mc/newtimefbaseln helpers are absent. pop_timef and pop_crossf legacy wrappers are not present at all — the in-scope decision (port vs. consolidate vs. stale_skip) belongs to the Phase 1 matrix.

    Relevant code

    • src/eegprep/functions/timefreqfunc/newtimef.py#L26-L86 — current ERSP/ITC entry point, divisive/log baseline only
    • src/eegprep/functions/timefreqfunc/newcrossf.py#L42-L82 — phasecoher/coher/crossspec only; other types raise
    • src/eegprep/functions/popfunc/pop_newtimef.py#L227-L241 — _reject_unsupported_options enumerates the gap (timewarp, rboot/pboot/erspboot/itcboot, alpha≠0, basenorm, trialbase, plottype≠image)
    • src/eegprep/functions/popfunc/pop_newcrossf.py#L167-L174 — same pattern for crossf (rboot, boottype, baseboot, condboot, shuffle, subitc, amplag, alpha)
    • tests/test_phase4_timefreq_statistics.py#L1-L40 — existing Phase 4 surface tests to extend

    Proposed Approach

    Scope is too large for one PR. Recommend splitting into ~5 sequential sub-PRs, each landed only after Phase 1 (#132) merges and the parity-matrix rows for timefreqfunc/* are committed.

    1. Foundation: port timefreq (windowed-DFT + Morlet wavelet dispatcher) as a private helper under functions/timefreqfunc/, refactor newtimef/newcrossf to call it. No user-facing behavior change. Numerical parity test against MATLAB timefreq on a fixed-seed signal. (~300-400 lines.)
    2. Baseline normalization + newtimefbaseln: implement basenorm=on, trialbase=full/trial, and the four _BASELINE_CHOICES modes in pop_newtimef.py#L270-L275. Drop the _reject_unsupported_options clauses for basenorm/trialbase. MATLAB parity tests per mode. (~300 lines.)
    3. Bootstrap + multiple-comparison: port bootstat and correct_mc as new functions/timefreqfunc/ modules; wire alpha, rboot/pboot/erspboot/itcboot, boottype, baseboot, condboot, shuffle through both pop wrappers. Parity tests with fixed RNG seed; tolerances documented per AGENTS.md. (~500-700 lines.)
    4. Plot variants + remaining newcrossf types: implement curve plots (plottype='curve'), subitc, amplag. Matplotlib/Qt headless via matplotlib.use("Agg"). GUI visual parity captures for any dialog change. (~300 lines.)
    5. Legacy entry points: pop_timef/pop_crossf (and bare timef/crossf if the Phase 1 matrix marks them port rather than consolidated into the new* variants). timewarp/timewarpms/timewarpidx likely belong here too. (~300-500 lines.)

    Each sub-PR must update the Phase 1 parity-matrix rows it touches, add return_com=True history coverage in tests/test_console_workspace.py where pop wrappers gain options, and run lint + ty check + uv run pytest -m "not slow" per AGENTS.md.

    Open questions for a human before implementation starts:

    • Does Phase 1 classify pop_timef/pop_crossf/timef/crossf as port or consolidated (into pop_newtimef/pop_newcrossf)? Affects sub-PR 5 entirely.
    • MATLAB parity tolerance budget for bootstrap statistics — Phase 1 should set this; otherwise sub-PR 3 will have to pick one.
    • Are MATLAB Engine/Octave runners available in CI for bootstrap parity tests, or should those be @pytest.mark.matlab skip-when-absent only?

    Not opening a PR — this needs human direction on sub-PR breakdown and Phase 1 dependency resolution before any code lands.

  3. suraj-ranganath commented on Jun 7, 2026

    @suraj-ranganath
    MemberAuthor

    🤖 Resolved by the work now included in PR #152. Closing this constituent phase/follow-up issue now; parent epic #131 remains open until the epic PR merges.

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

    phase

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions