NeuroMusicLab / README.md
sofieff's picture
Initial commit: EEG Motor Imagery Music Composer
fa96cf5
|
raw
history blame
2.78 kB

🧠 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

  1. EEGDataProcessor (data_processor.py)

    • Loads and processes .mat EEG files
    • Handles epoching and preprocessing
    • Simulates real-time data for demo purposes
  2. MotorImageryClassifier (classifier.py)

    • Implements ShallowFBCSPNet model
    • Performs real-time classification
    • Provides confidence scores and probability distributions
  3. SoundManager (sound_library.py)

    • Maps classifications to audio files
    • Manages composition layers
    • Handles audio file loading and playback
  4. 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.