The most advanced, feature-packed EEG streaming script that will blow your mind!
A comprehensive Python script for real-time EEG data streaming, processing, and visualization using the OpenBCI Cyton board and BrainFlow SDK. Now with AI-powered brain state classification, MIND READING NEURAL NETWORK, brain-controlled music generation, smart home integration, and stunning real-time visualizations!
- Real-time AI detection of 7 different brain states:
- ๐ฏ Focused - When you're in the zone
- ๐ Relaxed - Chill and peaceful vibes
- ๐ฐ Stressed - High tension detected
- ๐ง Meditative - Deep zen state
- ๐คฉ Excited - High energy and enthusiasm
- ๐ด Drowsy - Getting sleepy
- ๐ Neutral - Baseline state
- Machine learning with confidence scores and probability distributions
- Emoji-based visual feedback that changes in real-time
Train an AI to literally read your thoughts! Perfect for viral YouTube content!
- ๐ง Motor Imagery Detection: Left hand vs right hand movement thoughts
- ๐งฎ Mental Math Recognition: Detect when you're doing calculations
- ๐ต Music Imagination: AI knows when you're thinking of songs
- ๐ Face Visualization: Detects when you're imagining faces
- ๐ Word Thinking: Recognizes specific word thoughts
- ๐ Rest State: Knows when your mind is clear
# Use the GUI for easy training (recommended)
python main/mind_reader_gui.py
# Or train via command line (advanced)
python main/brain_calibrator.py --port COM3# Perfect for YouTube videos!
python main/demo_mind_reader.py --port COM3 --duration 120- ๐ฌ Guided Training: Step-by-step instructions for each thought class
- ๐ Real-time Progress: Live training progress with emoji feedback
- ๐ง Neural Network: 3-layer MLP with 128-64-32 neurons
- ๐ฏ High Accuracy: Typically 70-90% accuracy on personal data
- ๐พ Model Persistence: Save and load your trained models
- ๐ฎ Demo Mode: Synthetic predictions for content creation
- "I TRAINED AN AI TO READ MY MIND!"
- "NEURAL NETWORK GUESSES MY THOUGHTS!"
- "AI DETECTED MY HAND MOVEMENTS JUST BY THINKING!"
- "MIND READING TECHNOLOGY IS HERE!"
- Your brain waves become music!
- Different brain states trigger unique musical scales and harmonies
- Real-time audio synthesis based on EEG band powers
- Alpha waves control volume, Beta waves control complexity
- Non-blocking audio so the music flows seamlessly
- Stunning dark-themed interface with animated elements
- Real-time spectrogram showing frequency content
- Dynamic color-coded plots that change with brain states
- Probability bar charts for all brain states
- Pulsing effects for high-confidence states
- Professional-grade PyQtGraph visualizations
- Philips Hue lights that change color based on your brain state
- Brightness controlled by confidence levels
- Focused = Orange, Relaxed = Teal, Stressed = Red, etc.
- Ambient lighting that responds to your mind!
- 1-40 Hz Butterworth bandpass and 60 Hz notch filtering
- Welch power spectral density computation
- Five frequency bands: Delta, Theta, Alpha, Beta, Gamma
- 10-second ring buffer for continuous processing
- 20 Hz real-time processing loop
- Comprehensive CSV export with:
- Raw EEG samples from all 8 channels
- Band power features for each channel
- Brain state classifications with confidence scores
- Individual probabilities for all states
- High-precision timestamps
- Real-time statistics tracking
- Session duration and sample counts
- Brain state change detection
- Music note generation counter
- Detailed performance logs
BrainPower/
โโโ main/ # Core applications
โ โโโ openbci_stream.py # Main EEG streaming app
โ โโโ mind_reader_gui.py # Neural network training GUI
โ โโโ demo_mind_reader.py # Mind reading demo
โ โโโ brain_calibrator.py # Brain state calibration
โโโ tools/ # Utilities and tools
โ โโโ check_ports.py # Serial port detection
โโโ docs/ # Documentation
โ โโโ README.md # This file
โ โโโ LICENSE # MIT License
โ โโโ requirements.txt # Python dependencies
โโโ *.py # Additional utility scripts
- Clone this repository
git clone https://github.com/Atomics-hub/BrainPower.git
cd BrainPower- Install all dependencies
pip install -r docs/requirements.txt- Check your serial ports (helpful for setup)
python tools/check_ports.py- Optional: Set up Philips Hue (for smart lighting)
- Find your Hue bridge IP address
- Press the bridge button before first connection
python main/openbci_stream.py --port COM3python main/openbci_stream.py --port /dev/ttyUSB0 --enable-smart-home --hue-bridge-ip 192.168.1.100 --duration 300python main/openbci_stream.py --port COM3 --disable-musicpython main/openbci_stream.py --port COM3 --duration 60 --csv-path youtube_demo.csv| Argument | Description | Default |
|---|---|---|
--port |
Serial port (required) | - |
--board-id |
BrainFlow board ID | 0 (Cyton) |
--duration |
Recording duration (seconds) | โ (infinite) |
--csv-path |
Enhanced CSV output path | ./eeg_log.csv |
--disable-music |
Turn off brain music | Music enabled |
--enable-smart-home |
Enable Hue integration | Disabled |
--hue-bridge-ip |
Philips Hue bridge IP | Auto-detect |
- ๐ก Data Acquisition: 250 Hz from 8 EEG channels
- ๐ Ring Buffer: 10-second continuous data storage
- โก Real-time Processing (20 Hz):
- 1-second sliding window analysis
- Butterworth filtering (1-40 Hz + 60 Hz notch)
- Welch PSD computation
- ๐ง AI brain state classification
- ๐ต Music generation trigger
- ๐ก Smart home control
- ๐ Enhanced visualization updates
- ๐ง Brain State Display: Large emoji + confidence bar
- ๐ Raw EEG Signal: Color-coded by brain state
- ๐ Real-time Spectrogram: Frequency waterfall
- ๐ Band Power Trends: 5 animated frequency bands
- ๐ฒ State Probabilities: Live bar chart
- Dynamic colors that change with brain states
- Pulsing animations for high confidence
- Smooth transitions between states
- Professional dark theme for better contrast
- ๐ฏ Focused: C Major (energetic, clear)
- ๐ Relaxed: C Minor Pentatonic (smooth, flowing)
- ๐ง Meditative: Perfect Fifths (harmonic, peaceful)
- ๐ฐ Stressed: Chromatic/Dissonant (tense, complex)
- ๐คฉ Excited: Major Triads (bright, uplifting)
- ๐ด Drowsy: Low, slow notes (deep, calming)
- ๐ Neutral: Suspended chords (balanced)
- Volume: Controlled by Alpha wave power
- Complexity: Controlled by Beta wave power
- Harmonics: Rich overtones for musical quality
- Envelope: Smooth attack/decay to prevent clicks
- Find your bridge IP: Use Philips Hue app
- Press the bridge button
- Run with
--enable-smart-home --hue-bridge-ip YOUR_IP
- ๐ฏ Focused: Orange (energizing)
- ๐ Relaxed: Teal (calming)
- ๐ฐ Stressed: Red (alert)
- ๐ง Meditative: Purple (spiritual)
- ๐คฉ Excited: Yellow (joyful)
- ๐ด Drowsy: Blue (sleepy)
- ๐ Neutral: Gray (balanced)
The CSV file now includes 40+ columns:
timestamp,ch_1,ch_2,...,ch_8,
ch_1_delta,ch_1_theta,ch_1_alpha,ch_1_beta,ch_1_gamma,
...(all channels)...,
brain_state,confidence,
focused_prob,relaxed_prob,stressed_prob,meditative_prob,
excited_prob,drowsy_prob,neutral_prob
- Meditation Challenge: Watch brain state change to ๐ง
- Focus Test: Try math problems and see ๐ฏ activation
- Music Reaction: Different songs trigger different states
- Smart Home Control: Lights change with your mood
- Stress Response: Show ๐ฐ state during difficult tasks
- Relaxation Journey: Guide viewers through ๐ state
- Real-time emoji changes are instantly engaging
- Music generation creates unique soundtracks
- Color-changing lights add visual drama
- Live brain state detection feels like magic
- Professional visualizations look incredibly cool
- Ensure OpenBCI board is in PC mode (not standalone)
- Check serial port permissions:
sudo chmod 666 /dev/ttyUSB0 - Verify port name in Device Manager (Windows) or
ls /dev/tty*(Linux/Mac)
- Close other serial port applications
- Ensure 4GB+ RAM for smooth operation
- Use powered USB hubs for stable connections
- Disable antivirus real-time scanning for audio folder
- Install ASIO drivers for low-latency audio (Windows)
- Check default audio device settings
- Adjust buffer sizes if audio stutters
- Ensure Hue bridge and computer are on same network
- Press bridge button before first connection
- Check firewall settings for bridge communication
- Real-time AI classification at 20 Hz processing rate
- Multi-threaded audio generation without blocking
- Professional-grade signal processing with BrainFlow
- Scalable architecture for easy feature additions
- Robust error handling prevents crashes
- Cross-platform compatibility (Windows, Linux, Mac)
- 3D brain visualization with activity mapping
- Web dashboard for remote monitoring
- Social media integration for sharing brain states
- VR/AR visualization support
- Mobile app companion
- Cloud data sync and analysis
- Multi-user sessions and competitions
This project is open source. Please ensure compliance with BrainFlow and OpenBCI licensing terms.
Senior Python Engineer - BrainPower Project
๐ Ready to go viral? Your brain has never been this entertaining!
Star this repo if it blew your mind! ๐คฏ