DETECTION OF EPILEPTIC SEIZURES IN EEG BY USING MACHINE LEARNING TECHNIQUES

In this research a public dataset of recordings of EEG signals of healthy subjects and epileptic patients was used to build three simple classifiers with low time complexity, these are decision tree, random forest and AdaBoost algorithm. The data was initially preprocessed to extract short waves of electrical signals representing brain activity. The signals are then used for the selected models. Experimental results showed that random forest achieved the best accuracy of detection of the presence/absence of epileptic seizure in the EEG signals at 97.23% followed by decision tree with accuracy of 96.93%. The least performing algorithm was the AdaBoost scoring accuracy of 87.23%. Further, the AUC scores were 99% for decision tree, 99.9% for random forest and 95.6% for AdaBoost. These results are comparable to state-of-the-art classifiers which have higher time complexity.


INTRODUCTION
In this modern era the functionality of brain has been the focus of scientific and technological advancements manifested in the appearance of several neuroimaging modalities as well as detection/diagnosis procedures. These modalities opened wide horizons in the diagnosis of neurological disorders to the degree that diagnosing diseases has become almost completely reliant on biomedical technologies (1).
Epilepsy is a neurological disorder manifested by recurrent seizures. It is estimated that around 1% of world population is affected by this condition (2). It is an unpredictable non-curable chronic mental illness (1). This disorder mars its patients with unbearable physical burdens but also psychological impacts including depression and anxiety (3). A seizure is a sudden shift in human behavior caused by momentarily disturbance of brain's electrical activity (1). Normally, the brain communicates using regular discharges of weak electric signals. There are two types of abnormal signals called interictal which occur prior to epileptic seizures and Ictal which are prominent at onset of epilepsy (4,5). Epilepsy can be controlled with medications and surgery, yet, without a reliable mechanism to predict when it is going happen medications would be of limited benefit (2). Electroencephalography (EEG) is a brain signal scanning technique which gives an insight into internal electrical activity of normal as well as abnormal brains. It is a painless, noninvasive, yet cost-efficient tool that can be used in conjunction with wearable and portable devices as an early warning mechanism for the incidence of seizures (3).
Currently, brain disorders including seizures are detected by experienced Neurologists through the analysis of recordings of EEG signals. (6). However DIAGNOSTYKA, Vol. 24, No. 1 (2023) AL-Huseiny M, Sajit A.: Detection of epileptic seizures in EEG by using machine learning techniques 2 the prediction of impending seizures is an extremely challenging task (7) due to the fact that the manual process is predictably time-consuming and subject to human errors (8) where long periods of time are required by specialists to analyze EEG records which can create an overwhelming workflow (9). Furthermore, EEG signals' intensity is very low in the μV range and hence interference from other physiological and non-physiological factors is common-place (10).
With the increased adoption of technologies and the sustained growth of biomedical data and the diversity of computing tools analyzing biomedical has steadily become streamlined and systematic (1). In this regard, several machine learning (ML) tools have been investigated including support vector machines (SVM), decision tree (DT), artificial neural network (ANN), k-nearest neighbors (KNN), naïve Bayes (NB), Gaussian mixture model (GMM), adaptive neuro-fuzzy inference systems (ANFIS), and deep learning models (DL) to detect epileptic seizures in EEG signals. (8).
Among these efforts the work in (11) which used discrete Jacobi polynomial transforms (JPTs) to decompose EEG signals into a 28-dimension feature. They applied Linear discriminant analysis (LDA) to reduce dimensionality, their resulting features were used to train support vector machine (SVM) classifier. It is important to mention here that SVM is usually unsuitable for large datasets and its performance declines with high levels of noise such as that in EEG signals. The authors of (8) used DWT wavelets analysis for EEG and applied Genetic algorithm (GA) in with K-nearest neighbors (KNN) and other machine learning classifiers. The researchers in (3) normalized EEG signals then applied Stockwell Transform, they extracted then chaotic features and Parseval's. Extreme Learning Machines (ELM) was used for classification. In (10) the authors used short-time Fourier transform with 28-s windows for pre-processing step. They then trained a generative adversarial network (GAN) for feature extraction. They used two fully-connected layers for classification. It must be indicated though that GANs are hard to train due to non-convergence and diminished gradient. In (12) sliding discrete Fourier transform (SDFT) was employed to transform signals into frequency domain then applied Feed-forward NN (FFNN) as well as adaptive network-based fuzzy inference (ANFIS) as classifiers. Their reported results indicate good accuracy and low classification run time. A deep learning system was developed in (13), it acquires multi-spectral features by using an ensemble architecture. Their system is dedicated the classification of the type of seizure. The authors of (14) extensively reviewed studies focused on the automatic detection of epileptic seizure by using deep learning (DL) approaches on different imaging and scanning techniques. Researchers of publication in (15) produced good studies regarding the application of Artificial Intelligence (AI) systems in the detection of epileptic seizures in EEG. Their work aimed at replicating the dynamics of brain network. Researchers in (16) experimented with computational methods and artificial intelligence to develop a framework for automatic epilepsy diagnosis and to device optimal treatment per patient. In (9) they compared long short-term memory (LSTM) and gated recurrent units (GRU) and applied a hybrid architecture of Convolutional Neural Networks (CNNs) and RNNs, they also investigated various initialization methods. Worth noting that these methods are known to be slow to converge and have reduced learning efficiency.
Inspired by the previous efforts, in this research three ML classifier models are developed and tested to detect epileptic seizures in EEG signals taken from a commonly used dataset. The first model is a weak classifier, the decision tree, the second is an ensemble classifier, the random forest, and the third is another ensemble classifier, the AdaBoost. A results summary is included in Section 3 showcasing the performance of the presented models in comparison to other state of the art algorithms. The reason for choosing these classical classifiers is to investigate possibility of building robust detection mechanism without sacrificing response time while in the same time keeping computational resources as low as possible. This can lead to the integration of this model in wearable devices with low power consumption for epileptic patients to aid in providing targeted treatment and reduce potential accidents.
The rest of this paper is organized as follows: in section 2 the dataset and the methodology used in this paper are detailed; in section 3 the experimental results are discussed and analyzed; and finally, the paper concludes in section 4.

