Skip to content

Stream 7: Plots and plot history (F71-F99) - #592

Merged
suraj-ranganath merged 12 commits into
developfrom
cursor/stream-7-plots-865f
Nov 11, 2026
Merged

suraj-ranganath merged 12 commits into
developfrom
cursor/stream-7-plots-865f

Conversation

@suraj-ranganath

@suraj-ranganath suraj-ranganath commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

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

Finding Root cause Fix Test
F71 topoplot indexed channel lists with np.abs on an empty float array when theta was an empty array, so missing coordinates crashed the spectra plot Spectra still draw. The scalp-map frequency field is disabled. topoplot raises ValueError naming the function and Edit > Channel locations when no finite theta/radius remains test_f71_missing_coordinates_skip_maps_and_disable_frequency_field
F72 plottopo dropped the whole scalp layout when any selected channel lacked coordinates, and each panel autoscaled Channels with coordinates stay on the head. Empty-theta channels sit beside it, using the EEGLAB side placement. Every panel shares ±max(abs(data)), with a calibration bar test_f72_empty_channels_stay_beside_a_shared_scale
F73 Rectangular pop_plotdata treated dialog limits 0 0 as per-panel autoscale The same shared scale and calibration bar apply to rectangular arrays test_f73_rectangular_arrays_share_one_scale
F74 pop_envtopo:compare called the single-dataset function and rejected a list One dataset raises pop_envtopo: Need at least 2 datasets. Two datasets open a subtract field defaulting to 2 1, subtract epoch means, and require matching ICA weights. A zero-power difference plots. History names EEG([i j]) only for dialog or subindices values test_f74_compare_needs_two_datasets_and_subtracts_means
F76 The default envelope title was the set name alone Default title is Largest ERP components of {setname}, or Largest ERP components when the name is empty test_f76_default_envelope_title_includes_the_dataset_name
F77 Component 3-D maps forced maplimits = [-1, 1] and the turbo colormap. The co-register dialog already exists Component maps use jet and a per-map absmax scale. The dialog spec is locked for the co-register, Talairach, and manual coreg controls test_f77_component_headplot_dialog_coregisters_and_documents_jet
F78 Blank channel-location axes were clipped at about ±0.6, so the EEGLAB footer and edge labels were cut off, and clicks did not toggle the label Wider axes, footer N of M electrode locations shown, and a click that swaps the name and the number test_f78_channel_location_footer_and_name_toggle
F79 spectopo applied a reversed freqrange as axis limits, which flipped the frequency axis ValueError names spectopo and requires [lo hi] with 0 <= lo < hi <= Nyquist test_f79_reversed_frequency_range_names_spectopo
F82 / F99 history_command emitted Python keywords, so menu history could not be pasted into EEGLAB or replayed as MATLAB text History uses MATLAB 'key', value pairs and a trailing semicolon. figure; prefixes spectrum, array, and latency-map plots. The console drops figure and translates EEG([2 1]) into ALLEEG entries. For pop_envtopo it also passes those numbers as subindices. NaN is written as NaN test_f82_plot_history_is_matlab_and_replays
F83 pop_comperp drew one channel-mean axis, so legend colors did not match per-channel traces Each channel or component is its own panel. Average, standard-deviation, and per-dataset traces share that panel, and the legend uses the same colors test_f83_comparison_legend_colors_match_the_traces
F85 Event latency statistics used raw sample indices Values come from eeg_getepochevent, so latency and duration are milliseconds test_f85_event_latency_is_epoch_relative_milliseconds
F87 The statistics figure showed five numbers, one normal curve, and a blank head with no selected-channel marker The panel includes trimmed mean and standard deviation, quantiles, and the Kolmogorov-Smirnov verdict. The histogram adds the trimmed normal. A channel map marks the selected electrode. The figure uses a smaller layout test_f87_statistics_figure_shows_trimmed_values_and_a_channel_marker
F99 Preferences history recorded every supplied key, including values that already matched the saved option History records only options whose value changed, as 'option_...', 0 or 1 test_f99_preferences_history_keeps_changed_options

Intentional differences from EEGLAB

Documented in docs/source/user_guide/eeglab_migration.rst:

  • spectopo names freqrange in the error. EEGLAB spectopo.m line 183 reports the same rejection through finputcheck.
  • pop_envtopo plots a near-zero difference for two identical datasets. EEGLAB can raise an axes-limit error on that difference.
  • pop_envtopo records EEG([i j]) when the dialog or subindices names that ALLEEG pair. A two-dataset list with no indices is recorded as pop_envtopo(EEG, ...). Replaying EEG([3 1]) keeps [3 1]. 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.
  • Component pop_headplot uses per-map absmax and jet. EEGLAB pop_headplot.m lines 424-439 fix component maplimits at [-1 1]. icadefs.m selects turbo on MATLAB newer than 20.01.
  • EEGLAB prefixes EEG = when a head-plot spline file is computed because pop_headplot returns the dataset. EEGPrep writes the spline file onto the dataset during the call and returns the figures.

