Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
fecef0b
ENH: add ctf275 montage
contsili Apr 7, 2025
81a81d0
ENH: add neuromag306 montage
contsili Apr 7, 2025
003a7ac
ENH: add ch_type in the Neuromag and CTF montages
contsili Apr 9, 2025
8bfba64
ENH: allow make_standard_montage to accept and parse the new meg mont…
contsili Apr 9, 2025
1857f14
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 9, 2025
73a5042
ENH: add neuromag and ctf to the builtin standard montages
contsili Apr 9, 2025
541078f
Merge branch 'axial_to_planar' of https://github.com/contsili/mne-pyt…
contsili Apr 9, 2025
61ba5a2
ENH: extend the initial setup/configuration of the function to MEG
contsili Apr 9, 2025
cb614d9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 9, 2025
aad0c4e
COS: comment
contsili Apr 9, 2025
0f956f7
Merge branch 'axial_to_planar' of https://github.com/contsili/mne-pyt…
contsili Apr 9, 2025
d4c043c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 9, 2025
10f8b7f
ENH: add example and TODOs
contsili Apr 9, 2025
a25eed0
Merge branch 'axial_to_planar' of https://github.com/contsili/mne-pyt…
contsili Apr 9, 2025
f36d9b1
ENH: added missing line in example
contsili Apr 9, 2025
23ba5cf
Merge remote-tracking branch 'upstream/main' into axial_to_planar
contsili Oct 11, 2025
ea76998
ENH: Add CTF and Neuromag montage CSV files
contsili Oct 12, 2025
bf411bf
ENH: Add read_meg_montage for loading MEG csv montages
contsili Oct 12, 2025
015113e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 12, 2025
e135ef9
ENH: Enhance interpolate_to to include MEG
contsili Oct 12, 2025
39f7046
Merge branch 'axial_to_planar' of https://github.com/contsili/mne-pyt…
contsili Oct 12, 2025
a589a4e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 12, 2025
1b3855d
ENH: Add MEG interpolation example
contsili Oct 12, 2025
253198c
Merge branch 'axial_to_planar' of https://github.com/contsili/mne-pyt…
contsili Oct 12, 2025
e2dd6cd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 12, 2025
6d0fc69
COS: Update example script docstrings to include MEG
contsili Oct 12, 2025
539b176
Merge branch 'axial_to_planar' of https://github.com/contsili/mne-pyt…
contsili Oct 12, 2025
221c357
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 12, 2025
bd99594
Merge remote-tracking branch 'upstream/main' into axial_to_planar
contsili Oct 12, 2025
9438af6
Merge branch 'axial_to_planar' of https://github.com/contsili/mne-pyt…
contsili Oct 12, 2025
82696c0
Merge remote-tracking branch 'upstream/main' into axial_to_planar
larsoner Oct 15, 2025
5eb71b3
FIX: Sty
larsoner Oct 15, 2025
0dc97c2
fix - do not handle ctf and neuromag as custom montages
contsili Oct 15, 2025
c8ea36e
Revert "fix - do not handle ctf and neuromag as custom montages"
contsili Oct 15, 2025
6bd0bc7
Revert "ENH: allow make_standard_montage to accept and parse the new …
contsili Oct 15, 2025
cb7b556
Revert "ENH: add neuromag and ctf to the builtin standard montages"
contsili Oct 15, 2025
0c4633a
Revert "ENH: add ch_type in the Neuromag and CTF montages"
contsili Oct 15, 2025
962db23
Revert "ENH: add neuromag306 montage"
contsili Oct 15, 2025
6dfdac5
Revert "ENH: add ctf275 montage"
contsili Oct 15, 2025
5e710fb
Merge branch 'main' into axial_to_planar
contsili Oct 15, 2025
7578e87
ENH: Refactor MEG interpolation example and update comments
contsili Oct 15, 2025
017b9d5
FIX: Import
larsoner Oct 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 73 additions & 4 deletions examples/preprocessing/interpolate_to.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,30 @@
.. _ex-interpolate-to-any-montage:

