How to Build Brain-Computer Interfaces:

How to Build Brain-Computer Interfaces: The Neurable Toolkit

Dr. Davide Valeriani, Senior Machine Learning Engineer
Knowledge

Building Brain-Computer Interfaces (BCIs) requires key interdisciplinary skills, including neuroscience to understand the brain and form robust hypotheses, signal processing to clean the neural recordings you capture with electroencephalography (EEG) sensors, and machine learning to transform these signals into meaningful insights and metrics. Therefore, it is critical to leverage on progress made across these three domains to really innovate and deliver the next-generation BCI.

Throughout the years, Neurable’s team has assembled a list of tools that we now use on a daily basis to test our hypotheses, develop and validate our algorithms, visualize and discuss the results at scientific meetings, and make sure we build a sustainable and scalable BCI infrastructure. This “Neurable toolkit” allows us to iterate quickly and deliver robust algorithms while ensuring the reliability and repeatability"

Python is at the heart of Neurable R&D

Our core scientific and machine learning infrastructure is built in Python, the most popular programming language in data science. It is easy to learn, very powerful, and with a myriad of external libraries and tools to satisfy all sorts of computer science needs. In particular, we make extensive use of pandas to organize and analyze our data, numpy and scipy to perform heavy mathematical operations, matplotlib and seaborn for visualization. But how do we transform raw EEG data into meaningful brain insights? Our secret sauce is based on two key libraries: mne, for preprocessing and extracting relevant information from brain signals, and scikit-learn, for developing machine learning models to transform cleaned EEG data into our measurements of focus and attention. We also extensively use keras for more advanced machine learning algorithms, such as deep neural networks. Based on all these libraries, we build our own Python packages that facilitate our daily work. For example, we have an internal library called data_utils that allows us to safely download the EEG data we collected from our central repository, preprocess them, extract features, and validate them… all with one library. In our central repository, data are stored anonymously and are encrypted, to guarantee privacy and security. Another Python package we built allows us to perform standard statistical analysis and graphics for neuroscience applications, which we plan to release as open-source software in the future.

Machine learning operations (MLOps)

To ensure our infrastructure is robust and scalable, we use additional tools on top of Python that allow us to track the lifecycle of all our algorithms, from investigation to deployment and monitoring. In particular, we use MLflow to record the parameters and details of every model we develop, to ensure our results are fully reproducible, as well as the evaluation metrics that help us accelerate the decisions on which models should we move to production.

Where to get started

If you are a BCI enthusiast like us but feel a bit lost on where to learn more, there are some amazing tools we recommend you check out. First and foremost, join our discord where you will get to interact with the Neurable community about BCIs and wearable neurotechnology. NeuroTechX, another community that many of us contribute to, also has an educational website (NeurotechEDU) where you can find tutorials and datasets to start your BCI projects. Other datasets for BCI applications are available at BNCI. If you want to learn Python, we highly recommend this book, which is also freely available in PDF format. If you prefer a more practical approach, there are a number of online classes you can take on platforms like Coursera or Udemy. This article focused on tools Neurable uses. If you want to know more about the science, check out our white paper.


Author(s)
Dr. Davide Valeriani, Senior Machine Learning Engineer
In: KnowledgeNovember 4, 2021