Skip to content

Commit 5011844

Browse files
ENH: broaden OPM coil handling for colocated topomaps (#13825)
1 parent c9e34f1 commit 5011844

4 files changed

Lines changed: 51 additions & 1 deletion

File tree

doc/changes/dev/13825.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improved colocated OPM topomap handling by recognizing additional OPM coil types (FieldLine and Kernel), by `Pragnya Khandelwal`_.

mne/_fiff/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,7 @@
11831183
FIFF.FIFFV_COIL_QUSPIN_ZFOPM_MAG2,
11841184
FIFF.FIFFV_COIL_FIELDLINE_OPM_MAG_GEN1,
11851185
FIFF.FIFFV_COIL_KERNEL_OPM_MAG_GEN1,
1186+
# If more OPM coil types are added here, update mne/viz/topomap.py too.
11861187
FIFF.FIFFV_COIL_KRISS_GRAD,
11871188
FIFF.FIFFV_COIL_COMPUMEDICS_ADULT_GRAD,
11881189
FIFF.FIFFV_COIL_COMPUMEDICS_PEDIATRIC_GRAD,

mne/viz/tests/test_topomap.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,49 @@ 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", "OPM005", "OPM006"]
803+
info = create_info(ch_names, 1000.0, ch_types="mag")
804+
# Two colocated trios 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+
[-0.03, 0.00, 0.05],
812+
[-0.03, 0.00, 0.05],
813+
]
814+
)
815+
orientations = np.array(
816+
[
817+
[0.5145, 0.0000, 0.8575], # radial-ish
818+
[0.0000, 1.0000, 0.0000], # tangential-ish
819+
[0.0000, 0.0000, 1.0000], # tangential-ish
820+
[-0.5145, 0.0000, 0.8575], # radial-ish
821+
[0.0000, 1.0000, 0.0000], # tangential-ish
822+
[0.0000, 0.0000, 1.0000], # tangential-ish
823+
]
824+
)
825+
with info._unlock():
826+
for idx, ch in enumerate(info["chs"]):
827+
ch["coil_type"] = FIFF.FIFFV_COIL_FIELDLINE_OPM_MAG_GEN1
828+
ch["loc"][:3] = positions[idx]
829+
ch["loc"][9:12] = orientations[idx]
830+
evoked = EvokedArray(np.zeros((len(ch_names), 5)), info)
831+
832+
picks, _pos, merge_channels, merged_names, *_ = topomap._prepare_topomap_plot(
833+
evoked, "mag"
834+
)
835+
836+
assert len(picks) == 6
837+
assert merge_channels
838+
assert len(merge_channels) == 2
839+
assert all(len(set_) == 3 for set_ in merge_channels)
840+
assert sum(name.endswith("MERGE-REMOVE") for name in merged_names) == 4
841+
842+
800843
def test_plot_topomap_nirs_overlap(fnirs_epochs):
801844
"""Test plotting nirs topomap with overlapping channels (gh-7414)."""
802845
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)