Repository navigation
Stream 7: Plots and plot history (F71-F99) - #592
Conversation
Spectra stay available without channel coordinates, ERP arrays share one scale, and component envelopes can compare two datasets. Plot history is MATLAB text that the console replays. Co-authored-by: Suraj Ranganath <[email protected]>
Dropping a channel before indexing the data array moved later values onto the wrong electrodes. History checks now expect the MATLAB semicolon. Co-authored-by: Suraj Ranganath <[email protected]>
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.
Keep the stream 7 plot notes together with the channel-location and BIDS coordinate entries from develop. Co-authored-by: Suraj Ranganath <[email protected]>
Bring the Claude review workflow in line with develop and keep both changelog entries. Co-authored-by: Suraj Ranganath <[email protected]>
|
Claude finished @suraj-ranganath's task in 2m 46s —— View job Code review
BlockingNone. Important
Details are in the inline comment. Nits
Test gaps
EEGLAB parity notes
Also checked, with no issues found:
|
| command = history_command( | ||
| "pop_timtopo", | ||
| history_range, | ||
| numeric_vector(plottimes).tolist(), | ||
| plot_title, | ||
| leading_figure=True, | ||
| **command_kwargs, | ||
| ) |
There was a problem hiding this comment.
Important: pop_timtopo history does not replay correctly in eegprep-console.
The history is now figure; pop_timtopo(EEG, [-50 100], [0], 'custom timtopo', 'winsize', [10]);, which matches EEGLAB's positional order. The Python signature is still pop_timtopo(EEG, plottimes, *args, ..., **kwargs) (pop_timtopo.py#L21-L30), and the body never reads *args.
_ConsoleCommandKeywordizer (console.py#L1214-L1259) binds the time range [-50, 100] to plottimes. The next argument, [0], is not a string key, so _keywordize_option_pairs stops there. The call then reaches the leftover_args and converted_keywords branch and is returned unchanged. When that call runs:
- scalp maps are drawn at −50 ms and 100 ms instead of 0 ms
- the time range, title, and
winsizeare silently dropped, because they go into the unused*args
Before this PR the same history replayed correctly as pop_timtopo(EEG, [0], timerange=..., ...). The replay tests only call ast.parse(...), so they do not catch this.
Suggested fix: match the signature to EEGLAB, pop_timtopo(EEG, timerange=None, plottimes=None, plottitle=None, *args, ...). Update the gui is None check and the call sites, such as pop_timtopo(sample_epoch, plottimes=[0]). Then add a test that replays the history and checks that the scalp-map latency stays [0].
There was a problem hiding this comment.
🤖 pop_timtopo now takes the EEGLAB argument order: time range, scalp-map latencies, then title. Replaying figure; pop_timtopo(EEG, [-50 100], [0], 'custom timtopo', 'winsize', [10]); draws the scalp map at 0 ms, and test_plot_history_preserves_effective_options executes that history and checks the latency.
The console was binding the time range to the scalp-map latencies. The function now takes the time range, latencies, and title in that order. Co-authored-by: Suraj Ranganath <[email protected]>
Console replay now checks a value that each plot history actually applies. Component envelopes choose two datasets before enforcing the two-dataset limit. Co-authored-by: Suraj Ranganath <[email protected]>
|
🤖 Follow-up on the review:
|
|
Claude finished @suraj-ranganath's task in 1m 30s —— View job Code review (re-review at
|
| history_range = timerange | ||
| if history_range is None or history_range == []: | ||
| history_range = [float(label_times[0]), float(label_times[-1])] if label_times.size else [] | ||
| eeg_name = "EEG" if subindices is None else f"EEG([{subindices[0]} {subindices[1]}])" |
There was a problem hiding this comment.
Important: compare history names the wrong datasets for direct list calls and for replays.
On a non-GUI call, subindices defaults to (1, 2) (L58-L60). Those are positions in the list that was passed in, not positions in ALLEEG. The console's new _matlab_eeg_index_to_alleeg (console.py) reads EEG([i j]) as ALLEEG indices. accept_pop_result stores the returned command in ALLCOM (console.py#L520-L525).
How it goes wrong:
- From the menu, choose
3 1. History recordspop_envtopo(EEG([3 1]), ...). This is correct. - Replay that line in
eegprep-console. It runspop_envtopo([ALLEEG[2], ALLEEG[0]], ...)and the plot is correct, but the call returnsEEG([1 2]), and that goes intoALLCOM. - Replay the new history line. It now plots dataset 1 − dataset 2, a different pair, without any warning.
Typing pop_envtopo([ALLEEG[2], ALLEEG[0]], [-100 100]) directly in the console records the same wrong EEG([1 2]).
Suggested fix: write EEG([i j]) only when the GUI resolved the indices against the full ALLEEG that the menu passed in. For a direct list call, which has no ALLEEG indices, do not invent any. Either return no history command, or have callers pass the indices explicitly, for example a subindices= keyword that the history then echoes. Add a test that replays EEG([3 1]) through _console_python_command and checks that the command returned by the replay still names [3 1].
There was a problem hiding this comment.
🤖 pop_envtopo writes EEG([i j]) only when those numbers come from the dialog or from an explicit subindices value. A two-dataset list with no indices is recorded as pop_envtopo(EEG, ...).
The console turns EEG([3 1]) into the selected datasets plus subindices=[3, 1]. The history returned by that call still names [3 1], and the envelope is dataset 3 minus dataset 1. test_envtopo_replay_keeps_the_named_datasets covers the replay.
EEGLAB pop_envtopo.m lines 170-174 write EEG([subindices]) only after the dialog creates subindices. A scripted two-dataset call leaves that history line unset, so EEGLAB does not record [1 2] here either. EEGPrep still returns a history command, and it keeps the real indices on replay. That difference is in docs/source/user_guide/eeglab_migration.rst.
A direct two-dataset list no longer stores EEG([1 2]). The console keeps EEG([3 1]) as subindices, so replaying that line still names those datasets. Co-authored-by: Suraj Ranganath <[email protected]>
Co-authored-by: Suraj Ranganath <[email protected]>
|
Claude finished @suraj-ranganath's task in 46s —— View job Code review (re-review at
|
Co-authored-by: Suraj Ranganath <[email protected]>
The one-shot timer ran before the dialog was modal, so cancel raised and exec blocked. Co-authored-by: Suraj Ranganath <[email protected]>
|
Claude finished @suraj-ranganath's task in 36s —— View job Code review (re-review at
|
The poll now closes a dialog that never appears and matches a visible top-level widget when the offscreen platform has no active modal. Co-authored-by: Suraj Ranganath <[email protected]>
The first-design warning is identified by its message. A fixed turn count expired before macOS exposed that box as a titled modal. Co-authored-by: Suraj Ranganath <[email protected]>
Fixes #552.
Summary
Release-readiness Stream 7: plot menus, shared ERP scales, component comparison, statistics figures, and MATLAB plot history that the console can replay.
Findings
topoplotindexed channel lists withnp.abson an empty float array whenthetawas an empty array, so missing coordinates crashed the spectra plottopoplotraisesValueErrornaming the function andEdit > Channel locationswhen no finite theta/radius remainstest_f71_missing_coordinates_skip_maps_and_disable_frequency_fieldplottopodropped the whole scalp layout when any selected channel lacked coordinates, and each panel autoscaledtest_f72_empty_channels_stay_beside_a_shared_scalepop_plotdatatreated dialog limits0 0as per-panel autoscaletest_f73_rectangular_arrays_share_one_scalepop_envtopo:comparecalled the single-dataset function and rejected a listpop_envtopo: Need at least 2 datasets. Two datasets open a subtract field defaulting to2 1, subtract epoch means, and require matching ICA weights. A zero-power difference plots. History namesEEG([i j])only for dialog orsubindicesvaluestest_f74_compare_needs_two_datasets_and_subtracts_meansLargest ERP components of {setname}, orLargest ERP componentswhen the name is emptytest_f76_default_envelope_title_includes_the_dataset_namemaplimits = [-1, 1]and the turbo colormap. The co-register dialog already existsjetand a per-mapabsmaxscale. The dialog spec is locked for the co-register, Talairach, and manual coreg controlstest_f77_component_headplot_dialog_coregisters_and_documents_jetN of M electrode locations shown, and a click that swaps the name and the numbertest_f78_channel_location_footer_and_name_togglespectopoapplied a reversedfreqrangeas axis limits, which flipped the frequency axisValueErrornamesspectopoand requires[lo hi]with0 <= lo < hi <= Nyquisttest_f79_reversed_frequency_range_names_spectopohistory_commandemitted Python keywords, so menu history could not be pasted into EEGLAB or replayed as MATLAB text'key', valuepairs and a trailing semicolon.figure;prefixes spectrum, array, and latency-map plots. The console dropsfigureand translatesEEG([2 1])intoALLEEGentries. Forpop_envtopoit also passes those numbers assubindices.NaNis written asNaNtest_f82_plot_history_is_matlab_and_replayspop_comperpdrew one channel-mean axis, so legend colors did not match per-channel tracestest_f83_comparison_legend_colors_match_the_traceseeg_getepochevent, so latency and duration are millisecondstest_f85_event_latency_is_epoch_relative_millisecondstest_f87_statistics_figure_shows_trimmed_values_and_a_channel_marker'option_...', 0or1test_f99_preferences_history_keeps_changed_optionsIntentional differences from EEGLAB
Documented in
docs/source/user_guide/eeglab_migration.rst:spectoponamesfreqrangein the error. EEGLABspectopo.mline 183 reports the same rejection throughfinputcheck.pop_envtopoplots a near-zero difference for two identical datasets. EEGLAB can raise an axes-limit error on that difference.pop_envtoporecordsEEG([i j])when the dialog orsubindicesnames that ALLEEG pair. A two-dataset list with no indices is recorded aspop_envtopo(EEG, ...). ReplayingEEG([3 1])keeps[3 1]. EEGLABpop_envtopo.mlines 170-174 writeEEG([subindices])only after the dialog createssubindices. A scripted two-dataset call leaves that history line unset.pop_headplotuses per-mapabsmaxandjet. EEGLABpop_headplot.mlines 424-439 fix componentmaplimitsat[-1 1].icadefs.mselectsturboon MATLAB newer than 20.01.EEG =when a head-plot spline file is computed becausepop_headplotreturns the dataset. EEGPrep writes the spline file onto the dataset during the call and returns the figures.Tests
tests/test_stream7_plots.py._console_python_command.test_envtopo_replay_keeps_the_named_datasetsreplaysEEG([3 1])and checks the returned history still names[3 1].QT_QPA_PLATFORM=offscreen uv run pytest tests/test_stream7_plots.py tests/test_phase4_plot_wrappers.py tests/test_phase4_timefreq_statistics.py tests/test_popfunc_visual_eeglab_tests.py tests/test_console_workspace.py tests/test_pop_topoplot.py tests/test_topoplot.py tests/test_pop_utils.py tests/test_stream11_preferences.py.MATLAB reference suite
MATLAB reference verification on jamming (MATLAB R2025b, EEGLAB d0963be9, eeglab_tests fec88f9f) at 83c0f19: tests/test_stream7_plots.py, tests/test_spectopo_parity.py, tests/test_envtopo_parity.py, 83 passed, 12 subtests passed, 0 failed. spectopo max abs difference 2.13e-14 dB; envtopo parity exact. Side-by-side figures for every #552 Stream 7 finding (F71 to F87, F99) show only cosmetic layout differences; documented differences are listed in the migration guide. Later commits merge develop and fix a test-only race.
GUI checks for the maintainer
Pinned EEGLAB
d0963be9d81acc5b66e84f8d3d7c89e3ce127cc4. Useeeglab_data.set,eeglab_data_epochs_ica.set, and one recording whose channel locations have labels only.Do not merge without Suraj's approval.