# Author: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
#
# License: BSD (3-clause)
import mne
from mne import io
from mne.datasets import sample
print(__doc__)
data_path = sample.data_path()
fname = data_path + '/MEG/sample/sample_audvis_raw.fif'
raw = io.Raw(fname)
include = [] # or stim channels ['STI 014']
raw.info['bads'] += ['EEG 053'] # bads + 1 more
# pick EEG channels
picks = mne.pick_types(raw.info, meg=True, eeg=True, stim=False, eog=True,
include=include, exclude='bads')
# setup rejection
reject = dict(eeg=80e-6, eog=150e-6)
# Compute the covariance from the raw data
cov = mne.compute_raw_covariance(raw, picks=picks, reject=reject)
print(cov)
Out:
<Covariance | size : 365 x 365, n_samples : 128926, data : [[ 5.26618768e-23 1.66242502e-23 -5.43032308e-25 ..., 3.87037416e-17
4.08735490e-17 -8.98324794e-17]
[ 1.66242502e-23 3.51083438e-23 -8.45087524e-25 ..., 4.93144457e-17
4.43234560e-17 -1.77341755e-16]
[ -5.43032308e-25 -8.45087524e-25 3.16802808e-25 ..., -4.42192297e-18
-3.34979293e-18 1.23631514e-17]
...,
[ 3.87037416e-17 4.93144457e-17 -4.42192297e-18 ..., 3.10506716e-10
2.47580672e-10 -5.10994239e-10]
[ 4.08735490e-17 4.43234560e-17 -3.34979293e-18 ..., 2.47580672e-10
2.34878454e-10 -4.16406684e-10]
[ -8.98324794e-17 -1.77341755e-16 1.23631514e-17 ..., -5.10994239e-10
-4.16406684e-10 1.91962239e-09]]>
Show covariance
fig_cov, fig_svd = mne.viz.plot_cov(cov, raw.info, colorbar=True, proj=True)
# try setting proj to False to see the effect
Total running time of the script: (0 minutes 8.037 seconds)
plot_estimate_covariance_matrix_raw.py
plot_estimate_covariance_matrix_raw.ipynb