Repository navigation
pop_precomp: Restore separate channel and component precomputation dialogs - #1037
Conversation
There was a problem hiding this comment.
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 finished @arnodelorme's task in 1m 35s —— View job Code review
BlockingNone. Important
Nits
Test gaps
EEGLAB parity notes
Checked for correctness bugs, EEGLAB parity against |
| ), | ||
| ControlSpec("pushbutton", "...", tag="ersp_button", vertshift=True, enabled=False), | ||
| ControlSpec("pushbutton", "Test", tag="ersp_test", vertshift=True, enabled=False), | ||
| ControlSpec("checkbox", "", tag="itc_on", value=False), |
There was a problem hiding this comment.
Important (EEGLAB parity / UX): itc_on has no callback, so the ERSP/ITC parameter field can only be enabled from ersp_on. If a user ticks ITCs but not ERSPs, ersp_params stays disabled. They can't edit the time-frequency parameters, yet _options_from_gui still sends them as erspparams.
In EEGLAB, both checkboxes run the same setitc/setersp handler, and it enables ersp_params when either box is checked (pop_precomp.m L307-L325: if (~set_ersp && ~set_itc) ... 'enable','off' else ... 'enable','on'). The connector this PR draws between the two rows presents them as sharing one field, so the UI currently contradicts itself.
Suggested fix: make the enable state depend on ersp_on OR itc_on. You could add a small multi-source variant of toggle_enabled in qt.py (for example "sources": [...]), or wire both checkboxes to one handler. Also add a test that ticks only itc_on and checks that ersp_params is enabled.
| if "mode" in result: | ||
| chanorcomp = _kind_from_gui(result) |
There was a problem hiding this comment.
Nit (AGENTS.md): The dialog no longer has a mode control, so result can never contain "mode". This branch and _kind_from_gui (L207-L208) are now dead code. AGENTS.md says to "Remove imports, variables, functions, and files that your change made unused."
Fix: delete these two lines and the _kind_from_gui helper; chanorcomp stays as the caller passed it.
| "itc": "on" if is_on(result.get("itc_on")) else "off", | ||
| "scalp": "on" if is_on(result.get("scalp_on")) else "off", | ||
| "allcomps": "on" if is_on(result.get("allcomps_on")) else "off", | ||
| "allcomps": "off" if is_on(result.get("component_rv_on", not is_on(result.get("allcomps_on")))) else "on", |
There was a problem hiding this comment.
Nit: The PR removes the allcomps_on control, so the allcomps_on fallback here is dead. The nested default also makes this line hard to read. EEGLAB's logic is just "if compallersp is missing, treat it as 1" (pop_precomp.m: if ~isfield(os, 'compallersp'), os.compallersp = 1; end ... if os.compallersp == 0, 'allcomps' 'on').
| "allcomps": "off" if is_on(result.get("component_rv_on", not is_on(result.get("allcomps_on")))) else "on", | |
| "allcomps": "off" if is_on(result.get("component_rv_on", True)) else "on", |
| # supergui.m then leaves the control out of the figure width (layout="supergui"). | ||
| fit_width: bool = True | ||
| vertshift: bool = False | ||
| vertexpand: float = 1.0 |
There was a problem hiding this comment.
Nit (AGENTS.md: "No speculative configurability"): No control in the repo sets vertexpand; only vertshift is used, by pop_precomp. The field is threaded through ControlSpec, SuperguiControl, qt.measured and supergui_layout with no caller and no test.
Suggestion: drop vertexpand until a dialog needs it. supergui_layout then reduces to posy - (0.5 * height if control.vertshift else 0), with height unchanged.
# Conflicts: # docs/source/user_guide/study_workflows.rst # tests/test_study_measures.py
arnodelorme
left a comment
There was a problem hiding this comment.
This review was written by an AI assistant during a nightly check, not by Arno.
Code review
- Overall assessment: Needs changes. Two regressions arise where the updated dialog defaults meet
std_precomp. - Highest-risk area: Forwarding dialog measure selections and
ersp_paramsfrompop_precompintostd_precomp. - Merge recommendation: Needs changes.
Blocking
None.
Important
-
Changing default
ersp_paramsfrom'timesout'to'ntimesout'silently drops the requested 200 time points (pop_precomp.py, std_precomp.py).- Why it matters:
pop_precomp_dialog_specnow setsersp_paramsto"'cycles', [3 0.8], 'nfreqs', 100, 'ntimesout', 200"to match EEGLABpop_precomp.mline 68. However,std_precomp._newtimefonly passestimesout=params.get("timesout", 80)and never passesntimesouttonewtimef. As a result, checkingERSPsorITCsin the dialog now ignores'ntimesout', 200(as well as any user edit to'ntimesout') and computes 80 output time points instead of 200. - Suggested fix: Pass
ntimesout=params.get("ntimesout")alongsidetimesout=params.get("timesout", 80)instd_precomp._newtimef.newtimef._effective_timesout(newtimef.py) already applies EEGLAB's precedence rules (vectortimesoutoverntimesout, andntimesoutover scalartimesout=80).
- Why it matters:
-
Selecting only
Scalp mapsin the component dialog raisesValueError(pop_precomp.py, pop_precomp.py, std_precomp.py).- Why it matters: Because
erp_onandspectra_onnow start unchecked (value=False), ticking onlyScalp maps(scalp_on=True) in the restored component dialog callsstd_precomp(..., "components", erp="off", spec="off", ersp="off", itc="off", scalp="on"), which fails withValueError: std_precomp requires at least one measure enabledbecause_selected_measuresonly checks("erp", "spec", "ersp", "itc"). In EEGLAB (pop_precomp.mlines 239 to 241 andstd_precomp.mlines 496 to 524), precomputing component scalp maps alone is valid, and_precompute_components(std_precomp.py) already computescluster["topo"]whenscalp=True. - Suggested fix: In
std_precomp, treatkind == "components" and is_on(scalp)as an enabled measure so component scalp topographies can be precomputed on their own.
- Why it matters: Because
Nits
- Disabled parameter boxes are still parsed and emitted into history (pop_precomp.py).
- Why it matters:
erp_params,spec_params, andersp_paramsnow start disabled (enabled=False) until their measure checkbox is ticked, but_options_from_guialways parses all three text fields. Submitting with onlyERPschecked still emitsspecparamsanderspparamsin the history command, and an invalid edit in a box that the user subsequently unchecked and disabled will still raise a parse error on submission. EEGLABpop_precomp.mlines 229 to 274 only parses parameter strings for checked measures. - Suggested fix: Only parse and attach
erpparamswhenis_on(result.get("erp_on")),specparamswhenis_on(result.get("spectra_on")), anderspparamswhenis_on(result.get("ersp_on")) or is_on(result.get("itc_on")).
- Why it matters:
Test gaps
- Add a test in
tests/test_study_measures.pysubmittingpop_precompin GUI mode withersp_on=Trueand the defaultersp_paramsstring ('ntimesout', 200on an epoch long enough for 200 frames, or a distinct'ntimesout', 12) and assertinglen(study["changrp"][0]["ersptimes"])matchesntimesoutrather than falling back to 80. - Add a test in
tests/test_study_measures.pysubmittingpop_precomp(study, datasets, "components", gui=True, ...)with onlyscalp_on=Trueand assertingstudy["cluster"][0]["topo"]is populated.
EEGLAB parity notes
supergui_layout(link2linesandvertshift),_LinkedRows, and multi-sourcetoggle_enabledmatchsupergui.mlines 264 to 301 andpop_precomp.mlines 308 to 325.- Pre-existing and out of scope for this PR: channel controls
interpolate_on,rmica1_on, andrmica2_on/rmica2_valremain display-only in_options_from_gui(std_precompcurrently ignoresinterp,rmicacomps, andrmclust).
Tests run
Ran on detached worktree at commit 940d30e28f621a6c8844623b10153f187f1066b6 (note: b641193704bca016de157b5f289011ee6057b3c8 merged stacked PR #1036 without modifying pop_precomp.py or std_precomp.py):
PYTHONPATH=<worktree>/src .venv/bin/python -m pytest <worktree>/tests/test_study_measures.py: 10 passed in 11.91s.PYTHONPATH=<worktree>/src .venv/bin/python -m pytest <worktree>/tests/test_gui_geometry.py <worktree>/tests/test_guifunc_primitives.py <worktree>/tests/test_gui_pop_study.py: 178 passed, 67 skipped (Linux MATLAB reference geometry), 1 deselected in 12.44s.
arnodelorme
left a comment
There was a problem hiding this comment.
This review was written by an AI assistant during a nightly check, not by Arno.
Code review
- Overall assessment: Looks good.
- Highest-risk area: Forwarding dialog measure options from
pop_precomptostd_precompandSTUDY.changrpchannel row mapping inpop_chanplot. - Merge recommendation: Safe to merge.
Blocking
None.
Important
None.
Nits
None.
Test gaps
None.
EEGLAB parity notes
- Verified separate channel and component dialog controls,
superguigeometry andgeomvert,link2linesandvertshiftplacement, shared ERSP and ITC parameter enablement,ntimesoutforwarding tonewtimef, componentscalpprecomputation, ignoring unchecked parameter boxes, andpop_chanplotchannel row and subject list behavior againstfunctions/studyfunc/pop_precomp.m,functions/studyfunc/pop_chanplot.m, andfunctions/guifunc/supergui.m. - Unchanged and out of scope for this PR: channel controls
interpolate_on,rmica1_on, andrmica2_on(rmica2_val) remain display only inpop_precompwhilestd_precompignoresinterp,rmicacomps, andrmclust.
Checked for correctness bugs, EEGLAB parity, data structure compatibility, tests for changed behavior, and CLAUDE.md/AGENTS.md compliance at commit 9c99e0b8571fcecc103321f41e25a9d74a8b1a8a.
Tests run
Ran in a detached worktree at 9c99e0b8571fcecc103321f41e25a9d74a8b1a8a:
PYTHONPATH=<worktree>/src .venv/bin/python -m pytest <worktree>/tests/test_study_measures.py <worktree>/tests/test_study_end_to_end.py <worktree>/tests/test_gui_pop_study.py <worktree>/tests/test_guifunc_primitives.py <worktree>/tests/test_gui_geometry.py: 203 passed, 70 skipped (Linux MATLAB reference geometry), 1 deselected in 14.20s..venv/bin/ruff checkand.venv/bin/ruff format --checkon changed files: passed..venv/bin/ty checkon changed modules: passed.
|
🤖 The third review finds no blocking or important problem (commit
|
🤖 Part of #973 and #875. Restore separate channel and component precomputation dialogs. Stacked on #1027.
Native measurements and validation
On N400 the native channel and component windows are 458 and 405 px high in both applications. Maximum functional-control offsets are 0.515 and 0.604 px respectively. Qt paints the ERSP/ITC connector as one decoration, corresponding to four blank MATLAB buttons, excluded from functional-control distances. True Qt ERP submissions on sample recordings agree with the EEGLAB std_erp backend across every channel or component and every time point, with worst relative differences 3.54e-7 and 2.31e-7. Twenty-six tests passed. EEGPrep stores these results in memory, as indicated by its overwrite label. The ERP-image computation and separate parameter/test launchers remain unavailable in EEGPrep.
Full inventory report for the project team. pop_precomp (p. 54). PDF · Editable Word.
EEGLAB reference run (December 1, 2026)
Workflow
EEGLAB reference(.github/workflows/eeglab-reference.yml, real MATLAB backend) on commitc920cf81of the branch of #1041, which contains this pull request's final commit9c99e0b8: https://github.com/sccn/eegprep/actions/runs/46605236026EEGLAB
d0963be9, eeglab_testsfec88f9f. Runtime 1 hour 16 minutes, most of it waiting in the queue.The two failures are on develop and not from this pull request:
tests/test_stream11_datasets.py::test_f42_merge_opens_newset_and_cancel_preserves_datasets, failing since #904 gave thepop_mergesetdialog an empty title.What changes in
std_precomp.'ntimesout'is now passed tonewtimef(it was ignored, so the dialog's 200 time points became 80), and component scalp maps can be precomputed without another measure, as in EEGLAB.