Making OpenBCI for Node Reactive
Switch branches/tags
Nothing to show
Clone or download
Latest commit e093512 Dec 2, 2017
Permalink
Failed to load latest commit information.
examples disable package lock Nov 28, 2017
src get sample event name from constants Nov 28, 2017
.gitignore disable package lock Nov 28, 2017
.npmrc disable package lock Nov 28, 2017
LICENSE added ganglion example Nov 23, 2017
README.md readme update Dec 2, 2017
package-lock.json 1.0.5 Nov 28, 2017
package.json 1.0.5 Nov 28, 2017

README.md

OpenBCI Observable

Reactive OpenBCI for Node

Getting started

This library works with the following OpenBCI hardware:

Get started by importing the library:

npm install --save openbci-observable
const { Cyton, Ganglion, Wifi } = require('openbci-observable');

// Or with an alias...

const BrainObservable  = require('openbci-observable').Ganglion;

Examples

Basic usage

Cyton
const { Cyton } = require('openbci-observable');

async function init () {
    const cyton = new Cyton();
    await cyton.connect();
    await cyton.start();

    cyton.stream.subscribe(sample =>
        console.log('sample', sample)
    );
}

init();
Ganglion
const { Ganglion } = require('openbci-observable');

async function init () {
    const ganglion = new Ganglion();
    await ganglion.connect();
    await ganglion.start();

    ganglion.stream.subscribe(sample =>
        console.log('sample', sample)
    );
}

init();
Wifi
const { Wifi } = require('openbci-observable');

async function init () {
    const wifi = new Wifi();
    await wifi.connect({ ipAddress: 'xx.xx.xx.xx' });
    await wifi.start();

    wifi.stream.subscribe(sample =>
        console.log('sample', sample)
    );
}

init();

Adding operators

** All operators from this library have been migrated to the eeg-pipes project. Now these can be used as "lettable" RxJS operators. **

// npm install openbci-observable eeg-pipes
const { Ganglion } = require('openbci-observable');
const { voltsToMicrovolts, bufferFFT, alphaRange } = require('eeg-pipes');

async function init () {
    const ganglion = new Ganglion();
    await ganglion.connect();
    await ganglion.start();

    ganglion.stream.pipe(
        voltsToMicrovolts(),
        bufferFFT({ bins: 256 })
        alphaRange()
    ).subscribe(buffer =>
        console.log('alpha buffer', buffer)
    );
}

init();

And now we have an FFT buffer of Alpha waves!

Dependencies Prerequisites

Make sure you have Node version >= 7.8 installed for development purpose.

License

MIT © Alex Castillo