A CNN Approach for Enhanced Epileptic Seizure Detection Through EEG Analysis
Abstract:
Epilepsy, the most prevalent neurological disorder, is marked by spontaneous, recurrent seizures due to widespread neuronal discharges in the brain. This condition afflicts approximately 1% of the global population, with only two-thirds responding to antiepileptic drugs and a smaller fraction benefiting from surgical interventions. The social stigma and emotional distress associated with epilepsy underscore the importance of timely and accurate seizure detection, which can significantly enhance patient outcomes and quality of life. This research introduces a novel convolutional neural network (CNN) architecture for epileptic seizure detection, leveraging electroencephalogram (EEG) signals. Contrasted with traditional machine-learning methodologies, this innovative approach demonstrates superior performance in seizure prediction. The accuracy of the proposed CNN model is established at 97.52%, outperforming the highest accuracy of 93.65% achieved by the Discriminant Analysis classifier among the various classifiers evaluated. The findings of this study not only present a groundbreaking method in the realm of epileptic seizure recognition but also reinforce the potential of deep learning techniques in medical diagnostics.1. Introduction
Epilepsy, a neurological condition characterized by recurrent, unanticipated seizures, arises from abnormalities in brain's electrical activity. These irregularities disrupt normal neuronal communication, manifesting in varied seizures that temporarily impair brain functions, altering consciousness, movement, sensory perception, or behavior. The manifestations of epilepsy, potentially stemming from underlying conditions such as brain tumors, traumatic injuries, or congenital anomalies, exhibit a broad spectrum of symptoms, including muscle spasms, loss of consciousness, memory gaps, and altered emotional or behavioral states. While pharmacological interventions often effectively manage epilepsy, reducing seizure frequency or controlling them entirely, some cases may witness spontaneous improvement without medication. Diagnosis typically involves a neurological assessment focused on seizure type and frequency, supplemented by EEG tests to record brain's electrical activity. Given the profound impact of seizures on individuals' lives, the development of artificial intelligence-based systems for seizure detection is gaining prominence.
Recent advancements in technology have led to the increasing application of artificial intelligence in biomedical fields (Yildirim, 2023; Eroglu et al., 2023; Eroğlu et al., 2023), particularly in developing computer-aided systems that alleviate experts' workload and facilitate use in non-expert settings. This study focuses on the detection of epileptic seizures using an artificial intelligence-based model, a topic also explored in existing literature. For instance, Sarić et al. (2020), employed a Field Programmable Gate Array (FPGA)-based feed-forward multilayer neural network architecture (MLP ANN) to categorize generalized and localized seizure types. Utilizing 822 signals from the Temple University Hospital Seizure Detection Corpus (TUH EEG Corpus), they achieved a diagnostic accuracy of 95.14% with their (5-12-3) MLP ANN on FPGA. Prathaban & Balasubramanian (2021) proposed an adaptive optimization method using a nonlinear conjugate gradient technique, a Sparsity-based EEG Reconstruction (SER), and a three-dimensional Optimized CNN (3D OCNN) classifier based on the Fletcher Reeves (FR) algorithm. Tested on three different databases (CHB-MIT, NINC, and SRM) with 300 entries, their empirical findings indicated a remarkable 98% accuracy. In another significant contribution, Wang et al. (2021) introduced a novel CNN for assessing time, frequency, and channel information of EEG signals. Incorporating three-dimensional kernels for facilitated feature extraction, their model was evaluated using the CHB-MIT EEG database, achieving an accuracy of 80.5%, surpassing existing state-of-the-art technologies.
In the evolving landscape of epileptic seizure detection, Mao et al. (2020) introduced a CNN-based model, integrating continuous wavelet transform (CWT) for the categorization of epileptic episodes. This model, transforming EEG signal data into time-frequency domain images via wavelet algorithms, achieved an accuracy of 72.49%. Almustafa (2020) explored the classification of the epileptic seizure dataset using various classifiers. The study highlighted the superiority of the random forest classifier over others like naïve Bayes, logistic regression, and decision trees, achieving a notable 97.08% accuracy. Shen et al. (2022) proposed an EEG-based real-time method for the detection of epileptic seizures, employing eigenvalue techniques and discrete wavelet transforms for feature extraction from lower-frequency bands. The RUSBoosted tree ensemble approach, coupled with a support vector machine for three-class categorization, was utilized, demonstrating a 97% accuracy rate across two datasets: the CHB-MIT long-term and the UB short-term datasets.
Mian Qaisar & Subasi (2020) developed a framework for the efficient diagnosis of epileptic seizures, achieving real-time compression and effective signal processing and transfer in EEG signal capture. Utilizing a standard three-class EEG dataset, their system demonstrated a maximum classification accuracy of 97% for a single class and an average of 96.4% across three classes. Beeraka et al. (2022) implemented the short-term Fourier transform block on an FPGA within deep learning models to enhance epileptic seizure detection. Their approach, integrating Bidirectional Long Short-Term Memory (Bi-LSTM) and CNN, utilized the Bonn EEG dataset, achieving an average classification accuracy of 93.9%, with the CNN and Bi-LSTM models reaching 97.2%.
The contributions and innovations of the current study are summarized as follows:
Development of a CNN-based model for EEG signal classification.
The model, comprising 12 layers including the input layer, offers expedited processing due to its reduced layer count.
The model achieves a 97.52% accuracy in early diagnosis of epileptic seizures from EEG signals.
It promises to reduce the workload of specialists and can be utilized for preliminary diagnosis in non-expert settings.
The structure of the study includes the materials and methods section, followed by application findings, discussion, and conclusion in subsequent sections.
2. Methodology
This section delineates the dataset utilized in the study, along with the CNN architectures, layers, and activation functions applied to EEG signals of epilepsy patients.
The dataset employed in this research, sourced from Kaggle (Epileptic Seizure Recognition., n.d.), is a modified version of a commonly used dataset for epileptic seizure detection. Originally, the dataset comprised five distinct classes, each containing 100 files, with each file recording 23.6 seconds of an individual's brain activity. These files were sampled to 4,097 data points per individual, representing the EEG recording values for 23.5 seconds. Figure 1 illustrates the first five lines of the epileptic seizure dataset.
The original data, consisting of 4,097 points per recording, was segmented into 23 parts and reorganized to form a matrix of 23×500 = 11,500 data points. This restructuring resulted in each row comprising 178 data points for one second of recording, with the final column (column 179, labeled 'y') denoting the class (1-5). Table 1 presents the label value for each class.
Class | Class Description |
1 | Recordings indicative of seizure activity. |
2 | EEG signals from regions with tumor presence. |
3 | EEG activity recorded from healthy brain regions, aiding in the identification of tumor locations. |
4 | Data captured with the patient's eyes closed. |
5 | Data captured while the patient's eyes were open. |
In this dataset obtained from the Kaggle platform, subjects in the first class exhibited epileptic seizures, while those in the second, third, fourth, and fifth classes did not. The dataset underwent preprocessing, with all non-seizure activities labeled as class '0' and seizure activities as class '1'. It was subsequently divided into an 80% training set and a 20% test set.
CNN architecture, a cornerstone of deep learning neural networks, is prevalently applied in image classification and signal processing. Distinct from traditional machine learning architectures, deep learning models autonomously execute these tasks, eliminating the need for manual feature extraction and preprocessing. CNN architectures, bypassing the necessity for expert knowledge in feature extraction, directly extract features through the model itself, facilitating the learning process. This advantage has led to a surge in the use of CNN architectures in recent years. Fundamentally, CNNs comprise four layers: convolution, activation, pooling, and fully connected layers (Tripathy & Singh, 2022; Başaran, 2022).
CNN architectures, with their layered structure, are typically divided into two segments. The first encompasses the feature extraction process, employing combinations of input, convolution, and pooling layers. The second segment consists of a fully connected layer, executing the classification task. The arrangement of these layers is not standardized, allowing for the creation of novel models through adjustment of layer sequences and parameter values within the network.
This subsection elucidates the various layers and activation functions employed in the design of CNN architectures.
Contrary to classical neural networks where data entry is a one-dimensional array, in CNN architectures, multidimensional array formats are utilized. The input layer transmits the raw image data, formatted as a matrix, to the convolutional layer (Alizard et al., 2022).
The convolutional layer's objective is to extract features from the input image using diverse-sized filters, referred to as kernels. It is within these regions that features, defined by each filter, are discerned in the output generated by the convolution process (Pandian et al., 2022).
The pooling layer operates by moving specific filters across the image with a predetermined stepping value. This action reduces the input size for subsequent network layers, thereby diminishing computational load. This layer is instrumental in decreasing data size and computational costs, and it aids in preventing network overfitting.
Commonly preferred activation functions in CNN architectures include Softmax and Rectified Linear Unit (ReLU). However, other functions like Sigmoid, Tanh, and Leaky ReLU are also utilize (Yildirim & Cinar, 2022).
ReLU: Employed frequently in nonlinear and CNN architectures' intermediate layers, ReLU activates neurons selectively. It outputs zero for negative input values, thus deactivating neurons in such scenarios. While advantageous in reducing simultaneous neuron activation, its drawback lies in converting all negative values to zero (Bai et al., 2023).
Softmax: Primarily used for multi-class classification problems, Softmax differs from the binary classification-oriented sigmoid function. In multi-class models, the output layer's neuron count corresponds to the number of target classes (Dubey et al., 2022).
Sigmoid: This function, converting input values into a range between 0 and 1, is widely applied for its continuous differentiability and consistent neuron output signs.
The choice of activation function varies based on the specific task at hand. For example, in classification problems, sigmoid functions might yield better results. However, the use of sigmoid and tanh is sometimes avoided due to the vanishing gradient issue, especially in hidden layers.
In the methodology, the ReLU activation function is predominantly applied in the hidden layers of the neural network architecture. This preference is attributed to the derivative of ReLU being one, which facilitates the learning process in these layers (Sharma et al., 2017).
To avert overfitting during training with large datasets, the dropout technique is applied, selectively deactivating nodes in the fully connected layer (Tufail et al., 2022).
The flatten layer converts matrix-sized data from convolution and pooling layers into a one-dimensional array, facilitating its processing in the fully connected layer (Nguyen et al., 2022).
In CNN architecture, preceding the classification layer, is a fully connected layer. This layer transforms multidimensional feature maps into a single dimension for classification. The fully connected layer's output is organized into classes equivalent to the target number of classes (Pal et al., 2022).
3. Results
In this study, a CNN-based model was developed for the detection of epileptic seizures from EEG signals. To benchmark the performance of this model, established classifiers in the field were utilized. The model's efficacy was assessed using k-nearest neighbor (KNN), logistic regression, discriminant analysis, and AdaBoost classifiers, focusing on the classification of four distinct scenarios to predict epileptic seizure occurrences. A portion constituting 20% of the epileptic seizure dataset was allocated for testing purposes. The classification accuracy of the dataset, using the aforementioned classifiers, was determined via confusion matrices and accuracy rates. Various parameters, including accuracy, sensitivity, specificity, False Discovery Rate (FDR), False Positive Rate (FPR), False Negative Rate (FNR), and F1-score, were employed to gauge the models' performance (Eroğlu et al., 2021; Yildirim, 2023).
The preprocessing phase involved the EEG recording dataset. To achieve balance, classes were designated as '0' for non-seizure activities and '1' for seizure activities. Identification and rectification of any null or missing values were undertaken to maintain data integrity. The first five rows of the dataset, post-class assignment, are depicted in Figure 2.
Normalization of each EEG sample was conducted, encompassing 178 data points using the StandardScaler function. This normalization ensured a mean of 0 and a variance of 1 for all features. Adaptation of the data to meet the input requirements of the CNN was executed, resulting in the division of the dataset into an 80% training set and a 20% testing set.
In the current investigation, four different classifiers were evaluated for their efficacy in comparison with the proposed model. The first classifier under consideration was the KNN classifier. The confusion matrix generated by the KNN classifier is depicted in Figure 3.
Analysis of the KNN confusion matrix (Figure 3) revealed an accuracy rate of 92.48% in classifying the test data. Of the 2,300 data points allocated for testing, the KNN classifier accurately predicted 2,127 instances, with 173 being incorrectly classified. The classifier exhibited equivalent performance in both “0” (non-seizure) and “1” (seizure) classes. Table 2 presents the performance measurement metrics for the KNN classifier.
| Accuracy (%) | Sensitivity | Specificity | F1 | FPR | FNR | FDR |
0 | 92.48% | 0.91 | 1.00 | 1.00 | 0.95 | 0.00 | 0.09 |
1 | 92.48% | 1.00 | 0.91 | 0.63 | 0.77 | 0.09 | 0.00 |
Examination of the KNN classifier's performance metrics indicated a highest accuracy rate of 92.48% for both “0” and “1” classes. The logistic regression classifier was another tool used for analysis. Figure 4 illustrates the confusion matrix produced by this classifier.
Upon scrutinizing the Logistic Regression confusion matrix (Figure 4), an accuracy rate of 83.17% was observed in classifying the test dataset. The Logistic Regression classifier correctly identified 1,913 out of the 2, 300 test data, while incorrectly classifying 387 instances. Performance metrics for the logistic regression classifier are summarized in Table 3.
Accuracy | Sensitivity | Specificity | F1 | FPR | FNR | FDR | |
0 | 83.17% | 0.83 | 0.95 | 1.00 | 0.90 | 0.05 | 0.17 |
1 | 83.17% | 0.95 | 0.83 | 0.18 | 0.30 | 0.17 | 0.05 |
The logistic regression classifier's performance metrics showed that the highest accuracy rate for both "0" and "1" classes was 83.17%. Additionally, discriminant analysis was utilized as a classifier for EEG signal categorization. The confusion matrix computed by the discriminant analysis classifier is shown in Figure 5.
Upon analysis of the discriminant analysis classifier's confusion matrix, as depicted in Figure 5, a classification accuracy rate of 93.65% was observed for the test dataset. Of the 2,300 test data points, 2,154 were correctly identified and 146 misclassified by the discriminant analysis classifier. The classifier's performance demonstrated parity in both the “0” (non-seizure) and “1” (seizure) classes. Table 4 delineates the performance measurement metrics for the discriminant analysis classifier.
| Accuracy (%) | Sensitivity | Specificity | F1 | FPR | FNR | FDR |
0 | 93.65% | 0.97 | 0.82 | 0.95 | 0.96 | 0.18 | 0.03 |
1 | 93.65% | 0.82 | 0.97 | 0.88 | 0.85 | 0.03 | 0.18 |
The Discriminant Analysis classifier's performance metrics underscored an equal highest accuracy rate of 93.65% for both the "0" and "1" classes. Further, the AdaBoost classifier was evaluated, and its corresponding confusion matrix is presented in Figure 6.
The examination of the AdaBoost confusion matrix (Figure 6) revealed an accuracy rate of 87.87% in classifying the test data. The AdaBoost classifier accurately predicted 2,021 instances, with 279 being incorrect classifications, out of the 2,300 data points allocated for testing. The classifier maintained consistent performance across the “0” and “1” classes. Table 5 displays the performance measurement metrics for the AdaBoost classifier.
| Accuracy (%) | Sensitivity | Specificity | F1 | FPR | FNR | FDR |
0 | 87.87% | 0.90 | 0.75 | 0.95 | 0.93 | 0.25 | 0.10 |
1 | 87.87% | 0.75 | 0.90 | 0.60 | 0.67 | 0.10 | 0.25 |
An analysis of the AdaBoost classifier's performance metrics indicated the highest accuracy rate of 87.87% for both "0" and "1" classes.
The proposed model, employing a multilayer CNN, has been developed for the analysis and prediction of epileptic seizures from EEG data. A schematic representation of this model is provided in Figure 7.
The primary architecture of the model is a CNN, which is particularly adept at processing time-series data, such as EEG readings. This CNN-based model encompasses an input layer, succeeded by alternating Conv1D and MaxPool1D layers. Each Conv1D layer is distinct in its filter count and kernel size and utilizes the ReLU activation function. MaxPool1D layers contribute to dimensionality reduction of the input, thereby decreasing the model's computational complexity. The reduced number of layers in the model ensures enhanced speed and efficiency in processing. The model is designed to alleviate the workload of experts and is feasible for use in non-specialist environments.
Incorporated after each convolution and max pooling layer is a dropout layer. This layer randomly disables a fraction of input units during each update in the training phase, a strategy intended to prevent overfitting.
The model culminates in a flatten layer, which collapses the spatial dimensions of the input into the channel size. This is followed by a dense layer comprising two neurons, employing the 'softmax' activation function. This layer is responsible for classifying the input into two categories: seizure and non-seizure, providing output probabilities.
For training, stochastic gradient descent is utilized as the optimization technique, and binary cross-entropy serves as the loss function. The performance of the model is assessed using various evaluation metrics. The confusion matrix corresponding to the classifier of the proposed model is illustrated in Figure 8.
Upon examining the confusion matrix of the proposed CNN-based model, as illustrated in Figure 8, an accuracy rate of 97.65% was achieved in the classification of the test data. The model correctly classified 2,246 out of the 2,300 data points allocated for testing, with 54 instances of misclassification. Uniform performance was observed in both the "0" (non-seizure) and "1" (seizure) classes. To assess the model's performance more intricately, precision, recall, and F1-score for each class were considered, alongside the creation of confusion matrices and classification reports. The accuracy and loss curves for the training and test sets of the proposed model are displayed in Figure 9.
A comparative analysis between the proposed model and other classifiers revealed a smaller disparity between the training and test accuracy curves in the proposed model, as opposed to the wider differences observed in the accuracy curves of other classifiers. This suggests a higher rate of correct prediction for each class in the proposed model's confusion matrix, compared to other models. Table 6 presents the performance measurement metrics derived from the proposed model.
| Accuracy (%) | Sensitivity | Specificity | F1 | FPR | FNR | FDR |
0 | 97.65% | 0.98 | 0.95 | 0.99 | 0.99 | 0.05 | 0.02 |
1 | 97.65% | 0.95 | 0.98 | 0.93 | 0.94 | 0.02 | 0.05 |
An examination of the proposed model's performance metrics underscored the highest accuracy rate of 97.65% for both "0" and "1" classes. Table 7 lists the accuracy values obtained in the proposed model alongside the four other classifiers used in the study.
KNN | Logistic Regression | Discriminant Analysis | AdaBoost | Proposed Model |
92.48 | 83.17 | 93.65 | 87.87 | 97.65 |
In the classification process of two distinct conditions derived from the epileptic seizure dataset, the proposed CNN-based model attained the highest accuracy rate, recorded at 97.65%. This performance was comparatively superior to that of other classifiers: discriminant analysis achieved an accuracy of 93.65%, KNN reached 92.48%, AdaBoost obtained 87.87%, and logistic regression was at 83.17%.
The proposed model, which yielded the highest accuracy, accurately predicted 2,246 out of 2,300 test data points, with 54 instances of misclassification. Analysis of the performance metrics indicated that both classes "0" and "1" achieved an equivalent highest accuracy of 97.65%.
Conversely, the classifier with the lowest accuracy was logistic regression, which correctly classified 1,913 out of 2,300 data points, misclassifying 387. Upon reviewing the performance metrics of the logistic regression classifier, it was observed that both the "0" class and the "1" class attained an accuracy rate of 83.17%.
4. Discussion
In the present study, a multilayer CNN model was developed for the automated detection of epileptic seizures from EEG recordings. The process encompassing data preprocessing, model training, and testing revealed that the model is capable of detecting seizures with an accuracy of 97.65%. This high degree of accuracy was also mirrored in the sensitivity, specificity, and F1-score metrics.
When compared to traditional classifiers such as discriminant analysis, KNN, AdaBoost, and Logistic Regression, which achieved accuracies of 93.65%, 92.48%, 87.87%, and 83.17% respectively, the proposed CNN model exhibited superior performance. This enhanced efficacy can be attributed to the deep learning capabilities of the CNN, which are adept at extracting complex features from time-series data. The comparative performance of the proposed model and these classifiers is depicted in Figure 10.
However, the model is not without limitations. The performance is notably contingent on the distribution and quality of the training dataset. To address this, future work will focus on training the model using larger and more varied EEG datasets. This approach is anticipated to further enhance the performance and robustness of the model.
In conclusion, the CNN model developed in this study has demonstrated its effectiveness as a tool for the automatic diagnosis of epileptic seizures. Such advancements in seizure detection hold the potential to significantly improve the management and monitoring of epilepsy treatment, ultimately contributing to better patient quality of life.
5. Conclusion
Epileptic seizures, resulting from cerebral abnormalities, affect approximately 1% of the global population and can have indirect impacts on patient health. Accurate prediction and early intervention are crucial in managing these seizures. In response to this need, a computer-aided model based on CNN technology was developed in this study. This method facilitates early diagnosis of epileptic seizures, potentially enabling more timely treatment.
The CNN-based model exhibited a high degree of effectiveness, achieving an accuracy of 97.65%. Such performance indicates that the model not only reduces the workload of healthcare professionals but also minimizes the likelihood of conventional diagnostic errors. Moreover, its utility extends beyond expert settings, suggesting its applicability in broader, non-specialist environments.
This study adheres to strict ethical guidelines, ensuring the rights and privacy of participants. Informed consent was obtained from all participants, and personal information was protected throughout the study. The methodology and procedures of this research have been approved by the appropriate ethics committee. Participants were informed of their rights, including the right to withdraw from the study at any time. All collected data is used solely for the purpose of this research and is stored and processed in a secure and confidential manner.
The data used to support the research findings are available from the corresponding author upon request.
The authors declare no conflict of interest.