mne.
compute_covariance
(epochs, keep_sample_mean=True, tmin=None, tmax=None, projs=None, method='empirical', method_params=None, cv=3, scalings=None, n_jobs=1, return_estimators=False, on_mismatch='raise', rank='', verbose=None)[source]¶Estimate noise covariance matrix from epochs.
The noise covariance is typically estimated on pre-stimulus periods when the stimulus onset is defined from events.
If the covariance is computed for multiple event types (events with different IDs), the following two options can be used and combined:
- either an Epochs object for each event type is created and a list of Epochs is passed to this function.
- an Epochs object is created for multiple events and passed to this function.
Parameters: |
|
---|---|
Returns: |
|
See also
compute_raw_covariance
Notes
Baseline correction or sufficient high-passing should be used
when creating the Epochs
to ensure that the data are zero mean,
otherwise the computed covariance matrix will be inaccurate.
Valid method
strings are:
'empirical'
The empirical or sample covariance (default)
'diagonal_fixed'
A diagonal regularization based on channel types as in
mne.cov.regularize()
.
'shrinkage'
Fixed shrinkage.
New in version 0.16.
'ledoit_wolf'
The Ledoit-Wolf estimator, which uses an empirical formula for the optimal shrinkage value [2].
'oas'
The OAS estimator [5], which uses a different empricial formula for the optimal shrinkage value.
New in version 0.16.
'shrunk'
Like ‘ledoit_wolf’, but with cross-validation for optimal alpha.
'pca'
Probabilistic PCA with low rank [3].
'factor_analysis'
Factor analysis with low rank [4].
'ledoit_wolf'
and 'pca'
are similar to 'shrunk'
and
'factor_analysis'
, respectively, except that they use
cross validation (which is useful when samples are correlated, which
is often the case for M/EEG data). The former two are not included in
the 'auto'
mode to avoid redundancy.
For multiple event types, it is also possible to create a
single Epochs
object with events obtained using
mne.merge_events()
. However, the resulting covariance matrix
will only be correct if keep_sample_mean is True
.
The covariance can be unstable if the number of samples is small.
In that case it is common to regularize the covariance estimate.
The method
parameter allows to regularize the covariance in an
automated way. It also allows to select between different alternative
estimation algorithms which themselves achieve regularization.
Details are described in [1].
For more information on the advanced estimation methods, see the sklearn manual.
References
[1] | (1, 2, 3) Engemann D. and Gramfort A. (2015) Automated model selection in covariance estimation and spatial whitening of MEG and EEG signals, vol. 108, 328-342, NeuroImage. |
[2] | (1, 2) Ledoit, O., Wolf, M., (2004). A well-conditioned estimator for large-dimensional covariance matrices. Journal of Multivariate Analysis 88 (2), 365 - 411. |
[3] | (1, 2) Tipping, M. E., Bishop, C. M., (1999). Probabilistic principal component analysis. Journal of the Royal Statistical Society: Series B (Statistical Methodology) 61 (3), 611 - 622. |
[4] | (1, 2) Barber, D., (2012). Bayesian reasoning and machine learning. Cambridge University Press., Algorithm 21.1 |
[5] | (1, 2) Chen et al. (2010). Shrinkage Algorithms for MMSE Covariance Estimation. IEEE Trans. on Sign. Proc., Volume 58, Issue 10, October 2010. |
mne.compute_covariance
¶