avatarTim de Boer

Summarize

The Building Blocks Of A Brain Computer Interface

A Beginner’s Guide to Brain-Computer Interfaces (part 1)

Building your own EEG brain-computer interface (BCI) is an exciting journey! Being able to connect your own brain to a computer really does sound awesome, doesn’t it? However, along a BCI-journey one can encounter a lot of hick-ups, problems, and maybe some disappointing results. Eventually, one realizes that the BCI-field is big. Really big. One could get discouraged and may even quit. So, how does one possibly learn all the necessary steps to succeed with their BCI-project, and not get discouraged?

Luckily, all the information to build a state-of-the-art BCI is available online. Finding this information however, can take a lot of time. If I look at my own first bedroom-BCI project, I realize I still had a lot to learn back then…

Now, after I just finished a 6 month research internship in EEG BCIs for motor imagery, I can say that I indeed have encountered a lot of problems, hick-ups, and disappointing results, but learned a lot from them as well and got some cool results in the end! I for sure am not anywhere near to an expert, but I think I am able to share these problems and give some practical advice about them!

And so, in an attempt to help other BCI enthusiasts, I have been writing down all the practical advice and information I have encountered in the last 6 months of working with EEG BCIs. In this series of blog posts, I will share each piece of advice I have encountered and bundle them all in one place here on Medium. These posts often include code examples, so you can directly use these tips to build your bedroom-BCI better, and faster than me!

To kick off this series, I will give an overview of the general steps of a BCI-pipeline. Next weeks, we will go more in depth in each of these steps!

Quick disclaimer: this series of blog posts is meant for an audience who already are a little bit more advanced in their knowledge of BCIs. If you are completely new to the field of BCIs, please check out my series of blog posts describing my first bedroom-BCI project to get started!

The BCI-cycle

Figure 1: The BCI cycle.

The BCI cycle consist of 6 general steps: the user, data collection, pre-processing, feature extraction, prediction, and the output of the system. Let’s go over each step.

The user

Of course, a BCI cannot exist without a user. Here, the user performs a certain mental task, resulting in brain activity in certain areas. Commonly used mental tasks to classify are motor imagery, emotion recognition, seizure detection, and event related potential detection. Below, some examples of each field is given together with their potential application.

Motor imagery: Detecting motor imagery of the left arm versus the right arm. This can be used to control a robotic arm of a paralyzed user, giving some functionality of their body back to the person.

Emotion recognition: Detection of depression. Depression can be treated with psychotherapy or medical prescription, however due to social pressure and other factors, it often goes undiagnosed.

Seizure detection: Prediction of a periods of seizure. The eventual application here is detecting upcoming seizures before onset.

Event related potential detection: In these tasks, a subject watches a rapid sequence of pictures or letters with the aim of focusing attention on specific indicators. Once a specific letter or image appears, a stereotypical response is seen in the data. Detection of this response is used to build non-verbal communication systems.

Data collection

When a user is performing a task, we need to collect their brain activity data. In this series, we focus on electroencephalography (EEG). Here, electrodes are placed on top of your scalp, measuring electrical activity originating from brain cells in the area beneath the electrode. Other methods of measuring brain activity exist as well, which I describe in my earlier series of blog posts.

Figure 2: An example of a EEG headset (left) and EEG signals (right).

Correct data collection may be the most important step in the BCI cycle. Not having the correct equipment can make it impossible to achieve your project goals. In later blog posts, I will explain how to choose the correct device for your goals.

Pre-processing

After data is collected, pre-processing is needed. Loads of factors influence the EEG signal, and add a lot of noise to the signal. General steps in pre-processing consist of power line noise removal (noise from other electronic devices), artifact detection, and re-referencing of the signal. These topics will be discussed in future blog posts as well.

Feature extraction

Brain activity occurs in differing amplitude (the maximum displacement of the signal) and frequency (the number of waves passing by per second). Different frequency bands correspond with different mental states, as brain activity in specific frequency intervals were found to be predominant over the other frequency intervals. This resulted in the distinction presented in Figure 3 below. To extract features in frequency bands relevant for your tasks, frequency filtering needs to be applied.

Figure 3: Brainwaves classified in 5 categories with corresponding mental states. Image copied from Muse.

An EEG device is placed on your scalp, and measures your brain activity with typically 4 to 32 electrodes. The device is relatively far from your brain, and by only having a limited amount of electrodes, the relevant brain signals can be spread around several EEG channels. A spatial filter combines information of EEG signals from several channels, trying to recover the original signal by gathering the relevant information from the different channels.

Both frequency filtering as spatial filtering will be touched upon in future blog posts!

Prediction

After feature extraction, we arrive at predictions. This is were machine learning models come into play, which try to distinguish the data into the classes (a.k.a., the mental states).

Output

For an online BCI system, prediction is not the last step! In an online BCI system, the prediction is used to control some external device. Think of a robotic arm for motor imagery, or the non-verbal communication system used with event-related potential detection.

It is important to note that this output in turn influences thought and goals of the user, completing the cycle. A user may have finished picking up an object with the robotic arm, and now needs to change direction. Or think of moving the robotic arm into the wrong direction; this needs to be corrected, or can cause frustration of the user, which also changes the brain signals!

One can imagine that having an online BCI gives more potential problems. But these problems make building such a system super exciting! In this series, we will eventually build towards such an online BCI system, and we will hopefully succeed!

Recap

Now we know all the steps in the BCI cycle, we are ready to delve into detail in each element of the cycle! Future blog posts will cover each element and more, including loads of code examples to get you working on your BCI project as soon as possible.

If you liked this post, please consider following me, and look into this publication to stay notified for future posts, or read part 2 here!

Brain Computer Interface
Machine Learning
Eeg
Recommended from ReadMedium