# Estimate data SNR using an inverse#

This estimates the SNR as a function of time for a set of data using a minimum-norm inverse operator.

```# Author: Eric Larson <larson.eric.d@gmail.com>
#
```
```from mne import read_evokeds
from mne.datasets.sample import data_path
from mne.viz import plot_snr_estimate

print(__doc__)

data_dir = data_path() / "MEG" / "sample"
fname_inv = data_dir / "sample_audvis-meg-oct-6-meg-inv.fif"
fname_evoked = data_dir / "sample_audvis-ave.fif"

plot_snr_estimate(evoked, inv)
```
```Reading inverse operator decomposition from /home/circleci/mne_data/MNE-sample-data/MEG/sample/sample_audvis-meg-oct-6-meg-inv.fif...
[done]
[done]
305 x 305 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
22494 x 22494 diagonal covariance (kind = 2) found.
22494 x 22494 diagonal covariance (kind = 6) found.
22494 x 22494 diagonal covariance (kind = 5) found.
Did not find the desired covariance matrix (kind = 3)
Computing patch statistics...
[done]
Computing patch statistics...
[done]
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
Source spaces transformed to the inverse solution coordinate frame
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)
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 (Right Auditory)
0 CTF compensation matrices available
nave = 61 - aspect type = 100
Projections have already been applied. Setting proj attribute to True.
Applying baseline correction (mode: mean)
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 visual)
0 CTF compensation matrices available
nave = 67 - aspect type = 100
Projections have already been applied. Setting proj attribute to True.
Applying baseline correction (mode: mean)
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 (Right visual)
0 CTF compensation matrices available
nave = 58 - aspect type = 100
Projections have already been applied. Setting proj attribute to True.
Applying baseline correction (mode: mean)
Preparing the inverse operator for use...
Scaled noise and source covariance from nave = 1 to nave = 55
Created the regularized inverter
Created an SSP operator (subspace dimension = 3)
Created the whitener using a noise covariance matrix with rank 302 (3 small eigenvalues omitted)
Picked 305 channels from the data
Effective nchan = 305 - 3 = 302
```

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

Gallery generated by Sphinx-Gallery