Giter Club home page Giter Club logo

openbci_nodejs's Introduction

OpenBCI NodeJS SDK

banner

Provide a single source to program all OpenBCI biosensors in NodeJS

Stories in Ready Join the chat at https://gitter.im/OpenBCI/OpenBCI_NodeJS Build Status npm

Welcome!

First and foremost, Welcome! πŸŽ‰ Willkommen! 🎊 Bienvenue! 🎈🎈🎈

Thank you for visiting the OpenBCI NodeJS SDK repository. This repository does not contain any specific source code and bugs for a specific biosensor should be open in their respective repositories: Cyton | Ganglion | WiFi Shield | Utilities. Checkout this blog post to understand the rational behind this modular structure of our java script code base.

This document (the README file) is a hub to give you some information about the project. Jump straight to one of the sections below, or just scroll down to find out more.

What are we doing?

The problem

  • There are a bunch of NodeJS repos for the Ganglion, Cyton and Wifi Shield
  • Examples are spread out across all these NodeJS repos
  • Some examples across NodeJS repos have the same code
  • There is no common interface for these NodeJS repos
  • NodeJS is a powerful tool for

So, if even the very best developers want to use NodeJS with their OpenBCI boards, they are left scratching their heads with where to begin. integrate the current easy to use Cyton and Ganglion NodeJS drivers, they are still burdened by the limitations of the physical hardware on the OpenBCI system.

The solution

The OpenBCI NodeJS SDK will:

  • Allow NodeJS users to import one module and use any board they choose
  • Provide examples of using NodeJS to port data to other apps like python and lab streaming layer
  • Provide a no low level device specific code to prevent the need to rewrite new examples for each board
  • Provide examples of filtering and different functions to transform raw data
  • Provide a common interface to all openbci boards to increase the speed at which new boards can be integrated

Using this repo provides a building block for developing with NodeJS. The goal for the NodeJS library is to provide a single source to program all OpenBCI biosensors in NodeJS

Who are we?

If we look back in time, we see this library took shape when the Cyton board was the only OpenBCI board around. Then the Ganglion came around which required it's own nodejs libary! When the wifi shield was in development, we created the wifi nodejs driver which was had a lot of overlap with Cyton and Ganglion nodejs drivers. Therefore we pulled out the common code between all three NodeJS modules and created the [nodejs utilities][link_nodejs_utilities] which as of today is also available to use in the browser.

The contributors to these repos are people using NodeJS mainly for their data acquisition purposes. For example, the entire OpenBCI GUI is dependent on the NodeJS ecosystem to provide cross platform support.

What do we need?

You! In whatever way you can help.

We need expertise in programming, user experience, software sustainability, documentation and technical writing and project management.

We'd love your feedback along the way.

Our primary goal is to provide a single source to program all OpenBCI biosensors in NodeJS, and we're excited to support the professional development of any and all of our contributors. If you're looking to learn to code, try out working collaboratively, or translate you skills to the digital domain, we're here to help.

Get involved

If you think you can help in any of the areas listed above (and we bet you can) or in any of the many areas that we haven't yet thought of (and here we're sure you can) then please check out our contributors' guidelines and our roadmap.

Please note that it's very important to us that we maintain a positive and supportive environment for everyone who wants to participate. When you join us we ask that you follow our code of conduct in all interactions both on and offline.

Contact us

If you want to report a problem or suggest an enhancement we'd love for you to open an issue at this github repository because then we can get right on it.

You can also hang out, ask questions and share stories in the OpenBCI NodeJS room on Gitter.

Find out more

You might be interested in:

And of course, you'll want to know our:

Glossary

OpenBCI boards are commonly referred to as biosensors. A biosensor converts biological data into digital data.

The Ganglion has 4 channels, meaning the Ganglion can take four simultaneous voltage readings.

The Cyton has 8 channels and Cyton with Daisy has 16 channels.

Generally speaking, the Cyton records at a high quality with less noise. Noise is anything that is not signal.

Thank you

Thank you so much (Danke schΓΆn! Merci beaucoup!) for visiting the project and we do hope that you'll join us on this amazing journey to make programming with OpenBCI fun and easy.

Installation:

npm install openbci

Developing:

Running:

npm install --all

License:

MIT

openbci_nodejs's People

Contributors

andrewheusser avatar asyrique avatar baffo32 avatar conorrussomanno avatar gabrielibagon avatar gerrievanzyl avatar gitter-badger avatar haniawni avatar khwilson avatar nategeorge avatar octopicorn avatar teonbrooks avatar waffle-iron 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openbci_nodejs's Issues

Samples out of order

When streaming from the board, I noticed that some of the samples are coming in out of order. here is a plot of a couple seconds of data. You can see that there is a systematic pattern to which samples are being presented out of order, and the out of order sample number looks to be increasing linearly.

image

and here's some example data. If you look after 62, 24 is presented a second time. could be a duplicate, or a sample from another block of data

array([[ 0],
       [19],
       [20],
       [21],
       [22],
       [23],
       [ 1],
       [ 2],
       [ 3],
       [ 4],
       [ 5],
       [ 6],
       [ 7],
       [ 8],
       [ 9],
       [10],
       [11],
       [12],
       [13],
       [14],
       [15],
       [16],
       [17],
       [18],
       [19],
       [20],
       [21],
       [22],
       [23],
       [24],
       [25],
       [26],
       [27],
       [28],
       [29],
       [30],
       [31],
       [32],
       [33],
       [34],
       [35],
       [36],
       [37],
       [38],
       [39],
       [40],
       [41],
       [42],
       [43],
       [44],
       [45],
       [46],
       [47],
       [48],
       [49],
       [50],
       [51],
       [52],
       [53],
       [54],
       [55],
       [56],
       [57],
       [58],
       [59],
       [60],
       [61],
       [62],
       [24],
       [63],
       [64],
       [65],
       [66],
       [67],
       [68],
       [69],
       [70],
       [71],
       [72],
       [73],
       [74],
       [75],
       [76],
       [77],
       [78],
       [79],
       [80],
       [81],
       [82],
       [83],
       [84],
       [85],
       [86],
       [87],
       [88],
       [89],
       [90],
       [91],
       [92],
       [93]])

ENH pass scale data as a parameter

