Skip to content

Fix channel ordering - #13943

Merged
larsoner merged 7 commits into
mne-tools:mainfrom
Gnefil:fix-channel-ordering
Jun 12, 2026
Merged

Fix channel ordering#13943
larsoner merged 7 commits into
mne-tools:mainfrom
Gnefil:fix-channel-ordering

Conversation

@Gnefil

@Gnefil Gnefil commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Reference issue (if any)

Fixes #13924.

What does this implement/fix?

Fixes actually two bugs shown in one example. The scope is mne.viz.plot_compare_evokeds(evokeds, axes="topo").
When a single evoked is passed with arbitrary channel order, it mismatches with respect to topo map, showing the wrong channels.
When various evokeds are passed with different channel orders, they don't align automatically, showing the wrong channels on topo map again.

This PR fixes both.

Additional information

Test cases that failed and then succeeded were added.

@welcome

welcome Bot commented Jun 4, 2026

Copy link
Copy Markdown

Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴

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

This turned out be to be a nice clean fix. The CI's are unhappy because you changed what should be a warn into a print.

Comment thread mne/evoked.py Outdated
@Gnefil
Gnefil marked this pull request as ready for review June 6, 2026 03:55
@Gnefil
Gnefil requested review from agramfort and drammock as code owners June 6, 2026 03:55
Copilot AI review requested due to automatic review settings June 6, 2026 03:55
@Gnefil
Gnefil requested a review from mscheltienne as a code owner June 6, 2026 03:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR fixes plot_compare_evokeds(..., axes="topo") channel alignment issues when evokeds/channels are provided in arbitrary orders, and adds regression tests and a changelog entry.

Changes:

  • Reorder/align evoked channel order in plot_compare_evokeds by enabling in-place reordering in _check_evokeds_ch_names_times.
  • Fix topo plotting loop to ignore the legend axis and map picks to topo axes correctly.
  • Add tests covering reordered channels and multi-evoked alignment in topo mode, plus a changelog entry.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
mne/viz/tests/test_evoked.py Adds regression tests for topo mode when channels/evokeds come in different orders.
mne/viz/evoked.py Ensures channel alignment is applied (in-place) and adjusts the topo plotting loop to handle potential legend axes.
mne/evoked.py Extends _check_evokeds_ch_names_times with an inplace option to support in-place channel reordering.
doc/changes/dev/13943.bugfix.rst Documents the topo-mode bugfix in the changelog.

Comment thread mne/viz/evoked.py
Comment thread doc/changes/dev/13943.bugfix.rst Outdated
Comment thread mne/viz/tests/test_evoked.py
Gnefil and others added 2 commits June 6, 2026 18:43
@wmvanvliet wmvanvliet added the BUG label Jun 9, 2026
@wmvanvliet

Copy link
Copy Markdown
Contributor

@Gnefil Could you create an account on https://app.circleci.com so the docs build will also run for you?

@Gnefil

Gnefil commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

I have been trying to make CircleCI work for me. So far, I have pushed until this point, but I don't seem to have a permission to rerun it.
image

I have read the contribution guide, #13837 and journey at #13848 to handle CI properly. But, the instructions are surprisingly unstraightforward.

  1. I couldn't find the right entrance to public mne-python pipeline, only the personal repos, which don't even include the PR branch.
    The solution was to go directly to the target space: https://app.circleci.com/pipelines/github/mne-tools/mne-python. Any other trials in CircleCI logged as the GitHub user to find this mne-python failed.

  2. The CI can't be run manually unless permission is granted, I think?
    I could make a dummy commit to try to trigger the tests, but it's not clean. Any other ways to run it?

@larsoner
larsoner merged commit 1555a3c into mne-tools:main Jun 12, 2026
31 checks passed
@larsoner

Copy link
Copy Markdown
Member

Thanks @Gnefil ! Hopefully CircleCI cooperates on the next PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Channel ordering bug in mne.viz.plot_compare_evokeds when axes="topo"

4 participants