This documentation is for development version 0.18.dev0.

mne.cov.regularize

mne.cov.regularize(cov, info, mag=0.1, grad=0.1, eeg=0.1, exclude='bads', proj=True, seeg=0.1, ecog=0.1, hbo=0.1, hbr=0.1, rank=None, scalings=None, verbose=None)[source]

Regularize noise covariance matrix.

This method works by adding a constant to the diagonal for each channel type separately. Special care is taken to keep the rank of the data constant.

Note

This function is kept for reasons of backward-compatibility. Please consider explicitly using the method parameter in mne.compute_covariance() to directly combine estimation with regularization in a data-driven fashion. See the faq for more information.

Parameters:
cov : Covariance

The noise covariance matrix.

info : dict

The measurement info (used to get channel types and bad channels).

mag : float (default 0.1)

Regularization factor for MEG magnetometers.

grad : float (default 0.1)

Regularization factor for MEG gradiometers. Must be the same as mag if data have been processed with SSS.

eeg : float (default 0.1)

Regularization factor for EEG.

exclude : list | ‘bads’ (default ‘bads’)

List of channels to mark as bad. If ‘bads’, bads channels are extracted from both info[‘bads’] and cov[‘bads’].

proj : bool (default True)

Apply projections to keep rank of data.

seeg : float (default 0.1)

Regularization factor for sEEG signals.

ecog : float (default 0.1)

Regularization factor for ECoG signals.

hbo : float (default 0.1)

Regularization factor for HBO signals.

hbr : float (default 0.1)

Regularization factor for HBR signals.

rank : None | int | dict | ‘full’

Specified rank of the noise covariance matrix. If None (default), the rank is detected automatically. If int, the rank is specified for the MEG channels. A dictionary with entries ‘eeg’, ‘meg’ or any other data channel type such as ‘seeg’ or ‘ecog’ can be used to specify the rank for each modality. If ‘full’, the covariance is assumed to be full-rank when regularizing (unless proj=True, in which case projections are accounted for).

New in version 0.17.

scalings : dict | None

Data will be rescaled before rank estimation to improve accuracy. See mne.compute_covariance().

New in version 0.17.

verbose : bool, str, int, or None

If not None, override default verbose level (see mne.verbose() and Logging documentation for more).

Returns:
reg_cov : Covariance

The regularized covariance matrix.