Geek Culture

A new tech publication by Start it up (https://medium.com/swlh).

Understanding Brain-Computer Interfaces with Python

Adam Gulamhusein
Geek Culture
Published in
12 min readAug 4, 2021

--

A technical approach to understanding BCIs

Image by the author of source estimation using sample data.

Something about the brain evokes intrigue from almost anyone who views it; it is both ambiguous in its intricacy and specific in its action. Further, the sophistication of the brain demands a level of ingenuity and creativity when studying it.

In my previous article, An Introduction to Brain-Computer Interfaces¹, I have detailed some of the complexities of the brain and the associated neurotechnologies. These complexities can be difficult to understand, but certain tools allow almost anyone to be able to work with neuroimaging data and replicate scientific experiments².

The MNE-Python³ module is an open-source python package used for viewing neurophysiological tools. It is one of the only accessible tools that allow for online sample data of EEG, ECoG, MEG, and other acquisition methods to be viewed, manipulated, and analyzed. This library is extremely helpful in visualizing many of the steps used in various BCI systems and better understand this emerging technology. This article will cover the capabilities of MNE and working with sample datasets to test some of these capabilities.

MNE Breakdown

1. Importing Modules

For those who are more experienced, you will probably be familiar with Jupyter Labs and Anaconda which is what you should work with when using MNE. Downloading Anaconda and then installing MNE will allow you to use Jupyter Labs on localhost and will greatly speed up the programming process. When running your program in Jupyter Labs, you can break up your code into blocks that can be independently run; this is much more convenient than typical IDEs.

However, once your program is finished, you can move it to an IDE of your choice (ensure to install MNE in your venv if you’re using one) and run the program. When I did this, I did run into a few issues that were mostly resolved with downloading and importing a few different modules.

import matplotlib
import matplotlib.pyplot as plt
import PyQt5
import pathlib
import mne
import mne_bids
from mne.datasets import sample
import picard
from surfer import Brain
import sobol_seq

import os.path
import os.path as op
from os import path

from…

--

--

Adam Gulamhusein
Adam Gulamhusein

Written by Adam Gulamhusein

TEDx Speaker | HYRS Alum (Neurosurgical RA) | TKS Student | SHAD Alum | 2021 Calgary Brain Bee Winner

No responses yet