MNECovMatrix
Namespace: MNELIB · Library: MNE Library
#include <mne/mne_cov_matrix.h>
class MNELIB::MNECovMatrix
Covariance matrix storage.
Stores a noise or source covariance matrix in dense (packed lower-triangle), diagonal, or sparse form together with its eigendecomposition and associated metadata (projection operator, SSS info, channel classification, bad channels).
Public Methods
MNECovMatrix(p_kind, p_ncov, p_names, p_cov, p_cov_diag, p_cov_sparse)
Construct a covariance matrix.
Parameters:
-
p_kind : int Covariance kind (sensor or source).
-
p_ncov : int Dimension (number of channels).
-
p_names : const QStringList & Channel names.
-
p_cov : const Eigen::VectorXd & Packed lower-triangle data (may be empty).
-
p_cov_diag : const Eigen::VectorXd & Diagonal data (may be empty).
-
p_cov_sparse : *FiffSparseMatrix ** Sparse covariance data (may be nullptr).
~MNECovMatrix()
Destructor.
dup()
Create a deep copy of this covariance matrix including data, channel classes, bad channel list, projection, and SSS info.
Returns:
- std::unique_ptr< MNECovMatrix > — A newly allocated copy.
is_diag()
Check whether this covariance matrix is stored in diagonal form.
Returns:
- int — Non-zero if diagonal, zero if full or sparse.
add_inv()
Compute the inverse square-root of eigenvalues (or diagonal elements) for whitening, storing the result in inv_lambda.
Returns:
- int — OK on success, FAIL if neither diagonal nor decomposed.
condition(rank_threshold, use_rank)
Condition the covariance matrix by eigendecomposition with per-channel-type scaling, zeroing sub-threshold eigenvalues, and reconstructing.
Parameters:
-
rank_threshold : float Eigenvalue threshold ratio for rank estimation.
-
use_rank : int If positive, override the automatic rank estimate.
Returns:
- int — The estimated rank, or FAIL on error.
decompose_eigen_small(p_small, use_rank)
Perform eigenvalue decomposition of the covariance matrix, zero sub-threshold eigenvalues, classify eigenvectors by channel type, and compute inverse square-roots for whitening.
Parameters:
-
p_small : float Eigenvalue threshold (negative uses default).
-
use_rank : int If positive, override automatic rank estimate.
Returns:
- int — OK on success, FAIL on error.
decompose_eigen()
Convenience wrapper for decompose_eigen_small() with default threshold and no rank override.
Returns:
- int — OK on success, FAIL on error.