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, fnirs_cw_amplitude=0.1, fnirs_od=0.1, csd=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.


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.


The noise covariance matrix.


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

magfloat (default 0.1)

Regularization factor for MEG magnetometers.

gradfloat (default 0.1)

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

eegfloat (default 0.1)

Regularization factor for EEG.

excludelist | ‘bads’ (default ‘bads’)

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

projbool (default True)

Apply projections to keep rank of data.

seegfloat (default 0.1)

Regularization factor for sEEG signals.

ecogfloat (default 0.1)

Regularization factor for ECoG signals.

hbofloat (default 0.1)

Regularization factor for HBO signals.

hbrfloat (default 0.1)

Regularization factor for HBR signals.

fnirs_cw_amplitudefloat (default 0.1)

Regularization factor for fNIRS raw signals.

fnirs_odfloat (default 0.1)

Regularization factor for fNIRS optical density signals.

csdfloat (default 0.1)

Regularization factor for EEG-CSD signals.

rankNone | dict | ‘info’ | ‘full’

This controls the rank computation that can be read from the measurement info or estimated from the data. See Notes of mne.compute_rank() for details.The default is None.

New in version 0.17.

New in version 0.18: Support for ‘info’ mode.

scalingsdict | None

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

New in version 0.17.

verbosebool, str, int, or None

If not None, override default verbose level (see mne.verbose() and Logging documentation for more). If used, it should be passed as a keyword-argument only.


The regularized covariance matrix.