From b75347cda45aea92448e4826382199916773957c Mon Sep 17 00:00:00 2001 From: PragnyaKhandelwal Date: Thu, 16 Apr 2026 23:08:43 +0530 Subject: [PATCH 1/2] MAINT: add OPM overlap grouping helper --- mne/viz/tests/test_topomap.py | 11 +++++++++++ mne/viz/topomap.py | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/mne/viz/tests/test_topomap.py b/mne/viz/tests/test_topomap.py index 1d5a72283b2..d364d196f18 100644 --- a/mne/viz/tests/test_topomap.py +++ b/mne/viz/tests/test_topomap.py @@ -840,6 +840,17 @@ def test_prepare_topomap_plot_opm_non_quspin_coils(): assert sum(name.endswith("MERGE-REMOVE") for name in merged_names) == 4 +def test_split_opm_overlaps(triaxial_evoked): + """Test splitting colocated OPM overlap sets into orientation groups.""" + _picks, _pos, merge_channels, _merged_names, *_ = topomap._prepare_topomap_plot( + triaxial_evoked, "mag" + ) + + radial, tangential = topomap._split_opm_overlaps(merge_channels) + assert radial == ["OPM001", "OPM004"] + assert tangential == ["OPM002", "OPM003", "OPM005", "OPM006"] + + def test_plot_topomap_nirs_overlap(fnirs_epochs): """Test plotting nirs topomap with overlapping channels (gh-7414).""" fig = fnirs_epochs["A"].average(picks="hbo").plot_topomap() diff --git a/mne/viz/topomap.py b/mne/viz/topomap.py index c56bb05d172..fcbd213ce78 100644 --- a/mne/viz/topomap.py +++ b/mne/viz/topomap.py @@ -312,6 +312,23 @@ def _find_radial_channel(info, overlapping_set): return radial_sensor +def _split_opm_overlaps(overlapping_channels): + """Split OPM overlap sets into radial and tangential channel groups. + + This keeps the first channel from each overlap set, which is the radial + channel as determined by :func:`_find_overlaps`, separate from the + remaining tangential channels. The result can be used by later plotting + code to render separate topomaps per orientation family. + """ + radial = [overlap_set[0] for overlap_set in overlapping_channels] + tangential = list( + itertools.chain.from_iterable( + overlap_set[1:] for overlap_set in overlapping_channels + ) + ) + return radial, tangential + + def _plot_update_evoked_topomap(params, bools): """Update topomaps.""" from ..channels.layout import _merge_ch_data From 8cf2ad0cf0758f1c87b85701ba7e9420d0da8437 Mon Sep 17 00:00:00 2001 From: PragnyaKhandelwal Date: Thu, 16 Apr 2026 23:34:00 +0530 Subject: [PATCH 2/2] DOC: added changelog entry --- doc/changes/dev/13847.other.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changes/dev/13847.other.rst diff --git a/doc/changes/dev/13847.other.rst b/doc/changes/dev/13847.other.rst new file mode 100644 index 00000000000..affa381cc35 --- /dev/null +++ b/doc/changes/dev/13847.other.rst @@ -0,0 +1 @@ +Added a helper to split colocated OPM overlap sets into radial and tangential channel groups, and updated topomap regression coverage to use shared triaxial OPM fixtures, by `Pragnya Khandelwal`_.