Game controlled via a Brain-Computer Interface (BCI).
Blinking fires the spacebar keydown
event.
Based on urish/t-rex-brainer
but modified so it can also ingest data from an EEG LSL server.
First of all, you need to have a LSL server streaming EEG data. Use Notebook 3a from the Brain-Computer Interfacing Bootcamp Course repo to start up a mock LSL server that streams EEG data from a dataset.
Start by cloning this repo
git clone https://github.com/rameerez/brain-controlled-game.git
And then cd
into it
cd brain-controlled-game
Let's first display the actual game window.
Install dependencies
npm install
npm install -g live-server
And start up the web server
live-server
Now, we need a Python flask
server that sends events to the game web window. The goal of this "event server" is to read EEG data from a LSL streaming and fire events when it detects the right artifacts.
Open up a new console, cd
into the project folder and then cd
into the Python server folder
cd python_event_server
Install dependencies
pip install flask flask-sse redis gunicorn gevent mne
pip install https://api.github.com/repos/mne-tools/mne-realtime/zipball/master
Now, we need Redis to allow the Python server message system to work. Install and run redis on your machine:
brew install redis
And then run the local redis server
redis-server /usr/local/etc/redis.conf
Download the Latest release
compiled version of Redis: https://github.com/microsoftarchive/redis/releases/download/win-3.0.504/Redis-x64-3.0.504.zip
Uncompress the .zip
file and execute redis-server.exe
A black terminal screen with the Redis logo should pop up indicating that a local server of Redis is now up and running.
// TODO search for redis installation instructions on Linux
Once Redis is installed and running, fire up the Python event server:
gunicorn main:app --worker-class gevent --bind 127.0.0.1:50005
And everything should be set up now.
Issue on Windows
On Windows systems, the above line throws a ImportError: No module named fcntl
error. This is because gunicorn
relies on fcntl
, which is a Linux-only library and thus not available on Windows. An (untested) workaround might be using a mock fcntl
module as described here: https://stackoverflow.com/a/25471508/2565681