Convert bdf to brainflow csv and vice versa
DashBarkHuss
Chicago
I want to convert an openbci bdf to a openbci brainflow csv.
1. Are the eeg channel values the same in both files or do they need to be scaled?
2. How would I get the sample index from a bdf to add it for the brainflow csv? I'm a bit confused about what those values even are since they often repeat, and don't behave like regular indexes.
Comments
Mentioning Richard @retiutut, the GUI developer.
Something to start with, would be using the EDFBrowser feature to convert the BDF to CSV. Then see in which column the sample index is stored. The GUI / Brainflow CSV is described:
https://docs.openbci.com/Software/OpenBCISoftware/GUIDocs/#cyton
https://www.teuniz.net/edfbrowser/bdfplus format description.html
https://www.teuniz.net/edfbrowser/EDFbrowser manual.html#EDFBDF_to_ASCII_format_converter
https://openbci.com/forum/index.php?p=/discussion/3344/differences-between-raw-csv-data-and-bdf-format-data
https://www.google.com/search?as_q=bdf+raw&as_sitesearch=openbci.com [search results: bdf+raw ]
The data stream from Cyton and Ganglion is sent over Bluetooth via 'radio packets'. These packets are numbered consecutively and can help the GUI receiving code tell if any packets are dropped. But the number is only in a small range based on the sample rate of the device. So on Cyton the sample indexes go from 0 to 249, then back to zero. (Since Cyton sample rate is 250 Hz.) On Ganglion, sample rate is 200 Hz. Also on Ganglion TWO samples are sent per radio packet. So the stream contains two packets with the same number before going to the next.
I'm unclear on whether the BDF stream contains these sample index numbers, since that is not part of the BDF standard.
https://www.teuniz.net/edfbrowser/bdfplus format description.html
https://www.edfplus.info/specs/edfplus.html [BDF is derived from EDF]
Generic Brainflow data format described here:
https://brainflow.readthedocs.io/en/stable/DataFormatDesc.html
I built an open-source tool that may help with the BDF-reading portion of this:
https://edf2csv.vercel.app/
You can run:
npx edf2csv recording.bdf
It reads BioSemi BDF/BDF+ recordings and exports the physical signal values, channel information, annotations, and metadata as ordinary CSV/JSON files. It runs locally and does not resample channels or alter their units.
For transparency, I am the developer.
One important limitation is that it produces a general signal CSV rather than BrainFlow's exact CSV layout. If BrainFlow playback requires its own sample-index, timestamp, or marker columns, you would still need a small formatting step after conversion. However, it should handle the binary BDF decoding and give you the underlying values in a much easier format to work with.