======================================================
Interpolate EEG data to any montage
Interpolate MEG or EEG data to any montage
======================================================

This example demonstrates how to interpolate EEG channels to match a given montage.
This can be useful for standardizing
This example demonstrates both EEG montage interpolation and MEG system
transformation.

For EEG, this can be useful for standardizing
EEG channel layouts across different datasets (see :footcite:`MellotEtAl2024`).

- Using the field interpolation for EEG data.
- Using the target montage "biosemi16".
- Using the MNE interpolation for MEG data to transform from Neuromag
(planar gradiometers and magnetometers) to CTF (axial gradiometers).


In this example, the data from the original EEG channels will be
In the first example, the data from the original EEG channels will be
interpolated onto the positions defined by the "biosemi16" montage.

In the second example, we will interpolate MEG data from a 306-sensor Neuromag
to 275-sensor CTF system.
"""

# Authors: Antoine Collas <[email protected]>
# Konstantinos Tsilimparis <[email protected]>
# License: BSD-3-Clause
# Copyright the MNE-Python contributors.

Expand All @@ -30,6 +39,9 @@
ylim = (-10, 10)

# %%
# Part 1: EEG System Transformation
# ==================================

# Load EEG data
data_path = sample.data_path()
eeg_file_path = data_path / "MEG" / "sample" / "sample_audvis-ave.fif"
Expand Down Expand Up @@ -75,6 +87,63 @@
)
axs[2].set_title("Interpolated to Standard 1020 Montage using MNE interpolation")

# %%
# Part 2: MEG System Transformation
# ==================================
# We demonstrate transforming MEG data from Neuromag (planar gradiometers
# and magnetometers) to CTF (axial gradiometers) sensor configuration.

# Load the full evoked data with MEG channels
evoked_meg = mne.read_evokeds(
eeg_file_path, condition="Left Auditory", baseline=(None, 0)
)
evoked_meg.pick("meg")

print("Original Neuromag system:")
print(f" Number of magnetometers: {len(mne.pick_types(evoked_meg.info, meg='mag'))}")
print(f" Number of gradiometers: {len(mne.pick_types(evoked_meg.info, meg='grad'))}")

# %%
# Transform to CTF sensor configuration
# ======================================

# Interpolate Neuromag to CTF
evoked_ctf = evoked_meg.copy().interpolate_to("ctf275", mode="accurate")

print("\nTransformed to CTF system:")
print(f" Number of MEG channels: {len(mne.pick_types(evoked_ctf.info, meg=True))}")
print(f" Bad channels in original: {evoked_meg.info['bads']}")

# %%
# Compare evoked responses: Original Neuromag vs Transformed CTF
# The data should be similar but projected onto different sensor arrays

# Set consistent y-limits for comparison
ylim_meg = dict(grad=[-300, 300], mag=[-600, 600], meg=[-300, 300])

fig, axes = plt.subplots(3, 1, figsize=(10, 8), layout="constrained")

# Plot original Neuromag gradiometers
evoked_meg.copy().pick("grad").plot(
axes=axes[0], show=False, spatial_colors=True, ylim=ylim_meg, time_unit="s"
)
axes[0].set_title("Original Neuromag Planar Gradiometers", fontsize=14)


# Plot original Neuromag magnetometers
evoked_meg.copy().pick("mag").plot(
axes=axes[1], show=False, spatial_colors=True, ylim=ylim_meg, time_unit="s"
)
axes[1].set_title("Original Neuromag Magnetometers", fontsize=14)

# Plot transformed CTF gradiometers
evoked_ctf.plot(
axes=axes[2], show=False, spatial_colors=True, ylim=ylim_meg, time_unit="s"
)
axes[2].set_title("Transformed to CTF275 Axial Gradiometers", fontsize=14)

plt.show()

# %%
# References
# ----------
Expand Down
Loading
Loading