# lordfiddinck/bci-eeg-pipeline architecture

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

- Interactive diagram: https://gitdiagram.com/lordfiddinck/bci-eeg-pipeline
- Repository: https://github.com/lordfiddinck/bci-eeg-pipeline

## Overview

This repository is an exploratory EEG brain-computer-interface pipeline: offline session preparation and model training produce command classifiers, while a separate live client sends buffered EEG to an external inference API. The README documents filtering, wavelet denoising, electrode-grid interpolation, and four-class training; the sampled training code confirms band filtering and per-class CNNs. Session-to-training-set assembly and the inference server are outside the repository. The graph includes documented stages, but omits unverified implementation links where sampled source does not show the call.

Main entry points: [`train_model.py`](https://github.com/lordfiddinck/bci-eeg-pipeline/blob/main/train_model.py) (Training pipeline), [`eeg_stream.py`](https://github.com/lordfiddinck/bci-eeg-pipeline/blob/main/eeg_stream.py) (Stream client), [`preprocessing.py`](https://github.com/lordfiddinck/bci-eeg-pipeline/blob/main/preprocessing.py) (Session preprocessing), [`config.py`](https://github.com/lordfiddinck/bci-eeg-pipeline/blob/main/config.py) (Shared configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_offline["Offline preparation"]
  node_rawfiles["EEG and key logs"]
  node_preprocess["Session preprocessing<br/>[preprocessing.py]"]
  node_session["Processed session"]
  node_features["Signal features"]
  node_grid["Electrode grid<br/>[matrix_support.py]"]
  node_config["Shared configuration<br/>[config.py]"]
end

subgraph group_model["Model training"]
  node_trainingdata["Training datasets"]
  node_trainer["Training pipeline<br/>[train_model.py]"]
  node_singularnet["SingularNet models<br/>[train_model.py]"]
  node_checkpoints["Model checkpoints"]
end

subgraph group_live["Live inference"]
  node_lsl["LSL stream"]
  node_streamclient["Stream client<br/>[eeg_stream.py]"]
  node_command["Predicted command"]
end

node_researcher(("Data operator"))
node_headset(("EEG headset"))
node_inferenceapi["Inference API"]

node_researcher -->|"provides"| node_rawfiles
node_rawfiles -->|"loads and aligns"| node_preprocess
node_preprocess -->|"saves session"| node_session
node_trainingdata -->|"loads samples"| node_trainer
node_trainer -->|"calls band filtering"| node_features
node_features -->|"prepares grid input"| node_grid
node_grid -->|"supplies CNN input"| node_trainer
node_trainer -->|"trains per-class"| node_singularnet
node_trainer -->|"writes weights"| node_checkpoints
node_preprocess -->|"reads paths"| node_config
node_trainer -->|"reads settings"| node_config
node_streamclient -->|"reads stream settings"| node_config
node_headset -->|"broadcasts EEG"| node_lsl
node_lsl -->|"provides samples"| node_streamclient
node_streamclient -->|"posts windows"| node_inferenceapi
node_inferenceapi -->|"returns predictions"| node_streamclient
node_streamclient -->|"interprets output"| node_command

click node_preprocess "https://github.com/lordfiddinck/bci-eeg-pipeline/blob/main/preprocessing.py"
click node_features "https://github.com/lordfiddinck/bci-eeg-pipeline/blob/main/feature_extraction.py"
click node_grid "https://github.com/lordfiddinck/bci-eeg-pipeline/blob/main/matrix_support.py"
click node_trainer "https://github.com/lordfiddinck/bci-eeg-pipeline/blob/main/train_model.py"
click node_singularnet "https://github.com/lordfiddinck/bci-eeg-pipeline/blob/main/train_model.py"
click node_config "https://github.com/lordfiddinck/bci-eeg-pipeline/blob/main/config.py"
click node_streamclient "https://github.com/lordfiddinck/bci-eeg-pipeline/blob/main/eeg_stream.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_rawfiles,node_preprocess,node_session,node_features,node_grid,node_config toneBlue
class node_trainingdata,node_trainer,node_singularnet,node_checkpoints toneAmber
class node_lsl,node_streamclient,node_command,node_inferenceapi toneMint
class node_researcher,node_headset toneIndigo
```

## Components

### Offline preparation

- **EEG and key logs**
- [Session preprocessing](https://github.com/lordfiddinck/bci-eeg-pipeline/blob/main/preprocessing.py): `preprocessing.py`
- **Processed session**
- [Signal features](https://github.com/lordfiddinck/bci-eeg-pipeline/blob/main/feature_extraction.py): `feature_extraction.py`
- [Electrode grid](https://github.com/lordfiddinck/bci-eeg-pipeline/blob/main/matrix_support.py): `matrix_support.py`
- [Shared configuration](https://github.com/lordfiddinck/bci-eeg-pipeline/blob/main/config.py): `config.py`

### Model training

- **Training datasets**
- [Training pipeline](https://github.com/lordfiddinck/bci-eeg-pipeline/blob/main/train_model.py): `train_model.py`
- [SingularNet models](https://github.com/lordfiddinck/bci-eeg-pipeline/blob/main/train_model.py): `train_model.py`
- **Model checkpoints**

### Live inference

- **LSL stream**
- [Stream client](https://github.com/lordfiddinck/bci-eeg-pipeline/blob/main/eeg_stream.py): `eeg_stream.py`
- **Predicted command**

### Other components

- **Data operator**
- **EEG headset**
- **Inference API**

## Connections

- Data operator → EEG and key logs: provides (evidence: `README.md`)
- EEG and key logs → Session preprocessing: loads and aligns (evidence: `preprocessing.py`)
- Session preprocessing → Processed session: saves session (evidence: `preprocessing.py`)
- Training datasets → Training pipeline: loads samples (evidence: `train_model.py`)
- Training pipeline → Signal features: calls band filtering (evidence: `train_model.py`)
- Signal features → Electrode grid: prepares grid input (evidence: `README.md`)
- Electrode grid → Training pipeline: supplies CNN input (evidence: `README.md`)
- Training pipeline → SingularNet models: trains per-class (evidence: `train_model.py`)
- Training pipeline → Model checkpoints: writes weights (evidence: `README.md`)
- Session preprocessing → Shared configuration: reads paths (evidence: `preprocessing.py`)
- Training pipeline → Shared configuration: reads settings (evidence: `train_model.py`)
- Stream client → Shared configuration: reads stream settings (evidence: `eeg_stream.py`)
- EEG headset → LSL stream: broadcasts EEG (evidence: `README.md`)
- LSL stream → Stream client: provides samples (evidence: `eeg_stream.py`)
- Stream client → Inference API: posts windows (evidence: `eeg_stream.py`)
- Inference API → Stream client: returns predictions (evidence: `eeg_stream.py`)
- Stream client → Predicted command: interprets output (evidence: `eeg_stream.py`)
