LabStreamingLayer (LSL) stream from OpenBCI - Here's how

This answer is due to JFrey and others, but since the pieces are scattered around, I thought I'd post the solution in its own thread for clarity.  This uses the OpenBCI and LSL Python libraries, so requires some basic python execution know-how (adding packages and executing code).  It assumes you've already setup your OpenBCI hardware from the Getting Started guide.
  1. Download the OpenBCI Python code here: https://github.com/OpenBCI/OpenBCI_Python
  2. Download the LSL Python library:  https://github.com/sccn/labstreaminglayer/tree/master/LSL/liblsl-Python. You may have to download the .zip of the whole project from here: https://github.com/sccn/labstreaminglayer
  3. Plug in the USB dongle of OpenBCI and turn it on.  Find its port number. 
    • Windows: As in the Getting Started guide, open an OpenBCI .pde processing script, push the play button, and then in the window that opens select “LIVE” as the data source.  The first COM choice in the list that appears should be the OpenBCI dongle’s. 
  4. In your python environment, install the packages that user.py (from the OpenBCI python repo) needs, as well as the liblsl-python package.
  5. If you are on Windows, and your OpenBCI USB is registering as e.g. COM1, then run user.py from the OpenBCI python code with parameters as follows: python user.py -p=COM1 --add streamer_lsl
  6. If that succeeds, you should get a message similar to: 
    -------INSTANTIATING BOARD-------
    Connecting to V3 at port COM13
    Serial established...
    ....more text ....
    -->
  7. At that prompt, enter the command: /start  
    This starts two LSL streams, named "OpenBCI_EEG" and "OpenBCI_AUX", at least on my system.  You can view them with Stream Viewer, which is an app within the overall LSL repo.

Comments

  • Thanks for the tuto :)

    For step 2, in fact now LSL is available through PIP, so if you have it installed you can use "pip install pylsl"  ; or if you don't have admin rights "pip install pylsl --user" (tested on linux)
  • wjcroftwjcroft Mount Shasta, CA
    edited January 2016
    Winslow, Jeremy, great tutorial and updates. This tutorial could even get mentioned over on the docs area,

    http://docs.openbci.com/research tools/

    If for example Rodrigo @Rceballos98 sees your post.


  • edited March 2016
    I try to install OpenBCI Python files and LSL. Where should I install them or is copying to some specific folder enough? If I try to run user.py or Open_bci_v3.py they stop immediately for error messages "No module  named serial" and No module named yapsy.PluginManager. At least yapsy I have installed, but maybe to the wrong directory.

    I have Python 2.7 and 3.5 installed with Anaconda. Machine in Macbook Pro with El Capitan.

    How should I install Python modules?

    Many thanks for advises :-)

    JJ 
  • wjcroftwjcroft Mount Shasta, CA
    edited March 2016
    @jussijaatinen, hi. I merged your LSL / Python question into this existing thread which contains a tutorial guide by Winslow and Jeremy. See the previous posts.

    The other LSL thread is here,

    http://openbci.com/forum/index.php?p=/discussion/334/labstreaminglayer-into-bcilab-eeglab-matlab

    Also see,

    https://www.google.com/search?q=python+pip

    William

  • GabeIbagonGabeIbagon San Diego, California
    Hi @Winslow_Strong, I wrote up a tutorial based on your advice! Thanks a lot for the help. Here's the guide:


  • I have a started writing a tutorial for Windows OS about that but I forgot to post it. It might be helpful. 


    I'm going to assume you have Windows (64-bit/32-bit).

    • Download & Install Python 2.7.10 (from here: https://www.python.org/downloads/release/python-2710/).
    • Open Windows CMD command (to do so: Windows+R then run "cmd" ).
    • To make sure you have installed Python correctly type this: "pip list"  (This will also make sure that you've installed Python with PIP script, which is a package used to install other packages written in Python)

    image

    • Now, you need to install the following packages using these commands:
    PySide:  "pip install pyside"
    yapsy:   "pip install yapsy"
    pylsl:   "pip install pylsl"
    pyserial:   "pip install pyserial"
    numpy:   "pip install numpy" (Note: this might take longer time to be installed than other packages)
    "python user.py -p COM5 -a streamer_lsl --no-filtering"
    • Notice that I'm using "COM5", make sure which port you're using, you can find that out from Device Manager > Ports (You should see it there).
    • Save the .bat file, then run it. (Make sure you have already switched on your device, if it connects, just type "/start" to start streaming).
    • Now you have two options:
    1. You can use :LabRecorder, to record the data then import it to matlab using MATLAB-imoprter (downlod it from here: ftp://sccn.ucsd.edu/pub/software/LSL/Apps/MATLAB Importer-1.10.zip)
    2. You can use BCILAB to stream data directly from LSL, because you have already ran RunUser.bat.
  • The code implies that it will auto-detect a daisy module if present (i.e. on the 16-channel systems), but it wasn't for me, and I was only getting 8 channels.  I needed to add the "Force daisy" argument of "-d" to the other arguments, and then all 16 channels work.  

    Maybe @Gabelbagon can add this bit to the tutorial?
  • Hi I am looking to write a C driver module for OpenBCI. This will allow it to natively wrap to LSL and every other language. I wrote the Node.js driver for OpenBCI and am looking for performance improvements using C for the lowest level Serial interfacing. Any one have any advice?
  • I'm also the guy rewriting the firmware so I think I am poised to lead the charge in making one driver that can be wrapped/binded to by all programming languages.
  • wjcroftwjcroft Mount Shasta, CA
    Hi, AJ, take a look at the BrainBay data stream parsing state machne,

    http://openbci.com/forum/index.php?p=/discussion/730/parsing-openbci-data-stream-using-c

    Is the revised firmware interrupt based, as mentioned on previous threads here?

    Regards,

Sign In or Register to comment.