CoolFace
Apppublic

hamedtu/eeg_dsr_demo

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
App README

๐Ÿง  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. 1.EEGDataProcessor (data_processor.py)
  2. 2.Loads and processes .mat EEG files
  3. 3.Handles epoching and preprocessing
  4. 4.Simulates real-time data for demo purposes
  1. 1.MotorImageryClassifier (classifier.py)
  2. 2.Implements ShallowFBCSPNet model
  3. 3.Performs real-time classification
  4. 4.Provides confidence scores and probability distributions
  1. 1.SoundManager (sound_library.py)
  2. 2.Maps classifications to audio files
  3. 3.Manages composition layers
  4. 4.Handles audio file loading and playback
  1. 1.Gradio Interface (app.py)
  2. 2.Web-based user interface
  3. 3.Real-time visualization
  4. 4.Composition management tools

๐Ÿš€ Quick Start

Requirements

Python 3.9โ€“3.11 recommended. Install dependencies:

bash
python -m pip install -r requirements.txt

How to run (Gradio)

Local launch:

bash
python app.py

This starts a server on http://127.0.0.1:7860 by default.

#