R Package: eegwhiten

Published:

Package: eegwhiten (EEG Signal Whitening Toolkit)
Version: 1.1.0
Maintainer: Yiming Shen

Overview

eegwhiten provides a robust suite of methods for whitening and standardizing EEG signals. Whitening is a critical preprocessing step for decorrelating signal channels, which is essential for effective covariance estimation and subsequent classification in BCI pipelines.

Key Methodologies

The package implements the following whitening transformations:

  1. PCA Whitening: Principal Component Analysis based whitening to maximize variance in orthogonal directions.
  2. ZCA Whitening (Mahalanobis): Zero-phase Component Analysis, preserving the spatial arrangement of the original sensors while decorrelating them.
  3. Cholesky Decomposition: Uses the Cholesky factor of the inverse covariance matrix for efficient whitening.
  4. Standardization: Basic signal scaling and centering utilities.

Installation & Usage

You can install the development version from GitHub:

# install.packages("devtools")
devtools::install_github("Yiming-S/eegwhiten")

Quick Start

library(eegwhiten)

# Apply ZCA whitening to an EEG epoch
# X is an [n_channels x n_timepoints] matrix
X_whitened <- eeg_whiten(X, method = "ZCA")

# Check correlation matrix (should be Identity)
print(round(cor(t(X_whitened)), 2))

View on GitHub