1.2.17 • Published 3 years ago

biolink-testing v1.2.17

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Biolink

Muse and Insai headband JavaScript Library (using Web Bluetooth)

  • Usage with Jupyter (tslab)

Getting Started

  • npm install
  • npm install typescript (If not already installed)

Usage example

import { MuseClient } from 'biolink'

async function main() {
  let client = new MuseClient({})
  await client.connect()
  await client.start()
  client.eegReadings.subscribe((eeg) => {
    console.log(eeg)
  })
  // Works for Muse2 and MuseS
  client.ppgReadings.subscribe((ppg) => {
    console.log(ppg)
  })
  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.

import {bluetooth} from "webbluetooth"
import {MUSE_SERVICE} from "./lib/constants"
import {MuseClient} from "./index"

async function connect() {
    console.log('Request')
    let device = bluetooth.requestDevice({
        filters: [{services: [MUSE_SERVICE]}]
    })

    const gatt = await (await device).gatt.connect()
    const client = new MuseClient({})
    console.log(gatt)
    await client.connect(gatt)
    await client.start()
    client.eegReadings!.subscribe(e => console.log(e))

}

connect()

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')
}

Common problems

If you are a Windows user, you may run into issues with bluetooth. Follow the instructions located here. After completing these steps, you may encounter runtime issues. If you encounter the following errors:

  • No compatible USB Bluetooth 4.0 device found on supported device
    • You need to add the USB ID values to the ../node_modules/@abandonware/bluetooth-hci-socket/lib/usb.js file under the VENDOR_DEVICE_LIST section. The USB ID values can be found when updating the driver through the Zadig program.
  • LIBUSB_ERROR_ACCESS
    • You need to run your script/notebook as an administrator.
1.2.16

3 years ago

1.2.17

3 years ago

1.2.12

3 years ago

1.2.14

3 years ago

1.2.15

3 years ago

1.2.11

3 years ago

1.2.9

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.10

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago