Skip to content

Commit ef5d5a2

Browse files
ENH: broaden OPM coil handling for colocated topomaps
1 parent 852e8ff commit ef5d5a2

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

mne/viz/tests/test_topomap.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,43 @@ def test_plot_topomap_opm():
797797
assert len(fig_evoked.axes) == 5
798798

799799

800+
def test_prepare_topomap_plot_opm_non_quspin_coils():
801+
"""Test colocated OPM handling for non-QuSpin OPM coil types."""
802+
ch_names = ["OPM001", "OPM002", "OPM003", "OPM004"]
803+
info = create_info(ch_names, 1000.0, ch_types="mag")
804+
# Two colocated pairs with different orientations.
805+
positions = np.array(
806+
[
807+
[0.03, 0.00, 0.05],
808+
[0.03, 0.00, 0.05],
809+
[-0.03, 0.00, 0.05],
810+
[-0.03, 0.00, 0.05],
811+
]
812+
)
813+
orientations = np.array(
814+
[
815+
[0.5145, 0.0000, 0.8575], # radial-ish
816+
[0.0000, 1.0000, 0.0000], # tangential-ish
817+
[-0.5145, 0.0000, 0.8575], # radial-ish
818+
[0.0000, 1.0000, 0.0000], # tangential-ish
819+
]
820+
)
821+
with info._unlock():
822+
for idx, ch in enumerate(info["chs"]):
823+
ch["coil_type"] = FIFF.FIFFV_COIL_FIELDLINE_OPM_MAG_GEN1
824+
ch["loc"][:3] = positions[idx]
825+
ch["loc"][9:12] = orientations[idx]
826+
evoked = EvokedArray(np.zeros((len(ch_names), 5)), info)
827+
828+
picks, _pos, merge_channels, merged_names, *_ = topomap._prepare_topomap_plot(
829+
evoked, "mag"
830+
)
831+
832+
assert len(picks) == 4
833+
assert merge_channels
834+
assert sum(name.endswith("MERGE-REMOVE") for name in merged_names) == 2
835+
836+
800837
def test_plot_topomap_nirs_overlap(fnirs_epochs):
801838
"""Test plotting nirs topomap with overlapping channels (gh-7414)."""
802839
fig = fnirs_epochs["A"].average(picks="hbo").plot_topomap()

mne/viz/topomap.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@
7777
)
7878

7979
_fnirs_types = ("hbo", "hbr", "fnirs_cw_amplitude", "fnirs_od")
80-
_opm_coils = (FIFF.FIFFV_COIL_QUSPIN_ZFOPM_MAG, FIFF.FIFFV_COIL_QUSPIN_ZFOPM_MAG2)
80+
_opm_coils = (
81+
FIFF.FIFFV_COIL_QUSPIN_ZFOPM_MAG,
82+
FIFF.FIFFV_COIL_QUSPIN_ZFOPM_MAG2,
83+
FIFF.FIFFV_COIL_FIELDLINE_OPM_MAG_GEN1,
84+
FIFF.FIFFV_COIL_KERNEL_OPM_MAG_GEN1,
85+
)
8186

8287

8388
# 3.8+ uses a single Collection artist rather than .collections

0 commit comments

Comments
 (0)