Python Package: DA4BCI-Python
Milestone:
Package: DA4BCI-Python
Title: A Unified Framework for Domain Adaptation in EEG-based BCI
Language: Python
Authors: Yiming Shen and David Degras
License: MIT
Overview
DA4BCI-Python is the Python implementation of the DA4BCI method library. It mirrors the R package’s public ideas while serving as the practical backend for Python workflows such as CrossDA and the DA Lab pages in ShiftDx.
Toolkit Role
DA4BCI-Python is used when the full experiment pipeline is written in Python, especially for MOABB, scikit-learn, pyriemann, and Streamlit workflows.
Python EEG features -> DA4BCI-Python adaptation -> CrossDA / ShiftDx / custom experiments
Main Capabilities
- Domain-adaptation methods: TCA, SA, MIDA, CORAL, GFK, RD, ART, PT, OT, and M3D.
- Shift metrics: MMD, Energy distance, Wasserstein distance, Mahalanobis distance, and proxy A-distance.
- SPD geometry: Riemannian means, log/exp maps, geodesics, covariance alignment, and transport utilities.
- Preprocessing helpers: Euclidean alignment, KMM reweighting, and label-shift EM.
- Drift detection: Page-Hinkley online detector.
- Visualization: before/after PCA and t-SNE comparison plots.
Example Use
from da4bci import domain_adaptation, distance_summary
result = domain_adaptation(
source,
target,
method="coral",
control={"lambda": 1e-5},
)
distance_summary(result["weighted_source_data"], result["target_data"])