Coder Social home page Coder Social logo

thealch3m1st / muse-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from urish/muse-js

0.0 0.0 0.0 419 KB

Muse 2016 EEG Headset JavaScript Library (using Web Bluetooth)

Home Page: https://medium.com/@urish/reactive-brain-waves-af07864bb7d4

License: MIT License

TypeScript 98.67% JavaScript 1.33%

muse-js's Introduction

muse-js

Build Status

Muse 2016 EEG Headset JavaScript Library (using Web Bluetooth)

Running the demo app

yarn
yarn start

and then open http://localhost:4445/

Usage example

import { MuseClient } from 'muse-js';

async function main() {
  let client = new MuseClient();
  await client.connect();
  await client.start();
  client.eegReadings.subscribe(reading => {
    console.log(reading);
  });
  client.telemetryData.subscribe(telemetry => {
    console.log(telemetry);
  });
  client.accelerometerData.subscribe(acceleration => {
    console.log(acceleration);
  });
}

main();

Using in node.js

You can use this library to connect to the Muse EEG headset from your node.js application. Use the bleat package which emulates the Web Bluetooth API on top of noble:

const noble = require('noble');
const bluetooth = require('bleat').webbluetooth;

async function connect() {
    let device = await bluetooth.requestDevice({
        filters: [{ services: [MUSE_SERVICE] }]
    });
    const gatt = await device.gatt.connect();
    const client = new MuseClient();
    await client.connect(gatt);
    await client.start();
    // Now do whatever with muse client...
}

noble.on('stateChange', (state) => {
    if (state === 'poweredOn') {
        connect();
    }
});

You can find a fully working example in the muse-lsl repo.

Auxiliary Electrode

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 the enableAux property to true, just before calling the connect method:

async function main() {
  let client = new MuseClient();
  client.enableAux = true;
  await client.connect();
}

Event Markers

For convenience, there is an eventMarkers stream included in MuseClient that you can use in order to introduce timestamped event markers into your project. Just subscribe to eventMarkers and use the injectMarker method with the value and optional timestamp of an event to send it through the stream.

async function main() {
    let client = new MuseClient();
    client.eventMarkers.subscribe((event) => {
        console.log(event);
    });
    client.injectMarker("house")
    client.injectMarker("face")
    client.injectMarker("dog")
}

Projects using muse-js

  • 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.

muse-js's People

Contributors

dependabot[bot] avatar jdpigeon avatar sophiedeziel avatar thealch3m1st avatar urish avatar wtcross avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.