System Architecture for Brain-Computer Interface based on Machine Learning and Internet of Things

—Brain functions are required to be read for curing neurological illness. Brain-Computer Interface (BCI) connects the brain to the digital world for brain signals receiving, recording, processing, and comprehending. With a Brain-Computer Interface (BCI), the information from the user’s brain is fed into actuation devices, which then carry out the actions programmed into them. The Internet of Things (IoT) has made it possible to connect a wide range of everyday devices. Asynchronous BCIs can benefit from an improved system architecture proposed in this paper. Individuals with severe motor impairments will particularly get benefit from this feature. Control commands were translated using a rule-based translation algorithm in traditional BCI systems, which relied only on EEG recordings of brain signals. Examining BCI technology’s various and cross-disciplinary applications, this argument produces speculative conclusions about how BCI instruments combined with machine learning algorithms could affect the forthcoming procedures and practices. Compressive sensing and neural networks are used to compress and reconstruct ECoG data presented in this article. The neural networks are used to combine the classifier outputs adaptively based on the feedback. A stochastic gradient descent solver is employed to generate a multi-layer perceptron regressor. An example network is shown to take a 50% compression ratio and 89% reconstruction accuracy after training with real-world, medium-sized datasets as shown in this paper.


I. INTRODUCTION
Brain-Computer Interface (BCI) also known as Mind Machine Interface (MMI), is a technology that connects the brain to a computer or other electronic device in order to investigate the normal brain's functioning, including its original output level and muscle pathway [1]. In order to create a link between the brain and the computer, two requirements must be met:  Various states of the brain should be distinguished.

 Detection and classification of similar features
practically.
It is possible to monitor brain activity using a variety of methods, the most common of which being Electroencephalograms (EEG), Electrocardiograms, Magnetic Resonance Imaging, Magneto-Encephalograms, and Positron Emission Tomograms (PET) [2].
A variety of approaches can be used to detect or measure these electrical and chemical impulses. There are issues and advancements to be made, just like with any other system, so it works on them. Both the efferent and afferent systems may be affected. The brain can be connected directly to its environment if the neurological system is effectively bypassed [3][4][5]. This can be done through BCI. While first designed to provide alternative methods of communication for those with disabilities, these devices now have the potential to provide "other sensations" for those who are unable to do so. Braincomputer interfaces (BCIs) provide direct communication between the brain and the world around it.
A patient can use a BCI to control a specific computer application, such as a computer cursor or a robotic limb. Patients with lock-in syndrome, for example, can benefit from developing a communication network even when they are paralyzed. Many researchers have been working on BCIs to capture and analyze EEG patterns associated with mental states throughout the past few years [6,7,8,9,10]. EEG activity in the left side of the motor cortex is associated with visualizing a change in the posture of the right hand. Other often employed mental exercises include moving the left hand, toes, and tongue around the mouth and feet. The block diagram for BCI can be shown in Fig. 1. Fig. 1. BCI Framework. www.ijacsa.thesai.org A Brain-Computer Interface (BCI) based on electroencephalography (EEG) is used in this study. Depending on where the electrode is placed, there are two main approaches to collecting EEG data. Non-invasive electrodes are attached to the scalp while invasive electrodes are attached directly to the cerebral cortex [11]. The non-invasive approach is less intrusive and more portable than fMRI, making it suited for performance arts. Improvements in biomedical signal processing have led to Electroencephalography (EEG) signals being utilized to diagnose brain illnesses and widely used in Brain-Computer Interface (BCI) devices. In order to operate external equipment like a wheelchair or a computer, BCI employs electrical impulses from the brain, in the form of EEG waves, as an input. Electroencephalography (EEG) is a method for recording electrical brain wave activity along the scalp as a result of neural activation in the brain. An electroencephalogram (EEG) is a short-term recording of the electrical activity of the brain for a short period of time (usually 20-40 minutes), which is accomplished by attaching electrodes to the scalp of the subject. EEG can be used to diagnose a variety of neurological illnesses, although it is most commonly used to treat epilepsy. EEG can be useful in the early stages of some serious disorders, such as coma, brain death, and encephalopathies. There are various different diseases for which electroencephalography (EEG) can be used as a first-line diagnostic approach. EEG is still the most commonly used method for diagnosing even if MRI and CT scans are increasingly prevalent currently. In the EEG approach, evoked potentials (EP) are utilized to average the EEG activity to stimulus responses in visual, auditory, or somatosensory activity. In addition, event-related potentials (ERPs) are employed in cognitive sciences, psychophysiology, and cognitive psychology for averaging EEG responses to complicated stimuli. This paper has been organized in five sections. Section 1 is introduction that refers the basics and contexts of research with introduction to various ongoing and future aspects. Section 2 is for background study and research that mentions the contributions of significant research in the field, their relevance and reference to this research work. Section 3 is about research methodologies that specify the adopted research processes and methods to carry out this research work. Section 4 and Section 5 are about implementation and results, and conclusion, respectively.

