- Notifications
You must be signed in to change notification settings - Fork79
Muse 2016 EEG Headset JavaScript Library (using Web Bluetooth)
License
urish/muse-js
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Muse 1, Muse 2, and Muse S EEG Headset JavaScript Library (using Web Bluetooth).
yarnyarn start
and then openhttp://localhost:4445/
import{MuseClient}from'muse-js';asyncfunctionmain(){letclient=newMuseClient();awaitclient.connect();awaitclient.start();client.eegReadings.subscribe(reading=>{console.log(reading);});client.telemetryData.subscribe(telemetry=>{console.log(telemetry);});client.accelerometerData.subscribe(acceleration=>{console.log(acceleration);});}main();
You can use this library to connect to the Muse EEG headset from your node.js application.Use thebleat package which emulates the Web Bluetooth API on top ofnoble:
constnoble=require('noble');constbluetooth=require('bleat').webbluetooth;asyncfunctionconnect(){letdevice=awaitbluetooth.requestDevice({filters:[{services:[MUSE_SERVICE]}]});constgatt=awaitdevice.gatt.connect();constclient=newMuseClient();awaitclient.connect(gatt);awaitclient.start();// Now do whatever with muse client...}noble.on('stateChange',(state)=>{if(state==='poweredOn'){connect();}});
You can find a fully working example in themuse-lsl repo.
The Muse 2016 EEG headsets contains four electrodes, and you can connect an additional Auxiliary electrode through the Micro USB port. By default, muse-js does not read data from the Auxiliary electrode channel. You can change this behavior and enable the Auxiliary electrode by setting theenableAux
property totrue
, just before calling theconnect
method:
asyncfunctionmain(){letclient=newMuseClient();client.enableAux=true;awaitclient.connect();}
The Muse 2 and Muse S contain PPG/optical blood sensors, which this library supports. There are three signal streams, ppg1, ppg2, and ppg3. These are ambient, infrared, and red (respectively) on the Muse 2, and (we think, unconfirmed) infrared, green, and unknown (respectively) on the Muse S. To use PPG, ensure you enable it before connecting to a Muse. PPG is not present and thus will not work on Muse 1/1.5, and enabling it may have unexpected consequences.
To enable PPG:
asyncfunctionmain(){letclient=newMuseClient();client.enablePpg=true;awaitclient.connect();}
To subscribe and receive values from PPG, it's just like subscribing to EEG (seeUsage Example):
client.ppgReadings.subscribe((ppgreading)=>{console.log(ppgreading);});
For convenience, there is aneventMarkers
stream included inMuseClient
that you can use in order to introduce timestamped event markers into your project. Just subscribe toeventMarkers
and use theinjectMarker
method with the value and optional timestamp of an event to send it through the stream.
asyncfunctionmain(){letclient=newMuseClient();client.eventMarkers.subscribe((event)=>{console.log(event);});client.injectMarker("house")client.injectMarker("face")client.injectMarker("dog")}
- EEGEdu - Interactive Brain Playground.Source code using React, Polaris and chartjs.
- EEG Explorer - Visual EEG readings from the Muse EEG Headset.Source code using Angular, Material Design and smoothie charts.
About
Muse 2016 EEG Headset JavaScript Library (using Web Bluetooth)