The story of how was created the Brain-computer interface (Open-source DIY)

Ildarr
Nerd For Tech
Published in
9 min readFeb 15, 2022

--

PiEEG low-cost brain computer interface https://pieeg.com/

Abbreviation
BCI Brain-computer interface
EEG Electroencephalogram
SBC Single-board computer
ADC Analog-digital converter

My name is Ildar, I am an electronic researcher and developer. Our idea of creating a low-cost Brain-Computer interface appeared two years ago in one of the scientific conferences in Tokyo, during one of the futuristic conversations, even before the events of the pandemic. The idea was naive and simple — we wanted to control robots with the power of thought with the motor imagery method. (https://en.wikipedia.org/wiki/Motor_imagery)

Since I was the only electrician in the company, I took up this activity myself. Initially, I planned to take the most available device on the market, it seemed to me, should be something very simple and affordable, something like Arduino. Finally, what was on the market did not suit me, for the most part — the price, and in fact, there are not so many devices for open-source developers.

Very briefly, what is BCI. The BCI measures EEG signals from the surface of the head, these are signals in microvolts divided into several frequency ranges (Alpha — 8–13 Hz, Beta — 14–40 Hz, Theta — 4–8 Hz, Delta is 0.5–3 Hz, Gamma is above 40 Hz). These frequency ranges can provide some information about the subject. It sounds simple, but there are a couple of nuances, in addition to a well-designed board, signal quality is significantly affected by the next factors:
- any physical activity (artifacts);
- electromagnetic interference;
- the quality of electrode connections, and indeed everything, really everything.
EEG signals are measured through electrodes [1, 2021], we choose dry electrodes because they are easier to use (ideally, the gel is not needed, but in fact, it is better with the gel). But even after all this, received EEG signals will still not be suitable for receiving any useful information. The next step is signal processing, which is an attempt to find useful correlations in the EEG signals and remove other noise. And this is a huge topic! and in fact, if there is magic (or where it is needed), then it is here. There are a lot of methods, and they are very diverse, we wrote the following review papers on this topic:
- neural processing ([2, 2021]);
-feature selection ([3, 2020]).
And I’m still working in this direction.
And now closer to the point, this note is about the hardware for BCI. I write briefly and simply, who needs the details, all sources are in the public domain, and I will be very glad to receive your comments.

At first, doubts, but is it possible? without any experience in neurosciences, take and develop BCI. To understand this, I read a lot read. To begin, what is simpler: — medium, forums, upon keywords- all kinds of different variations with BCI. Next, I studied everything that could find in knows for me libraries — scholar.google, researchgate, Elsevier, Taylor and Francis, Springer, etc. I understand that many people don’t have admission to not open-access articles, this is a painful topic for many researchers, especially aggravated after the very sad events in Massachusetts in 2013 years. Only, we have what we have, scientists publish in private access not because they want to hide their research from prying eyes or make money, but because, simply, there was simply no sponsor for publication. You can argue that there are preprints (Arxiv for example), I agree, only for a scientific career — the publication rating is important, we can talk about it long, but it is necessary to talk. If the article is not in open access, then write to the authors, ask questions, never be shy, this is a normal process, for the most part, the authors are glad that there is interest in their work. My reading process took 1 month, several hours a day — but it’s worth it because allows me to understand what is on the market, what the market needs, what are the prospects, areas of research, etc. it is better to spend time than to reinvent the wheel. In general, market research gave me the belief that yes, we must do it, especially in an open-source format.

How we developed — the brain-computer interface
The heart of the BCI is the ADC — and the weakest point of the device is the part between the electrode and an ADC — this analog signal in µV — which is only happy to collect all the possible noise that only it can find. After digitizing the signal, standard operations are already underway — this is a band-pass filter ( I used 1–30 Hz), any language will help you — I implemented it in Python. ADC in the market are not so much, especially for neuroscience tasks — Texas tool and analog device. We chose ADS 1299 from Texas Instruments.

Attempt 1 (1 March 2020)
In the first attempt, I assembled the circuit on a breadboard, all elements were selected with minimal noise. As expected, it all looked terrible. Well, nevertheless, I could communicate with the ADS, studied the registers, but as expected, the amount of noise did not let me understand, it is an EEG signal or not.

Attempt 1 — ironbci

Attempt 2 (8 October 2020)
Already better, I made a PCB board, and success, the board worked. It was able to read the EEG signal, detect the main artifacts. But the size of the board was too huge, in this version were used Wi-Fi, Bluetooth, radio, serial port, and an SD card for data transfer. The main thing for me was that the device worked, and the design was correct [4, 2020].

Attempt 2 — ironbci

Attempt 3 (1 January 2021)
The same design with reduced form. The device worked — but since we had a sandwich, I still can’t reliably connect the boards to each other, it would seem a simple part, but I spent a lot of time looking for the necessary pins since the SPI connection between the MK and the ADC was constantly lost.

Attempt 3 — ironbci

Attempt 4 (7 April 2021)
Considering all the mistakes of the last year was created the final device — ironbci.

Attempt 4 — ironbci

Used the next microcontroller — STM32F406VE. The MK is not particularly involved in computing capabilities in this project and was chosen depending on the periphery (SPI). [5, 2021].

ironbci project details
GitHub (electrical scheme, Gerber files, BOM files, hex. file, etc.)
Youtube https://youtu.be/y1O7FNJLeh4 Demonstration of artifacts (chewing and blinking) on STM32F407 and ADS1299
Youtube https://youtu.be/kfbvYXvBCJk Iron BCI hardware — disassembly process

One of the main ideas was to use a board with additional sensors, among startups, the so-called “killer feature” — but for me, the task is to remove all artifacts from EEG signals. The task is to record EEG signals in everyday life and, use a set of sensors to control and neutralize artifacts in EEG signals. [6, 2021]. The idea has not yet been implemented, more data is needed.

ironbci — sensor board
ironbci — sensor board scheme

But the idea is very good, and hope to continue to work on it.

Everything seemed perfect. But the chip shortage happened. As result, the self-cost of our device has skyrocketed from $100 to $600 (and that’s just for 8 electrodes). But the good news is that I made this project not just open, but as open as possible and provided a video instruction for self-ordering this device on PCBWAY (it seemed to me that the source code would be enough, but I received too many questions about “how DIY” and realized that a full explanation is better). Everyone can order this device himself, for this you do not need to have experience in electronics, etc.
Do it yourself, full instructions on how to create this device in the pcbway factory

But I didn’t really want to quit this activity, after so much research. And that’s why decided that the easiest way is to take only an ADC board from an ironbci device and use it as a shield for a single board computer.

Attempt 5 (16 October 2021)
Now, we came to PIEEG shied that convert Raspberry Pi to BCI [7, 2022]. Raspberry was chosen only because it is the most popular single-board computer in the market. Data exchange between Raspberry and the board was implemented in C (transfer speed is important)

and real-time data processing in python since python is one of the most popular languages in data science.

Attempt 5 — PIEEG

The main application that we see in this is the control of robotic devices, the possibility for an application depends on the imagination and capabilities of the user. (8, 2022)

The script through blinking was presented in GitHub, where the signal is decomposed through a fast Fourier transform and then, in each frequency range, we detect the amplitude signaling blinking. This video details how to control a robot in real-time with this device

In the picture, it looks like this

PIEEG scheme

Of course, today it is possible to reliably control a robot only with invasive interfaces, and this device is not for real application. Our goal is to provide an opportunity to study the mechanisms for controlling robots through EEG signals. Machine learning is a revolution in the field of data processing that happened only a few years ago, so the availability of a dataset can allow many new things to be done in this field.

If it is possible to control the robot through the motor imagery method, then the only thing holding us back is the lack of a dataset. The possibility of using non-invasive methods to control mechanical limbs will be a revolutionary event in the field of neuroscience.

In general, I very briefly described the development process, according to your comments, as necessary, I will write in more detail. Your ideas are welcome, write) This project was not funded by anyone, it was done in free time from work and all sources are in open access, so judge strictly (not a typo)

