Complications with using Python on MacOS to Receive and Process EEG data
As a somewhat new student to the neurotech field and specifically EEG data manipulation, my first task seemed simple - connect the OpenBCI hardware with my Mac via Bluetooth, and then attempt to manipulate the EEG data using Python. Python, arguably one of the easier programming
languages, would be a perfect option for making EEG data more comprehensible by filtering unwanted frequencies, setting minimum and maximum ranges, and extracting only useful data.
My resources included:
a comprehensive OpenBCI website with an entire Python Software section explaining how to connect hardware to software
Multiple GitHub repositories, digital file storages, to clone and build for my system.
The world wide web
The start, I must say, was quite exciting and hopeful. The first steps included an installation of the OpenBCI GUI provided by the OpenBci website. With only slight confusion about which directory, or folder, to put this application, the GUI was quickly functional.
According to the OpenBci website, I needed to download a few (or so I thought) dependencies, such as programming languages and computing packages, to get the bluetooth connection working. The dependencies included the latest version of Python, NumPy (supports data in large, multi-dimensional arrays/matrices), pySerial (connects data streaming from different devices), and Yapsy (builds a plug-in system that adds specific features to existing programs).
Luckily, my Mac came with the python 2.7.10 already installed. Wonderful. Installing numpy involved simply cloning a Github repository.
Sashas-MacBook-Air:bci sashaschtein$ git clone
Installing pyserial required a bit more effort. As there was no GitHub repository to clone, I installed a python installation platform, pip. My Mac already had easy_install making pip ‘easy’ to ‘install’.
sudo easy_install pip
sudo pip install pyserial
Similar to the process I used for pyserial, I used pip to install Yapsy:
sudo pip install Yapsy
All the dependencies that were indicated on the website were now installed without any complications. Now, on to downloading and installing the OpenBCI-Python GitHub repository.
Making sure that all tools are located in the correct directory, (I created a directory, ‘bci’ to place all my bci libraries and files into), I cloned the GitHub repository for OpenBCI-Python from terminal into the bci folder. From first glance it seemed like this repository needed to be built. I built the repository using the setup.py file provided:
sudo python setup.py install
Time to run the application. Running the user.py file from the repository (python user.py -l) produced this unexpected error:
WARNING: no plugin selected, you will only be able to communicate with the board. You should select at least one plugin with '--add [plugin_name]'. Use '--list' to show available plugins or '--info [plugin_name]' to get more information.
Board type: OpenBCI Cyton (v3 API)
Traceback (most recent call last):
File "user.py", line 62, in <module>
from openbci import cyton as bci
File "/Users/sashaschtein/bci/OpenBCI_Python/openbci/__init__.py", line 3, in <module>
from .ganglion import OpenBCIGanglion
File "/Users/sashaschtein/bci/OpenBCI_Python/openbci/ganglion.py", line 26, in <module>
from bluepy.btle import Scanner, DefaultDelegate, Peripheral
ImportError: No module named bluepy.btle
Upon some inspection, the first problem I noted right off the bat was that the board type was incorrect. My team and I purchased a Ganglion motherboard, while the user.py file was programmed in such a way that defaulted to a Cyton motherboard. After opening the user.py file and scanning through complex code that seemed far too advanced for me, I eventually found how this runtime error could be fixed: changing to a ganglion board by running (python user.py -- board ganglion). This, however, was a wasted effort, as the real error (compilation error) was not in the board type, but in the lacking bluepy.btle library, a library that my laptop did not possess. (ImportError: No module named bluepy.btle)
The task now was to install bluepy.btle.
Installing bluepy using pip (sudo pip install bluepy) produced quite a few errors. In order to even begin compilation of bluepy, another class, bluepyhelper, needed to compile first. On top of this, bluepyhelper was dependent on glib, endian, and byteswap system softwares. As if things couldn’t get more difficult, my MacOS did not have any of those libraries, so the new task was now to simply download and install the dependencies. Right? This task however was anything but simple. Even if these libraries are downloaded, the bluepy Makefile required access to these directories when compiling bluepyhelper (and ultimately bluepy). Yet again, I downloaded the bluepy directory and placed it the bci directory I created earlier:
git clone https://github.com/IanHarvey/bluepy.git
Now that the bluepy directory was downloaded, the missing libraries could be linked, and bluepy Makefile could point to their .h files. A certain installation platform, homebrew was required for these library installations.
/usr/bin/ruby -e "$(curl -fsSL