Giter Site home page Giter Site logo

openbci-observable's Introduction

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

openbci-observable's People

Contributors

alexcastillo avatar jaykan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

openbci-observable's Issues

Great work!

This is an excellent project! I'll see if i can finish the test coverage for my ts obci implementation this weekend and send you a link so we can compare. I really like what you've done with channel filtering...

UnhandledPromiseRejectionWarning: TypeError: No path specified

I'm trying to run the Cyton example code and I'm getting a "No path specified" exception

Here's the code that I'm using:

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();

Inside new Cyton(), the init function calls autoFindOpenBCIBoard(), which tries to find a valid serial port. If successful, it ends with this code:

          if (this.options.verbose) console.log('auto found board');
          resolve(this.portName);

However, this doesn't block the call to await cyton.connect(); which tries to connect to portName which is undefined.

Frequency band operators

Do you think it would be more general to have a bandpass with the lower and upper limit and a label versus have the frequency ranges predefined (e.g. alpha, delta, gamma, etc.)?

Install openbci-observable error

Hi,

I am trying to install openbci-observable by running the command npm --save openbci-observable and getting the following error:

Screen Shot 2020-02-05 at 12 32 01 PM

Could it be the version problem? I would appreciate any advice.

Can this be used for react native app?

Unfortunately, I can't seem to make it work in react native as some modules are native, and react native doesn't support those modules?

Is there any other solution?

OpenBCIRx async start()

@alexcastillo,

When running npm start, I was getting syntax errors that relates async start() locally. However, when I created a brand new node project and install openbci-rx as its dependencies and run, everything is working as expected. Please find attached screenshot for the detailed error:

screen shot 2017-04-03 at 4 25 24 pm

It would be great if you can run via the example demos locally, maybe there are additional steps that I'm not aware in order to run examples locally, please let me know!

Add bufferWindow operator

We need a way to buffer up to X count and window by Y count every Y.
For example:

Let's say we have 512 bins (an array with 512 items) and a window count of 10. We want to buffer until 512 items then on the next 10, add it to the end of the buffer and slice the first 10 items in the buffer (to window). In this example, the first .next is called on item 512, the second .nextis called on item 522 with a total buffer count of 512 since the first 10 were removed. That being said, all .nextwill be called every 10 items except the first one.

I tired OTB RxJS operators bufferCount and windowCount and got close but none of them as far as I'm concerned, are calling .next every skip number.

Does that make sense?

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.