II. BACKGROUND STUDY AND RESEARCH
In order to identify changes in the surface of the head as a result of electrical activity in the brain, EEG is largely used in neuroscience and clinical neurological procedures. Wet (gelled) silver/silver chloride electrodes (Ag/AgCl), typically with the help of an EEG cap, are used in the state-of-the-art approach. It takes a long time and a lot of effort to get ready for an event like this. Electrolyte stability also limits the wear time (gels). Brain-computer interfaces (BCIs) are a new field of application for EEG [12][13][14][15]. Silver-chloride-coated metal discs, often composed of stainless steel, tin, gold, or silver, are applied to the scalp in specific places. The International 10/20 system is used to specify the positions. All electrodes are numbered, and a letter is assigned to each one. The letter identifies the location of the electrode in relation to the brain. Examples include the F-Frontal lobe and T-temporal lobe.
Dry contact electrodes must have acceptable hair layer penetration, biocompatibility, electrochemical stability, and signal quality comparable to typical wet electrodes in order to be viable. Aside from the long-term applicability and patient comfort that we strive for, we also want to ensure compatibility with bio-signal amplifiers, ease of use, and preparation time for patients [16]. As a result, three major types of electrodes have been created: Titanium nitride covers the first two gold multipin electrodes as well as (ii) polyurethane multi-pin electrodes. In order to make gold multi-pin electrodes, the electrical precision brass pins are gold-coated and soldered to an epoxy baseplate. Fig. 2 depicts the four stages of the BCI configuration for this project, from data collection via EEG and analog-to-digital conversion to digital signal processing, feature selection, and control of external mechatronic devices [17]. In the first step, non-invasive EEG data is collected, and in the second step, digital EEG signals are processed with filters. Custom algorithms and mechatronics have been developed in the second and third phases to monitor the appearance of individual brain waves and produce the desired sounds. For PDR detection, a unique feature selection technique is used in the third phase. In the final stage, eight wirelessly connected modules of custom percussion instruments produce synchronized sounds [18]. As a result, the BCI system generates repetitive noises that prompt the performer to record reliable EEG data.
OpenBCI's high-quality open-source BCI solution is employed in this research. The system architecture is built using frameworks that are commonly used to run BCIs. OpenBCI's STL files are used to 3D print the headgear used for the initial round of EEG data collecting [19,20,21,22]. A Cyton board, an Arduino-compatible, eight-channel neural interface with a 32-bit processor, is attached to the headwear's rear. For example, the OpenBCI GUI can analyze the digitized EEG data from this board to remove artifacts and identify certain features.
Analog signals are detected by placing electrodes on one's scalp for EEG-based BCI. For use with the Ultra-Cortex Mark III-Nova and Ultra-Cortex Mark IV 3D-printed EEG headgear, electrodes are mounted according to International 10-20 system specifications [23]. Conductive silver chloride (AgCl) is used to coat the dry electrode, making it easier for the performer to use and more durable for long-term performances. The Welch method uses windowed Fourier transformations of signal segments to calculate the Fourier spectral characteristics. Using only frequency data is the fundamental shortcoming of the method, as it does not use time-domain data [24]. However, studies have shown that EEG signals can be improved by combining frequency and time-domain data. The band power in multiple frequency bands is calculated from the AR spectrum and the power sum is used as independent parameters. Fig. 3 shows the block diagram of the proposed methodology for this research work.

A. Classification
Research on BCI-specific machine learning models using data from children with impairments is few, to our knowledge. It was in 2020 that Aydin applied LDA, KNN, and SVM to two fNIRS datasets containing typical developing adults (average age 28.5 3.7 years). For motor imagery fNIRS-BCI signals, LDA showed the maximum classification accuracy, while SVM had the best performance for mental arithmetic. The best KNN outcomes were achieved with a low k. It was determined that the number of features should be proportional to the value of k in this investigation [25]. When compared to a single powerful learner, ensemble classifiers have improved classification accuracy. SVM, LDA, and rLDA were compared against bagging using four different data sets involving motor imagery, mental arithmetic, and word production tasks. There were no significant differences in bitrate or classification accuracy between bagging and alternative algorithms across the datasets. According to their last remarks, they urged the development of novel ensemble classification methods. Seven models were chosen in this work because of the lack of research on classifying learners for a fNIRS-BCI. Based on past research, we chose KNN, SVM, LDA, and Bagging as our top four models. Random Forests, AdaBoost, and Extra Tree were introduced to the ensemble of classifiers. 10-fold stratified cross-validations were conducted on each model's hyperparameters to measure classification accuracy [26,27,28]. Accuracy, sensitivity, and specificity were used to measure classification performance.

B. Feature Selection
Spontaneous electrical activity in neurons, as measured by EEG, is examined in general for its amplitude and frequency. Using scalp EEG, the experiment collects data and focuses on the frequency of the scalp EEG in the visual cortex. EEG data is transformed from the time domain to the frequency domain using the fast Fourier transform (FFT) technique. To monitor PDR and control sound mechanisms, the Open Sound Control protocol uses a special algorithm that analyses the frequency information from the digitalized EEG data after the FFT method is applied in the GUI of OpenBCI (OSC). However, EEGs can vary greatly depending on the individual, their age, their gender, and their overall health. There is a 7.5-15Hz PDR tolerance. As we get older, the EEG slows down, and this development is more pronounced for males than for women. Young people's EEG data isn't yet mature because they're under the age of 26. Children under the age of 8 Hz can have a PDR that is slower than 8Hz. As a result, it's critical to check the performer's PDR scope before running the function.

C. Dataset
The proposed approaches are evaluated using the ECoG recordings from Dataset I of the BCI Competition III, as depicted in Fig. 4. BCI experiment participants conducted hypothetical motions of their left little finger or tongue to record motor imagery signals. Recorded ECoG signals were sampled at 1000 Hz. Amplification and storage at microvolt values made it easier to classify the recorded potentials. Sample recordings of either imaginary finger or tongue movement were recorded for three seconds. To avoid visual evoked potentials, the recording began 0.5 seconds after the visual round ended.

D. Auto-Regressive Features
Automatic regression (AR) models are used to represent random processes in statistics and signal processing, and they are particularly useful for modeling time-varying processes. Output variables are modeled by the AR to be reliant on their prior values. AR denotes an autoregressive model with order p. To put it another way, the AR (p) model is The backshift operator B can be used to write this in the same way: Thus, an AR model can be thought of as the output of a white noise-inputted all-pole infinite impulse response filter.

E. Data Acquisition
To ensure accuracy and quality, it compares the target signal to background noise. Once this digital brain data has been decoded into the intended action, it can be classified, and the necessary attributes calculated and selected from the neural data.  In addition, optional feedback is sent to BCI users (which generates brain signals) and the cycle is again repeated. An anti-clockwise motion (as seen in Fig. 5) stimulates the simulation of data to begin.
The input from the stimulation data decoder is processed using various machine learning (ML) methodologies (neural networks). It's important to note that the generated input provides high-level information about the multimedia devices that will be triggered, their frequencies, and the timing of their activation.
BCI technology-related parameters were subsequently specified using thresholding patterns that received neural input in the intended action and generalized form have been shown in the Fig. 6. To display multimedia-based actions, the process moves from brain data simulation to user interface and interactivity.

