pop_topoplot conversion - #286
Conversation
EEGLAB scales component maps with maplimits='absmax' (per-map), while ERP latency maps share one symmetric absmax. The port applied a single shared scale to both, washing out weak components next to strong ones. Keep the shared scale for ERP maps and let topoplot resolve 'absmax' per component map.
Component maps use an arbitrary per-map scale, so a numeric colorbar is meaningless. Have pop_topoplot own the colorbar (as EEGLAB does) and mark component-map colorbars with -/0/+ polarity labels; ERP colorbars stay numeric.
EEGLAB's topoplot expands the color axis 5% beyond the data limits (caxis). Apply the same margin when resolving absmax/numeric maplimits so scalp-map color scaling matches EEGLAB exactly (verified: ERP shared clim +/-16.52 and per-component clim match MATLAB). Also improves spectopo, which scales its maps via topoplot 'absmax'.
|
@claude please review and comment on the current PR. Point out points of concern. |
|
Claude finished @innaamogolonova's task in 4m 3s —— View job PR Review:
|
|
Addressing review comments: #1 — _clim_kwargs asymmetric widening: This is faithful to EEGLAB — topoplot.m:1247-1250 applies the same per-endpoint v → 1.05·v to numeric maplimits, not just absmax, so a range-relative pad would diverge from the oracle. Keeping as-is (all pop_topoplot callers pass symmetric limits anyway). #2 — backend guard too permissive: Fixed in e2c5707 — display is now gated on whether the backend is interactive (excluding Agg/PDF/SVG/PS/Cairo/template), so non-interactive backends no longer warn. Also aligned with EEGLAB, which shows the figure from both the GUI and the command line. #3 — shared colorbar reflects the last map: Intentional parity — EEGLAB's component pages do the same (cbar('vert',0,get(gca,'clim')) uses the last axes' clim), and the -/0/+ labels exist precisely to signal that the scale is per-map, not a shared numeric one. Keeping as-is. #4 — weak negative assertion: Fixed in 1053db8 — the ERP branch now positively asserts the colorbar labels are numeric (≥2 non-empty labels, each parses as a float) instead of just != ["-","0","+"]. #5 — self-referential expected values: This test is intentionally regression-only: it verifies the per-map scaling and 5% margin are applied consistently. The numeric core it relies on — the interpolated grid — is already pinned against MATLAB to 1e-5 in TestTopoplotParity, so external-oracle coverage exists where it matters. #6 — minor cleanups: Done in 76f4247 — dropped the unused _add_map_colorbar return and rewrote the _clim_kwargs comment to state the exact formula (1.05*v per endpoint). The dict(options) copy is intentional, since _plot_map_pages pops from it. |
|
@claude please review and comment on the current PR. Review the addressed comment changes. Point out points of concern. |
|
Claude finished @innaamogolonova's task in 2m 44s —— View job PR Re-review: addressed comment changes
SummaryThe three commits that landed since the first pass address the two blocking concerns and the test-quality nit cleanly. The one I flagged as a latent correctness bug (#1) turns out to be a misread on my part — EEGLAB really does apply the 5% margin per-endpoint regardless of how Verified against EEGLAB#1 — cax_sgn = sign([amin amax]);
if ~all(cax_sgn == 0)
caxis([amin+cax_sgn(1)*(0.05*abs(amin)) amax+cax_sgn(2)*(0.05*abs(amax))]);
endsits outside the #4 — Positive numeric-label assertion. #6 — Cleanups. Concerns worth mentioning (all minor)1. Zero-endpoint edge case in
|
|
ERP scalp maps after fix in sccn/eeglab#952
|






pop_topoplot: EEGLAB scalp-map parity
Brings
pop_topoplot(and the sharedtopoplot) in line with EEGLAB for 2-D scalp maps.Changes
maplimits='absmax'vs shared behavior.-/0/+(arbitrary per-map scale), like EEGLAB; ERP colorbars stay numeric.pop_topoplotandplot_channel_locationspreviously built figures but never displayed them (same class of bug as the earlier spectopo fix).topoplotwidens the color axis by EEGLAB's 5%caxismargin, so color scaling matches exactly (also improvesspectopo, which scales viatopoplot).Verified against MATLAB EEGLAB
Ziidentical to2e-13; colormap (turbo) and contour levels identical.[0 100 200 300]→±16.52; components[1 2 3]→±4.51 / ±1.92 / ±1.78.tests/test_pop_topoplot.pyupdated; suite green.Notes