Monday, August 18, 2014

First Data with OpenBCI V3

It's here!  It's here!  The (near) future has arrived!  I have received an early OpenBCI V3 board from my friends over at OpenBCI.  Check out the photo below.  It's a little smaller than I expected.  Very cool!  Let's get it running and see what it can do!

The OpenBCI V3 board is a smaller than I expected.  Looks great!

Note that the V3 board includes a built-in microprocessor.  This means that you no longer have to buy a separate Arduino to act as host.  That's pretty sweet.  OpenBCI gives you two choices of microprocessor: at ATmega 328 (the 8-bit option) or a PIC32 (the 32-bit option).  While the power of the 32-bit PIC is appealing, I chose the ATmega because that allows me to program the OpenBCI board as if it were an Arduino Uno.  I hear that the 32-bit PIC version can also be programmed from the Arduino IDE, but the Uno is my friend, and I chose to stick with him.  

Another change with the V3 version is that it has a built-in Bluetooth module.  In fact, to maximize electrical safety for the user, the wireless Bluetooth link is now the only way to get data off the device in real-time (though it does have a built-in SD card for those looking to simply log data).  This is quite a change...and a change for the better, in my opinion.

OpenBCI says that the Bluetooth module is compatible with standard protocols (to enable connection to your mobile device) and that it has a special high-speed mode, if you have a mating BT module for your PC.  To enable these high-speed modes, OpenBCI includes a BT USB dongle, which is shown at the bottom of the picture below.

Using the new OpenBCI V3 board to record my ECG.  I used one disposable ECG electrode
on each wrist.  The OpenBCI board was powered by a 9V battery, which is in the black
battery case.  The OpenBCI board transferred the data to the PC via Bluetooth.
OpenBCI includes a BT dongle for the PC, which is shown in the bottom-left.

Once I got my hardware, I started in.  Unfortunately, as part of the deal with me getting this hardware so early, the software to run the hardware is not yet complete.  So, I had a little work to do.

When diving into new hardware, it's best to take baby steps.  Start from something that works and then add features incrementally, with lots of tests along the way.  This makes it much easier to identify and squash the bugs as they pop up.  For my first work with OpenBCI V3, here's my approach

  1. Test the wireless link using pre-defined dummy data
  2. Test getting data from the ADS1299 using its built-in test signals
  3. Test getting real data from the ADS1299 by recording my ECG
  4. Test the full system by recording my EEG

Dummy Data:  To get this process started, Joel (of OpenBCI) provided some example code that exercised the wireless link using dummy data.  He even pre-loaded this software on to the V3 board for me.  So, all I had to do was plug in the USB BT dongle, connect a battery to the OpenBCI board, and I was good to go.  I started my Terminal program on my PC and was immediately interacting with the OpenBCI V3 board.  It correctly transferred the pre-defined dummy data.  Success!

Built-In Test Signals:  Building from this working code base, and building from OpenBCI's initial code for configuring the ADS1299 EEG chip, I added the ability to grab data from the ADS1299 and send it out the wireless link.  I started with the ADS1299's built-in test signals.  After some fiddling with 24-bit vs 32-bit number formats (and then discovering that Joel already programmed the solution for me), I got the nice square wave signal as shown below.  This proves that I can communicate with the ADS1299 chip and that I've got all the number formats correct.  Success again!

Data from my OpenBCI V3 board...this is a built-in test signal being generated
by the ADS1299 EEG chip.  Since it looks beautiful, it means that I have confirmed
that I can configure the chip and that all my number formats are correct.

ECG Data:  As you may know from my previous "getting started" post, I like to start my collection of real data by recording my ECG (ie, heart signals).  I do this because ECG signals are so much stronger and simpler than EEG signals.  Having strong signals makes it more obvious when the system is working correctly (and when it is not working correctly).  So, I got out my disposable ECG electrodes, put one on each wrist, and started recording.  As you can see in the plot below, I got a nice sample of my ECG.  My code for OpenBCI V3 might be rough, and my code is definitely not feature-complete, but it does work.

My wrist-to-wrist ECG looks pretty good.

The sample of data shows that my heart rate was about 80 beats per minute, which is a little high for simply sitting in a chair at my computer.  Maybe I was just excited to be having success playing with the new hardware!  I'm like that.

So, returning to my four step process described earlier, I've got 3 of the steps completed.  Before I do the last step -- collected actual EEG data -- I'd like to revise the code a little more.  Right now, I cannot view the streaming data in real time because the data format is a little different then before.  To move forward, I need to adjust the code in my Processing GUI so that it can interpret the data packets and plot the data in real time.  Once I get that to happen, I'll hook up some electrodes to my head and maybe make my robot dance some more!  Wish me luck!

Follow-Up: Raw data and analysis code is here.
Follow-Up:  First EEG Data from the V3 Board is here.

