Skip to content

Commit c24a2ea

Browse files
DOC: add example showing grouped triaxial OPM topomaps
1 parent d695e87 commit c24a2ea

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""
2+
=====================================
3+
Plot grouped triaxial OPM topomaps
4+
=====================================
5+
6+
This example demonstrates grouped radial/tangential topomap rendering for
7+
colocated triaxial OPM sensors using a small segment of the UCL OPM auditory
8+
dataset. The grouped rendering places radial maps alongside tangential maps
9+
so orientation information is explicit.
10+
11+
"""
12+
# Authors: MNE contributors
13+
# License: BSD-3-Clause
14+
15+
import matplotlib.pyplot as plt
16+
import numpy as np
17+
18+
import mne
19+
20+
# Load a small segment of the UCL OPM dataset
21+
subject = "sub-002"
22+
data_path = mne.datasets.ucl_opm_auditory.data_path()
23+
opm_file = (
24+
data_path / subject / "ses-001" / "meg" / "sub-002_ses-001_task-aef_run-001_meg.bin"
25+
)
26+
27+
# Read and crop for speed
28+
raw = mne.io.read_raw_fil(opm_file, verbose="error")
29+
raw.crop(120, 210).load_data()
30+
31+
# Create epochs and average to get evoked
32+
events = mne.find_events(raw, min_duration=0.1)
33+
epochs = mne.Epochs(
34+
raw, events, tmin=-0.1, tmax=0.4, baseline=(None, 0), verbose="error"
35+
)
36+
evoked = epochs.average()
37+
38+
# Find a peak time and plot grouped topomap
39+
t_peak = evoked.times[np.argmax(np.std(evoked.copy().pick("meg").data, axis=0))]
40+
fig = evoked.plot_topomap(times=[float(t_peak)], ch_type="mag")
41+
plt.show()

0 commit comments

Comments
 (0)