Detection of Epileptic Seizures in EEG by Using Ma
Detection of Epileptic Seizures in EEG by Using Ma
AL-Huseiny M, Sajit A. Detection of epileptic seizures in EEG by using machine learning techniques. Diagnostyka. 2023;24(1):2023108.
https://doi.org/10.29354/diag/158277.
e-ISSN 2449-5220
DIAGNOSTYKA, 2023, Vol. 24, No. 1
DOI: 10.29354/diag/158277
1
Abstract
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.
© 2023 by the Authors. Licensee Polish Society of Technical Diagnostics (Warsaw. Poland). This article is an open
access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license
(http://creativecommons.org/licenses/by/4.0/).
2 DIAGNOSTYKA, Vol. 24, No. 1 (2023)
AL-Huseiny M, Sajit A.: Detection of epileptic seizures in EEG by using machine learning techniques
the prediction of impending seizures is an extremely the detection of epileptic seizures in EEG. Their
challenging task (7) due to the fact that the manual work aimed at replicating the dynamics of brain
process is predictably time-consuming and subject network. Researchers in (16) experimented with
to human errors (8) where long periods of time are computational methods and artificial intelligence to
required by specialists to analyze EEG records develop a framework for automatic epilepsy
which can create an overwhelming workflow (9). diagnosis and to device optimal treatment per
Furthermore, EEG signals’ intensity is very low in patient. In (9) they compared long short-term
the μV range and hence interference from other memory (LSTM) and gated recurrent units (GRU)
physiological and non-physiological factors is and applied a hybrid architecture of Convolutional
common-place (10). Neural Networks (CNNs) and RNNs, they also
With the increased adoption of technologies and investigated various initialization methods. Worth
the sustained growth of biomedical data and the noting that these methods are known to be slow to
diversity of computing tools analyzing biomedical converge and have reduced learning efficiency.
has steadily become streamlined and systematic (1). Inspired by the previous efforts, in this research
In this regard, several machine learning (ML) tools three ML classifier models are developed and tested
have been investigated including support vector to detect epileptic seizures in EEG signals taken
machines (SVM), decision tree (DT), artificial from a commonly used dataset. The first model is a
neural network (ANN), k-nearest neighbors (KNN), weak classifier, the decision tree, the second is an
naïve Bayes (NB), Gaussian mixture model (GMM), ensemble classifier, the random forest, and the third
adaptive neuro-fuzzy inference systems (ANFIS), is another ensemble classifier, the AdaBoost. A
and deep learning models (DL) to detect epileptic results summary is included in Section 3 showcasing
seizures in EEG signals. (8). the performance of the presented models in
Among these efforts the work in (11) which used comparison to other state of the art algorithms. The
discrete Jacobi polynomial transforms (JPTs) to reason for choosing these classical classifiers is to
decompose EEG signals into a 28-dimension feature. investigate possibility of building robust detection
They applied Linear discriminant analysis (LDA) to mechanism without sacrificing response time while
reduce dimensionality, their resulting features were in the same time keeping computational resources as
used to train support vector machine (SVM) low as possible. This can lead to the integration of
classifier. It is important to mention here that SVM this model in wearable devices with low power
is usually unsuitable for large datasets and its consumption for epileptic patients to aid in providing
performance declines with high levels of noise such targeted treatment and reduce potential accidents.
as that in EEG signals. The authors of (8) used DWT The rest of this paper is organized as follows: in
wavelets analysis for EEG and applied Genetic section 2 the dataset and the methodology used in
algorithm (GA) in with K-nearest neighbors (KNN) this paper are detailed; in section 3 the experimental
and other machine learning classifiers. The results are discussed and analyzed; and finally, the
researchers in (3) normalized EEG signals then paper concludes in section 4.
applied Stockwell Transform, they extracted then
chaotic features and Parseval's. Extreme Learning 2. MATERIALS AND METHODOLOGY
Machines (ELM) was used for classification. In (10)
the authors used short-time Fourier transform with The proposed framework consists of a set of pre-
28-s windows for pre-processing step. They then processing steps, followed by the setup of a machine
trained a generative adversarial network (GAN) for learning model. This research uses a weak classifier
feature extraction. They used two fully-connected (Decision Tree or DT), An interesting point about
layers for classification. It must be indicated though weak learners is that they learn part of the problem,
that GANs are hard to train due to non-convergence meaning that they rarely overfit, i.e. they have low
and diminished gradient. In (12) sliding discrete variance and high bias (17). Further, they are simple
Fourier transform (SDFT) was employed to to implement which makes them good building
transform signals into frequency domain then blocks for another type of learners used here, the
applied Feed-forward NN (FFNN) as well as ensemble classifiers (Random Forest or RF and
adaptive network-based fuzzy inference (ANFIS) as AdaBoost or AB). Evidently, the time complexities
classifiers. Their reported results indicate good of the suggested algorithms are relatively low. DT
accuracy and low classification run time. A deep has time complexity of O(n*log(n)*d), RF has time
learning system was developed in (13), it acquires complexity of O(n*log(n)*d*k) where n is the data
multi-spectral features by using an ensemble size, d is data dimensionality, and k represents the
architecture. Their system is dedicated the number of trees. Comparing this to other more
classification of the type of seizure. The authors of sophisticated algorithms such as SVM which has
(14) extensively reviewed studies focused on the time complexity of O(n²). 1D convolutional layer
automatic detection of epileptic seizure by using has time complexity of O(l*n*d2) where l is the
deep learning (DL) approaches on different imaging length of the filter, as such, the complexities of other
and scanning techniques. Researchers of publication algorithms such as CNN, GAN and etc. are expected
in (15) produced good studies regarding the to be even higher (18).
application of Artificial Intelligence (AI) systems in
DIAGNOSTYKA, Vol. 24, No. 1 (2023) 3
AL-Huseiny M, Sajit A.: Detection of epileptic seizures in EEG by using machine learning techniques
In ML ensemble combines a set of base during seizure and seizure-free times from five
algorithms to construct a single more robust subjects at the hippocampal region at the opposite
predictive algorithm, the base algorithm for both brain hemisphere and also within epileptogenic
ensembles used in this research is the Decision Tree. zone. Detailed decimation of the dataset is given in
The base algorithms are built as per normal. Table I.
Instances in the training dataset are weighted, the Table I Details of the EUB dataset (21)
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). 2.2. Preprocessing
The models are trained and validated by using a Following the work described by (22), digitized
widely used EEG dataset. The models were time series recording is subdivided into 23 segments
implemented by using Weka 3.8 tool (19) on a dual- of 178 data points for the duration of a little more
core Intel Core i5 MacBook Pro machine clocked at than one second each. This results in a total of 11500
2.5 GHz with 16 GB DDR3 RAM. The various segments of one second recording time at 178 data
stages of the proposed framework are presented points, each having one label.
subsequently: The data includes 5 categories depending on the
status and medical condition of the subject:
2.1. University of Bonn Dataset (EUB) 1. Eyes open: the subject’s eyes were open during
In this research a pre-processed and re-reshaped EEG recording (set A).
version of the well-known University of Bonn 2. Eyes closed: the subject’s eyes were closed
epilepsy dataset is used (20). The dataset is made of during EEG recording (set B).
EEG recordings of healthy subjects as well as 3. Healthy: epileptogenic zone is identified;
patients with epileptic seizures. The dataset includes recording is done in healthy region (set C).
five subsets denoted A–E examples of which are 4. Epileptogenic: recorded in epileptogenic zone
shown in Fig. 1. This figure shows five sample time during seizure free time (set D).
series of brain electric activity (measured in µVolts) 5. Seizure: recording is taken during seizure time
each representing one of the sets listed in Table I. (set E).
For the sake of binary classification (non-
epileptic vs epileptic), recordings of subjects from
categories (1-4) are considered non-epileptic (NE)
while signals from category (5) are considered
epileptic (EP).
prediction. The class with majority votes is regarded to find the best separating pair. The algorithm
the prediction of the random forest model (see Fig. attempts to exploit dependency among models and
2). The inner working of random forest relies on the boosts performance by assigning higher weights to
so-called wisdom of crowds. Whereby a set of mislabeled instances of data (28).
uncorrelated trees (models) operate on the same data
would collectively perform superior to each of them 2.6. Experiment Design
individually. This is so because some models In this research the three classifiers DT, RF and
compensate for the errors of other models. An AB are used, the data is initially preprocessed and
advantage point over decision trees is that RFs are then fed to the classifiers to build their respective
not constructed by using a greedy algorithm, this in models. These models are then used to classify the
turn increase the variance of predictions and data into one of two categories (binary): non-
improves robustness against overfitting (17). epileptic (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.1 through
Eq. 5 are used: Accuracy (Acc), Recall (Rec),
Precision (Pre), False Positive Rate (FPR), False
Negative Rate (FNR), as well as Area under
Receiver operating characteristics (AUC):
𝑇𝑃+𝑇𝑁
𝐴𝑐𝑐 = (1)
𝑇𝑃+𝑇𝑁+𝐹𝑃+𝐹𝑁
𝑇𝑃
𝑅𝑒𝑐 = (2)
𝑇𝑃+𝐹𝑁
𝑇𝑃
𝑃𝑟𝑒 = (3)
𝐹𝑃+𝑇𝑃
𝐹𝑃
𝐹𝑃𝑅 = (4)
Fig. 2. The operation of random forests, 𝐹𝑃+𝑇𝑁
𝐹𝑁
individual tree tally: six 1s and three 0s, 𝐹𝑁𝑅 = (5)
𝐹𝑁+𝑇𝑃
hence prediction:1. (25)
where TP, TN, FP, FN are respectively true positive
and negative and false positive and negative.
Table II Parameters and indicators of the three models
DT RF AB 3. RESULTS AND INTERPRETATION
No. leaves: 129 No. trees: 100 Size of tree: 1 per
Size of tree: 257 No. Iterations: 10 stump In this research the EUB dataset (20) of EEGs
No. Iterations: 10 Correctly No. Iterations: 10
was used to train three classifiers: a weak classifier,
Correctly classified: 11182 Correctly
classified: 11147 Incorrectly classified: 10032
DT, and two ensemble classifiers, RF and AB. The
Incorrectly classified: 318 Incorrectly approach taken by DT seems effective as it achieved
classified: 353 Build time: 41.38 classified 1468 higher accuracy (and balanced accuracy) and better
Build time: 3.69 second Build time: 10.79 area under ROC than AB, this performance was
second seconds slightly improved with the use of RF which seems
even more robust than DT. Thus, in Fig. 3. it is
2.5. AdaBoost noticed that the best achieved AUC was for the case
This model is an ensemble algorithm used to of RF while the least performing algorithm was the
solve classification problems. It falls in a category of AB.
algorithms called boosting, which arranges machine In medical applications it is common to rely on
learning sequentially in order to improve prediction measures other than accuracy. For the suggested
performance and reduce errors made by individual approaches it is noticeable that both DT and RF
models (17). AdaBoost (AB) (27) works by achieve remarkable ROC curves which indicates
combining several weak classifiers to form a strong very high True Positive Rate at a very low False
classifier. The weak classifiers here are DTs with a Positive Rate. As for AB, the results were less
single decision node, the stump. It relies on the remarkable. Another interesting measure
principles of complexity where more sophisticated particularly in medical diagnosis applications is the
systems are constructed from simpler components. FNR where it is less harmful to misdiagnose a
Here stumps are weighted according to the difficulty healthy subject than to misdiagnose a patient. The
of classifying certain instances. Hence, a stump proposed methods have shown excellent results for
selects a feature, Xn, and a threshold, Th, it then FNR especially the RF which score under 1% of
divides the instances into two sets with respect to Th. missed cases of actual epileptic patients.
This is repeated for all features and threshold values
DIAGNOSTYKA, Vol. 24, No. 1 (2023) 5
AL-Huseiny M, Sajit A.: Detection of epileptic seizures in EEG by using machine learning techniques
Classified
Confusion matrix: RF
NE EP
NE 9113 87
Actual
EP 231 2069
Classified
Confusion matrix: AB
NE EP
NE 9063 137
Actual
EP 1331 969
6 DIAGNOSTYKA, Vol. 24, No. 1 (2023)
AL-Huseiny M, Sajit A.: Detection of epileptic seizures in EEG by using machine learning techniques
Received 2022-10-07
Accepted 2022-12-22
Available online 2023-01-06