Skip to content
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
eed9959
FIX: correct sensor name ordering in plot_topomap when using Info object
Famous077 Feb 25, 2026
8aaae3b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 25, 2026
4eb129b
ADD: changelog entry for fix sensor name ordering in plot_topomap #13686
Famous077 Feb 26, 2026
8261a97
Merge remote-tracking branch 'upstream/main' into fix/plot-topomap-se…
Famous077 Feb 26, 2026
9485d36
Merge branch 'main' into fix/plot-topomap-sensor-names
Famous077 Feb 26, 2026
5f84b29
FIX: fix changelog entry format and add name to names.inc
Famous077 Feb 26, 2026
1a3b004
Merge branch 'fix/plot-topomap-sensor-names' of https://github.com/Fa…
Famous077 Feb 26, 2026
f751b66
Address review feedback: remove duplicate changelog, fix format, add …
Famous077 Mar 2, 2026
a81c960
Merge branch 'main' into fix/plot-topomap-sensor-names
Famous077 Mar 2, 2026
476fc4c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 2, 2026
f291f93
TST: move imports to module level in test_plot_topomap_info_names_ord…
Famous077 Mar 4, 2026
166d865
DOC: fix contributor name in changelog and names.inc
Famous077 Mar 4, 2026
81fec95
Merge branch 'main' into fix/plot-topomap-sensor-names
Famous077 Mar 4, 2026
ffe984a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 4, 2026
1a535a2
Merge branch 'main' into fix/plot-topomap-sensor-names
Famous077 Mar 5, 2026
14833a9
TST: verify displayed sensor names match expected in test_plot_topoma…
Famous077 Mar 5, 2026
9bb8f60
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 5, 2026
1896bd3
TST: restore plt.close('all') calls and keep new test
Famous077 Mar 6, 2026
bd396c3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 6, 2026
154a0a2
Merge branch 'main' into fix/plot-topomap-sensor-names
Famous077 Mar 6, 2026
a510517
Merge branch 'main' into fix/plot-topomap-sensor-names
Famous077 Mar 10, 2026
dbe3a56
FIX: assert ordered sensor names in test_plot_topomap_info_names_orde…
Famous077 Mar 12, 2026
bbe5ff3
Merge branch 'fix/plot-topomap-sensor-names' of https://github.com/Fa…
Famous077 Mar 12, 2026
26977da
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 12, 2026
049e87c
Merge branch 'main' into fix/plot-topomap-sensor-names
Famous077 Mar 12, 2026
b4bfc48
style: fix import grouping via pre-commit
Famous077 Mar 12, 2026
149d6c5
Merge branch 'fix/plot-topomap-sensor-names' of https://github.com/Fa…
Famous077 Mar 12, 2026
115633a
DOC: revert contributor name to Famous077 for consistency
Famous077 Mar 19, 2026
5b6b8f3
FIX: remove unnecessary names reordering in else branch and update te…
Famous077 Apr 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changes/dev/13686.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix sensor name ordering in :func:`~mne.viz.plot_topomap` when passing an :class:`~mne.Info` object as ``pos`` with ``names`` argument, by :newcontrib:`Famous Raj Bhat`.
18 changes: 18 additions & 0 deletions mne/viz/tests/test_topomap.py
Original file line number Diff line number Diff line change
Expand Up @@ -987,3 +987,21 @@ def test_plot_ch_adjacency():
msg = "Editing a 3d adjacency plot is not supported."
with pytest.raises(ValueError, match=msg):
plot_ch_adjacency(info, adj, ch_names, kind="3d", edit=True)


def test_plot_topomap_info_names_ordering():
"""Regression test for GH-12700.

plot_topomap() must preserve correct sensor name ordering when
passing an Info object as pos with a names argument.
"""
info = create_info(ch_names=["Fp1", "Fp2", "Fz"], sfreq=1000.0, ch_types="eeg")
montage = make_standard_montage("standard_1020")
info.set_montage(montage)
data = np.array([1.0, 2.0, 3.0])
names = ["Fp1", "Fp2", "Fz"]
im, _ = plot_topomap(data, info, names=names, show=False)
assert im is not None
displayed_names = [t.get_text() for t in im.axes.texts]
for name in names:
assert name in displayed_names, f"{name!r} not found in {displayed_names}"
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.

This doesn't check that name ordering is preserved, it just checks that the names are present.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ tsbinns I will update shortly.

4 changes: 4 additions & 0 deletions mne/viz/topomap.py
Original file line number Diff line number Diff line change
Expand Up @@ -1292,9 +1292,13 @@ def _plot_topomap(
pos = _find_topomap_coords(pos, picks=picks[::2], sphere=sphere)
data, _ = _merge_ch_data(data[picks], ch_type, [])
data = data.reshape(-1)
if names is not None:
names = [names[p] for p in picks[::2]]
else:
picks = list(range(data.shape[0]))
pos = _find_topomap_coords(pos, picks=picks, sphere=sphere)
if names is not None:
names = [names[p] for p in picks]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since here picks is just list(range(len(data))) I don't think this is needed?


extrapolate = _check_extrapolate(extrapolate, ch_type)
if data.ndim > 1:
Expand Down