Collecting Brain Signal Data Using The G.tec Unicorn EEG Headset In Python

A Beginner’s Guide to Brain-Computer Interfaces (part 4)

--

The g.tec Unicorn EEG headset is an awesome device, and comes with the Unicorn Recorder software to make recording data easy. However, for more complicated experiments, and real-time processing, one may want to work in Python. The company g.tec provides an Python API to easily stream your data to Python, but this API is not free. Moreover, one may want to build a custom streaming pipeline to Python. If that’s you, read further!

Streaming the data to Python is actually quite easy, using PyLSL, a Python interface to the Lab Streaming Layer (LSL). The Unicorn Suite software provides an extension, the Unicorn LSL Interface, which you can use to acquire data from the Unicorn and forward it to LSL! However, the steps needed to actually get your data into Python are not very well documented. So, in this blog posts, we will go over the steps needed to use the Unicorn with PyLSL to stream data to your Python program!

1. Connect your Unicorn to the Unicorn Suite

Firstly, we need to connect the Unicorn device to the Unicorn Suite software. g.tec actually provided some very handy YouTube tutorials regarding this. When succesful, let’s move on to step 2!

2. Connect the Unicorn to the LSL interface

In the Unicorn Suite software, go to DevTools > LSL Interface > Open. Then, launch the UnicornLSL executable, and your Unicorn device should appear as available device. Then, simply open the stream, and press start. Now, your Unicorn is streaming data to your laptop. Now we need to write some Python code to collect this data!

3. Write a Python script to collect data!

First, we only need to install the pylsl and pandas packages.

Then, we write this small Python script, and we’re all set!

Easy as that!

If this post was helpful, check out the publication page, where more practical BCI tutorials like this one will be posted in the future, and give me a follow to be notified for further posts!

--

--

Tim de Boer
A Beginner’s Guide to Brain-Computer Interfaces

Master graduate AI @VU Amsterdam. Currently learning and writing about building brain-computer interfaces. Support me: https://timdb877.medium.com/membership