Skip to content

Phase 6c standalone STUDY integration hardening - #92

Merged
suraj-ranganath merged 1 commit into
feature/study-standalone-completionfrom
phase/6c-standalone-integration
May 30, 2026
Merged

suraj-ranganath merged 1 commit into
feature/study-standalone-completionfrom
phase/6c-standalone-integration

Conversation

@suraj-ranganath

@suraj-ranganath suraj-ranganath commented May 30, 2026 •

Copy link
Copy Markdown
Member

Motivation

Phase 6c is the final integration and release-hardening pass for the STUDY/standalone epic #78. It also folds in the still-open Phase 5d end-to-end hardening scope so this PR closes both Phase 6c and Phase 5d.

Closes #82
Closes #80

Final integration scope

  • Adds an end-to-end multi-dataset STUDY workflow test covering saved ICA datasets, STUDY creation, design editing, channel and component precompute, plotting, preclustering, clustering, cluster plotting, study save/load with datasets, and console inspection.
  • Fixes integration bugs found by that workflow:
    • eeg_checkset now normalizes non-dict EEG["etc"] before storing ICA RMS-scaling backups from loaded MATLAB files.
    • trialinfo_from_eeg handles NumPy epoch arrays without ambiguous truth-value checks.
    • pop_chanplot now records replayable STUDY = pop_chanplot(...) history when it updates STUDY["etc"]["last_chanplot"].
  • Removes installed-runtime reliance on a vendored EEGLAB checkout for MATLAB/Octave compatibility helpers. get_eeglab() now resolves EEGLAB from EEGPREP_EEGLAB_ROOT or a sibling development checkout and fails clearly otherwise.
  • Updates STUDY docs/API summary and .notes/implementation-notes.html with final integration decisions, QA evidence, parity findings, and open risks.

End-to-end STUDY workflow evidence

New coverage in tests/test_study_end_to_end.py validates:

  • create/load path: two saved ICA .set fixtures are loaded through pop_loadstudy(..., load_datasets=True) after STUDY save/load;
  • design path: pop_studydesign selects a condition design;
  • precompute/plot path: pop_precomp computes channel and component measures and pop_chanplot records a replayable STUDY history command;
  • clustering path: pop_preclust, pop_clust, and pop_clustedit(action="plot") run on the integrated STUDY;
  • console sync path: EEGPrepConsoleWorkspace calls pop_chanplot and pop_clustedit, then asserts STUDY, CURRENTSTUDY, LASTCOM, and ALLCOM are synchronized.

Runtime dependency and menu inventory audit

  • Runtime grep/audit found no STUDY runtime path reading from src/eegprep/eeglab.
  • eeglabcompat no longer assumes packaged/vendored EEGLAB files exist at runtime.
  • Placeholder/menu tests pass with only the explicit EEGBrowser/eegplot exclusion remaining.
  • Study-owned menu actions asserted implemented: pop_study:edit, pop_studydesign, pop_precomp:channels, pop_chanplot, pop_precomp:components, pop_preclust, pop_clust, pop_clustedit, select_study_set, and clear_study.
  • EEGLAB menu inventory exported for startup/continuous/epoched/multiple states. Differences are expected EEGPrep branding/help/plugin-management labels plus startup ICLabel viewprops enablement. EEGLAB exporter does not support a study state; EEGPrep study-state inventory was exported separately and shows all Study menu entries enabled.

Visual parity and GUI Agent QA

Generated local visual parity artifacts under .visual-parity/ and did not commit them. GitHub user-attachment evidence is posted in PR comment #92 (comment).

  • main_window_study: EEGLAB and EEGPrep captures succeeded; compare report mean_abs_delta=0.035897, different_pixel_ratio=0.091817.
  • study_menu, pop_study_dialog, pop_studydesign_dialog: both EEGLAB and EEGPrep captures succeeded; compare metrics are dominated by macOS crop/window-size mismatch and known dialog-scope differences.
  • pop_precomp_dialog: EEGPrep capture succeeded; EEGLAB capture timed out after 180 seconds.
  • pop_chanplot_dialog, pop_preclust_dialog, pop_clust_dialog, pop_clustedit_dialog: EEGPrep-only captures succeeded after the EEGLAB timeout.

GUI Agent QA used Computer Use against the Qt pop_precomp dialog:

  • verified accessible controls for target mode, measure checkboxes, parameter fields, Help, Cancel, and OK;
  • opened and closed packaged Help for pop_precomp;
  • edited spectrum params to 'winsize', 32, enabled ERSPs, pressed OK, and verified the returned dialog result.