Tests

  • New: tests/test_stream7_plots.py.
  • History assertions in the phase-4 plot, time-frequency, visual, topoplot, and console tests now expect MATLAB text and replay it through _console_python_command.
  • test_envtopo_replay_keeps_the_named_datasets replays EEG([3 1]) and checks the returned history still names [3 1].
  • Local: 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. Use eeglab_data.set, eeglab_data_epochs_ica.set, and one recording whose channel locations have labels only.

EEG = pop_loadset('eeglab_data_epochs_ica.set');
% F71: clear coordinates, then channel spectra. Expect spectra and no scalp maps.
EEG2 = EEG;
for k = 1:EEG2.nbchan
    EEG2.chanlocs(k).theta = [];
    EEG2.chanlocs(k).radius = [];
end
pop_spectopo(EEG2, 1, [EEG.xmin EEG.xmax]*1000, 'EEG', 'percent', 100, 'freq', [6 10 22], 'freqrange', [2 25], 'electrodes', 'off');

% F72 / F73
pop_plottopo(EEG, 1:EEG.nbchan, EEG.setname, 0, 'ydir', 1);
pop_plotdata(EEG, 1, 1:EEG.nbchan, 1:EEG.trials, EEG.setname, 0, 1, [0 0]);

% F79: expect a finputcheck error. EEGPrep raises ValueError naming spectopo.
spectopo(mean(EEG.data,3), EEG.pnts, EEG.srate, 'freqrange', [25 2]);

% F82: menu history should look like
% figure; pop_spectopo(EEG, 1, [xmin xmax], 'EEG', 'percent', 100, 'freq', [6 10 22], 'freqrange', [2 25], 'electrodes', 'off');

% F85
pop_eventstat(EEG, 'latency', {'square'}, [], 5);

% F74: load two copies, then Plot > Component ERPs > With component maps (compare).
% With one dataset the menu should report that two datasets are required.
ALLEEG = []; EEG = eeg_emptyset;
[ALLEEG, EEG, CURRENTSET] = eeg_store(ALLEEG, EEG, 0); % replace with two real sets
pop_envtopo(ALLEEG, 'gui', 'on'); % or the compare menu callback

Do not merge without Suraj's approval.

Open in Web Open in Cursor 

cursoragent and others added 2 commits November 11, 2026 06:28
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]>
@suraj-ranganath
suraj-ranganath marked this pull request as ready for review November 11, 2026 07:11

@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.

@suraj-ranganath
suraj-ranganath marked this pull request as draft November 11, 2026 07:12
@suraj-ranganath
suraj-ranganath marked this pull request as ready for review November 11, 2026 07:12
@suraj-ranganath
suraj-ranganath marked this pull request as draft November 11, 2026 07:22
@suraj-ranganath
suraj-ranganath marked this pull request as ready for review November 11, 2026 07:22
Keep the stream 7 plot notes together with the channel-location and
BIDS coordinate entries from develop.

Co-authored-by: Suraj Ranganath <[email protected]>
@suraj-ranganath
suraj-ranganath marked this pull request as draft November 11, 2026 07:46
@suraj-ranganath
suraj-ranganath marked this pull request as ready for review November 11, 2026 07:46
Bring the Claude review workflow in line with develop and keep both
changelog entries.

Co-authored-by: Suraj Ranganath <[email protected]>
@suraj-ranganath
suraj-ranganath marked this pull request as draft November 11, 2026 08:22
@suraj-ranganath
suraj-ranganath marked this pull request as ready for review November 11, 2026 08:22
@claude

claude Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @suraj-ranganath's task in 2m 46s —— View job


Code review

  • Overall assessment: Needs changes. One history-replay regression. Everything else I checked matches the PR description.
  • Highest-risk area: Converting plot history to MATLAB text (plot_utils.history_command). Replay now depends on each Python pop_* signature matching EEGLAB's positional order.
  • Merge recommendation: Needs changes.

Blocking

None.

Important

