If you are an advanced user and looking to work outside the machine learning provided by Crown, then you'll find this guide useful. We're writing this guide with the understanding that the reader knows how to run python3 and work with unfiltered EEG data.
Warning: LSL is experimental and time intervals can vary between samples due to resource constraints on the embedded Linux running within the Crown. Please consider using the Python SDK to send data through LSL instead of the embedded Linux if you run into issues.
Prerequisites
Install Virtual Environment
I use a virtual environment for usability and consistency. If you want to as well, I recommend installing virtualenv.
pip3 install virtualenv
If you run into issues, then you may want to run with sudo:
sudo -H pip3 install virtualenv
Create Virtual Environment
I've got a starter project if you want to follow along, you may download it from github.com/neurosity/notion-pylsl-starter. Otherwise, create a new directory for your project. Once you have the starter downloaded or new directory created, run:
virtualenv venv
source venv/bin/activate
Required steps for Notion
We assume you have already:
- Created an account
- Powered on and charged your Notion
- Got your notion online
- Claimed your Notion
- Activated LSL to get EEG data from Notion.
Working with PyLSL
Installing PyLSL
The first step is to install the PyLSL dependency. From your terminal, run:
pip install pylsl
Create a Python File
Make a new file called main.py.
Copy and paste the following into your main.py file, this file was directly taken from the main pylsl repo and is called ReceiveData.py.
"""Example program to show how to read a multi-channel time series from LSL."""
from pylsl import StreamInlet, resolve_stream
try:
# first resolve an EEG stream on the lab network
print("looking for an EEG stream...")
streams = resolve_stream('type', 'EEG')
# create a new inlet to read from the stream
inlet = StreamInlet(streams[0])
while True:
# get a new sample (you can also omit the timestamp part if you're not
# interested in it)
sample, timestamp = inlet.pull_sample()
print(timestamp, sample)
except KeyboardInterrupt as e:
print("Ending program")
raise e
Running PyLSL
Make sure you have
- LSL turned on in the developer console
- Your Notion is online and not charging
- Your computer is on the same computer network as your Notion.
Use the developer console to verify the WiFi network of your Notion:
Then in the terminal run:
python main.py
Which will automatically find the stream and read data from it!
If you run into any problems or have any suggestions on how to improve this tutorial, please comment below.
Comments
0 comments
Please sign in to leave a comment.