A comprehensive Python application for real-time EEG monitoring and meditation state analysis using the Muse 2 headband. This educational project includes brain wave processing, meditation analysis, and Ubuntu 24.04 compatibility fixes.
⚠️ IMPORTANT DISCLAIMER: This software is provided for educational and research purposes only. It is not a medical device and should not be used for medical diagnosis or treatment. Use at your own risk. Always consult qualified medical professionals for health-related concerns.
- 🎯 Real-time EEG Visualization: Live plots of all 4 EEG channels (TP9, AF7, AF8, TP10)
- 🧘 Meditation Analysis: Research-inspired algorithms for brain state classification
- 📊 Multi-sensor Integration: EEG + PPG heart rate + accelerometer data
- ⚡ Modern GUI: PyQt5 interface with real-time plotting
- 🔧 Ubuntu 24.04 Fixed: Includes critical muselsl library patches
- 📈 Session Tracking: 10-second and 1-minute meditation score tracking
- 🎚️ Personal Calibration: 20-second baseline calibration for improved accuracy
- 🔄 Auto-reconnection: Robust connection management with error recovery
# One-command setup for Ubuntu 24.04
./setup.shThis script will automatically install all dependencies, apply patches, and verify the system.
# Run comprehensive system diagnostic
python system_check.pyThis will verify all requirements and provide specific guidance for any issues.
# This fixes critical muselsl bugs for Ubuntu 24.04
python patch_muselsl.pypip install -r requirements.txt# Start the main application
python working_muse_gui.py- Turn on your Muse 2 headband (LED should blink)
- In the GUI, click "🚀 START Muse Streaming"
- Wait for automatic device discovery and connection
- Watch real-time brain wave data flow!
- 🧠 4-Channel EEG Plots: Real-time visualization of TP9, AF7, AF8, TP10 electrodes
- 🎯 Meditation Scoring: Live brain state analysis (0-100 scale)
- 📊 Session Tracking: Historical data with 10s and 1-minute intervals
- ⚙️ Calibration System: Personal baseline establishment for improved accuracy
- 📋 Activity Log: Real-time connection status and system messages
- 🔄 Auto-recovery: Automatic reconnection on connection loss
- Research-Inspired Analysis: Uses frontal lobe EEG patterns for meditation detection
- Multi-timeframe Tracking: Both short-term and long-term meditation trends
- Signal Quality Monitoring: Real-time assessment of electrode contact
- High-Performance Visualization: pyqtgraph plotting for real-time data
The system uses advanced research-based algorithms to analyze brain states:
- 🟢 Deep Meditation (75-100): Strong relaxed awareness, optimal meditative state
- 🟡 Calm/Relaxed (60-75): Good meditation indicators, peaceful mind
- 🟠 Mild Relaxation (40-60): Light relaxation with some mental activity
- 🔴 Active/Stressed (0-40): High mental activity, active thinking
- Personal Calibration: 20-second baseline establishment for accurate scoring
- Real-time Processing: Updates every 2 seconds for immediate feedback
- Multi-factor Analysis: Signal amplitude, smoothness, and hemisphere synchronization
- Session Tracking: Historical meditation data with trend analysis
The system analyzes EEG patterns based on established meditation research:
- Signal Amplitude: Lower amplitude indicates reduced mental activity
- Signal Smoothness: Smoother signals suggest more relaxed brain states
- Hemisphere Synchronization: Balanced left/right brain activity indicates meditation
- Stability: Consistent readings over time indicate sustained meditative states
Muse 2 Hardware (Bluetooth)
↓
Fixed muselsl Library (Ubuntu 24.04 compatible)
↓
LSL (Lab Streaming Layer)
↓
PyQt5 GUI Application
↓
Real-time Brain Analysis & Visualization
- 🔗 muselsl: Bluetooth communication with Muse 2 (patched for Ubuntu 24.04)
- 📊 pylsl: Lab Streaming Layer for real-time data streaming
- 🖥️ PyQt5: Modern GUI framework with dark theme
- 📈 pyqtgraph: High-performance real-time plotting (up to 256 Hz)
- 🧮 NumPy/SciPy: Advanced signal processing and mathematical computations
- 🔵 Bleak: Modern Bluetooth Low Energy backend for device discovery
- 🔨 Fixed muselsl Library: Resolved critical Ubuntu 24.04 compatibility issues
- ⚡ Enhanced Data Pipeline: Improved LSL streaming reliability
- 🔄 Robust Error Handling: Automatic reconnection and graceful failure management
- 📊 Advanced Analytics: Multi-timeframe meditation tracking and statistics
- 🎨 Modern UI: Clean interface with real-time performance optimization
# Check Bluetooth status
sudo systemctl status bluetooth
# Restart Bluetooth service
sudo systemctl restart bluetooth
# Ensure Muse 2 is on (LED should blink)
# Try moving closer to computer (within 3 feet)# Test if the patch worked
python test_lsl_working.py
# If test fails, reapply the patch
python patch_muselsl.py- This is normal - Bluetooth connections can be intermittent
- Click "START Muse Streaming" again to reconnect
- The system will automatically attempt reconnection
- Clean electrodes: Use alcohol wipe on Muse 2 contact points
- Proper fit: Ensure snug but comfortable headband position
- Hair interference: Move hair away from electrode contact areas
- Skin contact: Ensure all 4 electrodes touch skin properly
- Use Calibration: Click "CALIBRATE (20s)" button for personalized baselines
- Proper environment: Use in quiet environment without distractions
- Relaxed posture: Sit comfortably with eyes closed
- Practice: Meditation detection improves with consistent use
# Set environment variable for better Qt performance
export QT_X11_NO_MITSHM=1
python working_muse_gui.py- Close unnecessary applications
- The system is optimized for real-time performance
- CPU usage of 10-20% is normal for real-time EEG processing
working_muse_gui.py- Primary GUI application with all featuresrequirements.txt- Python package dependencies
patch_muselsl.py- Critical Ubuntu 24.04 compatibility fixessetup.sh- Automated installation and configuration script- Apply patch:
python patch_muselsl.py - Restore original:
python patch_muselsl.py restore - Auto setup:
./setup.sh
system_check.py- Comprehensive system diagnostic and health checktest_lsl_working.py- Tests LSL streaming functionalityverify_gui_data.py- Monitors GUI data receptionquick_lsl_test.py- Quick LSL stream detection test
README.md- This comprehensive guideSYSTEM_OVERVIEW.md- Detailed technical documentationWORKING_SYSTEM_README.md- System status and featuresBREAKTHROUGH_SUMMARY.md- Technical achievements and testing results
- Muse 2 EEG Headband (4-channel EEG by InteraXon)
- Bluetooth LE Support (Most modern computers)
- USB Power (for computer during extended sessions)
- Ubuntu 20.04+ (tested extensively on 24.04)
- Python 3.8+ (tested with 3.10)
- Anaconda/Miniconda (recommended for package management)
- CPU: Multi-core recommended for smooth real-time processing
- RAM: 4GB minimum, 8GB recommended
- Display: 1920x1080+ for optimal GUI experience
-
Apply the Ubuntu 24.04 patch (ESSENTIAL):
python patch_muselsl.py
-
Test the fix:
python test_lsl_working.py
-
Start the application:
python working_muse_gui.py
- Turn on Muse 2 (LED should blink blue)
- Launch GUI:
python working_muse_gui.py - Click "🚀 START Muse Streaming"
- Wait for connection (usually 10-30 seconds)
- Calibrate (recommended): Click "CALIBRATE (20s)"
- Monitor your meditation with real-time feedback!
- When: After connecting, sit quietly for best results
- Duration: 20 seconds of calm, relaxed sitting
- Purpose: Establishes your personal EEG baseline
- Result: More accurate meditation scoring tailored to your brain patterns
- Meditation Score: 0-100 scale updated every 2 seconds
- Color Coding: Green (deep meditation) → Yellow (calm) → Orange (mild) → Red (active)
- Tracking Plots: Shows your meditation trends over time
- Statistics: Displays average, maximum, and minimum scores
The system simultaneously monitors:
- 🧠 EEG: 4-channel brain wave activity (256 Hz)
- 💓 PPG: Heart rate and blood flow (64 Hz)
- 📱 ACC: Head movement and posture (52 Hz)
- Signal Quality Assessment: Monitors electrode contact
- Artifact Detection: Identifies movement and blink artifacts
- Trend Analysis: Tracks meditation improvement over sessions
- Session Reports: Detailed statistics and insights
The system can be modified for:
- Research Applications: Export raw data for analysis
- Therapeutic Use: Adjust meditation algorithms for specific needs
- Educational Demos: Simplified interfaces for teaching
- Extended Monitoring: Long-term session recording
- ✅ Fixed Critical Bugs: Resolved Ubuntu 24.04 muselsl compatibility issues
- ✅ Modern GUI: Built real-time EEG visualization interface
- ✅ Advanced Analytics: Implemented sophisticated meditation detection algorithms
- ✅ Robust Architecture: Created production-ready brain-computer interface
- ✅ Multi-Platform Support: Comprehensive Linux compatibility with error handling
- 1,400+ sensor samples successfully processed in testing
- Real-time processing at 256 Hz EEG sample rate
- Smooth visualization with 60 FPS interface updates
- Reliable connection management with automatic recovery
- Experimental accuracy in meditation state detection
This project demonstrates mastery of:
- 🔬 Signal Processing: Advanced EEG analysis and filtering
- 💻 Real-time Systems: High-frequency data streaming and processing
- 🧠 Neuroscience: Brain wave patterns and meditation research
- 🖥️ GUI Development: Modern PyQt5 interface design
- 🔧 System Integration: Hardware-software interface programming
- 🛠️ Debugging: Complex Bluetooth and library compatibility issues
This project is for educational and research purposes. Muse is a trademark of InteraXon Inc.
The system includes important fixes for the open-source muselsl library to ensure Ubuntu 24.04 compatibility, contributing back to the community.
For technical issues:
- Check the Troubleshooting section above
- Run diagnostic tests:
python test_lsl_working.py - Verify the patch is applied:
python patch_muselsl.py
For Muse 2 hardware issues, consult InteraXon's support documentation.
We welcome contributions from the community! Please see our Contributing Guidelines for details on:
- 🐛 Bug Reports: Help us improve the system
- 💡 Feature Requests: Suggest new capabilities
- 🔧 Code Contributions: Submit improvements and fixes
- 📚 Documentation: Help make the project more accessible
- Fork the repository on GitHub
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and test thoroughly
- Submit a pull request with a clear description
- ✅ Core Functionality: Complete and operational
- ✅ Ubuntu 24.04: Fully supported with patches
- ✅ GUI Interface: Modern PyQt5 implementation
- ✅ EEG Analysis: Research-inspired meditation detection algorithms
- 🔄 Cross-platform: Windows/macOS support in progress
- 🔄 Advanced Features: ML-enhanced analysis planned
- Dexter MacIver - Project creator and primary developer
- muselsl - Muse headband communication (with Ubuntu 24.04 patches)
- PyQt5 - Modern GUI framework
- pyqtgraph - High-performance real-time plotting
- NumPy/SciPy - Scientific computing foundation
- pylsl - Lab Streaming Layer for real-time data
This project includes critical bug fixes for the open-source muselsl library, specifically addressing Ubuntu 24.04 compatibility issues that benefit the entire EEG development community.
- 📖 Documentation: Complete guides in this repository
- 🐛 Bug Reports: GitHub Issues
- 💡 Feature Requests: GitHub Issues
- 🤝 Discussions: GitHub Discussions
🎉 You now have a complete EEG brain monitoring system for educational and research use!
Ready for meditation training, research applications, and educational demonstrations.
⚠️ USE AT YOUR OWN RISK: This is experimental software for educational purposes. Not intended for medical use or clinical diagnosis. Users assume full responsibility for any consequences of use.
⭐ If this project helps you, please consider giving it a star on GitHub! ⭐