pop_timtopo history replays with the wrong arguments. In src/eegprep/functions/popfunc/pop_timtopo.py, pop_timtopo (L67-L74), the history is now pop_timtopo(EEG, [range], [plottimes], 'title', 'winsize', ...). The Python signature is still pop_timtopo(EEG, plottimes, *args, ...), and the body ignores *args.

  • The console keywordizer binds the time range to plottimes. It then stops at the next numeric list and leaves the call positional.
  • Replaying a menu command therefore draws scalp maps at the time-range edges and silently drops the range, title, and winsize.
  • The previous Python-keyword history replayed correctly.
  • Fix: change the signature to EEGLAB's order, (EEG, timerange, plottimes, plottitle, ...), and update the call sites.

Details are in the inline comment.

Nits

  • In pop_spectopo.py (around L142-L145), the elif freqs: branch never adds anything. history_options already holds freqs/freq whenever freqs is non-empty. Drop the branch.

Test gaps

  • test_f82_plot_history_is_matlab_and_replays and _assert_python_command only call ast.parse on the replayed text. That checks the syntax, not which parameter each argument binds to, which is how the pop_timtopo regression got through. For every plot whose history changed from keywords to positional MATLAB form (pop_timtopo, pop_spectopo, pop_plottopo, pop_plotdata, pop_envtopo), add one test: run _console_python_command(command) with eval against {"EEG": eeg, **pop functions} and plot="off", then check one effective value, such as the scalp-map latency for timtopo or freqrange for spectopo.
  • test_f77_..._documents_jet only checks the dialog labels. Nothing asserts the new component behaviour: colormap='jet' and maplimits='absmax' when typeplot=0.

EEGLAB parity notes

  • Needs confirmation: the vendored EEGLAB checkout is not present in this runner, so I could not check this against pop_envtopo.m. MenuActionDispatcher passes all of ALLEEG to pop_envtopo, which raises Cannot process more than two datasets when more than two are loaded. The compare menu therefore stops working once a third dataset is loaded. Meanwhile, _parse_subindices validates against 1..count as if more than two datasets were supported. If EEGLAB's compare dialog picks two datasets from a larger ALLEEG, the length check should happen after subindices is resolved. If EEGLAB also rejects more than two, the unused range check can be simplified.
  • I did not run the MATLAB reference suite or any Python tests: this environment does not allow executing Python. I found the pop_timtopo problem by reading the console keywordizer, not by running it. The PR body already notes that the MATLAB reference run is still needed before merge.

Also checked, with no issues found:

  • the EEG([2 1]) → ALLEEG translation and nested-vector tokenizing
  • NaN history formatting
  • pop_editoptions writing history only for changed options
  • topoplot keeping its original channel indices when coordinates are missing
  • plottopo placing empty-theta channels beside the head and sharing one amplitude scale
  • pop_comperp lining up its per-channel overlays and chanlocs with the chans selection
  • pop_eventstat taking millisecond latencies from eeg_getepochevent
  • the zero-reference guard in envtopo
  • headplot absmax/jet handling

Comment on lines +67 to +74
command = history_command(
"pop_timtopo",
history_range,
numeric_vector(plottimes).tolist(),
plot_title,
leading_figure=True,
**command_kwargs,
)

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.

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 winsize are 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].

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 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.

cursoragent and others added 2 commits November 11, 2026 08:29
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]>
@cursor

cursor Bot commented Nov 11, 2026

Copy link
Copy Markdown

🤖 Follow-up on the review:

  • Removed the unused elif freqs: branch in pop_spectopo. history_options already carries freq or freqs.
  • test_positional_plot_history_replays_with_the_values_that_were_requested runs the MATLAB history for pop_spectopo, pop_plottopo, pop_plotdata, and pop_envtopo through the console keywordizer, executes it with plot='off', and checks a value that takes effect (frequency window, channel and time range, amplitude limits, and the envelope). Those signatures already follow EEGLAB's positional order, so they did not need the pop_timtopo change.
  • test_f77_component_headplot_dialog_coregisters_and_documents_jet now draws a component head plot and checks colormap jet with a symmetric per-map absmax scale.
  • EEGLAB pop_envtopo.m (pin 8ac485f6) shows the subtract field whenever length(EEG) > 1, applies EEG(subindices(1:2)), and only then rejects a list that is still longer than two. The compare callback in eeglab.m passes all of ALLEEG after requiring at least two datasets. pop_envtopo now selects the two indices before that limit. A direct call with three datasets and no dialog still raises Cannot process more than two datasets.

@suraj-ranganath
suraj-ranganath marked this pull request as draft November 11, 2026 08:37
@suraj-ranganath
suraj-ranganath marked this pull request as ready for review November 11, 2026 08:37
@claude

claude Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @suraj-ranganath's task in 1m 30s —— View job


