Mathematical Derivation: ZCA Whitening Implementation

1 minute read

Published:

This document details the ZCA (Zero-phase Component Analysis) Whitening method implemented in ZCA.R. ZCA is unique because it decorrelates the data while keeping the transformed signals as close as possible to the original signals in the least-squares sense.

1. Core Concept

Unlike PCA whitening, which rotates the data to the principal component axes, ZCA whitening rotates the data back to the original axes after scaling. This preserves the spatial arrangement of EEG channels, making the whitened data topographically interpretable.

\(\operatorname{Cov}(\mathbf z)\) of the points shown
1.000.000.001.00

Each dot is a sample, coloured by its position in the raw cloud so you can follow it. ZCA goes through the PCA result (step 2) and then rotates back, so the colour wheel ends where it started: the whitened data stays as close as possible to the original channels.

2. Mathematical Formulation

Step 1: Eigendecomposition

As with PCA, we start with the eigendecomposition of the covariance matrix $\Sigma$:

\[\Sigma = U \Lambda U^\top\]

Step 2: Constructing the Whitening Matrix

The ZCA whitening matrix $W_{\text{ZCA}}$ is defined as:

\[W_{\text{ZCA}} = U \Lambda^{-1/2} U^\top\]

Notice that $W_{\text{ZCA}}$ is symmetric. It is essentially the inverse square root of the covariance matrix, $\Sigma^{-1/2}$.

R Code Correspondence:

# U * diag(1/sqrt(lambda)) * U^T
U_diag <- U %*% diag(1 / sqrt(lambda)) %*% t(U)
W <- U_diag