R Package: TensorEEG

Milestone:

TensorEEG cover

Package: TensorEEG
Title: Physics-Constrained EEG Simulation and Covariance-Aware Augmentation
Language: R
License: MIT

Overview

TensorEEG has two connected goals. First, it simulates physically constrained synthetic EEG tensors with volume-conduction geometry, structured source dynamics, artifacts, and trial-wise drift. Second, it audits covariance-level augmentation methods for cross-session BCI transfer using SPD-aware fidelity metrics and manifest-based replay.

Toolkit Role

TensorEEG provides the simulation and audit layer of the toolkit. It is meant for stress-testing algorithms and checking whether synthetic covariance stacks preserve the geometry needed for downstream BCI decoding.

Synthetic EEG / real covariance anchors -> TensorEEG augmentation -> fidelity audit and replay

Main Capabilities

  • EEG simulation as third-order tensors with dimensions time, channels, and trials.
  • Volume-conduction geometry using sensor/source placement and graph-Laplacian smoothing.
  • Manifold drift using OU/AR(1) or fBm-style rotation paths.
  • Covariance augmentation family: E0, G0, G1, G2, and A0.
  • Six-metric covariance fidelity audit, including log-Euclidean and affine-invariant distances.
  • Manifest read/replay for reproducibility audits across experiment cells.

Example Use

library(TensorEEG)
data(example_anchors)

aug <- augment_cov_geodesic_mixup(
  example_anchors,
  labels,
  n_aug = 3,
  beta_alpha = 1.0,
  seed = 1004
)

audit_covariance_fidelity(example_anchors, aug$cov, aug$anchor)

View on GitHub