Code review (re-review at b9f6374)

  • Pre-review gate and head check: the PR is open, not a draft, and its head is b9f6374, the commit I checked out.

  • Read the changes since the last review: the pop_timtopo signature, pop_envtopo dataset selection, the replay tests, and the pop_spectopo nit.

  • Correctness and parity passes

  • Posted review

  • Overall assessment: Needs changes, for one history-replay issue in pop_envtopo compare mode. The earlier findings are resolved.

  • Highest-risk area: pop_envtopo history. It writes EEG([i j]) as positions in the list it was given, while the console reads EEG([i j]) as ALLEEG positions.

  • Merge recommendation: Needs changes.

Blocking

None.

Important

pop_envtopo compare history names the wrong datasets after a replay. The problem is in src/eegprep/functions/popfunc/pop_envtopo.py:107.

  • A direct list call such as pop_envtopo([ALLEEG[2], ALLEEG[0]], ...) falls back to subindices=(1, 2) and returns pop_envtopo(EEG([1 2]), ...).
  • accept_pop_result puts that command in ALLCOM. _matlab_eeg_index_to_alleeg then turns it into [ALLEEG[0], ALLEEG[1]].
  • So replaying a menu command recorded as EEG([3 1]) draws the right plot but records EEG([1 2]). Replaying that new line plots a different pair of datasets, with no warning.
  • Fix: write EEG([i j]) only when the GUI resolved the indices against the full ALLEEG. A direct list call should not invent indices: either return no history command, or take the indices from an explicit subindices= keyword.
  • Test: replay EEG([3 1]) through the console and check that the command the replay returns still names [3 1].

Details are in the inline comment.

Nits

None.

Test gaps

None beyond the replay test above. The previous gaps are closed:

  • test_plot_history_preserves_effective_options runs the pop_timtopo history and checks the scalp-map latency.
  • test_positional_plot_history_replays_with_the_values_that_were_requested replays the spectopo, plottopo, plotdata and envtopo histories and checks a value each one applies.
  • F77 now checks that the component head plot uses jet with a symmetric absmax scale.
  • F74 covers picking 3 1 from three datasets in the GUI.

EEGLAB parity notes

None new. The vendored EEGLAB checkout is not in this runner, so I could not re-read pop_envtopo.m or pop_timtopo.m. The author's citation of pop_envtopo.m (pin 8ac485f6) is consistent with the new order: choose the two datasets first, then enforce the two-dataset limit.

Checked, no issues

  • pop_timtopo now takes (EEG, timerange, plottimes, plottitle). All callers in src/, docs/, tests/ and the help resource use keywords or the new order.
  • The dropped elif freqs: branch in pop_spectopo changes no behavior.
  • With subindices from the GUI, pop_envtopo reorders datasets before the > 2 check. A direct call with three datasets still raises.

Not run

I could not run pytest because this runner's sandbox denied the command. This review is from reading the code. The MATLAB reference suite is still outstanding, as the PR body says.

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]}])"

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.

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:

  1. From the menu, choose 3 1. History records pop_envtopo(EEG([3 1]), ...). This is correct.
  2. Replay that line in eegprep-console. It runs pop_envtopo([ALLEEG[2], ALLEEG[0]], ...) and the plot is correct, but the call returns EEG([1 2]), and that goes into ALLCOM.
  3. 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].

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 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.

cursoragent and others added 2 commits November 11, 2026 09:15
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]>
@suraj-ranganath
suraj-ranganath marked this pull request as draft November 11, 2026 09:18
@suraj-ranganath
suraj-ranganath marked this pull request as ready for review November 11, 2026 09:18
@claude

claude Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @suraj-ranganath's task in 46s —— View job


Code review (re-review at 83c0f19)

  • Pre-review gate: the PR is open and not a draft. Its head is 83c0f19, which matches the checkout. No earlier review marker was found.

  • Read the changes since the last review (571babe): how pop_envtopo records subindices, and how the console translates them

  • Correctness and parity passes

  • Post review

  • Overall assessment: Looks good. This commit fixes the replay problem with pop_envtopo compare history from the last review, and I found no new issues.

  • Highest-risk area: The console's handling of EEG([i j]) in envtopo history, in _pop_envtopo_dataset_indices.

  • Merge recommendation: Safe to merge once a human approves and the MATLAB reference run is recorded. The PR changes core plotting and signal-processing code, so AGENTS.md requires both.

Blocking

None.

Important

None.

Nits

None.

Test gaps

