hamedtu/eeg_dsr_demo
0
๐ง EEG Motor Imagery Music Composer
A sophisticated machine learning application that transforms brain signals into music compositions using motor imagery classification. This system uses a trained ShallowFBCSPNet model to classify different motor imagery tasks from EEG data and creates layered musical compositions based on the classification results.
๐ฏ Features
- Real-time EEG Classification: Uses ShallowFBCSPNet architecture for motor imagery classification
- Music Composition: Automatically creates layered music compositions from classification results
- Interactive Gradio Interface: User-friendly web interface for real-time interaction
- Six Motor Imagery Classes: Left/right hand, left/right leg, tongue, and neutral states
- Sound Mapping: Each motor imagery class is mapped to different musical instruments
- Composition Management: Save, clear, and manage your musical creations
๐๏ธ Architecture
Project Structure
โโโ app.py # Main Gradio application
โโโ classifier.py # Motor imagery classifier with ShallowFBCSPNet
โโโ data_processor.py # EEG data loading and preprocessing
โโโ sound_library.py # Sound management and composition system
โโโ config.py # Configuration settings
โโโ requirements.txt # Python dependencies
โโโ SoundHelix-Song-1/ # Audio files for different instruments
โ โโโ bass.wav
โ โโโ drums.wav
โ โโโ other.wav
โ โโโ vocals.wav
โโโ src/ # Additional source files
โโโ model.py
โโโ preprocessing.py
โโโ train.py
โโโ visualize.pySystem Components
- EEGDataProcessor (
data_processor.py) - Loads and processes .mat EEG files
- Handles epoching and preprocessing
- Simulates real-time data for demo purposes
- MotorImageryClassifier (
classifier.py) - Implements ShallowFBCSPNet model
- Performs real-time classification
- Provides confidence scores and probability distributions
- SoundManager (
sound_library.py) - Maps classifications to audio files
- Manages composition layers
- Handles audio file loading and playback
- Gradio Interface (
app.py) - Web-based user interface
- Real-time visualization
- Composition management tools
๐ Quick Start
Requirements
Python 3.9โ3.11 recommended. Install dependencies:
python -m pip install -r requirements.txtHow to run (Gradio)
Local launch:
python app.pyThis starts a server on http://127.0.0.1:7860 by default.
#
