# altaheri/tcformer architecture

> Architecture diagram of the GitHub repository altaheri/tcformer, 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/altaheri/tcformer
- Repository: https://github.com/altaheri/tcformer

## Overview

TCFormer is an EEG motor-imagery decoding research and training repository. Its main workflow selects a dataset and model, loads and preprocesses EEG trials into subject-dependent or LOSO splits, trains and tests a classifier, then records metrics and summaries. The README also documents multiple benchmark datasets, alternative model architectures, augmentation, and per-subject and dataset-level result summaries. The graph preserves those major branches; connections not demonstrated by the excerpts or README are omitted.

Main entry points: [`train_pipeline.py`](https://github.com/altaheri/tcformer/blob/main/train_pipeline.py) (Experiment runner), [`utils/get_datamodule_cls.py`](https://github.com/altaheri/tcformer/blob/main/utils/get_datamodule_cls.py) (Dataset selection), [`models/tcformer.py`](https://github.com/altaheri/tcformer/blob/main/models/tcformer.py) (TCFormer network), [`utils/get_model_cls.py`](https://github.com/altaheri/tcformer/blob/main/utils/get_model_cls.py) (Model selection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Experiment workflow"]
  node_pipeline["Experiment runner<br/>[train_pipeline.py]"]
  node_data_select["Dataset selection"]
  node_model_select["Model selection<br/>[get_model_cls.py]"]
  node_classifier["Classifier training"]
end

subgraph group_data["EEG data"]
  node_base_data["Data module base<br/>[base.py]"]
  node_bcic2a["BCI IV-2a splits<br/>[bcic4_2a.py]"]
  node_bcic2b["BCI IV-2b splits<br/>[bcic4_2b.py]"]
  node_hgd["High-Gamma splits<br/>[hgd.py]"]
  node_rehmi["REH-MI splits<br/>[reh_mi.py]"]
  node_bcic3["BCI III-IVa splits<br/>[bcic3.py]"]
  node_bcic4_loader["BCI IV loader<br/>[load_bcic4.py]"]
  node_hgd_loader["High-Gamma loader<br/>[load_hgd.py]"]
  node_rehmi_loader["REH-MI loader<br/>[load_rehmi.py]"]
  node_bcic3_loader["BCI III-IVa loader<br/>[load_bcic3.py]"]
end

subgraph group_models["Model architectures"]
  node_tcformer["TCFormer network<br/>[tcformer.py]"]
  node_attention["Attention blocks"]
  node_channel_attention["Channel-group attention"]
  node_model_modules["Convolution modules<br/>[modules.py]"]
  node_other_models["Benchmark models"]
end

subgraph group_support["Training and analysis"]
  node_augmentation["Trial augmentation<br/>[interaug.py]"]
  node_metrics["Metrics and plots<br/>[metrics.py]"]
  node_plotting["Result plots<br/>[plotting.py]"]
  node_latency["Inference latency<br/>[latency.py]"]
  node_per_subject["Per-subject summary"]
  node_aggregate["Dataset summary"]
end

node_researcher(("Researcher"))

node_researcher -->|"runs experiments"| node_pipeline
node_pipeline -->|"selects dataset"| node_data_select
node_pipeline -->|"selects model"| node_model_select
node_data_select -->|"resolves module"| node_bcic2a
node_data_select -->|"resolves module"| node_bcic2b
node_data_select -->|"resolves module"| node_hgd
node_data_select -->|"resolves module"| node_rehmi
node_data_select -->|"resolves module"| node_bcic3
node_bcic2a -->|"loads trials"| node_bcic4_loader
node_bcic2b -->|"loads trials"| node_bcic4_loader
node_hgd -->|"loads trials"| node_hgd_loader
node_rehmi -->|"loads trials"| node_rehmi_loader
node_bcic3 -->|"loads trials"| node_bcic3_loader
node_base_data -->|"augments batches"| node_augmentation
node_model_select -->|"resolves model"| node_tcformer
node_model_select -->|"resolves model"| node_other_models
node_pipeline -->|"instantiates model"| node_classifier
node_tcformer -->|"uses training module"| node_classifier
node_tcformer -->|"uses attention"| node_channel_attention
node_tcformer -->|"uses convolutions"| node_model_modules
node_other_models -->|"shares training module"| node_classifier
node_pipeline -->|"records metrics"| node_metrics
node_pipeline -->|"plots results"| node_plotting
node_pipeline -->|"measures latency"| node_latency
node_researcher -->|"summarizes subjects"| node_per_subject
node_researcher -->|"aggregates results"| node_aggregate

click node_pipeline "https://github.com/altaheri/tcformer/blob/main/train_pipeline.py"
click node_data_select "https://github.com/altaheri/tcformer/blob/main/utils/get_datamodule_cls.py"
click node_model_select "https://github.com/altaheri/tcformer/blob/main/utils/get_model_cls.py"
click node_classifier "https://github.com/altaheri/tcformer/blob/main/models/classification_module.py"
click node_base_data "https://github.com/altaheri/tcformer/blob/main/datamodules/base.py"
click node_bcic2a "https://github.com/altaheri/tcformer/blob/main/datamodules/bcic4_2a.py"
click node_bcic2b "https://github.com/altaheri/tcformer/blob/main/datamodules/bcic4_2b.py"
click node_hgd "https://github.com/altaheri/tcformer/blob/main/datamodules/hgd.py"
click node_rehmi "https://github.com/altaheri/tcformer/blob/main/datamodules/reh_mi.py"
click node_bcic3 "https://github.com/altaheri/tcformer/blob/main/datamodules/bcic3.py"
click node_bcic4_loader "https://github.com/altaheri/tcformer/blob/main/utils/load_bcic4.py"
click node_hgd_loader "https://github.com/altaheri/tcformer/blob/main/utils/load_hgd.py"
click node_rehmi_loader "https://github.com/altaheri/tcformer/blob/main/utils/load_rehmi.py"
click node_bcic3_loader "https://github.com/altaheri/tcformer/blob/main/utils/load_bcic3.py"
click node_augmentation "https://github.com/altaheri/tcformer/blob/main/utils/interaug.py"
click node_tcformer "https://github.com/altaheri/tcformer/blob/main/models/tcformer.py"
click node_attention "https://github.com/altaheri/tcformer/blob/main/models/attention_blocks.py"
click node_channel_attention "https://github.com/altaheri/tcformer/blob/main/models/channel_group_attention.py"
click node_model_modules "https://github.com/altaheri/tcformer/blob/main/models/modules.py"
click node_other_models "https://github.com/altaheri/tcformer/tree/main/models"
click node_metrics "https://github.com/altaheri/tcformer/blob/main/utils/metrics.py"
click node_plotting "https://github.com/altaheri/tcformer/blob/main/utils/plotting.py"
click node_latency "https://github.com/altaheri/tcformer/blob/main/utils/latency.py"
click node_per_subject "https://github.com/altaheri/tcformer/blob/main/summarize_per_subject.py"
click node_aggregate "https://github.com/altaheri/tcformer/blob/main/summarize_results.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_pipeline,node_data_select,node_model_select,node_classifier toneBlue
class node_base_data,node_bcic2a,node_bcic2b,node_hgd,node_rehmi,node_bcic3,node_bcic4_loader,node_hgd_loader,node_rehmi_loader,node_bcic3_loader toneAmber
class node_tcformer,node_attention,node_channel_attention,node_model_modules,node_other_models toneMint
class node_augmentation,node_metrics,node_plotting,node_latency,node_per_subject,node_aggregate toneRose
class node_researcher toneIndigo
```

## Components

### Experiment workflow

- [Experiment runner](https://github.com/altaheri/tcformer/blob/main/train_pipeline.py): `train_pipeline.py`
- [Dataset selection](https://github.com/altaheri/tcformer/blob/main/utils/get_datamodule_cls.py): `utils/get_datamodule_cls.py`
- [Model selection](https://github.com/altaheri/tcformer/blob/main/utils/get_model_cls.py): `utils/get_model_cls.py`
- [Classifier training](https://github.com/altaheri/tcformer/blob/main/models/classification_module.py): `models/classification_module.py`

### EEG data

- [Data module base](https://github.com/altaheri/tcformer/blob/main/datamodules/base.py): `datamodules/base.py`
- [BCI IV-2a splits](https://github.com/altaheri/tcformer/blob/main/datamodules/bcic4_2a.py): `datamodules/bcic4_2a.py`
- [BCI IV-2b splits](https://github.com/altaheri/tcformer/blob/main/datamodules/bcic4_2b.py): `datamodules/bcic4_2b.py`
- [High-Gamma splits](https://github.com/altaheri/tcformer/blob/main/datamodules/hgd.py): `datamodules/hgd.py`
- [REH-MI splits](https://github.com/altaheri/tcformer/blob/main/datamodules/reh_mi.py): `datamodules/reh_mi.py`
- [BCI III-IVa splits](https://github.com/altaheri/tcformer/blob/main/datamodules/bcic3.py): `datamodules/bcic3.py`
- [BCI IV loader](https://github.com/altaheri/tcformer/blob/main/utils/load_bcic4.py): `utils/load_bcic4.py`
- [High-Gamma loader](https://github.com/altaheri/tcformer/blob/main/utils/load_hgd.py): `utils/load_hgd.py`
- [REH-MI loader](https://github.com/altaheri/tcformer/blob/main/utils/load_rehmi.py): `utils/load_rehmi.py`
- [BCI III-IVa loader](https://github.com/altaheri/tcformer/blob/main/utils/load_bcic3.py): `utils/load_bcic3.py`

### Model architectures

- [TCFormer network](https://github.com/altaheri/tcformer/blob/main/models/tcformer.py): `models/tcformer.py`
- [Attention blocks](https://github.com/altaheri/tcformer/blob/main/models/attention_blocks.py): `models/attention_blocks.py`
- [Channel-group attention](https://github.com/altaheri/tcformer/blob/main/models/channel_group_attention.py): `models/channel_group_attention.py`
- [Convolution modules](https://github.com/altaheri/tcformer/blob/main/models/modules.py): `models/modules.py`
- [Benchmark models](https://github.com/altaheri/tcformer/tree/main/models): `models`

### Training and analysis

- [Trial augmentation](https://github.com/altaheri/tcformer/blob/main/utils/interaug.py): `utils/interaug.py`
- [Metrics and plots](https://github.com/altaheri/tcformer/blob/main/utils/metrics.py): `utils/metrics.py`
- [Result plots](https://github.com/altaheri/tcformer/blob/main/utils/plotting.py): `utils/plotting.py`
- [Inference latency](https://github.com/altaheri/tcformer/blob/main/utils/latency.py): `utils/latency.py`
- [Per-subject summary](https://github.com/altaheri/tcformer/blob/main/summarize_per_subject.py): `summarize_per_subject.py`
- [Dataset summary](https://github.com/altaheri/tcformer/blob/main/summarize_results.py): `summarize_results.py`

### Other components

- **Researcher**

## Connections

- Researcher → Experiment runner: runs experiments
- Experiment runner → Dataset selection: selects dataset (evidence: `train_pipeline.py`)
- Experiment runner → Model selection: selects model (evidence: `train_pipeline.py`)
- Dataset selection → BCI IV-2a splits: resolves module (evidence: `utils/get_datamodule_cls.py`)
- Dataset selection → BCI IV-2b splits: resolves module (evidence: `utils/get_datamodule_cls.py`)
- Dataset selection → High-Gamma splits: resolves module (evidence: `utils/get_datamodule_cls.py`)
- Dataset selection → REH-MI splits: resolves module (evidence: `utils/get_datamodule_cls.py`)
- Dataset selection → BCI III-IVa splits: resolves module (evidence: `utils/get_datamodule_cls.py`)
- BCI IV-2a splits → BCI IV loader: loads trials (evidence: `datamodules/bcic4_2a.py`)
- BCI IV-2b splits → BCI IV loader: loads trials (evidence: `datamodules/bcic4_2b.py`)
- High-Gamma splits → High-Gamma loader: loads trials (evidence: `datamodules/hgd.py`)
- REH-MI splits → REH-MI loader: loads trials (evidence: `datamodules/reh_mi.py`)
- BCI III-IVa splits → BCI III-IVa loader: loads trials (evidence: `datamodules/bcic3.py`)
- Data module base → Trial augmentation: augments batches (evidence: `datamodules/base.py`)
- Model selection → TCFormer network: resolves model (evidence: `utils/get_model_cls.py`)
- Model selection → Benchmark models: resolves model (evidence: `utils/get_model_cls.py`)
- Experiment runner → Classifier training: instantiates model (evidence: `train_pipeline.py`)
- TCFormer network → Classifier training: uses training module (evidence: `models/tcformer.py`)
- TCFormer network → Channel-group attention: uses attention (evidence: `models/tcformer.py`)
- TCFormer network → Convolution modules: uses convolutions (evidence: `models/tcformer.py`)
- Benchmark models → Classifier training: shares training module (evidence: `models/atcnet.py`)
- Experiment runner → Metrics and plots: records metrics (evidence: `train_pipeline.py`)
- Experiment runner → Result plots: plots results (evidence: `train_pipeline.py`)
- Experiment runner → Inference latency: measures latency (evidence: `train_pipeline.py`)
- Researcher → Per-subject summary: summarizes subjects
- Researcher → Dataset summary: aggregates results