MATERIALS AND METHODOLOGY
The proposed framework consists of a set of preprocessing steps, followed by the setup of a machine learning model. This research uses a weak classifier (Decision Tree or DT), An interesting point about weak learners is that they learn part of the problem, meaning that they rarely overfit, i.e. they have low variance and high bias (17). Further, they are simple to implement which makes them good building blocks for another type of learners used here, the ensemble classifiers (Random Forest or RF and AdaBoost or AB). Evidently, the time complexities of the suggested algorithms are relatively low. DT has time complexity of O(n*log(n)*d), RF has time complexity of O(n*log(n)*d*k) where n is the data size, d is data dimensionality, and k represents the number of trees. Comparing this to other more sophisticated algorithms such as SVM which has time complexity of O(n²). 1D convolutional layer has time complexity of O(l*n*d 2 ) where l is the length of the filter, as such, the complexities of other algorithms such as CNN, GAN and etc. are expected to be even higher (18). In ML ensemble combines a set of base algorithms to construct a single more robust predictive algorithm, the base algorithm for both ensembles used in this research is the Decision Tree. The base algorithms are built as per normal. Instances in the training dataset are weighted, the weights are then modified according to the overall model accuracy. Next level models (which are another instance of the base model) are then trained and augmented until best accuracy is achieved or stopping conditions are met. Eventually every level model is weighted depending on its contribution and these weights are also included in the classification of new data by the two suggested ensembles (17). The models are trained and validated by using a widely used EEG dataset. The models were implemented by using Weka 3.8 tool (19) on a dualcore Intel Core i5 MacBook Pro machine clocked at 2.5 GHz with 16 GB DDR3 RAM. The various stages of the proposed framework are presented subsequently:

University of Bonn Dataset (EUB)
In this research a pre-processed and re-reshaped version of the well-known University of Bonn epilepsy dataset is used (20). The dataset is made of EEG recordings of healthy subjects as well as patients with epileptic seizures. The dataset includes five subsets denoted A-E examples of which are shown in Fig. 1. This figure shows five sample time series of brain electric activity (measured in µVolts) each representing one of the sets listed in Table I. during seizure and seizure-free times from five subjects at the hippocampal region at the opposite brain hemisphere and also within epileptogenic zone. Detailed decimation of the dataset is given in Table I.

Preprocessing
Following the work described by (22), digitized time series recording is subdivided into 23 segments of 178 data points for the duration of a little more than one second each. This results in a total of 11500 segments of one second recording time at 178 data points, each having one label.
The data includes 5 categories depending on the status and medical condition of the subject: For the sake of binary classification (nonepileptic vs epileptic), recordings of subjects from categories (1-4) are considered non-epileptic (NE) while signals from category (5) are considered epileptic (EP).

Decision Trees (C4.5)
The C4.5 algorithm (23) is used to implement DTs for classifying data. These classifiers are employed to outline decision-making framework. The tree in essence constructs an association model which sorts data instances into interrelated categories starting from root node down to leaves. Each node represents a test of the data instances for a particular feature, while a branch corresponds to a possible value, range, or compliance of the feature to that test. The algorithm is usually considered to be a statistical classifier (24) where it is based on information gain. As such the criterion for making bifurcation is the normalized information gain measured through entropy. With the feature having the highest information gain is set to form a decision node. This classifier is regarded as a greedy algorithm and also one and two-level trees can be considered weak learner.