Verification

  • uv run --no-sync ruff check . passed.
  • uv run --no-sync ruff format --check . passed.
  • uv run --no-sync ty check passed after syncing optional gui and torch extras.
  • uv run --no-sync pytest tests/test_study_end_to_end.py tests/test_study_metadata.py tests/test_study_measures.py tests/test_study_clustering.py tests/test_console_workspace.py tests/test_menu_placeholder_inventory.py -q: 119 passed, 1 skipped.
  • uv run --no-sync pytest tests/test_study_end_to_end.py -m matlab -q: 1 skipped, 3 deselected. Exact blocker: matlab.engine is not installed in the uv environment.
  • EEGPREP_SKIP_MATLAB=1 uv run --no-sync pytest -m "not slow": 1618 passed, 229 skipped, 11 deselected, 163 warnings.
  • uv run --no-sync pytest tests/test_visual_parity.py -q: 24 passed, 30 subtests passed.
  • ./pre-commit.py: passed on staged files.

Remaining risks

  • Exact k-means labels remain implementation-sensitive because EEGPrep uses deterministic scikit-learn k-means rather than MATLAB k-means. The integration test asserts component coverage and cluster structure rather than exact label parity.
  • MATLAB-enabled STUDY metadata parity test is present but skipped locally because the MATLAB Python engine is unavailable, even though the MATLAB CLI exists.

@claude

claude Bot commented May 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @suraj-ranganath's task in 3m 36s —— View job


PR Review: Phase 6c standalone STUDY integration hardening

  • Read PR diff against origin/feature/study-standalone-completion
  • Review eeg_checkset.py etc normalization change
  • Review eeglabcompat.py get_eeglab resolution
  • Review _study_utils.py trialinfo handling
  • Review pop_chanplot.py history command change
  • Review new tests/test_study_end_to_end.py
  • Review docs changes
  • Post inline review comments
  • Post review summary

Summary

Overall the PR is tightly scoped, well-tested, and delivers what the description claims: a real end-to-end STUDY workflow test plus three small targeted fixes for the bugs it surfaced, plus the eeglabcompat decoupling required by AGENTS.md. I think this is in good shape to merge after the small nits below.

What I verified

  • The four src changes each map cleanly to a bug or workflow item described in the PR body.
  • _resolve_eeglab_root correctly removes the previous PACKAGE_ROOT / 'eeglab' lookup so the installed eegprep package no longer needs the vendored src/eegprep/eeglab/ checkout to exist at runtime — consistent with the AGENTS.md "Runtime code in the installed eegprep package must work without src/eegprep/eeglab/ present" rule.
  • The trialinfo_from_eeg fix is the right way to dodge numpy truthiness on epoch — eeg.get("epoch") or [] would have raised ValueError: ambiguous truth value on any non-empty ndarray.
  • The pop_chanplot history string change to STUDY = pop_chanplot(...) is needed because the function returns a mutated STUDY (new etc.last_chanplot); a bare pop_chanplot(...) replay would discard that update. The test (test_study_end_to_end_workflow_roundtrips_and_syncs_console) explicitly covers the console-driven replay path.
  • tests/test_study_end_to_end.py imports tests.fixtures like several other existing tests, so the package-style import works.

Findings

Posted as inline comments — all non-blocking:

  1. tests/test_study_end_to_end.py:117 — np.asarray(None).size == 1, so the icaweights assertion would pass for None. Tighten to eeg.get("icaweights") is not None and np.asarray(...).size.
  2. tests/test_study_end_to_end.py:104 — saved is unused; rename to _saved to signal intent.
  3. src/eegprep/functions/adminfunc/eeglabcompat.py:49-52 — error message only mentions EEGPREP_EEGLAB_ROOT, not the sibling ../eeglab fallback that is actually also searched.
  4. src/eegprep/functions/adminfunc/eeg_checkset.py:255 — the new isinstance(..., dict) guard silently discards any non-dict EEG['etc']. Fine for the empty-array case it targets, but worth a logger.debug on the overwrite for traceability.

Observations (no action required)

  • The _resolve_eeglab_root change is a small but real behavior change for contributors who relied on src/eegprep/eeglab/ being picked up automatically by parity helpers. They'll now need to either set EEGPREP_EEGLAB_ROOT or place a sibling checkout. This is intentional and matches the PR motivation; just flagging so it makes it into release notes if applicable.
  • Per the PR body, the visual-parity PNGs are deliberately not committed and were attached out-of-band as user attachments; that aligns with AGENTS.md and the eeglab-gui-visual-parity skill guidance.
  • test_study_metadata_matlab_parity_when_reference_is_available correctly skips when MATLAB engine is unavailable, preserving the parity-test skip behavior required by AGENTS.md.
    • Branch

@suraj-ranganath

Copy link
Copy Markdown
Member Author

🤖 GUI Agent QA report for Phase 6c

Scope

  • Branch/base: phase/6c-standalone-integration -> feature/study-standalone-completion
  • Features tested: integrated STUDY create/design/precompute/plot/preclust/cluster/save/load plus mixed GUI/help and console synchronization paths.
  • Data used: synthetic two-dataset ICA STUDY fixture in tests/test_study_end_to_end.py; visual parity demo STUDY fixtures from tools/visual_parity.