None. test_envtopo_replay_keeps_the_named_datasets covers all three cases:

  • replaying EEG([3 1]), after which the returned history still names [3 1]
  • the console translating that line to subindices=[3, 1]
  • choosing the pair from three datasets with subindices=[3, 1]

It also compares each envelope against a direct [third, first] call.

EEGLAB parity notes

None new. A direct call with two datasets and no indices now records pop_envtopo(EEG, ...) instead of inventing EEG([1 2]). EEGLAB pop_envtopo.m leaves that history line unset in the same case, and eeglab_migration.rst documents the difference.

Checked, no issues

  • pop_envtopo dataset selection:
    • An explicit subindices turns off the automatic GUI.
    • With more than two datasets, the pair is chosen and range-checked before the > 2 limit. With exactly two, the order is trusted as the caller gave it.
    • subindices is removed from kwargs before command_kwargs is built, so history does not repeat it as a 'subindices' pair.
  • Console translation:
    • _pop_envtopo_dataset_indices rewrites the first argument into ALLEEG entries and adds subindices= before the call's closing parenthesis.
    • This runs before _keywordize_console_pop_calls, so the replayed call is valid Python.
    • Commands with several statements are split first, so each pop_envtopo statement is handled on its own.
  • Validation: _index_pair and _parse_subindices reject indices below 1, and out-of-range indices when more than two datasets are passed.
  • Earlier findings: the pop_timtopo argument order, the replay tests for each positional plot, the jet/absmax head-plot assertion, and the dropped elif freqs: branch are all still in place.

Not run

  • pytest: the runner's sandbox would not let me run it, so this review is from reading the code.
  • MATLAB reference suite: still outstanding, as the PR body says.

cursoragent and others added 2 commits November 11, 2026 10:53
The one-shot timer ran before the dialog was modal, so cancel raised and exec blocked.

Co-authored-by: Suraj Ranganath <[email protected]>
@suraj-ranganath
suraj-ranganath marked this pull request as draft November 11, 2026 12:30
@suraj-ranganath
suraj-ranganath marked this pull request as ready for review November 11, 2026 12:30
@claude

claude Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

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


Code review (re-review at 5269ae9)

  • Pre-review gate: the PR is open and not a draft, and its head is 5269ae9, which matches the checkout. No earlier eegprep-claude-review marker was found.

  • Read the changes since the last review (83c0f19): the origin/develop merge (pop_chansel, [pop_chansel] Use the shared selection tokenizer #587, already reviewed upstream) and 5269ae9, which changes only tests

  • Correctness, convention, and parity passes on the new commit

  • Post review

  • Overall assessment: Looks good. The only change since the last review fixes a flaky study-design cancel test. No production code changed.

  • Highest-risk area: Unchanged from the last review: plot history in MATLAB form and the console replay of EEG([i j]) for pop_envtopo.

  • Merge recommendation: Safe to merge after a human approves and the MATLAB reference run is recorded. The PR changes core plotting and signal-processing code, so AGENTS.md requires both.

Blocking

None.

Important

None.

Nits

tests/test_gui_pop_study.py: _cancel_named_dialog repeats most of _on_modal.

  • Both helpers poll with QTimer.singleShot until a dialog appears, then act on it or reject it after 50 tries.
  • AGENTS.md asks tests to "reuse … local helpers already present in the relevant test file."
  • _on_modal keeps polling until the dialog becomes modal, which is the timing problem this commit fixes. So this call would already handle the cancel:
    _on_modal(qt_core, qt_widgets, lambda c: c.objectName() == "pop_studydesign", lambda c: c.findChild(qt_widgets.QPushButton, "cancel").click())
  • The new helper does add two things: it reports an error when the dialog never opens, and it falls back to any visible top-level widget. If those matter, add them to _on_modal rather than keeping a second poller.
  • The added dialog.setObjectName("") should not be needed either way. The earlier dialog is already closed, so it is not visible and is not the active modal widget.

This does not block merging.

Test gaps

None. Earlier coverage is still in place:

  • test_envtopo_replay_keeps_the_named_datasets
  • test_positional_plot_history_replays_with_the_values_that_were_requested
  • test_plot_history_preserves_effective_options
  • the F77 assertion that component head plots use jet with an absmax scale

EEGLAB parity notes

None new. The latest commit only changes tests.

Not run

  • pytest: I did not run it. This review is from reading the code.
  • MATLAB reference suite: still outstanding, as the PR body says.

cursoragent and others added 2 commits November 11, 2026 12:54
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]>
@suraj-ranganath
suraj-ranganath merged commit c1e0942 into develop Nov 11, 2026
10 checks passed
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.

[Release readiness] Stream 7: Plots and plot history

2 participants