Dear all, I am a student who is doing a project with OpenBCI. I can now realize live data streaming using OpenBCI GUI and the Brainbay. Is it possible for me to stream data into MATLAB and do some real-time DSP?
I think the way this is done at the Swartz lab, is to use EEGLAB (BCILAB) running on top of MATLAB. Then using LabStreamingLayer (LSL) to get the serial port EEG data into BCILAB + MATLAB.
Thanks for your comment! I have red through the link you provided and I am trying to connect the OPENBCI board to my PC through serial port. But I get some problem.
When I issue a command like "turn the channel off/on" or "reset the channel settings", it works fine. But when I send a "b" to start data streaming, I just receive some strange characters. The display of my serial port tool is like this:
Take a look at this video showing LabStreamingLayer used with the Cognionics EEG amplifier. We are porting this over to OpenBCI and should have it complete in a bit. The library supports direct MATLAB access, BCILAB, EEGLAB. As well these languages: (C, C++, Python, Java, C#). See the LSL link on the previous post.
The "meaningless" characters you show on your serial port tool, are actually the binary data stream packets that Joel referred to in his post. So one way you can interpret these is to parse them from the binary. Such as with this MATLAB library:
However my hunch is that this is much easier done with LSL. Since MATLAB is less suited to this type of binary character operations than say C++, in which LSL is written. I'll post again with a progress update.
I don't know where you are regarding LSL status, which piece of code already works or should work (ie, which language), but I pushed a LSL streamer plugin to the Python repo. Tested only with OpeViBE at the moment (what else? ), seems to play nice
Jeremy, that's great news, and will get @fxu003 going immediately.
I'm still futzing around with the conversion of of the LSL/Apps/Cognionics to Apps/OpenBCI. Involving the Qt window manager. Since that builds a Windows C++ executable, it will serve that community well.
For those not familiar with LSL, there are a collection of 'Apps', which feed data from a variety of user input sampled devices, such as EEG amps, keyboards, game controllers, mouse, etc. So in this case, a new executable "OpenBCI.exe".
And then there are libraries in C, C++, Python, Java, C#, MATLAB, that allow the programmer to 'consume' the data streams produced by those apps. So what Jeremy has done is to use the LSL Python library to create a plugin module of our OpenBCI_Python 'app' that can feed such streams.
This is good way to feed an LSL stream in an OS agnostic manner. And... to get input from the other devices LSL supports, those executables are still available as Windows apps. OR, could be converted to Python as well. All the "Apps" have a small dialog box type interface that lets you set parameters such as stream name, # channels, etc.
@fxu003 , let us know if you are able to read the OpenBCI stream from your MATLAB. Examples of how to use the various libraries is on the LSL site.
You'r right, I guess it'll be easier for new users to launch directly a binary file instead of having to install the whole python package, especially on Windows. However, I aldeady did my share of C++ by venturing into OpenViBE source code, so good luck with that
I followed what Jeremy's method. I was able to activate the streamer_lsl and I can see that the channels (EEG & AUX) are opened and activated. However, when I send the 'b' command to start streaming from the device, all I get is strange charachater and nothing is streamed to LSL.
Here is a copy of what I see when I run user.py
-------------BEGIN---------------
% updating channel settings to default
--> start
% initialization failed. Things to check:
% * is a card is inserted?
% Could not find FAT16/FAT32 partition. Make sure you've formatted the car
d
Could it be the problem coming from not having an SD card?
I disabled the SD by not allowing the chip to enable it and I was able to overcome the "initialization failed" message. I was also able to communicate with the board by activating/deactivating channels but when I send "b" to begin streaming, I get nothing.
The command to start the stream in not "start" but... "/start". One slash that could change everything, because otherwise the "s-t-a-r-t" command is sent to the board (and I don't know what kind of weird things it could trigger).
If you don't use the "/start" command but directly send "b" to the board, it may start to stream data, but there will be nothing on the client side to intercept and process the feed (ie read float values from binary data and pass them to the plugins).
It worked perfectly. Thank you very much. I wasn't paying very good attention to the slash.
One more thing, how can I send the "/exit" command if I am using CMD. Any other ideas of how I can keep sending more command because CMD doesn't allow me to enter more inputs while reading from the board.
Sending new commands once the stream is started is something we have to work on, at the moment you're right, it's not possible
[2 hours later]
Ok, it was easier to implement than I thought, I just pushed a new version that let you stop stream and issue new commands (+ some other fix). Please test and tell if there's any side effect that I did not see.
Now you should be able to configure (nearly) on-the-fly the board while you stream data. Eg, if you stream data with LSL plugin and read that with OpenViBE, issue in a row "/stop" "12" "/start" to disable the first two channels. On OpenViBE side, the data will stop coming for a second -- or more, depending on your typing speed -- and will then resume automatically with two zeroed channels. Handy to test configurations (bias, ref, etc.).
I intend to link OPEN BCI and matlab and work.I want to know how can you get live streaming of data into matlab from Open bci main board.Can anyone help me out with the code??
The libraries for each language are in the LSL sub-folder. The Apps folder contains C++ Windows executables (which you don't need if using our Python plugin), see the March 9 post section above: "For those not familiar with LSL..."
@devd / Srijan, hi. I merged your question into this existing thread on BCILAB / MATLAB access via LSL.
As far as motor control, easiest approach is to put that on a SEPARATE arduino on another serial (COM) port. Then send positioning commands to that arduino over the serial interface. This way you do not have to alter any code in the OpenBCI board or risk contamination of the EEG with motor control output signals.
Use the LSL library to get the EEG stream into MATLAB and thus EEGLAB / BCILAB.
I just noticed recently that SCCN / UCSD has migrated their repository from Google Code to GitHub, since Google Code is shutting down later this year. Looks like a lot of activity on the Github link. And they are also incorporating multiplatform builds and support. The binaries included on the Google Code repo were Windows only.
My guess is that the Github link is not quite ready as a distribution point for those wanting to download the various libraries and apps. So if you just want to use the "current" release, go to the Google Code site.
I also spotted no latter than today this updated repo (a bit of a nightmare to sort out "genuine" repositories when anyone can migrate code from google to github). I'm interested in LabRecorder, and while I had some segfaults, at least the app can now be launched straight from the repository on linux (ubuntu 14.04 x64), no need to compile a thing.
I'm using more and more LSL (OpenBCI, Bitalino, OpenVibe, various python scripts and processing), it's good to see that the project is well alive
Jeremy, hi. I think dmedine's migration is the main repo, as SCCN is contributing to it as well. As you say though, is confusing. My guess is it will eventually move back to SCCN when things settle down.
Hello, all. Yes, LSL is now hosted on my github page, here, although I should migrate it to a better spot. The google code repo is still up, but is no longer actively developed. I also plan to start a forum or mailing list to consolidate users' questions and experience. Feel free to fork, clone, and post issues on github!
I would like to use in real-time the data from openBCI in Matlab, but I don't have any idea of how doing this. To be honest i don't know how work Matlab to do thing in real-time and how it work to make communication with other software like openBCI.
I saw some discussion about that in this fórum, but i wasn't able to use the codes i found there.
Hi @DeDa , I merged your question into this existing thread on LSL / MATLAB. Did you read the API link mentioned above? You say you were not "able to use the codes I found there". Can you be more specific? Are you starting up the OpenBCI_Python LSL plugin at the same time? That is needed to feed the stream that MATLAB is consuming.
See the yellow highlighted link in the March 23 post above. API = application program interface, in other words, how to use a programming language subroutine library such as LSL.
The OpenBCI driver is not yet merged into official LSL, so you need to run our Python plugin before starting your own app.
Is there a tutorial on this? I've read this post several times and I'm unsure how to proceed. I have an OpenBCI that I would like to stream it's data into Matlab. I've concluded that using LSL seems to be the best approach. It seems someone here as done that. Can you provide a quick run down?
1. I've download LSL.
2. I've install BCILab.
3. I've looked at Apps and Examples.
4. Can I used the OpenBCI that came with the platform setting up an outlet (since it seems to use pylsl) or does the approach mentioned in this stream start from LSL source?
5. Once I set up the OpenBCI LSL outlet, can I just run the receive script in Matlab?
Can you try sending a Private Message to @alfahad , who got it working on his setup. See posts above from March 21. Unfortunately I don't have Matlab here myself. Just click on his name and then press the Message button.
Comments
http://sccn.ucsd.edu/eeglab/
http://sccn.ucsd.edu/wiki/BCILAB
http://code.google.com/p/labstreaminglayer/
I've forked the LSL sources, and am looking into adding OpenBCI. By just mostly cloning the Cognionics folder, warping it into OpenBCI format.
LSL by the way can also go directly into OpenViBE. LSL is a great way to synchronize timing marks across various user interface devices.
William
Take a look at this video showing LabStreamingLayer used with the Cognionics EEG amplifier. We are porting this over to OpenBCI and should have it complete in a bit. The library supports direct MATLAB access, BCILAB, EEGLAB. As well these languages: (C, C++, Python, Java, C#). See the LSL link on the previous post.
http://www.cognionics.com/index.php/products/software/software-development-and-api
The "meaningless" characters you show on your serial port tool, are actually the binary data stream packets that Joel referred to in his post. So one way you can interpret these is to parse them from the binary. Such as with this MATLAB library:
http://www.mathworks.com/help/instrument/serial-port-interface.html
However my hunch is that this is much easier done with LSL. Since MATLAB is less suited to this type of binary character operations than say C++, in which LSL is written. I'll post again with a progress update.
William
I'm still futzing around with the conversion of of the LSL/Apps/Cognionics to Apps/OpenBCI. Involving the Qt window manager. Since that builds a Windows C++ executable, it will serve that community well.
And then there are libraries in C, C++, Python, Java, C#, MATLAB, that allow the programmer to 'consume' the data streams produced by those apps. So what Jeremy has done is to use the LSL Python library to create a plugin module of our OpenBCI_Python 'app' that can feed such streams.
This is good way to feed an LSL stream in an OS agnostic manner. And... to get input from the other devices LSL supports, those executables are still available as Windows apps. OR, could be converted to Python as well. All the "Apps" have a small dialog box type interface that lets you set parameters such as stream name, # channels, etc.
@fxu003 , let us know if you are able to read the OpenBCI stream from your MATLAB. Examples of how to use the various libraries is on the LSL site.
William
https://code.google.com/p/labstreaminglayer/wiki/ExampleCode
Here's the API documentation, including examples for MATLAB and the other languages,
https://code.google.com/p/labstreaminglayer/wiki/ExampleCode
As far as motor control, easiest approach is to put that on a SEPARATE arduino on another serial (COM) port. Then send positioning commands to that arduino over the serial interface. This way you do not have to alter any code in the OpenBCI board or risk contamination of the EEG with motor control output signals.
Use the LSL library to get the EEG stream into MATLAB and thus EEGLAB / BCILAB.
William
My guess is that the Github link is not quite ready as a distribution point for those wanting to download the various libraries and apps. So if you just want to use the "current" release, go to the Google Code site.
Original:
http://code.google.com/p/labstreaminglayer/
New:
https://github.com/dmedine/labstreaminglayer/
It's possible that eventually dmedine will push his tree to SCCN, but that has not happened yet.
https://github.com/sccn
William
Hello everybody,
I'm starting to use openBCI, seems great !
I would like to use in real-time the data from openBCI in Matlab, but I don't have any idea of how doing this. To be honest i don't know how work Matlab to do thing in real-time and how it work to make communication with other software like openBCI.
I saw some discussion about that in this fórum, but i wasn't able to use the codes i found there.
Any help is welcome !
Thanks
Dd
William
Hi,
Thanks, i didn't understood that it need LSL, sorry, and i don't know what mean API,( is that "Application Programming Interface"...?),
I haved watch the demo vídeo of C.A.Kothe. I start to begin to understand a little bit...
I'll try to install LSL (I'm taking it from the link in the last post of dmedine), and i'll use as in the exemple of the demo.
I'll give some News.
Thanks a lot,
Dd
The OpenBCI driver is not yet merged into official LSL, so you need to run our Python plugin before starting your own app.
https://github.com/OpenBCI/OpenBCI_Python