Sunday, January 5, 2014

OpenBCI Driver in BrainBay

Recently, I got an email from Chris, the primary developer behind BrainBay.  He had seen my earlier post, where I'd found a way to get OpenBCI to send data to BrainBay for live visualization and processing.  I was able to make it work by forcing OpenBCI to mimic the data format used by OpenEEG.  Since OpenBCI is more capable than OpenEEG (OpenBCI has more channels and higher bit depth), fitting myself into the OpenEEG format was not an optimal solution.  Well, Chris saw an opportunity to remedy the situation, so he wrote an OpenBCI-specific driver for BrainBay.  Now, OpenBCI can send all 8 channels of data in full resolution to BrainBay!  Thanks, Chris!

Recording my ECG into BrainBay Using  the new OpenBCI-Specific Driver.
I'm holding the electrodes between my fingers.

Below is a screen shot of the BrainBay hardware setup screen using the new OpenBCI driver.  It's pretty straight-forward...select the COM port and select the baud rate for the communication and you're done.

Setup Screen in BrainBay for the New OpenBCI Driver
 Right now the driver assumes that you are using a 250 Hz sample rate (which is what OpenBCI's Arduino software defaults to), but if you tell OpenBCI to run faster, BrainBay lets you change that.  Simply go to BrainBay's "Options" menu and select "Application Settings".  There, you can change the sample rate to however you've configured your OpenBCI board.

Once Chris made this OpenBCI driver, we had to test it out to make sure that it worked.  Since Chris didn't have an OpenBCI board, he couldn't test it himself.  So, he'd point me to his GitHub, I'd download his latest version of BrainBay, and I'd test it for him.  An important part of testing is doing things repeatably.  So, I added a mode to the OpenBCI software where it would output simple test waveforms instead of the real EEG data. (It is true that the ADS1299 has a bunch of test signals built-in, but none let you do different waveforms per channel.  That's what I coded up for OpenBCI.)

Below is a screen shot of BrainBay after we got the OpenBCI driver all debugged.  The synthetic test waveforms that were being output by OpenBCI are the simple ramp waves shown below.  Once we finally got it to look like this, I was so happy!

Confirming Correct Operation in BrainBay via Synthetically Generated Data from My OpenBCI Board.

With basic operation confirmed, I wanted to test it with real biosignals.  So, I did what I always do as my first test...ECG.  As seen in the picture at the beginning of this post, I used a couple of really basic electrodes connected to an OpenBCI V1 board.  To get my ECG, I simply held those basic between by finger tips (I licked my finger tips to increase their conductivity).  Generally, this is a really bad way to do an ECG...the muscle artifact from actively holding the electrodes can swamp your signal.  But, with a very light tough, it can be good enough to prove that that the system is working.  And it was working.  A screen shot of my ECG is shown below.  This is a pretty decent looking ECG trace...it's got a nice little P-wave, a sharp R-wave, and a nice rounded T-wave.  Very fine.

Recording my ECG From OpenBCI Using the New Driver in BrainBay.  Looks good!

So, unlike my previous time posting about BrainBay, this latest recording is all at OpenBCI's native capabilities.  There was no dumbing it down to fit within OpenEEG's data format.  With Chris' latest version of BrainBay, you can now use all 8-channels that OpenBCI generates at OpenBCI's full 24-bit resolution.

Latest BrainBay on GitHub: https://github.com/ChrisVeigl/BrainBay

Thanks, Chris!

9 comments:

  1. Hi Chip,

    I got my device working (It's a combination of Arm microcontroller STM32F407 with TI ADS1299 Evaluation module).
    I'm trying to push data from the board to Brainbay. It's great that BrainBay got a new driver for 8 channels 24 bit data. However, I don't have any documentation for this driver rather than Chris code on Github
    https://github.com/ChrisVeigl/BrainBay/blob/c0121b247a60bada948a8351b1c1fdb682b35081/src/ob_eeg.cpp

    Could you please have a post about this? The protocol, a sample data package, some code maybe... The OpenBCI code in GitHub is the 6 channel 16bit one.
    I'm not clear about the package lenght and Framenumber...And why it is 4 bytes per channel...

    Thanks a lot!

    ReplyDelete
    Replies
    1. Hi Taro,

      The latest BrainBay driver reads the regular OpenBCI binary output. OpneBCI no longer needs to be put into a special output mode.

      The standard OpenBCI format is defined both in the rduino code on OpenBCI's Git (see ADS1299Mananger) and it is defined in the Wiki on Git:

      https://github.com/OpenBCI/OpenBCI/wiki/Data-Format-for-OpenBCI-V1-and-V2

      Finally, each channel is 4 bytes because, internal to the Arduino we expand the 24-bit number from the ADS1299 into a standard int32. That enables some filtering or other processing of the data on the Arduino, if desired. Then, when the Arduino goes to send it out the serial port, I kept it as a standard 4-byte int32 instead of truncating to a 24-bit number.

      It is possible that we'll switch back to sending just a 24-bit number when we move to OpenBCI V3. It'll all depend upon the throughput that we get on Bluetooth.

      Hope this helps!

      Delete
    2. Hi Chip,
      I got a new update in for my hardware in my blog. Also, I presented a simple stupid way to utilize the package counting variable in your firmware for tracking package lost.
      http://eegexplore.blogspot.com/2014/11/armbrain-prototype-2-bring-it-on.html

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Hi,

    I created a small device based on ADS1292 for EOG measurements for my lucid dreaming device. This is similar to ADS1299, but with lower performance and only two channels. I replicated the OpenBCI packet format and used the BrainBay OpenBCI device to visualize the signal. Here is the project and an ECG signal of my heart :)
    http://bois083.wordpress.com/lucid-dreaming-device/version-5-0/the-prototype/

    Your blog helped me a lot. Thanks!

    ReplyDelete
  4. Hi everyone,
    i was working with brain bay and open bci offlate.
    Is it possible to interface brain bay and arduino so that i can have a hardware application on arduino running(eg blinking led)using my signals from open bci??
    Can you please help??

    ReplyDelete
  5. Hi Chip,
    I am working with the ProtoCentral ADS1292R ECG/Respiration kit for measuring the ECG using three leads. I have connected the board with Arduino Uno and configured it as per the specifications given in the link below.
    http://www.protocentral.com/blog/getting-started-with-ads1292r-ecgrespiration-shield-n9
    Using the BrainBay configuration file loaded in BrainBay and connecting the board through Arduino to PC, the signal acquired in BrainBay is same, a simple line with no variation in the oscilloscope display. I tried to take ECG signal many times but same display was obtained each time. Also there is some data transmission taking place from Arduino to PC as the TX light of the Arduino starts blinking when I select connect COM port in BrainBay but nothing gets displayed on the Oscilloscope.
    Hope for your reply soon,
    Thank You.

    ReplyDelete
  6. Do you know how many volts represents a hexadecimal value, for example 0x000001, in the brainbay osciloscope?

    ReplyDelete