# luo-huan-123/btta-dg architecture

> Architecture diagram of the GitHub repository luo-huan-123/btta-dg, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/luo-huan-123/btta-dg
- Repository: https://github.com/luo-huan-123/btta-dg

## Overview

BTTA-DG is a motor-imagery EEG decoding project whose documented workflow is dataset preparation, source-domain pretraining, then held-out-subject test-time adaptation and evaluation. The graph preserves dataset loading/splitting, Sinc feature extraction, Dirichlet estimation, GMM refinement, and checkpoint use. The excerpts do not expose the full adaptation call sequence, so those internal links rely on README statements where noted; no augmentation edge is shown because its runtime use is not evidenced.

Main entry points: [`BTTA_DG.py`](https://github.com/luo-huan-123/btta-dg/blob/master/BTTA_DG.py) (BTTA-DG runner), [`pretrain_SincAdaptNet.py`](https://github.com/luo-huan-123/btta-dg/blob/master/pretrain_SincAdaptNet.py) (Sinc pretraining), [`utils/dataloader.py`](https://github.com/luo-huan-123/btta-dg/blob/master/utils/dataloader.py) (MI data loader), [`download_data.py`](https://github.com/luo-huan-123/btta-dg/blob/master/download_data.py) (Dataset export)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["EEG data"]
  node_acquire["Dataset export<br/>[download_data.py]"]
  node_datasetfiles[("EEG dataset files")]
  node_loader["MI data loader<br/>[dataloader.py]"]
end

subgraph group_training["Source training"]
  node_pretrain["Sinc pretraining"]
  node_ea["Covariance alignment"]
  node_network["SincAdaptNet<br/>[SincAdaptNet.py]"]
  node_checkpoints[("Model checkpoints")]
end

subgraph group_adaptation["Test-time decoding"]
  node_adapt["BTTA-DG runner<br/>[BTTA_DG.py]"]
  node_eegmodel["EEG feature wrapper<br/>[BTTA_DG.py]"]
  node_dirichlet["Dirichlet estimator<br/>[BTTA_DG.py]"]
  node_gmm["Online GMM inference<br/>[BTTA_DG.py]"]
  node_results["Evaluation results"]
end

subgraph group_internal["Shared internals"]
  node_split["Subject splitting<br/>[data_utils.py]"]
end

node_user(("Researcher"))
node_moabb(("MOABB datasets"))

node_user -->|"exports datasets"| node_acquire
node_moabb -->|"provides data"| node_acquire
node_acquire -->|"writes arrays"| node_datasetfiles
node_datasetfiles -->|"loads arrays"| node_loader
node_loader -->|"uses split"| node_split
node_user -->|"starts training"| node_pretrain
node_pretrain -->|"loads trials"| node_loader
node_pretrain -->|"aligns signals"| node_ea
node_pretrain -->|"trains model"| node_network
node_pretrain -->|"saves weights"| node_checkpoints
node_user -->|"runs adaptation"| node_adapt
node_adapt -->|"loads trials"| node_loader
node_adapt -->|"loads weights"| node_checkpoints
node_adapt -->|"builds wrapper"| node_eegmodel
node_eegmodel -->|"uses extractor"| node_network
node_adapt -->|"estimates parameters"| node_dirichlet
node_adapt -->|"refines predictions"| node_gmm
node_adapt -->|"records evaluation"| node_results

click node_acquire "https://github.com/luo-huan-123/btta-dg/blob/master/download_data.py"
click node_loader "https://github.com/luo-huan-123/btta-dg/blob/master/utils/dataloader.py"
click node_split "https://github.com/luo-huan-123/btta-dg/blob/master/utils/data_utils.py"
click node_pretrain "https://github.com/luo-huan-123/btta-dg/blob/master/pretrain_SincAdaptNet.py"
click node_ea "https://github.com/luo-huan-123/btta-dg/blob/master/pretrain_SincAdaptNet.py"
click node_network "https://github.com/luo-huan-123/btta-dg/blob/master/SincAdaptNet.py"
click node_adapt "https://github.com/luo-huan-123/btta-dg/blob/master/BTTA_DG.py"
click node_eegmodel "https://github.com/luo-huan-123/btta-dg/blob/master/BTTA_DG.py"
click node_dirichlet "https://github.com/luo-huan-123/btta-dg/blob/master/BTTA_DG.py"
click node_gmm "https://github.com/luo-huan-123/btta-dg/blob/master/BTTA_DG.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_acquire,node_datasetfiles,node_loader toneBlue
class node_pretrain,node_ea,node_network,node_checkpoints toneAmber
class node_adapt,node_eegmodel,node_dirichlet,node_gmm,node_results toneMint
class node_split toneRose
class node_user,node_moabb toneIndigo
```

## Components

### EEG data

- [Dataset export](https://github.com/luo-huan-123/btta-dg/blob/master/download_data.py): `download_data.py`
- **EEG dataset files**
- [MI data loader](https://github.com/luo-huan-123/btta-dg/blob/master/utils/dataloader.py): `utils/dataloader.py`

### Source training

- [Sinc pretraining](https://github.com/luo-huan-123/btta-dg/blob/master/pretrain_SincAdaptNet.py): `pretrain_SincAdaptNet.py`
- [Covariance alignment](https://github.com/luo-huan-123/btta-dg/blob/master/pretrain_SincAdaptNet.py): `pretrain_SincAdaptNet.py`
- [SincAdaptNet](https://github.com/luo-huan-123/btta-dg/blob/master/SincAdaptNet.py): `SincAdaptNet.py`
- **Model checkpoints**

### Test-time decoding

- [BTTA-DG runner](https://github.com/luo-huan-123/btta-dg/blob/master/BTTA_DG.py): `BTTA_DG.py`
- [EEG feature wrapper](https://github.com/luo-huan-123/btta-dg/blob/master/BTTA_DG.py): `BTTA_DG.py`
- [Dirichlet estimator](https://github.com/luo-huan-123/btta-dg/blob/master/BTTA_DG.py): `BTTA_DG.py`
- [Online GMM inference](https://github.com/luo-huan-123/btta-dg/blob/master/BTTA_DG.py): `BTTA_DG.py`
- **Evaluation results**

### Shared internals

- [Subject splitting](https://github.com/luo-huan-123/btta-dg/blob/master/utils/data_utils.py): `utils/data_utils.py`

### Other components

- **Researcher**
- **MOABB datasets**

## Connections

- Researcher → Dataset export: exports datasets (evidence: `README.md`)
- MOABB datasets → Dataset export: provides data (evidence: `download_data.py`)
- Dataset export → EEG dataset files: writes arrays (evidence: `download_data.py`)
- EEG dataset files → MI data loader: loads arrays (evidence: `utils/dataloader.py`)
- MI data loader → Subject splitting: uses split (evidence: `utils/dataloader.py`)
- Researcher → Sinc pretraining: starts training (evidence: `README.md`)
- Sinc pretraining → MI data loader: loads trials (evidence: `pretrain_SincAdaptNet.py`)
- Sinc pretraining → Covariance alignment: aligns signals (evidence: `pretrain_SincAdaptNet.py`)
- Sinc pretraining → SincAdaptNet: trains model (evidence: `pretrain_SincAdaptNet.py`)
- Sinc pretraining → Model checkpoints: saves weights (evidence: `pretrain_SincAdaptNet.py`)
- Researcher → BTTA-DG runner: runs adaptation (evidence: `README.md`)
- BTTA-DG runner → MI data loader: loads trials (evidence: `BTTA_DG.py`)
- BTTA-DG runner → Model checkpoints: loads weights (evidence: `BTTA_DG.py`)
- BTTA-DG runner → EEG feature wrapper: builds wrapper (evidence: `BTTA_DG.py`)
- EEG feature wrapper → SincAdaptNet: uses extractor (evidence: `BTTA_DG.py`)
- BTTA-DG runner → Dirichlet estimator: estimates parameters (evidence: `README.md`)
- BTTA-DG runner → Online GMM inference: refines predictions (evidence: `README.md`)
- BTTA-DG runner → Evaluation results: records evaluation (evidence: `BTTA_DG.py`)