17 comments:

  1. Chip, fantastic. Great to see this all working with the photos. And obviously hats off to Joel and the elves working furiously behind the scenes. Curious what kind of data rates are possible with the dongle. (And perhaps with a built-in bluetooth you might have in your laptop.)

    ReplyDelete
    Replies
    1. Don't forget to post an entry on the Forum to entice people over here!

      Delete
    2. Thanks for the suggestion! I posted it at:

      http://openbci.com/index.php/forum#/discussion/140/first-data-with-openbci-v3

      Delete
  2. Hi there, Thanks for the report. I pre-ordered my board but could not find any documentation on the new site which seems under construction. You have answered a few of my questions.

    ReplyDelete
  3. Greetings Chip,

    I had posted my request in the comments, but I dont see it as such I am re-posting it agaiin. I am a newbee in terms of BCI and will love to connect with you and William Croft on some handholding and guidance. I have been involved in neuroscience since the last couple of years and would love to share with you and william the project I am working on pertaining to cognitive decline due to aging and stress. I would request both you and william to please revert with your contact info so that I may further my connversation with you both. My email address is zul.kazani@gmail.com and skype add is zul_kazani.

    Looking forward to hearing back from you and also william.

    Thanks,

    Zul

    ReplyDelete
  4. Hey!! If you dont have any sentimental feelings to the older versions of the openBCI boards can i please buy one of them of you. I live in South Africa and have been following your developments closely. Ordering from open BCI i will only have a new board in two months and if i order the components to build one it will be the same case. Would it be possible to buy one of your older versions from you? even v1 would be fine. I really want to get into this ASAP

    ReplyDelete
    Replies
    1. Sorry, I'm going to keep my V1 and V2 boards...while the wireless connection of V3 is *really* nice, sometimes you want a hard-wired connection, which is what my V1 and V2 boards have.

      Delete
  5. Hi Chip,
    IS there a limitation in using the 8 bit board of openBCI to process the 24bit data of ADS1299 ? ( for EEG applications) I am hoping to purchase an opnBCI board but not sure whether to get the 8 bit board or the 32 bit board. I also checked the openBCI site and couldn't find any updated tutorials. Keep up the good work and keep updating your work with Version 3. Thanks a lot! Very informative blog :)

    ReplyDelete
    Replies
    1. Hi!

      You will certainly get the full 24-bit data out of 8-bit OpenBCI board. No problem there. The trouble comes with doing lots of processing (filtering, FFTs, etc) on the OpenBCI board itself.

      The "8-bit OpenBCI" is an Arduino Uno at heart. So, if you're played with Unos, you know that they are limited in how much computation they can do.

      I usually do all of the EEG processing on the PC, so it isn't an issue. If you wanted to do it without the PC, that's where you'd want to step up to the 32-bit OpenBCI...you'll just be able to get a lot more done.

      Chip

      Delete
    2. Hi Chip!

      Thanks for the info. I ordered the 32-bit openBCI board and am getting ready with the technical data until it arrives. My application is detecting Auditory evoked potentials from EEG and I have some grey areas to clarify.

      1) does openBCI board give me full access to lead off detection/ bias drive and Gains specified by ads1299 board?
      2) I need an impedance check on electrodes before the start of measurements. Can this be coded to be done automatically by openBCI board?
      3) I am checking out your codes on github on the 8bit board. Can these be used as test codes to start off with the 32 bit version or does the coding have to be in c language instead of arduino platform?

      Do you have any test codes for the 32 bit model ?

      Thanks a lot :)
      Hasini

      Delete
    3. In answer to your questions:

      1) I believe that the answer is "yes" regarding the lead-off detection and bias drive

      2) "Automatically" is the tough part to your question. What do you mean "automatically"? When I use the older V1/V2 boards, I start up the system, I activate the impedance checking, and I visually examine the results on the screen. Since my electrodes are rarely at a low enough impedance, I have to re-seat my electrodes a few times. Once I get it all good, I turn off the impedance check. I don't really see how this can be automated further.

      3) I've never used the 32-bit version, but I believe that it is programmed using ChipKIT's extension to the Arduino IDE. So, if you're comfortable with Arduino, you should be able to program the 32-bit OpenBCI just as easily (though, again, I've never done it).

      Also, more generally, the OpenBCI boards will be shipped with software already loaded (and, of course, you'll be able to download that software off the OpenBCI GitHub). So, you should be able to get it working immediately.

      Chip

      Delete
  6. Thank you for this post and your continuos work to make the openbci more accesible.

    Any one knows how to export openbci data into edf format...? I've been trying for a long time with no results. Anyone?

    ReplyDelete
  7. This free utility, EDFbrowser can read csv text files and write EDF as well as a number of other formats.

    http://www.teuniz.net/edfbrowser/

    You may need to slightly tweek the text file first before reading it, but assume you have ways to do that.

    ReplyDelete
  8. Hi,

    Thnak you for your response. The thing is that i've tried to do that. However, the option save as... is not available. And the only way i can export edf is by printing to edf file, which only allows for a brief segment. Do you know any solution to this?

    Thank you!

    ReplyDelete
  9. Ramon, hi. Did you look under Tools / Convert Ascii to EDF?

    http://www.teuniz.net/edfbrowser/EDFbrowser%20manual.html#ASCII_to_EDF_converter

    ReplyDelete
  10. Hi, has anybody tried to use OpenBCI board with BCI2000 P300 speller? I am unable to acquire the signals however, I can do so successfully with OpenBCI connected to OpenViBE.

    ReplyDelete