Flavio Frohlich
  • Home
  • Contact
  • Thoughts
  • Book
  • IN THE NEWS
  • ABOUT
  • Speaker

10/25/2020

Collecting EEG Signals with a Raspberry PI and a MUSE 2 headset

4 Comments

Read Now
 
Few weeks ago, I have posted on Twitter that I am interested in examining to what extent consumer-grade EEG headsets could be used in scientific studies. There are few papers out there that test devices but I decided that I need to try them myself to see how good the signal quality is and whether these devices could be suitable for long-term monitoring in clinical trials of our Carolina Center for Neurostimulation.
I will share with you all my insights and thoughts on this journey. Please chime in and share your perspective and tips. This first post summarizes some troubleshooting I had to do to get the MUSE 2 headset to communicate with a Raspberry PI 4, a quite powerful single-board computer (SBC). I felt like back in the days of graduate school (almost twenty years ago!) when compiling code was part of my daily work. As it turns out, there are some fantastic resources out there and please understand that I did not develop anything new here, rather I found the right tools and figured out some quirks to things to work as they should. In the hope that such step-by-step instructions are helpful, here is what I did.
  1. I got a Raspberry PI 4, a high-speed 32GB micro SD card, the matched 7-inch capacitive touchscreen, and a nice enclosure (all links will take you to Amazon, please note that I use affiliate links). The idea is that together this forms a nice stand-alone unit to receive EEG signals (instead of relying on somebody's smart phone that comes with its own privacy challenges etc., more on that in a later post).
  2. I got the MUSE 2 headset, more on the MUSE S in another post.
  3. To download and install Raspberry Pi OS (32-bit), I used the Raspberry PI OS downloader. This tool downloads the OS and copies onto the SD card.
  4. I assembled the device using these instructions, inserted the SD card, and booted the device (I powered it with my cell phone charger, it requires a USB-C connector on the device side).
  5. I answered the few simple questions about language etc and configured it to connect to my wireless.
  6. The OS then automatically checked and installed all upgrades, which then required a reboot.
  7. I then installed the fantastic muselsl python package by Alexandre Barachant. Here is where it got interesting. Muselsl includes some python packages that I only got to properly install on Python 3, thus I used the following command to install it (note that I use sudo to ensure to have the proper privileges for all of the installation steps):
    sudo pip3 install muselsl
  8. At this point everything should work, except it does not! The reason for this that library required for the Raspberry PI is not available, the file is called liblsl32.so. I clicked through some of the super helpful discussion threads on github to learn how to download and compile this file.
  9. Download the LSL folder from the labstreaming layer github.
  10. Change over into that director (after unzipping) and create an additional director where the compiled code will go with the following commands:
    cd labstreaminglayer/LSL/liblsl
    mkdir build
    cd build
  11. Now, before you are ready to compile you need to install the tool cmake that is required for preparing compilation. I used the following command:
    sudo apt install cmake
  12. Now you can compile using the following command (again, a heartfelt thank you to the developers at the SCCN who have developed this tool and provided help with this on their github page):
    make .. -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ -DCMAKE_SHARED_LINKER_FLAGS="-Wl,--allow-multiple-definition"
  13. You will now have the right file in your built folder, it will have the name liblsl.so.1.14.0. Now all you need to do is to copy this into the right folder with the following command:
    sudo cp liblsl.so.1.14.0 /usr/local/lib/python3.7/dist-packages/pylsl/liblsl32.so
  14. Before muselsl works, there is one last step, which is to install one more package to make sure that that scipy package runs. Here is the command:
    sudo apt-get install libatlas-base-dev
  15. At this point, you should be able to connect to your muse device and start streaming data. I used the following sample Python script provided by the authors of muse-lsl:
    from muselsl import stream, list_muses
    uses = list_muses()
    stream(muses[0]['address'])
  16. Done! Please keep me posted if this works for you. I will follow up with more code to test the device and also some sample data, including a discussion of the recording quality. Stay tuned!
      

Share

4 Comments
Details

    Author

    Flavio.

    Archives

    October 2020
    September 2020
    August 2020
    October 2019
    September 2019
    August 2019
    July 2019
    March 2019
    December 2018
    October 2018
    September 2018
    April 2018
    March 2018
    February 2018
    January 2018
    December 2017
    November 2017
    September 2017
    August 2017
    July 2017
    June 2017
    April 2017
    March 2017
    February 2017
    January 2017
    December 2016
    November 2016
    October 2016
    February 2016
    January 2016

    Categories

    All

    RSS Feed

Proudly powered by Weebly
  • Home
  • Contact
  • Thoughts
  • Book
  • IN THE NEWS
  • ABOUT
  • Speaker