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’, verbose=None)[source]¶Estimate noise covariance matrix from epochs.
The noise covariance is typically estimated on pre-stim periods when the stim 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.
Note
Baseline correction should be used when creating the Epochs. Otherwise the computed covariance matrix will be inaccurate.
Note
For multiple event types, it is also possible to create a single Epochs object with events obtained using merge_events(). However, the resulting covariance matrix will only be correct if keep_sample_mean is True.
Note
The covariance can be unstable if the number of samples is
not sufficient. In that case it is common to regularize a
covariance estimate. The method
parameter of this
function 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 [R21].
Parameters: | epochs : instance of Epochs, or a list of Epochs objects
keep_sample_mean : bool (default True)
tmin : float | None (default None)
tmax : float | None (default None)
projs : list of Projection | None (default None)
method : str | list | None (default ‘empirical’)
method_params : dict | None (default None)
cv : int | sklearn cross_validation object (default 3)
scalings : dict | None (default None)
n_jobs : int (default 1)
return_estimators : bool (default False)
on_mismatch : str
verbose : bool | str | int | or None (default None)
|
---|---|
Returns: | cov : instance of Covariance | list
|
See also
compute_raw_covariance
References
[R21] | (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. |
[R22] | (1, 2) Ledoit, O., Wolf, M., (2004). A well-conditioned estimator for large-dimensional covariance matrices. Journal of Multivariate Analysis 88 (2), 365 - 411. |
[R23] | (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. |
[R24] | (1, 2) Barber, D., (2012). Bayesian reasoning and machine learning. Cambridge University Press., Algorithm 21.1 |