Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Interactive Muse 2 EEG visualizer

This script provides a simple dashboard for connecting to a Muse 2 EEG headband, streaming the raw EEG data via Lab Streaming Layer (LSL) and visualising it in real‑time. It also computes the power in the traditional EEG frequency bands (delta, theta, alpha, beta and gamma) and displays these as a bar chart. You can optionally record the data to a CSV file.

Features

  • Start/stop streaming from a Muse device using the muselsl package. The dashboard will scan for available headbands and automatically connect to the first one it finds. Under the hood the script spawns a separate process that runs the muselsl command‑line tool to handle the Bluetooth connection and stream the data over LSL.
  • Live plots of the four EEG channels (TP9, AF7, AF8 and TP10). The plot updates at 1 Hz and shows the most recent 10 seconds of data. The X‑axis is relative time (seconds) and the Y‑axis is microvolts.
  • Computation of absolute band power for five classical frequency bands (delta 1–4 Hz, theta 4–8 Hz, alpha 7.5–13 Hz, beta 13–30 Hz and gamma 30–44 Hz). Band powers are estimated using Welch’s method and integrated over each frequency band. Results are displayed for each channel as a grouped bar chart.
  • Optional recording of the streamed data to a CSV file. While recording you can click “Stop recording & download” to export a CSV file containing timestamps and microvolt values for the four channels.

The user interface is implemented with Dash (Plotly’s web framework) which means it runs in your browser but executes locally on your machine. To use the app you’ll need to install a handful of Python packages. See the installation instructions below.

This script assumes a sampling rate of 256 Hz for the raw EEG signal. The Muse 2 specification lists a 256 Hz sampling rate for its four primary electrodes【965099736774822†L2-L4】. If the sampling rate changes in the future, adjust the FS constant accordingly.

Requirements

Install the following packages in your Python environment before running the script:

pip install muselsl pylsl dash plotly scipy numpy pandas

Depending on your operating system you may also need to install bleak, pygatt or BlueMuse to provide the low‑level Bluetooth connectivity. See the muselsl documentation for full details. For Windows users, installing BlueMuse often provides the most reliable connection.

Usage

Run the script from a terminal:

python muse_visualizer.py

Your default web browser will open to http://127.0.0.1:8050/ where you can control the streaming and view the data. If the browser does not open automatically, navigate there manually.

About

This allows for the vizualization of brainwaves using the Muse 2 headset. This program can run on a local browser but requires Blue Muse application to properly connect to the host PC.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages