Spaces:
Sleeping
Sleeping
π§ 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.py
System 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.txt
How to run (Gradio)
Local launch:
python app.py
This starts a server on http://127.0.0.1:7860 by default.