|Screenshot from BrainBay's Website of One Person's Processing and Visualization Configuration. The configurations are completely user defined, which is powerful...and confusing to a new person.|
>>> Getting Data into BrainBay
By default, BrainBay can be configured to receive data streamed from a few different EEG systems. It seems that most people probably use the OpenEEG hardware (such as the Olimex unit linked earlier). The OpenEEG hardware communicates to the PC using a binary data format. If I want to inject OpenBCI data into BrainBay, the easiest way is to make my OpenBCI system look like an OpenEEG system. This means that I need to alter my Arduino software (which is what my OpenBCI is connected to) to output the EEG data in the same format as used by OpenEEG. Easy!
Um, but what is the OpenEEG data transfer format?
Well, the core of the OpenEEG hardware is an AVR processor like the Arduino, so the embedded software running on the OpenEEG hardware should be intelligible to someone with experience in Arduino. You could download the software, read it (if you were suitably skilled) and figure out the data format. Given the number of AVR macros employed in that code, however, figuring out what's going on can be challenging for a lot of folks (including myself).
Alternatively, if you look in BrainBay's own Developer Manual and jump to Section 6, it discusses the data format in actual words. Very nice. I chose to target the "P2" data format.
You may notice that this format has a couple of limitations relative to the capabilities of OpenBCI. First, this data format only allows for 6 EEG channels, whereas OpenBCI has 8 channels. So, we'll lose two EEG channels, which is unfortunate but not horrible. Second, note that this format only allows for 16-bit EEG values, whereas OpenBCI generates EEG data samples at 24-bit resolution. So, I'll have to cut 8 bits of resolution, which means that I'll lose some dynamic range. A 16-bit value still has a lot of dynamic range, so this will probably be OK.
(Super-technical aside: I'll need to decide whether to truncate the lowest bits (and lose resolution at the lowest signal levels) or to cut the highest bits and lose the ability to handle large DC offsets. I think that I'll split the difference and cut some from both the high and low sides of my dynamic range. For the moment, I do this by dividing my 24-bit sample by 32 and cast from my 32-bit data type to a 16-bit data type. The "divide by 32" step, in effect, drops 5 bits of resolution from the low end of my dynamic range, which means that the casting drops 3 bits of headroom on the high end of my dynamic range.)
>>> Configuring BrainBay for OpenBCI
So, after writing a small extension to my existing Arduino software for translating the OpenBCI data into this new format, I can successfully get my OpenBCI data into BrainBay. Yay! There are, however, a couple of small changes to the settings in BrainBay to get the most out of the OpenBCI data. Specially, in the "EEG Block" used by BrainBay to get data from the EEG hardware, you'll need to alter the "Baud Rate"," Sampling Rate", and "Resolution". With my current settings in the Arduino software (which might change in the future), here's how I configured the EEG input block in BrainBay:
|To Use OpenBCI in BrainBay, select "Modular EEG P2" and then change the Baud Rate to 115200, change the Resolution to 1432 and (not shown) change the Sampling Rate to 250 Hz.|
Sampling Rate: OpenEEG runs at 256 Hz. The sampling rate for OpenBCI has several different settings, but my Arduino software has it running at 250 Hz. In BrainBay, you should change the value to 250 Hz so that BrainBay shows the graphs with the correct time and frequency scales.
Resolution: OpenEEG samples have a resolution of 10-bits (ie 1024 counts). Full-scale is 512 uV (ie, +/- 256 uV). BrainBay always assumes that full scale is 512 uV and, in this window, it is asking how many counts correspond to 512 uV. For OpenEEG, you enter 1024 because it spans 512 uV with its 10-bit (ie 1024 count) digitizer. For OpenBCI, it's a little more complicated. The correct value (for now) is to enter 1432.
(Second super-technical aside: I get this value by finding OpenBCI's internal scale factor, which is (2^24) / (4.5 V / 24x Gain) = 89.5 counts / microVolt. I then cut this down by by 32x bit-reduction divisor discussed earlier, which yields 2.796 counts / microVolt. Finally, BrainBay expects "full scale" to be 512 uV, so to find out the number of "counts" it takes to represent this value, you take 512 uV * 2.796 counts / microVolt and get 1432 counts. Viola!)
>>> Example: OpenBCI Data in BrainBay
Once you get all of those settings correct, you can setup a simple data flow in BrainBay and start watching your OpenBCI data flow smoothly and beautifully. Below is an example of using OpenBCI for ECG (see here for the setup). You can see the four blocks: (1) the EEG block to receive the data from OpenBCI via serial link, (2) a sharp 60 Hz notch filter to eliminate line noise, (3) a gentle bandpass filter to remove low frequency drift, and (4) an oscilloscope block to graph the data. Look at how nice and clear my ECG is!
|Using BrainBay to Receive Data from OpenBCI and Plot the Results in Real Time. Awesome!|
>>> Next Steps
The major downside of BrainBay is that it is only on Windows. In the future, I'm going to look into interfacing OpenBCI with OpenViBE, which is another powerful open source software platform for receiving, processing, and visualizing EEG data. It looks like it is also primarily aimed at Windows, but it is nice to have another choice in addition BrainBay and in addition to my own Matlab and Processing and Python interfaces.
Follow-Up: Here's a post where I describe how to make ECG measurements.
Follow-Up: Chris (the developer of BrainBay) wrote a BrainBay driver for OpenBCI. Check it out!