Skip to content

[Fable 5 Architecture Closeout] Phase 2 β€” rejection, ICA, and clean_rawdata helper convergenceΒ #209

Closed

Description

@suraj-ranganath

πŸ€– Part of #207. This phase removes duplicated EEG rejection, ICA, and cleaning helper logic where duplicate copies can change scientific results or visual rejection state.

Summary

Unify the core EEG data helpers that affect rejection marks, component activations, ICA finalization, and clean_rawdata channel removal. These paths must remain numerically correct and EEGLAB-predictable because they influence what users reject or keep.

Scope

Covers remaining findings from #197/#205 including:

  • Parallel winrej / rejection-family scaffolding in _eegplot_rejection.py and pop_eegplot.py.
  • Duplicated epoched rejection scaffolds across pop_rejkurt, pop_jointprob, pop_eegthresh, pop_rejspec, and pop_rejtrend.
  • Divergent component_activations implementations in _rejection.py and _plot_utils.py; decide and document whether rejection trusts stored icaact or recomputes.
  • Triplicated ICA post-processing (sortcomps, posact) across eeg_runica.py, eeg_amica.py, and eeg_picard.py.
  • Divergent channel-removal and clean_channel_mask update blocks in clean_flatlines.py, clean_channels.py, and clean_channels_nolocs.py.

Acceptance Criteria

  • Shared rejection-family helpers produce the same browser marks and colors from every GUI/menu entry point.
  • Rejection pop wrappers keep their existing public signatures, history strings, and GUI behavior while delegating common apply/display/reject logic to one tested helper.
  • ICA post-processing is centralized and preserves icaweights, icasphere, icawinv, icaact, icachansind, component ordering, and sign invariants across runica/amica/picard.
  • clean_rawdata channel removal updates clean_channel_mask consistently for zero, partial, and all-channel removal cases.
  • Tests include sample-data and synthetic EEG coverage; MATLAB parity is used for deterministic ICA/rejection semantics where feasible.
  • GUI/console flows remain synchronized for browser/rejection actions.

References

  • AGENTS.md
  • .agents/skills/eegprep-feature-development/SKILL.md
  • .agents/skills/eeglab-gui-visual-parity/SKILL.md for browser/rejection GUI changes
  • EEGLAB references: pop_eegplot.m, eeg_rejmacro.m, ICA wrappers, and clean_rawdata plugin references.

/goal Prompt

/goal Complete Fable 5 architecture closeout Phase 2 from issue #<THIS_ISSUE>: converge rejection browser helpers, epoched rejection wrappers, component activation access, ICA finalization, and clean_rawdata channel-removal masks into canonical tested helpers. Use #197/#205 and EEGLAB source as the behavior oracle, preserve EEGPrep standalone runtime behavior and existing public pop_* contracts, add regression/parity tests before behavior changes, verify GUI plus eegprep-console synchronization for user-facing paths, and run focused pytest plus ruff, format, ty, and pre-commit. Keep changes scoped to rejection/ICA/cleaning ownership.

Activity

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

    @suraj-ranganath
    MemberAuthor

    πŸ€–

    Research

    #209 is partially converged already: epoched browser state lives in _eegplot_rejection.py, and rejection component scoring intentionally recomputes from weights/sphere instead of trusting cached icaact. Remaining drift: pop_eegthresh, pop_rejspec, and pop_rejtrend still duplicate the apply/display/reject scaffold, and clean_rawdata updates clean_channel_mask with three different variants. Duplicate-work preflight found no open PR for #209 scope; PR #190 is ICA GUI progress work and does not overlap final ICA field invariants.

    Relevant code

    Proposed Fix

    Add a generic epoched rejection application helper for precomputed mark methods, route threshold/spectrum/trend through it, and keep jointprob/kurtosis on the stats-aware helper. Add a clean_rawdata private helper that updates etc.clean_channel_mask using the EEGLAB rule: update existing retained positions when mask cardinality matches current channels, otherwise create a current-channel mask. Harden ICA finalization tests around shared sort/posact invariants and leave rejection component scoring recompute-only, with tests documenting stale icaact is ignored for rejection.

  3. suraj-ranganath commented on Jun 12, 2026

    @suraj-ranganath
    MemberAuthor

    πŸ€– Completed by merged phase PR #215 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