Random Forest
Random forests (RF) (26) are constructed from numerous decision trees which form an ensemble where each tree in the random forest generates a DIAGNOSTYKA, Vol. 24, No. 1 (2023) AL-Huseiny M, Sajit A.: Detection of epileptic seizures in EEG by using machine learning techniques 4 prediction. The class with majority votes is regarded the prediction of the random forest model (see Fig.  2). The inner working of random forest relies on the so-called wisdom of crowds. Whereby a set of uncorrelated trees (models) operate on the same data would collectively perform superior to each of them individually. This is so because some models compensate for the errors of other models. An advantage point over decision trees is that RFs are not constructed by using a greedy algorithm, this in turn increase the variance of predictions and improves robustness against overfitting (17).

AdaBoost
This model is an ensemble algorithm used to solve classification problems. It falls in a category of algorithms called boosting, which arranges machine learning sequentially in order to improve prediction performance and reduce errors made by individual models (17). AdaBoost (AB) (27) works by combining several weak classifiers to form a strong classifier. The weak classifiers here are DTs with a single decision node, the stump. It relies on the principles of complexity where more sophisticated systems are constructed from simpler components. Here stumps are weighted according to the difficulty of classifying certain instances. Hence, a stump selects a feature, Xn, and a threshold, Th, it then divides the instances into two sets with respect to Th. This is repeated for all features and threshold values to find the best separating pair. The algorithm attempts to exploit dependency among models and boosts performance by assigning higher weights to mislabeled instances of data (28).

Experiment Design
In this research the three classifiers DT, RF and AB are used, the data is initially preprocessed and then fed to the classifiers to build their respective models. These models are then used to classify the data into one of two categories (binary): nonepileptic (NE) and epileptic (EP). The parameters used to build these models and the outcomes after training and testing each of them over 11500 data instances with 178 attributes are listed in Table II.
For proper validation and to avoid overfitting the trained models to the underlying data, 10-folds cross validation is employed. Keeping in mind the unbalanced nature of the dataset used and to quantify classification outcomes the metrics in Eq.

RESULTS AND INTERPRETATION
In this research the EUB dataset (20) of EEGs was used to train three classifiers: a weak classifier, DT, and two ensemble classifiers, RF and AB. The approach taken by DT seems effective as it achieved higher accuracy (and balanced accuracy) and better area under ROC than AB, this performance was slightly improved with the use of RF which seems even more robust than DT. Thus, in Fig. 3. it is noticed that the best achieved AUC was for the case of RF while the least performing algorithm was the AB.
In medical applications it is common to rely on measures other than accuracy. For the suggested approaches it is noticeable that both DT and RF achieve remarkable ROC curves which indicates very high True Positive Rate at a very low False Positive Rate. As for AB, the results were less remarkable.
Another interesting measure particularly in medical diagnosis applications is the FNR where it is less harmful to misdiagnose a healthy subject than to misdiagnose a patient. The proposed methods have shown excellent results for FNR especially the RF which score under 1% of missed cases of actual epileptic patients.  Table III includes a listing of the abovementioned results along with some comparing results from various previous methods. These results show that the proposed which are relatively simple and inexpensive algorithms are comparable to the state-of-the-art methods with the advantage of being mostly less demanding in terms of resources as well as the simplicity of implementation. For better analysis of a detailed account of results for the three algorithms their confusion matrices are listed in Table IV where NE refers to non-epileptic and EP refers to epileptic.
The detailed measures presented in show that the utilized classic classifiers managed to achieve high learning capabilities despite being easy to implement and inexpensive to run on low-end machines. Also, it is noted that some more complex approaches which are normally used to achieve better and more robust learning results do not perform very well on this type of problems. This leads to the thinking that the nature of the problem rather than the sophistication of the method might have the ruling factor on the final performance of machine learning problems.

CONCLUSIONS
In this research a public dataset of recordings of EEG signals for healthy subjects and epileptic patients was used to build three simple classifiers. The selected models are a weak learner, the decision tree, and two ensemble learners, the random forest and the AdaBoost algorithm. The data was initially preprocessed to extract short waves of electrical signals representing brain activity. The signals are then used to build the selected models. The aim of the research was to investigate the capabilities of classic tools in dealing with complex real-life problems represented in low dimensional dataset. Experimental results showed that random forest achieved the best accuracy of detection of the presence/absence of epileptic seizure in the EEG signals at 97.23% followed by decision tree with accuracy of 96.93%. The least performing algorithm was the AdaBoost scoring accuracy of 87.23%. These results put these algorithms at par with some of the most powerful classifiers as indicated herein. Another interesting observation that the suggested classifiers have also shown that their results are robust in terms of tendency to resist overfitting the data and working as good on both sides of the binary problem, this is evident in the form of excellent AUC score at 99% for decision tree, 99.9% for random forest and 95.6% for AdaBoost. As such it is clear that such simple models can be of crucial benefit if for instance utilized for use on small wearable IoT devices to accompany epileptic patients and alert health services or relatives in the event of severe attack or when being unattended or at danger.

Declaration of competing interest:
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.