Remap MEG channel types

In this example, MEG data are remapped from one channel type to another. This is useful to:

  • visualize combined magnetometers and gradiometers as magnetometers or gradiometers.

  • run statistics from both magnetometers and gradiometers while working with a single type of channels.

  • mag (original), -0.200 s, 0.033 s, 0.266 s, 0.499 s, fT
  • mag (interpolated from mag + grad), -0.200 s, 0.033 s, 0.266 s, 0.499 s, fT
  • grad (original), -0.200 s, 0.033 s, 0.266 s, 0.499 s, fT/cm
  • grad (interpolated from mag + grad), -0.200 s, 0.033 s, 0.266 s, 0.499 s, fT/cm

Out:

Reading /home/circleci/mne_data/MNE-sample-data/MEG/sample/sample_audvis-ave.fif ...
    Read a total of 4 projection items:
        PCA-v1 (1 x 102) active
        PCA-v2 (1 x 102) active
        PCA-v3 (1 x 102) active
        Average EEG reference (1 x 60) active
    Found the data of interest:
        t =    -199.80 ...     499.49 ms (Left Auditory)
        0 CTF compensation matrices available
        nave = 55 - aspect type = 100
Projections have already been applied. Setting proj attribute to True.
Applying baseline correction (mode: mean)
    Computing dot products for 305 MEG channels...
    Computing cross products for 305 → 102 MEG channels...
    Preparing the mapping matrix...
    Truncating at 210/305 components to omit less than 0.0001 (9.9e-05)
Removing projector <Projection | Average EEG reference, active : True, n_channels : 60>
Removing projector <Projection | PCA-v1, active : True, n_channels : 102>
Removing projector <Projection | PCA-v2, active : True, n_channels : 102>
Removing projector <Projection | PCA-v3, active : True, n_channels : 102>
Removing projector <Projection | Average EEG reference, active : True, n_channels : 60>
    Computing dot products for 305 MEG channels...
    Computing cross products for 305 → 203 MEG channels...
    Preparing the mapping matrix...
    Truncating at 210/305 components to omit less than 0.0001 (9.9e-05)
Removing projector <Projection | PCA-v1, active : True, n_channels : 102>
Removing projector <Projection | PCA-v2, active : True, n_channels : 102>
Removing projector <Projection | PCA-v3, active : True, n_channels : 102>
Removing projector <Projection | Average EEG reference, active : True, n_channels : 60>
Removing projector <Projection | PCA-v1, active : True, n_channels : 102>
Removing projector <Projection | PCA-v2, active : True, n_channels : 102>
Removing projector <Projection | PCA-v3, active : True, n_channels : 102>
Removing projector <Projection | Average EEG reference, active : True, n_channels : 60>

# Author: Mainak Jas <mainak.jas@telecom-paristech.fr>

# License: BSD (3-clause)

import mne
from mne.datasets import sample

print(__doc__)

# read the evoked
data_path = sample.data_path()
fname = data_path + '/MEG/sample/sample_audvis-ave.fif'
evoked = mne.read_evokeds(fname, condition='Left Auditory', baseline=(None, 0))

# go from grad + mag to mag
virt_evoked = evoked.as_type('mag')
evoked.plot_topomap(ch_type='mag', title='mag (original)', time_unit='s')
virt_evoked.plot_topomap(ch_type='mag', time_unit='s',
                         title='mag (interpolated from mag + grad)')

# go from grad + mag to grad
virt_evoked = evoked.as_type('grad')
evoked.plot_topomap(ch_type='grad', title='grad (original)', time_unit='s')
virt_evoked.plot_topomap(ch_type='grad', time_unit='s',
                         title='grad (interpolated from mag + grad)')

Total running time of the script: ( 0 minutes 7.126 seconds)

Estimated memory usage: 8 MB

Gallery generated by Sphinx-Gallery