Experimental code for Bures–Wasserstein Geometry and Reference Estimation for EEG Artifact Detection.
This repository implements covariance-matrix-based artifact detection on the TUAR and EEGEOG datasets. It supports training and evaluation of Potato-based models under both cross-subject and cross-session settings.
This repository is a placeholder for the implementation of our manuscript on transport-median scoring for EEG covariance anomaly detection.
The source code will be released when the manuscript enters the revision stage. The release will include preprocessing scripts, implementations of the controlled SPD scoring variants, evaluation protocols, and figure-generation code needed to reproduce the main experiments.
The datasets are not redistributed in this repository. Users should obtain them from the original data providers and comply with the corresponding data-use agreements.
This project converts EEG epochs into covariance matrices and classifies them as clean or artifact-contaminated using Riemannian Potato or Wasserstein Potato models.
The repository includes the following components:
-
DataLoader
- Loads TUAR and EEGEOG datasets
- Constructs cross-subject and cross-session splits
- Computes covariance matrices and manages cached data
-
Potato
- Basic Potato model
- Potato model for epsilon-separation experiments
- Potato model with cached covariance fitting
-
Experiment
- Connects data loaders with Potato models
- Runs repeated experiments automatically
- Saves confusion matrices and trained models
.
├── DataLoader
│ ├── ASemiSimulatedEEGEOGLoader.py
│ ├── PARAMETERS.py
│ ├── TUARLoader.py
│ ├── __init__.py
│ └── cache_control.py
├── Potato
│ ├── PotatoLoader.py
│ ├── __init__.py
│ ├── potato.py
│ ├── potato_cachedFitting.py
│ ├── potato_epsilon.py
│ └── utils.py
├── LICENSE
├── README.md
└── basicExperiment.py
- Load the EEG dataset.
- Convert each EEG epoch into a covariance matrix.
- Construct the train/test split according to the experimental setting:
- cross-subject
- cross-session
- Train a Potato model using clean covariance matrices from the training set.
- Predict whether each test covariance matrix is clean or artifact-contaminated.
- Save the confusion matrix as a CSV file. If needed, trained models and intermediate results are also saved as cached files.
Loader for constructing cross-subject and cross-session experiments on the TUAR dataset.
-
Input
subjectID: test subject ID
-
Output
X_train: clean covariance matrices from other subjectsX_test: covariance matrices from the target subjecty_test: labels for the target subject
-
Input
subjectID: target subject IDtestSession: target test session
-
Output
X_train: training covariance matricesX_test: test covariance matricesy_test: test labels
Loader for constructing cross-subject and cross-session experiments on the Semi-Simulated EEGEOG dataset.
-
Input
subjectID: test subject ID
-
Output
X_train: clean covariance matrices from other subjectsX_test: covariance matrices from the target subjecty_test: labels for the target subject
-
Input
subjectID: target subject IDtestSession: target test session
-
Output
X_train: training covariance matricesX_test: test covariance matricesy_test: test labels
Basic Potato model.
fit(X)transform(X)predict(X)predict_proba(X)
metric:"riemann"or"wasserstein"center_method:"mean"or"median"threshold- Optimal transport parameters:
ot_regot_num_iterot_tol
Potato model for epsilon-separation experiments.
median_epslog_epsstats_eps
Potato model for cache-based fitting.
This version avoids loading all covariance matrices into memory at once and instead accesses them using indices.
Example:
train_idx = np.arange(get_num_clean_covs())
model.fit(train_idx)cacheExists(...)cacheSave(...)