Automated/CLI Checks

  • uv run --no-sync pytest tests/test_study_end_to_end.py tests/test_study_metadata.py tests/test_study_measures.py tests/test_study_clustering.py tests/test_console_workspace.py tests/test_menu_placeholder_inventory.py -q: 119 passed, 1 skipped.
  • EEGPREP_SKIP_MATLAB=1 uv run --no-sync pytest -m "not slow": 1618 passed, 229 skipped, 11 deselected, 163 warnings.
  • uv run --no-sync pytest tests/test_study_end_to_end.py -m matlab -q: 1 skipped, 3 deselected; blocker is missing matlab.engine in the uv environment.

GUI Flow Results

Flow Steps Expected Actual Result
pop_precomp dialog help Opened Qt dialog, clicked Help, inspected packaged pop_precomp help, clicked Close Help opens from packaged resource and returns to dialog Help dialog opened with pop_precomp.md, Close returned to main dialog Passed
pop_precomp parameter edit Set spectrum params to 'winsize', 32 Text field accepts edited parameter string Accessibility tree and screenshot showed updated value Passed
pop_precomp measure toggle and OK Enabled ERSPs and clicked OK Dialog returns selected values and closes cleanly Process printed result with ersp_on=True, updated spec params, and no crash Passed
Console sync Ran end-to-end test console wrapper calls for pop_chanplot and pop_clustedit STUDY, CURRENTSTUDY, LASTCOM, ALLCOM stay synchronized Assertions passed; pop_chanplot history now replays as STUDY = pop_chanplot(...) Passed

Visual Evidence Generated Locally

  • Side-by-side: .visual-parity/main_window_study/side_by_side.png
  • Side-by-side: .visual-parity/study_menu/side_by_side.png
  • Side-by-side: .visual-parity/pop_study_dialog/side_by_side.png
  • Side-by-side: .visual-parity/pop_studydesign_dialog/side_by_side.png
  • EEGPrep-only captures: .visual-parity/pop_precomp_dialog/eegprep.png, .visual-parity/pop_chanplot_dialog/eegprep.png, .visual-parity/pop_preclust_dialog/eegprep.png, .visual-parity/pop_clust_dialog/eegprep.png, .visual-parity/pop_clustedit_dialog/eegprep.png

Issues Found

  1. pop_loadstudy(..., load_datasets=True) failed for saved ICA datasets when loaded EEG["etc"] was an empty NumPy array. Fixed in eeg_checkset.
  2. STUDY metadata refresh failed on loaded epoched datasets because trialinfo_from_eeg used ambiguous NumPy array truthiness for epoch. Fixed in _study_utils.py.
  3. Console history for pop_chanplot was not replayable as a STUDY update. Fixed by emitting STUDY = pop_chanplot(...).

Warnings/Residual Risk

  • EEGLAB pop_precomp_dialog visual capture timed out after 180s on macOS; EEGPrep-only evidence was generated for that and subsequent STUDY dialogs.
  • EEGLAB menu inventory exporter does not support study state; EEGPrep study-state inventory was exported separately.
  • Exact k-means label parity remains intentionally out of scope; tests assert structure and component coverage.

Cleanup

  • No GUI test process left running.
  • Visual artifacts remain uncommitted under .visual-parity/.

Comment thread tests/test_study_end_to_end.py Resolved
Comment thread tests/test_study_end_to_end.py Resolved
@suraj-ranganath
suraj-ranganath force-pushed the phase/6c-standalone-integration branch from f28378c to 0a8a7bd Compare May 30, 2026 12:16
@suraj-ranganath

Copy link
Copy Markdown
Member Author

🤖 Phase 6c visual parity user attachments

Attached visual evidence generated during the Phase 6c refresh. Side-by-side images are included where EEGLAB capture succeeded; EEGPrep-only images are included for STUDY dialogs where the EEGLAB capture path timed out and the QA report documents the blocker.

phase6c-main-window-study-side-by-side.png
phase6c-pop-chanplot-dialog-eegprep-only.png
phase6c-pop-clust-dialog-eegprep-only.png
phase6c-pop-clustedit-dialog-eegprep-only.png
phase6c-pop-preclust-dialog-eegprep-only.png
phase6c-pop-precomp-dialog-eegprep-only.png
phase6c-pop-study-dialog-side-by-side.png
phase6c-pop-studydesign-dialog-side-by-side.png
phase6c-study-menu-side-by-side.png

@suraj-ranganath
suraj-ranganath force-pushed the phase/6c-standalone-integration branch from 0a8a7bd to 559ab29 Compare May 30, 2026 18:01
@suraj-ranganath
suraj-ranganath merged commit 4c1d5e6 into feature/study-standalone-completion May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant