PreprintPDF Available

PIEEG: Turn a Raspberry Pi into a Brain-Computer-Interface to measure biosignals. arXiv:2201.02228

Authors:
Preprints and early-stage research may not have been peer reviewed yet.

Abstract

This paper presents an inexpensive, high-precision, but at the same time, easy-to-maintain PIEEG board to convert a RaspberryPI to a Brain-computer interface. This shield allows measuring and processing eight real-time EEG(Electroencephalography) signals. We used the most popular programming languages-C, C++ and Python to read the signals, recorded by the device. The process of reading EEG signals was demonstrated as completely and clearly as possible. This device can be easily used for machine learning enthusiasts to create projects for controlling robots and mechanical limbs using the power of thought. We will post use cases on GitHub (https://github.com/Ildaron/EEGwithRaspberryPI) for controlling a robotic machine, unmanned aerial vehicle, and more just using the power of thought.
PIEEG: Turn a Raspberry Pi into a Brain-Computer-Interface to measure biosignals
Ildar Rakhmatulin* – PhD electronic researcher
Sebastian Völkl - Brain-Computer-Interface developer
Abstract
This paper presents an inexpensive, high-precision, but at the same time, easy-to-maintain PIEEG
board to convert a RaspberryPI to a Brain-computer interface. This shield allows measuring and
processing eight real-time EEG(Electroencephalography) signals. We used the most popular
programming languages - C, C++ and Python to read the signals, recorded by the device . The process
of reading EEG signals was demonstrated as completely and clearly as possible. This device can be
easily used for machine learning enthusiasts to create projects for controlling robots and mechanical
limbs using the power of thought. We will post use cases on GitHub
(https://github.com/Ildaron/EEGwithRaspberryPI) for controlling a robotic machine, unmanned aerial
vehicle, and more just using the power of thought.
Source - https://github.com/Ildaron/EEGwithRaspberryPI
Web-Site - https://www.hackerbci.com/
Slack - pieeg.slack.com
License - GNU General Public License v3.0
*email: ildarr2016@gmail.com
keywords: PIEEG, ironbci, hackerbci, raspberryPi, EEG, brain-computer interface
Abbreviation
BCI Brain-computer interface
EEG Electroencephalogram
SBC Single-board computer
IC Integrated circuit
ADC Analog digital converter
1. Introduction
The popularity of BCI’s has increased significantly in recent years, making neuroscience more
accessible to scientists and engineers from various fields of activity. Neuroscience in particular has not
stood aside, and today machine learning is widely used to determine the relationship between thoughts
and EEG. We believe that the relationship between machine learning and neuroscience will only grow
as the scope of BCI expands significantly. Today BCI’s are actively used not only for medical
purposes [1, 2020] but also in many other industries, such as videogames [2, 2020], and this direction
is auspicious because it’s one of the fastest-growing [3, 2016]. As for other fields, Vo et al [4, 2019]
and Rakhmatulin [5, 2020] have providedan overview of the possibilities of machine learning and
EEG and described the prospects in this area quite favorably.
In recent years, many devices were introduced to the market as low-cost devices, but their prices also
usually started from a thousand dollars.At the same time, there is a problem in evaluating the quality
of the proposed devices on the market. In the review paper, Rashid et al. [6, 2020] showed that BCI
developers use different evaluation metrics to confirm the effectiveness of the developed devices,
which complicates the analysis of these BCIs. To avoid this problem, in addition to the technical
features, we presented the results of the experiments as completely as possible on the GitHub page
and uploaded the datasets for different cases.
In recent years, the activity on the BСI market has inspired optimism and gave reason to hope that
BCI may soon can become an everyday means of human-computer interaction. However the positive
start in the field of BCI hardware was interrupted by chip shortage [7, 2021], which complicated the
production process, drove up the cost of ICs and made them scarce. Therefore, it has become
expensive to develop full-fledged devices [8, 2021]. For this reason, we have developed an
Open-Source board that is designed to convert a RaspberryPI to a Brain-computer interface. We made
a shield because it reduced the number of ICs on the board and increased reliability. We chose the
RaspberryPi, mainly because it is the most popular SBC on the market [9, 2017]. It should also be
noted that one of the limiting factors for the widespread use of BCI is the difficulty in reading EEG
signals, as they are susceptible to electromagnetic, motion, and other types of noise. [10, 2021].
Therefore, signal processing by software is just as important as the hardware component of the BCI.
We have developed an open-source software where data collection takes place in С, which is
necessary for high speed, and signal processing in real-time by Python. We chose Python because it is
one of the most popular languages in data science [11, 2015] with many forums and documentation.
1.1 Review the paper
The following papers presented devices which in their characteristics are close to our device. Tyler et
al. [12, 2015] presented a board for measuring biosignals. The authors didn't provide information
about the component manufacturer, PCB layout, or PCB specifications. For these reasons, it is very
difficult to judge the potential of the device. Uktveris et al [13, 2018] developed a board for reading
biosignals with ADC ADS1299. The board presented in their work is aimed at the Arduino market as
a shield for the MEGA2560 models. Therefore, this board is only a transmitter, and signal processing
must be done on a computer. As for the combination of single-board computers and an ADC for
reading bio signals, we did not find similar devices among the published works. We found the most
similar project in GitHub (https://github.com/wjcroft/RaspberryPiADS1299)- but the publication on
this work is not presented, so it is very difficult to understand the quality of the received EEG signal.
For example, it is not clear whether voltage regulators were used, without which the ADS 1299 would
not be able to provide a clean EEG signal. We also did not find software for signal processing. The
development of the hardware part is an applied science and from the engineering point of view,
Gerber files, BOM files, and electrical circuits are needed to confirm the experiments.. Many works
are stated as open sources, but the authors did not indicate the source, so their statements about the
openness of the sources can be considered advertising. As for the SBCs for reading signals, we found
papers where SBCs were at best used as transmitters for sending data to a desktop computer [14,
2016], [15, 2021], but the capabilities of the SBC are greater than just being a transmitter. For these
reasons, we developed a shield that receives data and transmits it to the RaspberryPi, and we have
written software that processes data in real-time on RaspberryPi. Thus, we can say that the
RaspberryPi has become a BCI. A general view of the device showed in fig. 1.
Fig.1. General view of the device
The possibilities of the device are very extensive and largely depend on the user how he wants to use
this device. To start the measurement process, electrodes must be connected to a device that reads
data, processes received signals and controls external devices, fig.2.
Fig. 2. Schematic representation of the use of the device
This device can be used as a shield for OrangePI (http://www.orangepi.org/), BananaPI
(https://www.banana-pi.org/), and some other single-boards computers, for this just need to make a
match on GPIO40.
2. Technical details
Table 1 lists the main technical data of the device
Table 1. PIEEG characteristic
Description
Characteristics
1
Channels
8 channels for connecting electrodes, 1 channel for connecting a
reference, and 1 channel for connecting a bias signal, with
common-mode noise suppression
2
Protocol
Data transfer via SPI with a frequency from 250 SPS to 16 kSPS
3
Resolution
24 bits
4
Gain signal
1, 2, 4, 6, 8, 12, 24
5
Impedance
Control connections
6
Common-Mode
Rejection Ratio
CMRR
120
7
Internal noise
0.4 μV
8
External noise
0.8 μV
9
Noise/Ration SNR
130 dB
10
Indication status
Of power and live bits for ADS1299
11
User switch
3
The free 33 PIN from RaspberryPI GPIO40 can be used for user tasks, for example - connecting any
external devices.
For the measurement process, the PIEEG should be connected to the Raspberry PI3 or RaspberryPI4.
Then the device must be connected to a battery (power supply) and linked to the electrodes. Full
galvanic isolation from the mains required. This also applies to the monitor. Only use a monitor
that is powered by the same battery as and for the RaspberryPI, as in the fig.3-a. Electrodes should be
positioned according to International 10-20 system, fig.3-b. As electrodes we used dry electrodes, the
advantages of which are described in this article [16, 2021].
a b
Fig. 3. Assembled device. Screen, battery, cap and 8 electrolytes connected by according to
International 10-20 system -a, location of electrodes - b
3. Software
Today many signals processing software, both commercial and non-commercial can be used for signal
processing tasks. The following open source programs are on the market: Brainstorm
(https://neuroimage.usc.edu/brainstorm/Introduction), TAPEEG (https://sites.google.com/site/tapeeg/),
sLORETA (https://neurofeedbackalliance.org/sloreta/), Brainflow (https://brainflow.org/), Timeflux
(https://timeflux.io/). But it is worth noting, that the software review is just as complicated by the lack
of any comparison criteria as for the hardware, as we wrote earlier. At the same time, we do not share
the policy in which the authors of the hardware part need to add their devices to the software. Since
this policy increases the size of the software and the compilation time,t is much easier to make and
maintain a simple and understandable protocol for data transfer. For example, in our case, for the data
to the software is transmitted by an array for 8 channels, fig.4.
Fig. 4. Example of data transfer from device to software
The software should be as clear and simple as possible. When changing the code and using external
libraries, it is important to have as little compilation effort as possible. We did not find any suitable
software and developed our own software. Software details can be found on the GitHub page
https://github.com/Ildaron/EEGwithRaspberryPI/tree/master/GUI
4. Technical tests
In addition to the technical details presented in Table 1, we made a typical check of the device for
artifacts. The chewing artifact is one of the most pronounced artifacts, Wei, et al. [17, 2016] described
this artifact in detail in the EEG signals. Unlike chewing, blinking artifact [18, 2009] is quite often
used to control external objects, for example, to control electric wheelchairs [19, 2010]. For PIEEG
chewing and blinking artifacts detection in real-time presented in fig.5.
Fig.5. Chewing and blinking with EEG signal on PIEEG (real-time)
Band–pass filter with 1-30 Hz for the same data (not real-time) in fig. 8.
Fig. 6. Pass filter with 1-30 Hz for artifact and blinking
Alpha rhythm of alpha waves is the rhythmic activity of the EEG, recorded in the primary with open
or closed eyes at rest in 85-95%. This phenomenon is well studied and described in many works [20,
2019]. The alpha wave detection process shown in fig. 9.
Fig.7. Alpha waves detection in EEG signal without low-pass filter
Conclusion and discussion
This is currently one of the easiest devices to use for reading and processing biosignals. This board is
especially useful for researchers who set goals for controlling external objects, mechanical limbs
through blinking, paradigms, and the image motor, and more. We will update the site, upload datasets
and continue to improve the software and will publish cases on the use of this device to control
robotic objects.
In the next version of the hardware, we will consider the possibility of installing gyroscopes and
accelerometers to control the position of the object and add shields to protect against external
electromagnetic interference.
During the development, we largely followed the interests of the user, specially choosing the most
popular tools for signal processing. In the future, we plan to provide this function in the software for
detecting the paradigms P300 and SSVEP. These paradigms are currently one of the most popular
tools for controlling external objects using the power of thought. Our final task is to control a
mechanical limb by motor imagery methods, which has not yet been fully realized through
non-invasive methods. This method is the most natural and therefore the achievement of a positive
result in this area will significantly improve the position of BCI in the world of neurobiology.
Conflicts of Interest: None
Funding: None
Ethical Approval: Not required
References
1. Rakhmatulin, I. (2020). Deep learning and machine learning for EEG signal processing on the
example of recognizing the disease of alcoholism. https://doi.org/10.1101/2021.06.02.21258251
2. Alakus, T., Gonen, M., & Turkogly, I. (2020). Database for an emotion recognition system based on
EEG signals and various computer games – GAMEEMO. Biomedical Signal Processing and Control,
60, 101951. https://doi.org/10.1016/j.bspc.2020.101951
3. Gatzoulis, C., Loizides, F., & Zaphiris, P. (2016). Planning for Computer Games Research and
Industry: A Structured Dialogue Design Approach. Comput Game. 5, 95–114.
https://doi.org/10.1007/s40869-016-0019-y
4. Vo, H., Dang, L., Nguyen, I,. & Huynh, V. (2019). A Survey of Machine Learning algorithms in
EEG," 2019 6th NAFOSTED Conference on Information and Computer Science (NICS), 500-505.
doi: 10.1109/NICS48868.2019.9023884
5. Rakhmatulin, I. (2020). Review of EEG Feature Selection by Neural Networks. Int. J. Sci. Bus.
2020, 4, 101–112. http://dx.doi.org/10.2139/ssrn.3675950
6. Rashid, M., et al. (2020). Current Status, Challenges, and Possible Solutions of EEG-Based
Brain-Computer Interface: A Comprehensive Review. Front. Neurorobot.
https://doi.org/10.3389/fnbot.2020.00025
7. Sparkes, M. (2021). When the chips are down. New Scientist, 251, 3351, 42-46.
https://doi.org/10.1016/S0262-4079(21)01611-0
8. Rakhmatulin, I. (2021). The electronic board to replace the reference voltage on the earlobe for
EEG measurement. Measurement, 173, 108673. https://doi.org/10.1016/j.measurement.2020.108673
9. Ray, S., Dhaheri, A. (2017). Using Single Board Computers in University Education. Recent
Advances in Information Systems and Technologies. Advances in Intelligent Systems and Computing,
571. https://doi.org/10.1007/978-3-319-56541-5_38
10. Mumtaz, W., Rasheed, S., & Irfan, A. (2021). Review of challenges associated with the EEG
artifact removal methods. Biomedical Signal Processing and Control, 68, 102741.
https://doi.org/10.1016/j.bspc.2021.102741
11. Chollet, F., & others. (2015). Keras. Available at: https://github.com/fchollet/keras
12. Tyler. S., Leibbrandt, S., & Fitzgibbon, S. (2015). Measurement of neural signals from
inexpensive, wireless and dry EEG systems. Physiol Meas. 36(7), 1469–1484
13. Uktveris, T., Jusas, V. (2018). Development of a modular board for EEG signal acquisition.
Sensors. 18, 2140
14. Tejwani, K., Vadodariya, J., & Panchal, D. (2016). Biomedical Signal Detection using Raspberry
Pi and Emotiv EPOC. 3rd International Conference on Multidisciplinary Research & Practice, 6, 1,
ISSN 2321-2705
15. Ali, H., et al. (2021). EEG-based Brain Computer Interface Prosthetic Hand using Raspberry Pi 4.
(IJACSA) International Journal of Advanced Computer Science and Applications, 12, 9
16. Rakhmatulin, I., & Gan, Y. (2021). Review Dry and Non-Contact EEG Electrodes for 2010-2021
Years. Preprints, 2021030555 .doi: 10.20944/preprints202103.0555.v1
17. Wei, Z., Zou, J., & Zhang, J. (2016). Automatic recognition of chewing noises in epileptic EEG
based on period segmentation. Neurocomputing. 190, 107-116
18. Babusiak, B., & Gála, M. (2009). The eye-blinking artifacts detection and elimination in the EEG
record. IFAC Proceedings. 42, 1, 254-259. https://doi.org/10.3182/20090210-3-CZ-4002.00051
19. Lin, J., Chen, K., & Yang, W. (2010). EEG and eye-blinking signals through a Brain-Computer
Interface based control for electric wheelchairs with wireless scheme," 4th International Conference
on New Trends in Information Science and Service Science, 731-734
20. Seco, G., et al. (2019). EEG alpha rhythm detection on a portable device. Biomedical Signal
Processing and Control, 52, 97-102.https://doi.org/10.1016/j.bspc.2019.03.014
ResearchGate has not been able to resolve any citations for this publication.
Full-text available
Article
Brain-Computer Interface (BCI), in essence, aims at controlling different assistive devices through the utilization of brain waves. It is worth noting that the application of BCI is not limited to medical applications, and hence, the research in this field has gained due attention. Moreover, the significant number of related publications over the past two decades further indicates the consistent improvements and breakthroughs that have been made in this particular field. Nonetheless, it is also worth mentioning that with these improvements, new challenges are constantly discovered. This article provides a comprehensive review of the state-of-the-art of a complete BCI system. First, a brief overview of electroencephalogram (EEG)-based BCI systems is given. Secondly, a considerable number of popular BCI applications are reviewed in terms of electrophysiological control signals, feature extraction, classification algorithms, and performance evaluation metrics. Finally, the challenges to the recent BCI systems are discussed, and possible solutions to mitigate the issues are recommended.
Article
A new way of designing computer chips could be about to shake up one of the world's most secretive industries, says Matthew Sparkes
Article
An unstable reference point is a critical problem for electroencephalography (EEG) research since its instability introduces a significant distortion into the interpretation of the EEG signal. The main requirement for a reference point-electric potential should be unchanged. This is extremely difficult to implement in practice, due to biological processes occurring in the human body. Unlike other artifacts (network noise, electrical noise, blinking) that can be solved both by using analog circuitry (bandpass filters for noise, etc.) and by using various mathematical methods (method of head components for eye blink, etc.), a change in the potential of the reference point during the EEG measurement will be present in any case. Today, for a reference point an earlobe and overall average referential reference are used. The problems of using these methods are described in many works. In this manuscript, we propose a new method of using the reference point, electric potential which is generated by a 24-bit digital-to-analog converter (DAC). At the initial stage, a 24-bit analog-to-digital converter (ADC) reads the potential between the earlobes, and then on the STM 32 microcontroller through the DAC it generates such potential with an accuracy of 0.1 μV. From this moment, to calculate the voltage at the electrode, the voltage at the output of the DAC is used as the reference potential. Subsequently, the ADC makes comparisons of the potential between two points in the earlobes, which ideally should equal 0 V. In the case, if the difference between earlobes voltage is more than 0.1 μV, the DAC starts to compensate this value at its output, thereby averaging the value between the two earlobes. Algorithms in software to exclude instantaneous changes in potential on the earlobe were written in the STM32. Algorithms eliminate the uncontrolled effect of an increase of neuronal activity in the temporal region of the head. Thus, the developed prototype by DAC of the device replaces the potential on the earlobes and, based on mathematical calculations, provides a stable reference voltage for calculating the voltage on the electrodes.
Preprint
Alcoholism is one of the most common diseases in the world. This type of substance abuse leads to mental and physical dependence on ethanol-containing drinks. Alcoholism is accompanied by progressive degradation of the personality and damage to the internal organs. Today still not exists a quick diagnosis method to detect this disease. This article presents the method for the quick and anonymous alcoholism diagnosis by neural networks. For this method, don't need any private information about the subject. For the implementation, we considered various algorithms of machine learning and deep neural networks. In detail analyzed the correlation of the signals from electrodes by neural networks. The wavelet transforms and the fast Fourier transform was considered. The manuscript demonstrates that the deep neural network which operates only with a dataset of EEG correlation signals can anonymously classify the alcoholic and control groups with high accuracy. On the one hand, this method will allow subjects to be tested for alcoholism without any personal data, which will not cause inconvenience or shame in the subject, and on the other hand, the subject will not be able to deceive specialists who diagnose the subject for the presence of the disease.
Article
Electroencephalography (EEG), as a non-invasive modality, enables the representation of the underlying neuronal activities as electrical signals with high temporal resolution. In general, the EEG artifact removal methods have been considered as a fundamental preliminary step during EEG analysis. However, the associated challenges of EEG artifact removal methods should be addressed carefully, to fully utilize the data. This manuscript is based on the notion that the full capacity of the EEG artifact removal methods can be achieved while addressing the associated challenges well. Because these methods could enhance the inferences deduced from the EEG data. The focus of this manuscript is to elaborate challenges (e.g., the algorithm-specific challenges and general challenges) of the EEG artifact removal methods. Considering the challenges, the manuscript has presented recommendations to address them. The manuscript also provides information on Matlab and Python-based toolboxes developed for EEG preprocessing. In addition, this manuscript provides a brief account of the EEG artifact types along with an overview of the EEG artifact removal methods. In short, this manuscript provides information on various EEG artifact removal methods and the recommendations provided serve as guidelines for the selection of suitable tools and methods for EEG artifact corrections.
Article
The basis of the work of electroencephalography (EEG) is the registration of electrical impulses from the brain using a special sensor or electrode. This method is used to treat and diagnose various diseases. In the past few years, due to the development of neural network technologies, the interest of researchers in EEG has noticeably increased. Neural networks for training the model require obtaining data with minimal noise distortion. In the processing of EEG signals to eliminate noise (artifacts), signal filtering and various methods for extracting signs are used. The presented manuscript provides a detailed analysis of modern methods for extracting the signs of an EEG signal used in studies of the last decade. The information presented in this paper will allow researchers to understand how to more carefully process the data of EEG signals before using neural networks to classify the signal. Due to the absence of any standards in the method of extracting EEG signs, the most important moment of this manuscript is a detailed description of the necessary steps for recognizing artifacts, which will allow researchers to maximize the potential of neural networks in the tasks of classifying EEG signal.
Article
Portable EEG devices have a great potential to become efficient computer interfaces. However, a necessary step is to accurately describe the EEG signal in order to quantify brain rhythms. This study explored two signal analysis techniques, Matching Pursuit (MP) and Fast Fourier Transform (FFT), for differentiation between two states, eyes open (EO) and eyes closed (EC), through the detection of EEG alpha activity obtained from seven scalp regions, using a portable EEG device. Subjects were ten healthy male volunteers. MP results generally reproduced the results from FFT analysis, and all methods performed well on the occipital region. However, there was better state discrimination with MP atom number, and MP atom number was the only variable that reached statistical significance on all locations under study. When employing EEG alpha rhythm for EO vs. EC state discrimination, it may be useful to compute MP atom number, especially when extra-occipital acquisition is warranted.
Article
In this study, electroencephalography-based data for emotion recognition analysis are introduced. EEG signals were collected from 28 different subjects with a wearable and portable EEG device called the 14-channel EMOTIV EPOC+. Subjects played 4 different computer games that captured emotions (boring, calm, horror and funny) for 5 min, and the EEG data available for each subject consisted of 20 min in total. The subjects rated each computer game based on the scale of arousal and valence by applying the SAM form. We provide both raw and preprocessed EEG data with.csv and. mat format in our data repository. Each subject's rating score and SAM form are also available. With this work, we aim to provide an emotion dataset based on computer games, which is a new method in terms of collecting brain signals. Additionally, we want to determine the success of the portable EEG device and compare the success of this device with classical EEG devices. Finally, we perform pattern recognition and signal-processing methods to observe the performance of our dataset and to classify EEG signals based on the arousal-valence emotion dimension and positive/negative emotions. The database will be publicly available, and researchers can use the dataset for analyzing signals for their own proposed method in the literature.