R Package: DA4BCI

Milestone:

DA4BCI cover

Package: DA4BCI
Title: A Unified Framework for Domain Adaptation in EEG-based BCI
Language: R
Authors: Yiming Shen and David Degras
License: MIT

Overview

DA4BCI is the domain-adaptation layer of my EEG/BCI software ecosystem. It provides a common interface for aligning source and target EEG feature distributions across sessions or subjects, together with distance metrics for measuring whether an adaptation method actually reduced distribution shift.

Toolkit Role

DA4BCI sits after feature extraction and before evaluation or deployment diagnostics.

BCIFeatR / eegwhiten features -> DA4BCI alignment -> classifier and shift evaluation

Main Capabilities

  • Unified dispatcher: domain_adaptation(source_data, target_data, method = ...).
  • Linear and kernel methods: SA, TCA, MIDA, CORAL, and GFK.
  • Geometry-based methods: Riemannian distance alignment, ART, PT, and M3D.
  • Optimal transport: entropy-regularized Sinkhorn adaptation.
  • Shift metrics: MMD, Wasserstein distance, Energy distance, Mahalanobis distance, and Euclidean distance summaries.
  • Supporting utilities: Euclidean alignment, KMM source weighting, label-shift EM, proxy A-distance, and before/after visualization.

Example Use

library(DA4BCI)

res <- domain_adaptation(
  source_data,
  target_data,
  method = "coral",
  control = list(lambda = 1e-5)
)

distanceSummary(res$weighted_source_data, res$target_data)

View on GitHub