EEGLAB / MATLAB / Octave : read OpenBCI CSV files
All right,
So I have collected some initial data with the openBCI GUI and can see some .txt files in the "saved data" folder. I see it comprises of electrode voltage samples over time but am not certain of the exact structure of the file. Anyway, I want to import this data into EEGLAB for further processing. Any ideas how that can be done? or is there some other tool for processing openBCI recordings. Any input is appreciated
So I have collected some initial data with the openBCI GUI and can see some .txt files in the "saved data" folder. I see it comprises of electrode voltage samples over time but am not certain of the exact structure of the file. Anyway, I want to import this data into EEGLAB for further processing. Any ideas how that can be done? or is there some other tool for processing openBCI recordings. Any input is appreciated
Comments
A common interchange format for biosignal data is EDF. Many EEG signal processing programs support this. There are some converter programs that can import CSV and export EDF. EEGLAB can read EDF.
http://www.teuniz.net/edfbrowser/EDFbrowser manual.html#ASCII_to_EDF_converter
EDF assumes channel samples are 16 bits. Since many new amps use 24 bit channels, a revised standard was created by Biosemi, called BDF.
http://www.biosemi.com/faq/file_format.htm
More tools and format specs,
http://www.edfplus.info/downloads/index.html
The EDFBrowser is a general multichannel biosignal display program.
William
Another option: Run your data through this Python script to convert OpenBCI .txt files to OpenViBE-compatible CSV, and then use OpenViBE to convert to EDF (it has an EDF writer).
I took a look at that link you posted. The OpenBCI output file csv values ARE microvolts, not "raw 24 bit values" as the author Adam maintains. The sample values do have the DC offset, so that is usually removed with a high pass filter, e.g. at .5 hz.
http://openbci.com/forum/index.php?p=/discussion/201/large-millivolt-data-values-dc-offset
Will Adam revise his script?
Regards,
William
You're right. Thanks for catching that embarrassing error in my CSV conversion script. I've updated the post and the script accordingly, with credit to you in a note at the bottom of the post. (I've linked to your forum user. Let me know if there's another name or URL I should use, or if you would prefer not to be mentioned.)
The original version of that script had no conversion factor. Reading the OpenBCI data format documentation (http://docs.openbci.com/software/02-OpenBCI_Streaming_Data_Format), I mistakenly assumed that it applied to the saved CSV data. This was pretty silly in retrospect, because the CSV includes decimal values (among other reasons).
Thanks,
Adam
I was able to edit a test file and simply reduce it to a CSV with electrode output values listed in columns and then opened it in EEGLAB. Though when I plot the signal (2 electrode readings) I simply see two out out of phase sine waves which isnt what i expected. I removed the DC offset of course, and then tried to notch the 50 Hz frequency to get rid of power line interferences as I originally thought the interference is too strong to see the real signal. This didn't help however. Now i can see I never handled the uV value conversions so I will try your script first thing.
Btw, If I use the notch filter in the openBCI GUI while recording the data stream, does it store filtered values or the notch is simply for the display and I get original values in the file. Also maybe I should start another thread for this, but I dont see a record of the reference electrode being stored. I think that is needed if I want to reference all the data. Any thoughts on how that can be done?
Thank you and apologies if I am asking too many basic things. I am still learning the ropes for EEG processing.
> I was able to edit a test file and simply reduce it to a CSV with electrode output values listed in columns
No need to manually edit the file, use the csvread(__, 4, 1) function mentioned above to skip over the 4 comment lines and 1st column.
> Now i can see I never handled the uV value conversions
Please reread the posts above, that was a misunderstanding. The values in the CSV file are already in uV.
> does it store filtered values or the notch is simply for the display and I get original values in the file.
The values in the file are raw values, unfiltered by notch or any other processing. This is stated in the comments in the CSV file.
> I dont see a record of the reference electrode being stored.
The SRB lead acts as a common reference for both your active electrode channels. So those channels record the differential signal between that lead and SRB. Thus no 'reference' value is recorded in the file.
If you use a bandpass filter, say from .5 hz to 40 hz you will eliminate both the DC offset and any remaining mains noise.
William
You have removed a lot of confusions I had about the data. Now I can get some work done. I get most of what you have explained, but I still see a problem with the reference electrode issue. If I cannot have a record of the reference electrode itself, I cannot say "unreference" my data or rereference it. What I think is happening in my case is that when eeglab reads the data it computes an average reference automatically, the alternative is to provide a reference channel/channels, which I cannot do here. Maybe I should just switch tools.
I was using cleanline for removing DC offset but I will go ahead and use a bandbpass simply as you recommended.
Thanks for the info. I am aware why we need a reference signal to record data and use of polar reference methods for recording EEG activity. Your reply helps decide what i need to do though. I should simply decide on my reference first and then record data so that there is no need to rereference the data. Thanks for all the help. I will update you guys how my experiment goes.
Yasir
Oo perfect. I think I got it a bit wrong. I was thinking one needs some sense of the original reference electrode signal to add it back and then subtract the new reference. Your info makes sense. Thank you all for clerifying the misconceptions I had.
Regards,
Yasir