Understanding rank deficiencies in covariance estimation

Hi all,

Following up on a discussion from office hours last week… I’m hoping someone can confirm/clarify my understanding of how MNE-python handles rank deficiencies in (MEG) covariance estimation for minimum-norm estimates, when using the default rank = None in mne.compute_covariance. This is what I understand from looking at _compute_covariance_auto and _smart_eigh in mne.cov:

If the data matrix (X) used to estimate cov is rank deficient, then _smart_eigh will eigendecompose the matrix XTX and get projections to a subspace defined by the eigenvectors with non-zero eigenvalues (this is done in _get_ch_whitener). The data that are to be used for estimation are then projected into this space, effectively eliminating the redundant rows in the matrix and concerns about rank deficiency. The covariance matrix which is ultimately returned is estimated in this subspace, regardless of whether or how regularization is applied, and then projected back to the original space at the end of _compute_covariance_auto.

Does this sound correct or have I missed something here? Thanks!


  • MNE-Python version: 0.23.0
  • operating system: macOS

The relevant part of the code: mne-python/cov.py at maint/0.23 · mne-tools/mne-python · GitHub


sorry for the late reply. Yes this seems about right from the top of my mind.
To double check this put a break point in the code after the whitener is computed
and check its shape and eigenvalues.