Skip to content

Inference-only FastAPI service for EEG motor-imagery classification using CSP features and an LDA model.

Notifications You must be signed in to change notification settings

fractal360/EEG-MI-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EEG Motor Imagery Inference API (EEG-MI-API)

This repository provides a production-style inference API for EEG motor-imagery classification, built on top of a classical CSP + LDA pipeline.

Training and feature-generation pipeline: EEG-BCI-Pipeline


Overview

  • Task: EEG motor-imagery classification (left hand, right hand, foot, tongue)
  • Model: Common Spatial Patterns (CSP) + Linear Discriminant Analysis (LDA)
  • Role of API: Inference only (no training performed here)
  • Framework: FastAPI
  • Server: Uvicorn (ASGI)
  • Deployment: Docker (multi-stage build)

Architecture

Training (offline)

Training is performed separately in the EEG pipeline project.

Raw EEG epochs
  → band-pass filtering (8–30 Hz)
  → CSP.fit / CSP.transform
  → LDA.fit

Outputs (exported offline):

  • Trained CSP transformer (used client-side at inference time)
  • Trained LDA classifier (loaded server-side by this API)

Inference (this API)

Client:
  Raw EEG epoch
    → CSP.transform
    → feature vector (floats)

Server (this API):
  feature vector
    → LDA.predict
    → class label (0–3)

Important:

  • The API does not accept raw EEG
  • The API does not perform training
  • Only CSP feature vectors are accepted

API Endpoints

POST /predict

Predict motor-imagery class from CSP features.

Input:

{
  "features": [0.12, -0.34, 1.56]
}

Output:

{
  "prediction": 2
}

Running with Docker

docker build -t eeg-mi-api .
docker run --rm -p 8000:8000 eeg-mi-api

API available at http://localhost:8000


License

MIT

About

Inference-only FastAPI service for EEG motor-imagery classification using CSP features and an LDA model.

Topics

Resources

Stars

Watchers

Forks