Fix channel ordering - #13943
Conversation
…misalignment of evokeds in compare evoked topo mode
|
Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴 |
There was a problem hiding this comment.
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_evokedsby 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. |
Co-authored-by: Marijn van Vliet <w.m.vanvliet@gmail.com>
|
@Gnefil Could you create an account on https://app.circleci.com so the docs build will also run for you? |
|
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. I have read the contribution guide, #13837 and journey at #13848 to handle CI properly. But, the instructions are surprisingly unstraightforward.
|
|
Thanks @Gnefil ! Hopefully CircleCI cooperates on the next PR |

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.