Today we are in the process of applying for crowdsupply for PIEEG

we are doing this to create a community, collect a dataset, I hope together we can make significant progress in this direction.

It’s hard to write about everything — at every stage, I made mistakes, I solved problems every day, but it’s true, it’s normal.

Well, and a bit of ideology — open source is not only altruism (although even this argument is already enough, the technology, especially biotechnologies, should be aimed not at enrichment. One can argue, but there are a lot of ingenious people for whom this was taken for granted), the main is a way to create something really good, feedback works wonders, criticism is very useful.

I honestly came into the world of EEG to control mechanical limbs through a non-invasive method, accessible and simple. It hasn’t worked out yet, but it’s a step on the way to it.

PiEEG low-cost brain computer interface https://pieeg.com/

Linkedin https://www.linkedin.com/in/ildar-rakhmatulin-262a66112/

Reference
1. Rakhmatulin, I.; Gan, Y. (2021). Review Dry and Non-Contact EEG Electrodes for 2010–2021 Years. Preprints, 2021030555 (doi: 10.20944/preprints202103.0555.v1). https://www.preprints.org/manuscript/202103.0555/v1
2. Rakhmatulin, I. (2021). Progress in neural networks for EEG signal recognition in 2021. arXiv:2103.15755, https://arxiv.org/abs/2103.15755
3. Rakhmatulin, I. (2020). Review of EEG feature selection by neural networks, DOI: 10.5281/zenodo.3987894
4. Rakhmatulin, I. (2020). The electronic board to replace the reference voltage on the earlobe for EEG measurement, Measurement, 173, 108673 https://www.sciencedirect.com/science/article/abs/pii/S0263224120311854?via%3Dihub
5. Rakhmatulin, I., Parfenov, A., Traylor, Z. et al. (2021). Low-cost brain computer interface for everyday use. Exp Brain Res 239, 3573–3583 https://doi.org/10.1007/s00221-021-06231-4
6. Rakhmatulin, I. (2022). ironbci. Open source. Brain-computer interface with the embedded board to monitor the physiological subject’s condition and environmental parameters. arXiv:2111.03656
.

--

--