Repository navigation
pop_chanplot: Match channel rows and measure selection to the study - #1036
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 12s —— View job Code review
BlockingNone. Important
Nits
Test gaps
EEGLAB parity notesNone. The vendored
Note: I couldn't post the separate |
| measure = _measure_name(action) | ||
| selected = numeric_vector(result.get("chan_list", []), dtype=int).tolist() | ||
| channels = [] if not selected or 1 in selected else [index - 1 for index in selected if index > 1] | ||
| channels = selected |
There was a problem hiding this comment.
Important: rows are changrp positions, but the raw-ERP fallback reads them as dataset channel numbers.
Whenever STUDY.changrp exists, the rows now list changrp group names (L81-82). _plot_channel_measure only treats channels as group indices when the clicked measure is cached for channels. Otherwise _plot_loaded_erp reads the same numbers as 1-based channels of ALLEEG[0].
std_precomp can build changrp for only some channels (_precompute_channels loops over _channel_indices(chanorcomp, labels)). Example: std_precomp(..., channels=['Cz'], spec='on'), then OK with the default erp action. Row 1 ("All Cz") plots ALLEEG[0] channel 1 and records channels=[1] in history.
Suggested fix: when changrp exists and not _has_cached_channels(STUDY, measure), map each selected row to its group's channel with _group_channel_index(groups[row - 1], row). Or pass group names instead. Then add a test with a changrp that covers only some channels.
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
- Highest-risk area:
STUDY.changrpchannel mapping on uncached EEGLAB studies and untested Qt dialog callbacks - Merge recommendation: Needs changes
Blocking
None.
Important
- Severity: Important (
src/eegprep/functions/studyfunc/pop_chanplot.py,_run_guiand_group_channel_index,andeegprep/src/eegprep/functions/studyfunc/pop_chanplot.py
Lines 176 to 182 in 48efc63
): Wheneegprep/src/eegprep/functions/studyfunc/pop_chanplot.py
Lines 335 to 338 in 48efc63
_has_cached_channels(STUDY, measure)isFalse,_run_guimaps selected dialog rows through_group_channel_index(groups[row - 1], row), which readsgroup.get("inds") or [fallback]. Only EEGPrep'sstd_precompwrites"inds". MATLAB EEGLAB'sstd_changroup.mandpop_chanplot.mstorenameandchannelswithout"inds", and.studyfiles loaded from MATLAB have no in-memoryerpdata. If an EEGLAB.studyfile has a subsetSTUDY.changrp, had groups deleted or reordered in MATLAB, or merged non-identical dataset montages viaeeg_mergelocs,group.get("inds")is missing and_group_channel_indexfalls back torowinstead of matching the group's channel label againstdatasets[0], plotting the wrong channel or raisingValueErrorwhenlen(groups) > datasets[0]["nbchan"].
Suggested fix: Whengroup.get("inds")is empty in the raw ERP fallback path, resolvegroup.get("name")(or the first label ingroup.get("channels")) case-insensitively againstchannel_labels(datasets[0])(1-based) before falling back torow.
Nits
None.
Test gaps
- Severity: Important (
tests/test_study_measures.py,andeegprep/tests/test_study_measures.py
Lines 232 to 246 in 48efc63
src/eegprep/functions/guifunc/qt.py,):eegprep/src/eegprep/functions/guifunc/qt.py
Lines 539 to 553 in 48efc63
test_channel_dialog_subset_changrp_raw_erp_fallback_uses_group_channelbuilds the Qt widgets, asserts only thechan_listitem text, and returns a hardcoded{"chan_list": [1]}dictionary. None of the tests exercise the newselect_all_rowscallback, thestudy_channel_subjectsselection callback updatingchan_onechan, theavailable[measure]button enablement states, or clicking an enabled measure button (such asplot_chan_spectra) and reading widget values back via_read_widgetto verifymeasure_actionsurviveslayout="supergui"(which regressed in0302d8b5beforebfc5566achangedmeasure_actionfrom"spacer"to a hidden"text"control).
Suggested fix: Extend thepytest.mark.guitest intests/test_study_measures.pyon a multi-channel study withspec="on"to assertplot_chan_erpis disabled andplot_chan_spectrais enabled, clickselect_all_channelsto verify all rows select andchan_onechanupdates its labels, and clickplot_chan_spectraand read widget values through_read_widgetsopop_chanplotexecutesmeasure="spec".
EEGLAB parity notes
- Verified dialog layout,
geomvert, row labels,"All <chan>"entries, subject list suffix updates, and measure button enablement againstfunctions/studyfunc/pop_chanplot.m(lines 178 to 255 and 365 to 410). Aside from the uncachedSTUDY.changrplabel resolution noted under Important and the documentedknown_differencesOK-submission workflow, behavior matches EEGLAB.
Verification run
Ran in a detached worktree at 48efc636adf2bd46f1045f94a5990bc8a7d9c2f5:
PYTHONPATH=<worktree>/src .venv/bin/python -m pytest tests/test_study_measures.py tests/test_study_end_to_end.py tests/test_gui_geometry.py: 154 passed, 67 skipped (Linux-only reference positions).PYTHONPATH=<worktree>/src .venv/bin/python -m pytest tests/test_gui_pop_study.py tests/test_guifunc_primitives.py: 35 passed, 1 deselected..venv/bin/ruff checkand.venv/bin/ruff format --checkon changed Python files: passed.
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:
STUDY.changrpchannel row mapping and Qt dialog callbacks inpop_chanplot. - Merge recommendation: Safe to merge.
Blocking
None.
Important
None.
Nits
None.
Test gaps
None.
EEGLAB parity notes
- Verified channel row labels (
All <chan>),superguigeometry andgeomvert, subject list suffix updates on single and multiple row selection,Sel. allselection behavior, measure button enablement against cached channel and component measures, and uncachedSTUDY.changrplabel resolution againstfunctions/studyfunc/pop_chanplot.mandfunctions/studyfunc/std_changroup.m.
Checked for correctness bugs, EEGLAB parity, data structure compatibility, tests for changed behavior (pop_chanplot.py, qt.py, study_workflows.rst, test_study_measures.py), and CLAUDE.md/AGENTS.md compliance at commit c8f48a3043fbd8d5256a7256afc273efdbc93b1a.
Tests run in a detached worktree at c8f48a3043fbd8d5256a7256afc273efdbc93b1a:
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: 198 passed, 70 skipped (Linux reference geometry), 1 deselected in 12.00s..venv/bin/ruff checkand.venv/bin/ruff format --checkonqt.py,pop_chanplot.py, andtest_study_measures.py: passed.
🤖 Part of #969 and #875. Match channel rows and measure selection to the study. Stacked on #1027.
Native measurements and validation
The N400 dialog has a maximum vertical difference of 0.762 px. On the recorded EEGLAB sample epochs, two native ERP plot submissions agree with MATLAB std_erp over each entire channel waveform to 3.54e-7 relative error. Twenty-six tests passed on jamming. The fallback raw ERP remains available on OK.
Full inventory report for the project team. pop_chanplot (p. 53). PDF · Editable Word.