pyeeg.preprocess.Whitener.compute_rotation

Whitener.compute_rotation(C=None)

Compute the whitening rotation matrix from the (stored) covariance.

The eigenvalues/eigenvectors of the covariance matrix (either self.sigma or the provided C) are used to build the whitening matrix W. PCA whitening uses W = diag(1/sqrt(eigval)) @ eigvec.T and ZCA whitening uses W = eigvec @ diag(1/sqrt(eigval)) @ eigvec.T.

Parameters:

C (ndarray (nchannels, nchannels), optional) – Covariance matrix to diagonalize. If None, self.sigma (as computed by cov()) is used.

Returns:

Stores self.scale, self.U and self.W in place.

Return type:

None

Raises:

AssertionError – If self.sigma has not been computed yet and C is None.