Using Recorded OpenBCI Data in OpenViBE
OpenViBE is a open source EEG software suite. Somewhat like BrainBay, it has a visual scenario designer that allows you to manipulate your EEG data and apply all sorts of processing algorithms, filters, and much more. Sadly, it does not (yet) have a driver to acquire streaming data from the OpenBCI. It is apparently possible to get live OpenBCI signals into OpenViBE using this technique, but it's technically intricate.
Even without a driver, however, we can still use OpenViBE for analyzing signals recorded from the OpenBCI, at least in principle. The OpenBCI records data in CSV format, and OpenViBE includes a “box” that can read in CSV data.
In practice there are a few complications. OpenViBE’s CSV reader requires time-stamped samples, but the OpenBCI data doesn't include a time stamp, only a one-byte sample ID (which loops every 256 samples). The CSV fields are also ordered slightly differently, and include incompatible headers.
For an initial test, I tweaked a chunk of OpenBCI CSV data in OpenOffice Calc, and then read it into OpenViBE. This worked, but is impractical with multi-megabyte CSV files of hour-long EEG sessions.
Python to the rescue
To automate the process I wrote a simple python script that reads in OpenBCI CSV data, does the necessary conversions, and writes a OpenViBE-compatible CSV output.
This script is quite rough-and-ready, so there’s no guarantee it will work in all cases. Feel free to modify and improve, or make suggestions in the comments.
convert_obci_csv_to_openvibe.py
A few notes:
-
The script takes any CSV files found in the input directory, converts them, and writes them to the output directory. Input and output directories are specified (relative to the script location) in the config section of the script.
-
The script will only work properly with a CSV that includes columns for 8 EEG channels.
-
The OpenViBE CSV reader box is listed as “unstable”, so it will only show up in OpenViBE if you have "show unstable" checked in the box list, or have edited the appropriate config value.
-
You will probably need a filter to remove drift from the signals (at least I did). This can be done with OpenViBE's “Temporal Filter” box. I used a Butterworth band-pass filter from 1-50hz, but any low-cut or band-pass filter that eliminates DC drift should work.
Once you have the OpenBCI data in OpenViBE, you can also use OpenViBE’s file writer boxes to convert it to GDF or other formats.
UPDATE: The original posted version of this script was applying an erroneous conversion factor to the EEG data, based on my reading of the OpenBCI data format docs. Many thanks to OpenBCI forum member wjcroft for pointing out this error.