NeuroMusicLab / config.py
sofieff's picture
layering works
c2929af
raw
history blame
2.58 kB
"""
Configuration settings for the EEG Motor Imagery Music Composer
"""
import os
from pathlib import Path
# Application settings
APP_NAME = "EEG Motor Imagery Music Composer"
VERSION = "1.0.0"
# Data paths
BASE_DIR = Path(__file__).parent
DATA_DIR = BASE_DIR / "data"
SOUND_DIR = BASE_DIR / "sounds"
MODEL_DIR = BASE_DIR
# Model settings
MODEL_PATH = MODEL_DIR / "shallow_weights_all.pth"
# Model architecture: Always uses ShallowFBCSPNet from braindecode
# If pre-trained weights not found, will train using LOSO on available data
# EEG Data settings
SAMPLING_RATE = 200 # Hz
EPOCH_DURATION = 1.5 # seconds
N_CHANNELS = 19 # without ground and reference 19 electrodes
N_CLASSES = 6 # or 4
# Classification settings
CONFIDENCE_THRESHOLD = 0.3 # Minimum confidence to add sound layer (lowered for testing)
MAX_COMPOSITION_LAYERS = 6 # Maximum layers in composition
# Sound settings
SOUND_MAPPING = {
"left_hand": "1_SoundHelix-Song-6_(Bass).wav",
"right_hand": "1_SoundHelix-Song-6_(Drums).wav",
"neutral": None, # No sound for neutral/rest state
"left_leg": "1_SoundHelix-Song-6_(Other).wav",
"tongue": "1_SoundHelix-Song-6_(Vocals).wav",
"right_leg": "1_SoundHelix-Song-6_(Bass).wav" # Can be remapped by user
}
# Motor imagery class names
CLASS_NAMES = {
0: "left_hand",
1: "right_hand",
2: "neutral",
3: "left_leg",
4: "tongue",
5: "right_leg"
}
CLASS_DESCRIPTIONS = {
"left_hand": "🀚 Left Hand Movement",
"right_hand": "🀚 Right Hand Movement",
"neutral": "😐 Neutral/Rest State",
"left_leg": "🦡 Left Leg Movement",
"tongue": "πŸ‘… Tongue Movement",
"right_leg": "🦡 Right Leg Movement"
}
# Demo data paths (optional) - updated with available files
DEMO_DATA_PATHS = [
"data/HaLTSubjectA1602236StLRHandLegTongue.mat",
"data/HaLTSubjectA1603086StLRHandLegTongue.mat",
"data/HaLTSubjectA1603106StLRHandLegTongue.mat",
]
# Gradio settings
GRADIO_PORT = 7860
GRADIO_HOST = "0.0.0.0"
GRADIO_SHARE = False # Set to True to create public links
# Logging settings
LOG_LEVEL = "INFO"
LOG_FILE = BASE_DIR / "logs" / "app.log"
# Create necessary directories
def create_directories():
"""Create necessary directories if they don't exist."""
directories = [
DATA_DIR,
SOUND_DIR,
MODEL_DIR,
LOG_FILE.parent
]
for directory in directories:
directory.mkdir(parents=True, exist_ok=True)
if __name__ == "__main__":
create_directories()
print("Configuration directories created successfully!")