|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!
Hi Chip !ReplyDelete
this is Chris (developer of BrainBay) - and I finally found your blog :-)
very nice work you did for the OpenBCI !! - and: cute hack to get BrainBay working with the device. I recently made some improvements and tweaks and though it might be nice to support the OpenBCI device natively.
have a look at: https://github.com/ChrisVeigl/BrainBay
I tried to figure out the data protocol from your AVR firmware. BrainBay now sends a 'b' to the COM port if an OpenBCI device is connected at the session is started - in hope to activate the binary data stream from the device ;-)
I could not test anything in lack of the hardware - curious if it works or what bugs may appear :-)
.. will be the "First-Time-Right"-design ?? ;-)
Hey Chris, this is fantastic! It would be so great if there could be a native interface in BrainBay for OpenBCI. The part that I didn't like about my kludge described here is that I had to throw away a bunch of bits to fit within the 16-bit OpenEEG P2 format. I also didn't like throwing away two channels (OpenBCI has eight channels whereas OpenEEG P2 only supports six). If we could make BrainBay work with OpenBCI with all 8 channels at full bit depth (with the correct sample rate and scale factor, of course), it would be a party! I'll check out your github...Delete
okay great !Delete
please tell me if it works - maybe contact me via email (see brainbay site)
Hey Chris, sorry for the delay...I've been stuck at home without an OpenBCI unit. Oh, the horrors! I'll be able to get a unit tomorrow, so hopefully I can give it a go over the weekend.Delete
I checked out Chris' new driver for OpenBCI in BrainBay. After ironing out a couple bugs, it works great! Check it out: http://eeghacker.blogspot.com/2014/01/openbci-driver-in-brainbay.htmlDelete
did you understand how to read the Olimex SMT on MatLab? In particulary I'm still having trouble to understand how to split channel's signals on MatLab...thank you for your attention and your work.
The latest BrainBay 1.9 (Windows in VirtualBox on MacOs) doesn't seem to contain a dedicated Notch-Filter (anymore?). Trying to enter a BandStop-filter it crashes as soon as you enter a 2-digit frequency value (such as pressing the '5' when entering '51'.ReplyDelete
Hey everyone, do you think it might be possible to make Brainbay to work with a mobile Android device, so that Android receives the signal data via serial port and transfers it via bluetooth to the Desktop where Brainbay is running, is it possible?ReplyDelete
The latest version of OpenBCI is bluetooth enabled, so it can talk directly to the PC without going through the phone.Delete
Hi Chip, thanks a lot for your help. Can I have your email id please, I need to ask you some queries; hope that's fine with you.Delete
Is that OpenBCI V3 hardware and a new software io a v4 hardware?ReplyDelete
v3 uses an RFDuino compatible USB-stick as receiver.
This comment has been removed by the author.ReplyDelete
I did not. Sorry.Delete
Does someone know what type of video file is accepted on BrainBay. I've tryed to load .avi movies and it does not work.ReplyDelete
Im Laeeq and trying to get ecg waveform using ads1299-evm board.
Can you tell me the registers setting specially for config 3 register.