Skip to content

Phase 5c: STUDY preclustering, clustering, and cluster editing parity #83

Closed

Description

@suraj-ranganath

🤖 Phase issue for the STUDY and standalone integration epic #78.

Goal

Implement STUDY preclustering, component clustering, cluster editing, and cluster plotting parity on top of Phase 5a STUDY contracts and Phase 5b measure outputs.

Target branch and PR flow

  • Create the phase branch from feature/study-standalone-completion after Phase 5b lands, unless an early branch is explicitly coordinated with the Phase 5b agent.
  • Open the phase PR back into feature/study-standalone-completion.
  • The phase PR should close this issue.

Dependencies

In scope

  • Build preclustering arrays.
  • Component clustering workflows.
  • Cluster editing workflows.
  • Cluster plotting workflows.
  • std_* helpers required by preclustering, clustering, and cluster editing/plotting.
  • GUI dialogs, help Markdown, history strings, and valid Python console echoes for clustering workflows.

Out of scope

  • STUDY measure precompute and measure plotting; see Phase 5b.
  • Final cross-phase integration evidence and broad GUI Agent QA; see Phase 5d.
  • External-only LIMO behavior unless explicitly represented by a clear user-facing message.

Acceptance criteria

  • Precluster, cluster, cluster-edit, and cluster-plot workflows are usable from GUI, Python API, and eegprep-console.
  • Cluster data structures match EEGLAB expectations where deterministic.
  • Tests cover representative multi-dataset fixtures, missing component measures, missing ICA, cancel/error paths, history replay, and MATLAB parity where feasible.
  • GUI dialogs and plotting flows have visual parity captures and PR user-attachment side-by-side images.
  • Required lint/type/test commands pass.

/goal prompt

/goal Complete EEGPrep parity for STUDY preclustering, component clustering, cluster editing, and cluster plotting workflows. Build on Phase 5a and 5b outputs, inspect EEGLAB source first, implement GUI/API/eegprep-console paths, add multi-dataset and MATLAB parity tests where deterministic, add visual parity screenshots, run ruff/format/ty and focused plus non-slow pytest, and iterate until review finds no actionable parity or correctness issues.

Activity

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

    @claude
    Contributor

    🤖 Plan:

    Research

    Issue is actionable as scope (clear in-scope/out-of-scope, acceptance criteria) but not implementable now:

    • Hard dependencies still open. Phase 5a Phase 5a: STUDY metadata, design, file I/O, and session synchronization #65 (STUDY metadata/design/file I/O/session sync) and Phase 5b Phase 5b: STUDY precompute, measures, and plotting parity #79 (precompute/measures/plotting) are both `OPEN`. The issue itself states 5c should branch from `feature/study-standalone-completion` after 5b lands; no `feature/study-standalone-completion` ref exists on origin (only `feature/eeglab-completion`).
    • Without 5a's STUDY/design/session contracts and 5b's precomputed component measure layout (ERP/spec/ersp/itc/topo/dipole arrays on disk), preclust/clust cannot be defined deterministically — preclustering reads exactly the measures 5b writes, and clustedit edits the STUDY/cluster structure 5a defines.
    • Vendored EEGLAB tree `src/eegprep/eeglab/` is empty in this checkout, so EEGLAB parity reads required by AGENTS.md (`std_preclust`, `std_clustread`, `pop_clust`, `pop_clustedit`, `pop_preclust`, `std_topoplot`, `std_envtopo`, `std_propplot`, etc.) cannot be performed here.
    • Existing STUDY scaffold is minimal stubs only (~126 LOC across 6 files); preclust/clust/clustedit modules don't exist.

    Relevant code

    Proposed Approach

    This is a design-doc-class change (>>100 LOC, multi-module, multiple GUI dialogs, MATLAB parity). Not opening a PR per the >100-line policy.

    Recommended sequencing once 5a and 5b are in:

    1. Branch off `feature/study-standalone-completion` (not `develop` or `feature/eeglab-completion`) per the issue.
    2. Land EEGLAB parity oracles first. Either restore the vendored `src/eegprep/eeglab/` checkout for development-time parity reads, or coordinate with whoever maintains it before parity work starts. Runtime code must still work without it (AGENTS.md).
    3. Implement in this order, each as its own commit so review can follow the EEGLAB call chain:
      • `std_preclust` (build the cluster matrix from 5b measure arrays; preserves `cluster.preclust.preclustparams`/`preclustdata`).
      • `pop_preclust` GUI + `return_com` wrapper (preclust array dialog: per-measure norm/weight/dims, ERP/spec/ersp time/freq windows).
      • `std_clust` (kmeans/neural-net branch parity with EEGLAB defaults; deterministic seeding for tests).
      • `pop_clust` GUI + history.
      • `std_clustread`/`std_renameclust`/`std_mergeclust`/`std_moveoutlier`/`std_rejectoutliers` helpers needed by clustedit.
      • `pop_clustedit` GUI (tree view of clusters, per-cluster plot buttons → ERP/spec/ersp/itc/topo/dipole/scalp; cluster rename/merge/move/outlier).
      • Help Markdown at `src/eegprep/resources/help/pop_preclust.md`, `pop_clust.md`, `pop_clustedit.md`.
    4. Tests (mirror EEGLAB `std_*` fixtures):
      • Deterministic multi-dataset preclust array shape/contents from a fixed 5b measure fixture.
      • Kmeans run with a fixed seed → exact cluster assignments stable.
      • clustedit merge/move/rename mutations applied to STUDY round-trip through save/load.
      • Missing-component-measure and no-ICA paths raise EEGLAB-equivalent errors.
      • Cancel/error dialog paths in GUI tests.
      • History replay: `pop_preclust`/`pop_clust`/`pop_clustedit` strings re-execute cleanly in `eegprep-console`.
      • MATLAB parity gated by `EEGPREP_SKIP_MATLAB` for std_preclust array and kmeans assignments where deterministic.
    5. Visual parity via `.agents/skills/eeglab-gui-visual-parity` for each of the three dialogs; attach side-by-side images as PR comment attachments (not committed).
    6. Session sync: every action through `EEGPrepSession.store_current`/`add_history`/`notify_changed`; coverage added to `tests/test_console_workspace.py`.
    7. Remove `pop_preclust`/`pop_clust`/`pop_clustedit` from `menu_placeholders.PLACEHOLDER_ACTIONS` only as each is implemented.

    Estimated size: ~2-4 KLOC + tests across studyfunc, guifunc, resources/help, tests, docs. Plan to split into sub-PRs by step (preclust, clust, clustedit) targeting `feature/study-standalone-completion` to keep review tractable.

    Open questions for the assignee/reviewer before implementation:

    1. Restore vendored EEGLAB in `src/eegprep/eeglab/` for this work, or rely on online sccn/eeglab reads?
    2. Should 5c split into three PRs (preclust / clust / clustedit) or land as one large phase PR?
    3. Neural-net clustering branch: port or defer behind a clear "not implemented" message? EEGLAB ships kmeans by default; neural-net is rarely used.
    4. Dipole-based clustering measure: include now (depends on DIPFIT phase) or scope out and surface a clear error?

    Cannot proceed to implementation; this is blocked on #65 and #79 and on the integration branch existing.

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