Skip to content

pop_clust: Open clustering for precomputed STUDY matrices and confirm replacement - #982

Merged
arnodelorme merged 2 commits into
developfrom
agent/issue-967-clust
Dec 1, 2026
Merged

arnodelorme merged 2 commits into
developfrom
agent/issue-967-clust

Conversation

@arnodelorme

@arnodelorme arnodelorme commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

🤖 Part of #967 and #875. Open clustering for precomputed STUDY matrices and confirm replacement. Stacked on #974.

Live MATLAB, EEGPrep before and after

Function output distances

Vertical control offsets

Native measurements and validation

EEGLAB and EEGPrep opened at 209 px high. The largest vertical offset was 0.46 px. The earlier Qt call failed while evaluating a NumPy matrix and never displayed a window. The same ten recordings now give the same default of 16 clusters, the same parent cluster name and an editable outlier threshold after checking Separate outliers. Both dialogs warn before replacing an existing clustering. EEGPrep offers its two implemented methods, Kmeans and Kmeanscluster. All component membership labels matched exactly for four clusters formed from three or ten scalp-map principal components of the same sample recording. The 18 local tests passed. Five optional MATLAB tests were deselected and the two membership tests were reproduced through native MATLAB.

Full inventory report for the project team. pop_clust (p. 52). PDF · Editable Word.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@claude

claude Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @arnodelorme's task in 1m 5s —— View job


Code review

  • Overall assessment: Looks good. The replacement warning, the default cluster count, the parent cluster name in the title line, the outlier-threshold toggle and the grid layout all match functions/studyfunc/pop_clust.m (sccn/eeglab develop). Re-clustering still deletes the old child clusters because std_createclust calls remove_child_clusters, so the warning is accurate. Cancelling the warning returns the STUDY unchanged with an empty command.
  • Highest-risk area: the new default cluster count for sub-clustering (see parity notes).
  • Merge recommendation: Safe to merge.

Blocking

None.

Important

None.

Nits

  • pop_clust.py:56-62 and pop_clust.py:130-132 work out clustlevel and the target cluster separately, and handle an out-of-range level differently. pop_clust skips the warning; pop_clust_dialog_spec falls back to level 1. EEGLAB resets clustlevel to 1 when it is larger than length(STUDY.cluster) (pop_clust.m, "if STUDY.etc.preclust.clustlevel > length(STUDY.cluster)"). One small helper that returns (level, cluster), used in both places, would keep the two code paths from drifting apart. This is optional.

Test gaps

None. The two new GUI tests cover the cancel path (only the Warning dialog opens, the STUDY is unchanged and the command is empty) and the default from the mean of ceil(mean(len(comps))). In the second test, preclustdata has 21 rows, which shows the default no longer depends on the number of preclust rows.

EEGLAB parity notes

  • Warning condition: at level 1, len(clusters) > 2 matches EEGLAB, where rmindex = 2:end is never empty. At deeper levels, EEGLAB looks for clusters whose parent{1} matches the target cluster and skips Notclust*. EEGPrep checks the target cluster's child list instead. The two agree because std_createclust adds every child it creates to parent["child"].
  • Default cluster count: this now matches EEGLAB: ceil(mean(cellfun(@length, {STUDY.datasetinfo.comps}))), or 10 when that is 2 or less. The old default never exceeded the number of preclust rows; the new one can. When you sub-cluster a small cluster, for example 6 components while datasets average 15 selected components, the dialog suggests 15. Clicking OK then raises Number of clusters cannot exceed the number of preclustered components. EEGLAB fails the same way inside kmeans, so this is parity and not a regression to fix here. It might be worth a line in resources/help/pop_clust.md.
  • The algorithm menu lists only Kmeans and Kmeanscluster. EEGLAB also lists Neural Network, Affinity Propagation and Optimal Kmeans. The docstring records this difference.
  • I didn't check the removed fixed size and stylesheet against EEGLAB myself. The PR description reports a maximum vertical offset of 0.46 px at 209 px dialog height.

I did not run the tests: the sandbox needed approval for pytest.

Checked for correctness bugs, EEGLAB parity, data structure compatibility, tests for the changed behavior, and CLAUDE.md/AGENTS.md compliance.

@arnodelorme
arnodelorme changed the base branch from agent/issue-939-study-geom to develop December 1, 2026 06:54
@arnodelorme
arnodelorme merged commit 016c669 into develop Dec 1, 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