mne_denoise.compute_covariance#
- mne_denoise.compute_covariance(data: ndarray, *, method: str = 'empirical', shrinkage: float | None = None, weights: ndarray | None = None, assume_centered: bool = False, chunk_size: int | None = None) ndarray[source]#
Estimate a channel covariance matrix from NumPy data.
- Parameters:
- datandarray, shape (n_channels, n_times) or (n_channels, n_times, n_epochs)
Channel-first data. The 3-D layout is flattened over time and epochs.
- method{“empirical”, “shrinkage”, “oas”, “mcd”}, default=”empirical”
Covariance estimator.
- shrinkagefloat or None, default=None
Shrinkage intensity for method=”shrinkage”; None estimates it.
- weightsndarray or None, default=None
Non-negative observation weights. 2-D data uses (n_times,); 3-D data accepts (n_times,), (n_times, n_epochs), or the flattened length.
- assume_centeredbool, default=False
Skip mean subtraction when true.
- chunk_sizeint or None, default=None
Empirical-covariance chunk size.
- Returns:
- ndarray, shape (n_channels, n_channels)
NumPy covariance array, not an MNE Covariance object.
Notes
The empirical covariance uses a population denominator: n_times or the total weight. Weighted and chunked estimates are supported only for method=”empirical”.