IV. IMPLEMENTATION AND RESULTS
The computer-based assessment test of visuomotor skills was divided into two blocks, one standard, and one nonstandard for participants. This necessitated the use of cognitive-motor integration in order to treat the condition (CMI). Participants had to navigate a cursor as quickly and accurately as possible from the tablet's center to one of four peripheral goals using their dominant index finger (up, down, left, or right). Users clicked on an 8 millimeter wide solid green circle in the middle of the screen to begin their experiment. Upon seeing an open green 10 mm diameter peripheral target after a 200ms center hold period, the participant was given the "Go" signal and was free to begin moving. A green cursor was positioned over an open green target by sliding the touch screen with one's fingers.
Upon reaching the peripheral goal and remaining there for 500 milliseconds, the experiment was over. Next, the central target was presented after a 200-ms intertrial interval. At 37.5 millimeters from the tablet's central starting point, the tablet's peripheral targets were (center-to-center distance). Overall, there were 20 trials per task, with five trials for each goal. Participants used their fingers to move the cursor under their fingers to engage directly with the target in the conventional condition. As a result of the non-standard CMI scenario, a white line separated the display into two halves. Participants had to pay attention to the tablet's upper half for the targets and cursor. Participants had to glide their fingers along the tablet screen's bottom to move the cursor. The collected data will be used to improve classification accuracy on IVa datasets in our experimental assessment. Fig. 7's SCU architecture is modified to categorize these images using an SSVEP-based model. As a data reference channel, we employed the frontal cortex (Fz) instead of the nine sensor channels originally used to simplify SSVEP classification training. They demonstrated that this model outperformed both standard approaches and time-series specialized models like Recurrent Neural Networks when it came to recognize SSVEP EEG signals (RNN). All tests utilize one-dimensional convolutional layers as depicted in Fig. 8,  www.ijacsa.thesai.org batch normalization, and maximum pooling. After applying a bandpass filter between 9 and 60 Hz, as well as another filter at 50 Hz, the EEG channels are initially pre-processed before the data is eventually normalized between 0 and 1. For the experiments, dataset IV has been used from the BCI competition. The accuracy is the actual fraction of the samples that are correctly classified from the samples obtained in (4): The Precision is the percentage of relevant samples, evaluated as in (5): The Recall measures the positives identified correctly as in (6) Based on the findings provided in Table I, it appears that the Random Forest method outperformed the Neural Network and Gradient Boosting classifier. An individual's maximum level of accuracy was 70.2 percent, which was a reasonable improvement above the random guess accuracy of 33 percent. Because we used to leave one out cross-validation in this situation, the inter-subject accuracy of 56.8% was also quite encouraging. It was shown that training a model on an individual's data yielded better results for intra-class classification than utilizing data from various persons, which could raise concerns about privacy.
The use of the supervised forward feature selection method resulted in considerable improvements to our results. Reducing 60 feature set from 60 to 10 was done by removing unnecessary and distracting features. We were able to enhance our performance on the validation set as a result of our methodology's ability to reduce overfitting. This method had a 10 percent improvement in average accuracy and the maximum accuracy we could achieve with wearable devices was 80.6 percent, well above the accuracy of any previous method for EEG classification based on RGB colors. Fig. 9 and 10 represent the graphs for accuracies at 200ms time window using all and 10 features respectively. The classifier was able to correctly classify 72% of the subjects on average. The accuracy went up to 95% of the time Intra-subject classification was likewise superior to inter-subject classification in this situation. The accuracy of inter-subject classification was raised by 1.3 percent. In this situation, the Random Forest approach outperformed both the neural network and the gradient boosting techniques. Table II shows the results. Two types of classification were carried out: intra-subject and inter-subject. We used to leave out one subject crossvalidation for the second classification, where we trained the model using seven subjects' data and validated it using a single subject's data, then repeated it for all subjects. The average cross validation accuracy, ROC-AUC, and MCC of our model were used to assess its performance. The original and condensed datasets are also included in our results. Fig. 11 and  12 show the average accuracy, the average AUC score, and the average MCC score for both intra-subject and inter-subject categorization. Our greatest results were achieved in a 200ms time frame. A total of 200ms of experimentation was placed throughout this time. All peak frequencies and its harmonics have been shown in the Fig. 13 for fast Fourier transform (FFT) method that has an important role in processing for the discrete signals.

V. CONCLUSION
To help people with disabilities, brain-computer interfaces (BCI) have been developed. However, new uses for this technology have emerged, such as the expansion of human potential. This work presented novel system architecture for the BCI, and this article has shown to be easily configured and modular to access the different EEG signals. Locked-in individuals have no other way to communicate or exert control over their surroundings but through the use of a Brain-Computer Interface (BCI). When conducting a BCI, electrocorticography (ECoG) gives superior resolution to noninvasive methods. EEG signals, on the other hand, have a limited range of signal amplitude and bandwidth. ECoG can identify gamma activity more quickly than EEG because these high frequencies are more closely linked to specific sections of the motor, linguistic, and intellectual functions. Classification is done using a variety of machine learning algorithms. So, SVMs can be used to make generalizations that are good out of sample, if the parameters are specified correctly. This suggests that SVMs can be robust, even if the training sample has some bias, by selecting an acceptable generalization grade.