Skip to content

[Fable 5 Architecture Closeout] Phase 3 — STUDY, time-frequency, and statistics behavior consolidation #210

Closed

Description

@suraj-ranganath

🤖 Part of #207. This phase resolves duplicated STUDY, clustering, time-frequency, and statistical behavior that can otherwise give different scientific answers depending on entry point.

Summary

Consolidate STUDY measure/cache helpers, robust clustering dispatch, time-frequency bootstrap/FDR code, and empirical p-value conventions. This phase is behavior-changing where current code diverges from EEGLAB or from EEGPrep’s own canonical helpers, so every change needs a failing or characterization test.

Scope

Covers remaining findings from #197/#205 including:

  • pop_clust finite-outlier path dispatching to robust_kmeans and recording EEGLAB-compatible algorithm provenance.
  • pop_chanplot duplicating std_readdata / std_measureplot measure reading and plotting behavior.
  • Shared STUDY helpers: _trial_rows, factor-level matching, cached measure axes, default plot targets, range masks, measure field maps, and std_clustplot history construction.
  • Time-frequency duplicates: bootstrap thresholding, threshold vectors, bootstrap index/resampling helpers, newtimef FDR path, and remaining numeric-vector parsing after Phase 1.
  • Empirical p-value convention audit across PAC, bootstat, and statistics helpers; either converge or document intentionally distinct scientific definitions.

Acceptance Criteria

  • STUDY design/measure helpers have one owner and callers agree on trialinfo, measure axes, range masks, and default targets.
  • pop_clust finite-outlier behavior is EEGLAB-compatible or the divergence is explicitly justified with tests and docs.
  • Time-frequency significance behavior uses canonical helpers for FDR/bootstrap where equivalent; any intentionally different p-value convention is documented in code/docs and tested.
  • History emitted by STUDY plotting remains valid Python and round-trips in eegprep-console.
  • Tests cover multi-dataset STUDY fixtures, sample data where relevant, deterministic numerical parity, and invalid bounds/factor inputs.

References

  • AGENTS.md
  • .agents/skills/eegprep-feature-development/SKILL.md
  • EEGLAB references under functions/studyfunc, functions/timefreqfunc, and functions/statistics.

/goal Prompt

/goal Complete Fable 5 architecture closeout Phase 3 from issue #<THIS_ISSUE>: consolidate STUDY helper ownership, robust clustering dispatch, time-frequency bootstrap/FDR plumbing, and empirical p-value conventions from #197/#205. Use EEGLAB source and existing EEGPrep tests as the oracle, make behavior changes only with explicit tests and documented rationale, preserve console history and STUDY/session synchronization, run MATLAB parity where deterministic, and verify with focused pytest plus ruff, format, ty, and pre-commit.

Activity

  1. added
    phase
    on Jun 12, 2026
  2. suraj-ranganath commented on Jun 12, 2026

    @suraj-ranganath
    MemberAuthor

    🤖

    Research

    pop_clust still runs plain k-means for finite outliers, then hand-marks label 0 rows and records ['Kmeans', clus_num]; EEGLAB dispatches that path to robust_kmeans(..., STD, 5, algorithm) and records {'robust_kmeans', clus_num}. pop_chanplot still reads and plots cached channel/component measures through local _data/_axis/_cached_channel_groups helpers while std_readdata and _std_measureplot already own those contracts; shared STUDY trialinfo rows, factor matching, cached axes, range masks, and std_clustplot history still have forked implementations. Time-frequency has Phase 1 value parsing plus canonical bootstrap_threshold/fdr, but bootstrap index/resampling helpers remain split; PAC, bootstat, and statistics p-value conventions are intentionally distinct and need executable audit coverage.

    Relevant code

    Duplicate-work preflight: no open PRs for #210, pop_clust, pop_chanplot, std_readdata, std_measureplot, newtimef, or bootstat; issue #208 is adjacent shared-contract work already merged into the target base and does not overlap this phase.

    Proposed Fix

    Add characterization tests first for finite-outlier pop_clust provenance, pop_chanplot cached channel/component parity with std_readdata/measure plotting, shared trialinfo/factor/range/axis behavior, valid std_clustplot history, time-frequency bootstrap helper equivalence, and the intentionally distinct empirical p-value definitions. Then route pop_clust finite outliers through robust_kmeans; move shared STUDY contracts into _study_utils/std_readdata and import them from callers; make pop_chanplot delegate cached measure reading/plotting instead of owning parallel copies; add a small timefreqfunc/_bootstrap.py for baseboot, threshold-vector, and resampling helpers used by newtimef/newcrossf/bootstat. Keep PAC's bias-corrected one-sided p-value, bootstat's exact two-sided surrogate p-values, and statistics.stat_surrogate_pvals' EEGLAB last-axis tail folding as distinct definitions, with tests and docs explaining why they do not collapse.

  3. suraj-ranganath commented on Jun 12, 2026

    @suraj-ranganath
    MemberAuthor

    🤖 Completed by merged phase PR #217 into feature/fable5-architecture-closeout.

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