Reading/Writing a noise covariance matrix#

How to plot a noise covariance matrix.

# Author: Alexandre Gramfort <alexandre.gramfort@inria.fr>
#
# License: BSD-3-Clause
from os import path as op
import mne
from mne.datasets import sample

data_path = sample.data_path()
fname_cov = op.join(data_path, 'MEG', 'sample', 'sample_audvis-cov.fif')
fname_evo = op.join(data_path, 'MEG', 'sample', 'sample_audvis-ave.fif')

cov = mne.read_cov(fname_cov)
print(cov)
ev_info = mne.io.read_info(fname_evo)
    366 x 366 full covariance (kind = 1) found.
    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
<Covariance | size : 366 x 366, n_samples : 15972, data : [[ 2.27235589e-23  4.79818505e-24  7.12852747e-25 ...  4.85348042e-18
   2.02846360e-18  8.26727393e-18]
 [ 4.79818505e-24  5.33468523e-24  1.80261790e-25 ...  2.33583009e-19
  -6.93161055e-19  2.35199238e-18]
 [ 7.12852747e-25  1.80261790e-25  5.79073915e-26 ...  1.09498615e-19
   6.16924072e-21  2.93873875e-19]
 ...
 [ 4.85348042e-18  2.33583009e-19  1.09498615e-19 ...  1.40677185e-11
   1.27444183e-11  1.08634620e-11]
 [ 2.02846360e-18 -6.93161055e-19  6.16924072e-21 ...  1.27444183e-11
   1.59818134e-11  8.51070563e-12]
 [ 8.26727393e-18  2.35199238e-18  2.93873875e-19 ...  1.08634620e-11
   8.51070563e-12  1.53708918e-11]]>
    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

Plot covariance

cov.plot(ev_info, exclude='bads', show_svd=False)
Magnetometers covariance, Gradiometers covariance, EEG covariance

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

Estimated memory usage: 9 MB

Gallery generated by Sphinx-Gallery