module.exports = {
    convertPacketToSample: function (dataBuf) {
        var self = this;
        if(dataBuf === undefined || dataBuf === null) {
            return;
        }
        var numberOfBytes = dataBuf.byteLength;
        var scaleData = true; // <-------pass as parameter

ENH: Add Mac/Windows large serialport as option to simulator

The Mac and Windows FTDI virtual comm port drivers have big buffers of 4096 which create a fragmented data pulse, there must also be a time component, like every 500 ms it get's cleared, this should be looked into and mimicked in the simulator to provide a better testing environment for graphics developers.

Simulate auxData

It would be great to get simulated auxData. Currently just getting [0, 0, 0].

Time sync feature not working with firmware version 2

I've tried to use time sync feature by running timeSync.js in examples/timeSync.

I already updated my OpenBCI HW to firmware version 2. However, syncClocksFull() function is not working.

bash-3.2$  ls
node_modules package.json timeSync.js
bash-3.2$ node timeSync.js
connected
(node:89295) Warning: Possible EventEmitter memory leak detected. 11 synced listeners added. Use emitter.setMaxListeners() to increase limit
^C

Have any idea?
Additionally, Is there any method that I can debug my OpenBCI firmware?

ADD data simulator

For dev purposes, it would be great to have a simulated data stream (sinusoids of diff freqs for each chan or rand wave?) that one could use to work on OpenEXP app without connecting the board

ENH init

Make a robust initialization check.
'$$$' must be received before the board is operational.

simulator sample rate optionally parameter doesn't work

I think the issue is here. when you make the new openbciSimulator object, the simulatorSampleRate never makes it into the object, so its just set to the default 250

OpenBCIBoard.prototype.connect = function(portName) {
        this.connected = false;

        return new Promise((resolve,reject) => {
            // If we are simulating, set boardSerial to fake name
            var boardSerial;
            /* istanbul ignore else */
            if (this.options.simulate || portName === k.OBCISimulatorPortName) {
                this.options.simulate = true;
                if (this.options.verbose) console.log('using faux board ' + portName);
                boardSerial = new openBCISimulator.OpenBCISimulator(portName, {
                    verbose: this.options.verbose
                });
            } else {
                /* istanbul ignore if */
                if (this.options.verbose) console.log('using real board ' + portName);
                boardSerial = new serialPort.SerialPort(portName, {
                    baudRate: this.options.baudRate
                },(err) => {
                    if (err) reject(err);
                });
            }

Connect to disconnect to connect error

Critical error that can occur when one connects, streams, disconnects and then tries to reconnect, it's as if the board does not read the soft reset command

NTP

Let's get this ish settled. Excited about it. Essentially, each data packet will have a time stamp with it. for instance with OpenEXP, when the computer presents, we will have its ntp timestamp for the screen. when we retrieve the data packets, we could modify the packet to have the trigger/tag, then it will be marked in the data. or we can just print a trigger file and do the data correspondence later off-line

issue with board initialization

var ourBoard = require('openbci-sdk').OpenBCIBoard({
...     verbose: true
... });

returns

TypeError: this.numberOfChannels is not a function
    at OpenBCIFactory.OpenBCIBoard (/Users/daniel.gulyas/dev/openbci-narcolepsy/node_modules/openbci-sdk/openBCIBoard.js:97:69)
    at repl:1:39
    at REPLServer.defaultEval (repl.js:262:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:431:12)
    at emitOne (events.js:82:20)
    at REPLServer.emit (events.js:169:7)
    at REPLServer.Interface._onLine (readline.js:211:10)
    at REPLServer.Interface._line (readline.js:550:8)

but

        var OpenBCIBoard = require('openbci-sdk');
        var ourBoard = new OpenBCIBoard.OpenBCIBoard();

works fine! any ideas why?

`rawDataPacket` not being emitted

There is a bug where rawDataPacket is not being emitted.

Two things needs to happen:

  1. This bug needs to be patched
  2. An automated test needs to be put in place for this!

ADD ability to determine if channel is railed

Would be nice if we could query a channel number and see if it is railed like

for ( i = 0; i < board.numberOfChannels(); i++) {
    var railed = board.isRailedChannel(i + 1);
    if (railed) console.log("Channel " + (i+1) " railed");
}

startStream does not return promise

The documentation says this should return a promise but is just writes a value to the board. Should we make this a promise or change the comments? If it's possible that the command won't work occasionally, we should probably return a promise.

    /**
     * Purpose: Sends a start streaming command to the board.
     * @returns {Promise} indicating if the signal was able to be sent.
     * Note: You must have successfully connected to an OpenBCI board using the connect
     *           method. Just because the signal was able to be sent to the board, does not
     *           mean the board will start streaming.
     * Author: AJ Keller (@pushtheworldllc)
     */
    OpenBCIBoard.prototype.streamStart = function() {
        this.streaming = true;
        this._reset();
        return this.write(k.OBCIStreamStart);
    };

    /**
     * Purpose: Sends a stop streaming command to the board.
     * @returns {Promise} indicating if the signal was able to be sent.
     * Note: You must have successfully connected to an OpenBCI board using the connect
     *           method. Just because the signal was able to be sent to the board, does not
     *           mean the board stopped streaming.
     * Author: AJ Keller (@pushtheworldllc)
     */
    OpenBCIBoard.prototype.streamStop = function() {
        this.streaming = false;
        return this.write(k.OBCIStreamStop);
    };

Modules not importing correctly...

Several developers have complained that the module is not requiring properly.
The following do not import in the entry file:
var k = require('./OpenBCIConstants');
var OpenBCISample = require('./OpenBCISample');
var serialPort = require('serialport');

Don't emit accelerometer array when 0

The OpenBCI firmware sends packets at 250Hz, however the accelerometer is only at 25Hz. This leads to accelerometer data only being sent every 10 packets.

Proposal is to align standard with time synced packets in that an auxData Buffer 6 bytes long is emitted with every sample and if the data is greater than zero we will omit an accelData array with converted and scaled accelerometer values.

automatic testing of ADS1299

Use the test signals on the ADS1299 to verify the proper operation of the OpenBCI Module and the ADS1299. Should be able to route utilize a test signal and monitor the voltages streamed back to the board in order to automatically test the channels.

Fix Data Stream error

currently getting a "stream time out" message instead of data from the board after sent the start command

Goertzel

@pushtheworldllc, I need to walk through this in person. I get the equation but I want to make sure we have a solid test for it

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.