Interpolate bad channels for MEG/EEG channels

This example shows how to interpolate bad MEG/EEG channels

  • Using spherical splines as described in [1] for EEG data.
  • Using field interpolation for MEG data.

The bad channels will still be marked as bad. Only the data in those channels is removed.


[1]Perrin, F., Pernier, J., Bertrand, O. and Echallier, JF. (1989) Spherical splines for scalp potential and current density mapping. Electroencephalography and Clinical Neurophysiology, Feb; 72(2):184-7.
  • ../../_images/sphx_glr_plot_interpolate_bad_channels_001.png
  • ../../_images/sphx_glr_plot_interpolate_bad_channels_002.png


Reading /home/ubuntu/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.
No baseline correction applied
Applying baseline correction (mode: mean)
Computing interpolation matrix from 59 sensor positions
Interpolating 1 sensors
    Computing dot products for 305 coils...
    Computing cross products for coils 305 x 1 coils...
    Preparing the mapping matrix...
    [Truncate at 79 missing 0.0001]

# Authors: Denis A. Engemann <>
#          Mainak Jas <>
# License: BSD (3-clause)

import mne
from mne.datasets import sample


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))

# plot with bads

# compute interpolation (also works with Raw and Epochs objects)

# plot interpolated (previous bads)

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

Generated by Sphinx-Gallery