Next Article in Journal
Three-Dimensional Object Recognition Using Orthogonal Polynomials: An Embedded Kernel Approach
Previous Article in Journal
Intelligent Multi-Fault Diagnosis for a Simplified Aircraft Fuel System
Previous Article in Special Issue
Artificial Intelligence and Algorithmic Approaches of Health Security Systems: A Review
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Seizure Detection in Medical IoT: Hybrid CNN-LSTM-GRU Model with Data Balancing and XAI Integration

1
Department of Computer Science, College of Computer Engineering and Sciences, Prince Sattam Bin Abdulaziz University, Al-Kharj 16278, Saudi Arabia
2
Department of Computer Science and Engineering, Faculty of Electronic Engineering, Menoufia University, Menouf 32952, Egypt
3
Department of Information Systems, College of Computer Engineering and Sciences, Prince Sattam Bin Abdulaziz University, Al-Kharj 16278, Saudi Arabia
4
Structure and Materials Research Lab, Prince Sultan University, Riyadh 12435, Saudi Arabia
5
Department of Electrical Energy Engineering, College of Engineering & Technology, Arab Academy for Science Technology & Maritime Transport, Smart Village Campus, Giza 12577, Egypt
6
Industrial Electronics and Control Engineering Department, Faculty of Electronic Engineering, Menoufia University, Menouf 32952, Egypt
*
Authors to whom correspondence should be addressed.
Algorithms 2025, 18(2), 77; https://doi.org/10.3390/a18020077
Submission received: 17 December 2024 / Revised: 16 January 2025 / Accepted: 23 January 2025 / Published: 1 February 2025

Abstract

:
The brain acts as the body’s central command, overseeing diverse functions including thought, memory, speech, movement, and the regulation of various organs. When healthy, the brain functions seamlessly and automatically; however, disruptions can lead to serious conditions such as Alzheimer’s Disease, Brain Cancer, Stroke, and Epilepsy. Epilepsy, a neurological disorder marked by recurrent seizures, results from irregular electrical activity in the brain. These seizures, which can strain both patients and neurologists, are characterized by symptoms like the loss of awareness, unusual behavior, and confusion. This study presents an efficient EEG-based epileptic seizure detection framework utilizing a hybrid Convolutional Neural Network (CNN), Long Short-Term Memory (LSTM), and Gated Recurrent Unit (GRU) models approach to support automated and accurate diagnosis. Handling imbalanced EEG data, which can otherwise bias model outcomes and reduce predictive accuracy, is a key focus. Experimental results indicate that the proposed framework generally outperforms other Deep Learning and Machine Learning techniques with the highest accuracy at 99.13%. Likewise, an Explainable Artificial Intelligence (XAI) called SHAP (SHapley Additive exPlanations) is utilized to analyze the results and to improve the interpretability of the models from medical decision-making. This framework aligns with the objectives of the Medical Internet of Things (MIoT), advancing smart medical applications and services for effective epileptic seizure detection.

1. Introduction

Today, Artificial Intelligence (AI) has become a significant driver in personalized diagnosis, treatment planning, and disease management within telemedicine applications. This advancement is further enhanced by the integration of Internet of Things (IoT) technology [1,2], as highlighted in [3,4].
Electroencephalogram (EEG) signals are electrical impulses generated by brain activity. Wearable EEG devices enable elderly and disabled individuals to collect EEG data, which can then be processed into control signals through motor imagery, allowing for remote control functions. Since EEG signals exhibit unique patterns in different mental states, machine learning techniques are well-suited for their classification. Many researchers have highlighted the applications of EEG signals and brain–computer interfaces in areas such as smart homes [5] and healthcare devices [6]; however, limited attention has been given to securing and maintaining the privacy of the EEG data itself.
Medical Internet of Things (MIoT) refers to the integration of Internet of Things (IoT) technology into the healthcare sector to enable efficient, real-time monitoring, diagnosis, and management of patients’ health. In practice, the Medical Internet of Things (MIoT) framework centered around EEG data is vulnerable to various security threats, including both passive and active attacks. Passive attacks involve intercepting or eavesdropping on transmitted data, while active attacks include altering or manipulating EEG data. For instance, when a hospital uses a cloud service to predict epilepsy risks in patients, it is crucial to ensure not only accurate predictions but also the security and privacy of the transmitted data. Consequently, securely handling encrypted EEG data has become a significant challenge. Some researchers have started exploring encryption-integrated machine learning solutions in response to these concerns, as discussed in [7,8].
Advances in Artificial Intelligence (AI), Machine Learning (ML), and the Internet of Things (IoT) offer promising potential for enhancing disease classification and prediction in telemedicine applications. ML techniques, for example, can facilitate the early detection of skin conditions with high accuracy and reliability. Recently, IoT and medical systems have emerged as complementary technologies that enhance Medical Internet of Things (MIoT) applications. By integrating healthcare services with IoT devices, real-time monitoring, analysis, and decision-making become possible in complex healthcare systems, bringing substantial benefits to patient care. The MIoT system encompasses multiple tiers, as depicted in Figure 1, and are as follows:
Layer 1: In this layer, the essential role is played by MIoT sensors and actuators responsible for collecting and monitoring various medical and healthcare data.
Layer 2: This layer encompasses the utilization of gateway and edge devices, serving as intermediaries connecting the Wireless Sensor Network (WSN) to cloud servers. These devices form an integral part of the MIoT-based controller platform.
Layer 3: The utilization of cloud computing comes into play here, demonstrating its efficiency in powering intelligent medical IoT systems. The proposed system employs cloud computing servers for the storage and processing of industrial control field data obtained through the MIoT-based controller. The collected medical data are periodically transmitted to the appropriate channel via an IoT protocol like the Constrained Application Protocol (CoAP).
Layer 4: At this layer, the focus shifts towards crafting mobile and web applications that interface with cloud servers to access analytical outcomes generated by applying machine learning techniques to store medical and healthcare data. The primary objective is to provide actionable decision-making insights for healthcare institutions.
In general, the multitier architecture of an MIoT system facilitates seamless data flow, storage, and subsequent analysis.
Imbalanced data pose a significant challenge in EEG seizure detection, where it refers to an unequal distribution of instances across classes in the dataset. In EEG seizure detection, instances representing normal brain activity typically far exceed those depicting seizure events. This imbalance can result in biased model performance and inaccurate predictions, as the algorithm may favor the majority class (normal activity) while struggling to accurately identify the minority class (seizures).
Imbalanced data in EEG seizure detection can have significant consequences. Models trained on imbalanced datasets often default to classifying most instances as belonging to the majority class (normal brain activity) due to its prevalence, thereby overlooking the critical minority class (seizures). This leads to a problematic trade-off where the model’s high accuracy is largely due to its success in identifying the majority class, while it struggles to detect seizure events accurately.
Addressing imbalanced data in EEG seizure detection is essential for achieving accurate and reliable outcomes. Techniques like resampling—either by oversampling the minority class or under-sampling the majority class creating synthetic samples—and specialized algorithms such as ensemble methods can help balance class distributions. These approaches enable the model to effectively learn from both classes, ensuring that seizure instances are not overshadowed by the abundance of normal data, thus improving the overall performance and reliability of seizure detection.
In real-world scenarios, collecting medical data like EEG from devices poses additional challenges, often resulting in a class imbalance that complicates fault diagnosis. Training seizure detection models directly on such imbalanced datasets can lead to overfitting on the minority class and bias toward the majority class. To overcome this, we propose a specialized seizure detection framework, leveraging an optimized K-Nearest Neighbors (KNN) algorithm adapted for imbalanced EEG data, specifically designed to enhance performance in smart medical IoT systems. In brief, this paper provides a robust and intelligent framework for seizure detection considering the context of MIoT devices. With the impressive strides seen in MIoT health care, we emphasize the relevance and practicality of our ensemble model in this field. The contributions of this paper can be summarized as follows:
  • The proposed hybrid framework is a merge of deep learning techniques including Convolutional Neural Networks (CNNs), Long Short-Term Memory (LSTM) networks, and Gated Recurrent Units (GRUs) The suggested hybrid framework is validated for seizure detection in EEG signals.
  • The synthetic minority oversampling technique (SMOTE) is applied and is used to balance the dataset by creating additional samples for the minority class. Additionally, the Explainable Artificial Intelligence (XAI) technique, SHAP (Shapley Additive Explanations), is applied to evaluate the importance and effectiveness of the features.
  • To validate and determine the effectiveness of the proposed technique in identifying seizures, the comparison result with existing Machine Learning (ML) and Deep Learning (DL) models is conducted. The results demonstrate that the CNN-LSTM-GRU model performed better than other models in the detection of seizures. The proposed technique has a higher accuracy, precision, F1 score, recall, and specificity.
  • The proposed model is designed with real Medical IoT (MIoT) applications. So, the model extends the scope of seizure monitoring intelligently due to its scalability and flexibility. The designed approach allows a range of MIoT components to operate efficiently regardless of the deployment environment.
The article is organized as follows: Section 2 reviews previous studies related to the topic, while the proposed system for MIoT is outlined in Section 3. Section 4 details the experimental study and analyzes the results. Finally, Section 5 provides the conclusion on this innovative approach.

2. Materials and Methods

Recently, considerable focus has been placed on the classification and modeling of EEG data. Electroencephalography (EEG) has become an essential tool for remote epileptic seizure detection, and numerous methodologies have been developed for the early assessment of epilepsy [9,10,11]. Recent research has focused on optimizing EEG data classification and enhancing privacy through secure methods. Yong Jiao and colleagues [9] proposed a Sparse Group Representation Model (SGRM) that leverages intersubjective data to develop an accurate motor imagery-based Brain–Computer Interface (BCI), achieving a classification accuracy of 78.2%. Chatterjee and colleagues [10] utilized the Fuzzy Discernibility Matrix (FDM) for feature extraction from EEG signals, employing Support Vector Machine (SVM) and ensemble classifiers for accuracy evaluation, though the method encounters limitations in handling large EEG datasets and multiclass scenarios.
For EEG data classification, a deep Convolutional Neural Network (CNN) approach reached 86.41% accuracy in [11] and 85.62% in [12]. In another study, Coiflets wavelets were used for preprocessing, focusing on amplitude-based feature extraction [13]. Ward and colleagues [14] applied Joint Factor Analysis and I-vectors for feature extraction with Universal Background Models (UBMs) for classification, although this approach did not achieve optimal accuracy.
In [15], multi-feature fusion with CNNs was recommended for automated epilepsy detection. Another study [16] proposed an algorithm for noisy environments, using sample entropy and phase synchronization with Variational Mode Decomposition (VMD) for seizure detection. This model emphasized minimizing false alarms while ensuring cross-patient applicability. To improve efficiency, the dynamic Epileptic-Net model was introduced [17], and in [18], both time- and frequency-domain features were used with machine learning models (e.g., Logistic Regression, Decision Trees, SVM) to detect seizures within the Temple University Hospital (TUH) corpus. Additionally, Ref. [19] used discrete wavelet transform (DWT) and genetic algorithms with machine learning classifiers to enhance epileptic seizure detection accuracy and reduce computation time. Additionally, in [20], a novel method integrating Bi-LSTM, GRU, and Average Pooling demonstrated exceptional performance across binary and multiclass tasks. Also, some hybrid models are used as in [21,22,23].
One of the open research areas in AI and ML is XAI. Although AI, especially deep learning, has become increasingly sophisticated and complex, they are viewed as “black boxes”, making it difficult to understand how they compute the predictions or decisions. XAI provides the tools to explain and interpret these models in users appropriate ways to trust the models [24,25,26]. In the last decade there has been a lot of research focus into XAI in healthcare [27]. In Ref. [28] the revolutionary potential of Explainable AI (XAI) is demonstrated in developing Healthcare 5.0. It highlights the significance of explainability in boosting trust, privacy, and clinical decision-making by proposing a thorough architecture and solution taxonomy for XAI in applications like CT image analysis and ECG monitoring
Recently, considerable research has focused on EEG classification, as demonstrated by the studies discussed above. Table 1 shows a comparative summary of EEG data classification techniques in medical applications. However, little attention has been paid to applying optimization techniques to improve machine learning models and address the problem of imbalanced data in seizure recognition datasets. These datasets are used to classify EEG signals and aim to automatically detect seizures at an early stage. This paper presents an effective approach for seizure detection and prediction that not only addresses the problem of imbalanced EEG data, which often leads to overfitting, but also incorporates optimization techniques to improve model performance. The proposed system shows promise for deployment in smart healthcare applications.
The use of Artificial Intelligence (AI) in healthcare raises important ethical considerations that must be addressed to ensure its responsible application. One critical concern is bias in AI models, which can arise from imbalanced training data and may lead to unequal outcomes for different patient groups. Ensuring fairness requires diverse, representative datasets and rigorous validation across various populations to mitigate the risk of discriminatory practices. Another vital aspect is informed consent, where patients must be made aware of how their data are collected, processed, and utilized by AI systems. Transparency in AI decision-making, supported by Explainable AI techniques, is crucial for building trust between patients and healthcare providers. Additionally, safeguarding patient privacy and complying with regulatory frameworks such as HIPAA and GDPR are essential to uphold ethical standards. By addressing these considerations, the integration of AI in healthcare can be guided by the principles of fairness, accountability, and respect for patient autonomy.

3. Proposed Seizure Detection for MIoT

This section explains the main stages for our proposed model and demonstrates its construction for handling complex data typically associated with the MIoT.

3.1. Stages of Proposed Framework

Based on smart Medical Internet of Things (MIoT) systems technology which ensures the detection of seizures from EEG signals with maximum reliability, the proposed detection system is founded on a developed theoretical framework, consisting of, but not limited to, statistical learning, optimization theory, and deep learning techniques. We introduced a robust method for the automated identification and detection of seizures by a set of advanced Deep Learning (DL) methodologies, each adopted for its theoretical merits and its relevance to the identification problem while effectively addressing the challenge of imbalanced EEG data, all within the context of MIoT systems. The depicted system structure can be observed in Figure 2, encompassing a series of significant stages aimed at achieving accurate seizure prediction.
The main steps of the proposed system are elaborated as follows:
  • Step 1 (Data Acquisition): At this initial stage, the imbalanced seizure datasets are collected, forming the foundation for subsequent phases within the proposed framework.
  • Step 2 (Data Preprocessing): All instances of the dataset are imported to make them suitable for further processing within the framework. To effectively address the imbalance problem, the SMOTE technique is applied to handle seizure instances.
  • Step 3 (Model Training/Testing): The preprocessed and rebalanced dataset is divided into an 80–20 ratio, where 20% is allocated for the testing phase and 80% for the training phase. This initiates the training phase for hybrid Deep Learning models (i.e., CNN-LSTM-GRU). To evaluate the proposed framework, a subset of randomly selected training data is used for the chosen DL for seizure analysis.
  • Step 4 (Feature interpretability): In this segment of the framework, the SHAP (Shapley Additive Explanations) technique is employed to enhance interpretability, providing insights into feature contributions for the prediction. This makes it easier to comprehend how the model is attained and helps in the decision-making process

3.2. Proposed Model Architecture

SMOTE or the Synthetic Minority Over-sampling Technique can be said to be an effective algorithm in solving class imbalance issues in EEG data specifically for seizure classification. SMOTE improves the proportion of minorities to majorities in the given dataset by creating realistic synthetic samples rather than repeating the subjects of the minority class. It does so by using the existing samples of the minority class and drawing new points in the feature space defined by these samples. If this technique is utilized when dealing with EEG data, it will prevent the under-representation of seizure-related patterns, improving the efficiency of training the machine to classify both seizure and non-seizure instances thus raising the general classification performance.
Convolutional Neural Networks (CNNs) are applied due to their unique strength of feature extraction of the raw EEG data. This ability is important in mapping the complex and decorated patterns of the EEG signals associated with seizures, such as identifying some small changes that may be related to seizures. Whereas Recurrent Neural Networks (RNN) called LSTM and GRU are developed to avoid the loss gradient result, these architectures can represent temporal dependencies. Their capability to remember information over long sequences makes them suitable for continuous and time-varying data such as EEG, hence facilitating the monitoring and classification of seizures.
Our proposed technique is the combination of CNN with LSTM and GRU. The model has two types of inputs with two branches that connect to a final concatenation layer. In the case of the CNN branch, the first layer is an input layer where the dimensions are determined by the training dataset, followed by a 1D convolutional layer that applies the relevant filters to capture and retrieve local structures in EEG data. This is then followed by a MaxPooling layer designed to down-sample the convoluted feature maps or the activations and highlight the most critical features. The features are then flattened, ready for concatenation with the LSTM and GRU feature branches. So, the architecture of the hybrid model is as follows: The CNN branch has 3 Layers (Conv1D -> MaxPooling1D -> Flatten). It uses ReLU activation in the convolutional layer for non-linearity. The LSTM branch has 1 Layer u which uses ReLU activation in the LSTM layer. The GRU branch has 1 Layer. Similarly to LSTM, ReLU activation is used in the GRU layer. The concatenation layer combines the outputs of CNN, LSTM, and GRU into a single feature vector. The output layer has a dense layer with 1 unit and sigmoid activation for binary classification. The compilation details optimizer is Adam with loss function: binary cross-entropy and metrics are the accuracy.
The temporal dependencies within the model are managed in the second branch utilizing the LSTM and GRU layers. The LSTM layer is intended to learn the long-term dependencies thanks to its ability to learn sequences with varying complex dynamics. The GRU layer works similarly and is also utilized to learn varying patterns but in a rather more simplified manner. The output features generated from all three branches, the CNN, LSTM, and GRU, are merged through a concatenate layer, thereby allowing the fusion of the selected features collected from the CNN and the other selected features captured from the LSTM and GRU. The concatenated resulting output is further passed to the final dense layer which is fitted with a sigmoid activation function to enable it to perform a binary classification: seizure or no seizure. The construction is undertaken using the Adam optimizer and binary cross-entropy loss as the compilation of the model for 100 epochs.

4. Experimental Results

This section presents a description of the Epileptic Seizure Recognition Dataset, along with the performance metrics and results analysis of the proposed system.

4.1. Epileptic Seizure Recognition Dataset

The epileptic seizure dataset used in this study is sourced from [35], with its structure detailed as follows: it consists of 11,500 samples, each containing 178 features, following a normal distribution. The dataset is categorized into two binary classes, represented as Y = {0, 1} A comprehensive description of this dataset is provided in Table 2 and Figure 3.
The original dataset from the reference consists of 500 patients. For each patient, a 23.6 s recording of brain activity. The recording is sampled into 4097 data points, with each point representing the EEG signal value at a specific moment in time. The dataset includes recordings from 500 patients, with each patient contributing 4097 data points captured over the 23.6 s duration.

4.2. Evaluation Metrics

The effectiveness of Deep Learning models in classification and prediction tasks is commonly evaluated using metrics like accuracy. These evaluation metrics, including accuracy, can be derived by analyzing parameters from the confusion matrix, as illustrated in Table 3. The accuracy, precision, and recall metrics are calculated using Equations (1)–(4), respectively.
After calculating the parameters, the performance metrics can be computed as follows [36,37,38]:
A c c u r a c y = T P + T N T P + F P + F N + T N
P r e c i s i o n = T P T P + F P
R e c a l l = T P T P + F N
S p e c i f i c i t y = T N F P + T N
F 1 s c o r e = 2 × P r e c i s i o n × R e c a l l P r e c i s i o n + R e c a l l

4.3. Results Analysis

In the initial phase, EEG signals are preprocessed to improve their quality. This process begins with the application of the min–max normalization technique to standardize the dataset. First, the minimum and maximum values in the dataset are identified. Each data point is then scaled relative to these extremes to set the maximum value to 1 and the minimum to 0, placing all other values within the [0, 1] range.
To correct the dataset’s class imbalance, SMOTE is applied. Class imbalance refers to the situation when one or more classes have an extremely lower number of sample data than the other(s); this could make the model biased towards the majority class. With SMOTE, the seizure activity class is expanded by synthetic means instead of just randomly respawning some members of that class. This means that the feature space of the minority class instances is located, similar ones are paired up, and synthetic ones are created in between those pairs. This way the classes in the training set become balanced, improving the capability of the model to learn the distinguishing characteristics of the minority class thus improving the generalization of the model.
The design of the hybrid CNN-LSTM-GRU-based algorithm for the detection of seizures from EEG signals takes advantage of Convolutional Neural Networks (CNN), Long Short-Term Memory (LSTM), and Gated Recurrent Units (GRU) to consider all features from the EEG data.
Figure 4 shows the training and validation accuracy of our proposed framework for 100 epochs. The training accuracy rises sharply and flattens out at almost 100%, indicating that the model fits the training data very well. The validation accuracy increases in the same manner but stabilizes at a value slightly less than the training accuracy, around 99%. The above scenario of the training and validation accuracy indicates that there is no overfitting as the model has generalized well. The high accuracy level of 99.13% achieved within the framework demonstrates the strength of this framework in seizure detection using EEG signals.
From the ROC curve shown in Figure 5, our proposed framework achieves an accuracy of 99.15% which indicates exceptional performance in distinguishing between classes. The curve closely follows the top left corner of the graph, reflecting that the model accurately identifies almost every positive instance without incorrectly classifying any negatives as positives. Such a result signifies an ideal balance between sensitivity and specificity, suggesting the model’s highly reliable performance in classification tasks.
The XAI technique with the use of SHAP [25] is employed to enhance interpretability, providing insights into feature contributions for the prediction for the different model as shown in Figure 6 and Figure 7. This makes it easier to comprehend how the model is attained and helps in the decision-making process. So, the SHAP summary plot provides a comprehensive view of feature importance and its influence on seizure classification. The features are ranked by their impact, with X177 being the most influential in the proposed model. The local explanation and SHAP plot play a significant role in showing how the model came up with the prediction of a seizure, determining the specific features that contribute to the model’s output, enhancing interpretability, and identifying the key drivers in seizure detection.

4.4. Comparison Results

The comparison of the different DL models with the proposed model is conducted to evaluate the effectiveness of the proposed framework. The comparison results of confusion matrices are depicted in Figure 8. These confusion matrices, for the CNN, LSTM, GRU, and the proposed model show the superiority of the hybrid model in the detection of seizure conditions based on EEG readings. The proposed framework has been rated as the best among all, with the fewest false negatives appearing (11) and false positives present (21). The LSTM model follows with 46 misclassifications, and both the CNN and GRU achieve lower accuracies with 68 and 61 misclassifications, respectively. The proposed model significantly reduces false negatives and provides higher sensitivity and specificity, making it efficient for capturing seizure events alone without much risk of normal being classified as seizures. Overall, it can be noted that the CNN-LSTM-GRU model led to great progress in seizure detection as it guarantees proper functions that involve differentiating seizure and normal conditions present in EEG data.
For the value of accuracy if changing the test size, if we split the test to be 25% then the accuracy will be 99.15%, but if we reduce the test to 20% the accuracy will be 99.02% and if we increases the test to 30% the accuracy will be 98.84%.
To evaluate how the hybrid CNN-LSTM-GRU model stacks up against DL and traditional ML models in terms of accuracy, precision, recall, F1 score, and specificity, we have compared them. Table 4 shows the comparison results. It illustrates and summarizes the performance of different algorithms and techniques deployed in Machine Learning and Deep Learning datatypes for the binary classification of seizure in EEG datasets based on measures such as accuracy, precision, recall, F1 score, and specificity, among others as shown in Figure 8 and Figure 9. Where Logistic Regression (LR), Decision Tree (DT), Naive Bayes (NB), Support Vector Machine (SVM), Random Forest (RF), K-Nearest Neighbors (KNN), Convolutional Neural Network (CNN), Long Short-Term Memory (LSTM), Gated Recurrent Unit (GRU), and the hybrid model are studied. Here, the so-called traditional Machine Learning models, like LR and DT, show moderate to high results, though, in terms of effectivity, LR should be placed last at 62.07% accuracy. However, the DT model has a dramatically increased rate of accuracy at 92.34% with all the metrics being equal across the board. The Naive Bayes algorithm also shows quite pleasing outcomes and performance results with its accuracy standing at 88.91% and specificity at 96.8%, meaning that it can classify the classes effectively.
Figure 9 presents an evaluation comparison using a cluster bar chart among different ML algorithms, CNN, LSTM, GRU, and our proposed hybrid approach with and without SOMTE technique. It appears that Deep Learning approaches like, CNN, LSTM, or GRU, tend to perform better than conventional Machine Learning methods on most of the metrics, with CNN recording 96%:74% accuracy and LSTM achieving the highest accuracy among all the deep learning models of 98.48%. Since both LSTM and GRU belong to the family of recurrent neural networks, they achieved high recall and F1-score metrics, which indicates that they are good for time-sequence-related data. The hybrid model proposed in this paper achieves the best overall results with an accuracy of 99.13% and a precision, recall, and F1-score value of 99.13%, along with a specificity of 98.87%. These parameters show that the proposed system is the best-in-class discrimination and therefore arguments about sensitivity and specificity even-out. This additionally shows that the model would work well in classification tasks that can classify the seizure from EEG signals effectively. This result depicts how successful the combined model is in utilizing the advantages of different systems to deliver the best results.
To compare our approach with the recent state-of-the-art methods, four recently published methods referenced at [30,39,40,41,42] are used. These methods are all hybrid Deep Learning-based approaches that predict seizure epilepsy utilizing EEG signal. Table 5 shows this comparison.

4.5. Limitations and Challenges

There are many limitations and challenges in this study, such as the following:
Lack of External Evaluation: The framework’s performance, while impressive, is primarily evaluated using internal validation. The absence of external evaluation on diverse datasets limits its generalizability and raises concerns about its applicability to broader populations.
Synthetic Data Bias: Although SMOTE effectively addresses class imbalance, it may introduce biases by generating synthetic samples that do not fully capture the variability and complexity of real-world data.
Sensitive Medical Data Handling: Managing sensitive medical data presents significant challenges, necessitating strict compliance with data privacy regulations such as HIPAA or GDPR and the implementation of robust anonymization and security measures.
Computational Complexity: The hybrid model’s complexity, combining CNN, LSTM, and GRU architectures, may result in high computational demands, potentially limiting its deployment on resource-constrained devices, especially in real-time Medical IoT (MIoT) environments.
Scalability and Integration: Integrating the model into existing MIoT frameworks and ensuring scalability across diverse medical applications and hardware configurations remains challenging.
Addressing these limitations in future work is critical to enhancing the model’s robustness, generalizability, and practical utility in real-world medical scenarios.

5. Conclusions

Being the control center of the body, the brain is fundamental to the execution of cognitive tasks, retention of information, articulation, movements as well as the homeostasis of body systems. This paper presents an effective EEG-based system for the early detection of epileptic seizures from an EEG signal, utilizing the hybrid Deep Learning model of the CNN, LSTM, and GRU models. The proposed framework applies the SMOTE technique to efficiently solve the challenge of imbalanced EEG data for undistorted and correct classification. The model achieved 99.15%, ensuring that the accuracy surpassed the Deep Learning and Machine Learning models. The specialists were able to understand the model better using Explainable AI techniques such as SHAP which made the process of medical decision-making more user-friendly. This framework aligns with the objectives of the Medical Internet of Things (MIoT) scheme as it encourages the development of better medical applications toward timely and accurate epileptic seizure detection.

Author Contributions

Conceptualization, H.T., E.E.-D.H. and A.S.; methodology, E.E.-D.H.; project administration, H.T.; software, A.S.; validation and resources, A.S. and S.S.; visualization, S.S. and H.T.; writing—original draft, E.E.-D.H., A.S. and H.T.; writing—review and editing, S.S., S.H., H.T., E.E.-D.H. and A.S. All authors have read and agreed to the published version of the manuscript.

Funding

The authors extend their appreciation to Prince Sattam bin Abdulaziz University for funding this research work through the project number (PSAU/2024/01/29858).

Data Availability Statement

The original contributions presented in the study are included in the article; further inquiries can be directed to the corresponding author.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Hemdan, E.E.D.; Essa, Y.M.; Shouman, M.; El-Sayed, A.; Moustafa, A.N. An efficient IoT based smart water quality monitoring system. Multimed. Tools Appl. 2023, 82, 28827–28851. [Google Scholar] [CrossRef]
  2. Zayed, S.M.; Attiya, G.M.; El-Sayed, A.; Hemdan, E.E.D. A review study on digital twins with artificial intelligence and internet of things: Concepts, opportunities, challenges, tools and future scope. Multimed. Tools Appl. 2023, 82, 47081–47107. [Google Scholar] [CrossRef]
  3. Miotto, R.; Wang, F.; Wang, S.; Jiang, X.; Dudley, J.T. Deep learning for healthcare: Review, opportunities and challenges. Briefings Bioinform. 2018, 19, 1236–1246. [Google Scholar] [CrossRef] [PubMed]
  4. Shokri, R.; Shmatikov, V. Privacy-preserving deep learning. In Proceedings of the 2015 53rd Annual Allerton Conference on Communication, Control, and Computing (Allerton), Denver, CO, USA, 12–16 October 2015; pp. 909–910. [Google Scholar] [CrossRef]
  5. Zhang, X.; Yao, L.; Huang, C.; Sheng, Q.Z.; Wang, X. Enhancing Mind Controlled Smart Living Through Recurrent Neural Networks. In Proceedings of the 23rd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, Halifax, NS, Canada, 13–17 August 2017; Volume 13. [Google Scholar]
  6. Filho, C.A.S.; Attux, R.; Castellano, G. Can graph metrics be used for EEG-BCIs based on hand motor imagery? Biomed. Signal Process. Control 2018, 40, 359–365. [Google Scholar] [CrossRef]
  7. Liu, Y.; Huang, H.; Xiao, F.; Malekian, R.; Wang, W. Classification and recognition of encrypted EEG data based on neural network. J. Inf. Secur. Appl. 2020, 54, 102567. [Google Scholar] [CrossRef]
  8. Zhang, S.; Sun, L.; Mao, X.; Hu, C.; Liu, P. Review on EEG-Based Authentication Technology. Comput. Intell. Neurosci. 2021, 2021, 5229576. [Google Scholar] [CrossRef]
  9. Jiao, Y.; Zhang, Y.; Chen, X.; Yin, E.; Jin, J.; Wang, X.Y.; Cichocki, A. Sparse Group Representation Model for Motor Imagery EEG Classification. IEEE J. Biomed. Health Inform. 2018, 23, 631–641. [Google Scholar] [CrossRef] [PubMed]
  10. Chatterjee, R.; Maitra, T.; Islam, S.H.; Hassan, M.M.; Alamri, A.; Fortino, G. A novel machine learning based feature selection for motor imagery EEG signal classification in Internet of medical things environment. Futur. Gener. Comput. Syst. 2019, 98, 419–434. [Google Scholar] [CrossRef]
  11. Tang, Z.; Li, C.; Sun, S. Single-trial EEG classification of motor imagery using deep convolutional neural networks. Optik 2017, 130, 11–18. [Google Scholar] [CrossRef]
  12. Li, X.; La, R.; Wang, Y.; Niu, J.; Zeng, S.; Sun, S.; Zhu, J. EEG-based mild depression recognition using convolutional neural network. Med. Biol. Eng. Comput. 2019, 57, 1341–1352. [Google Scholar] [CrossRef] [PubMed]
  13. Alomari, M.H.; Abubaker, A.; Turani, A.; Baniyounes, A.M.; Manasreh, A. EEG Mouse: A Machine Learning-Based Brain Computer Interface. Int. J. Adv. Comput. Sci. Appl. 2014, 5, 4. [Google Scholar] [CrossRef]
  14. Ward, C.; Picone, J.; Obeid, I. Applications of UBMs and I-vectors in EEG subject verification. In Proceedings of the 2016 38th Annual International Conference of the IEEE Engineering in Medicine and Biology Society (EMBC), Orlando, FL, USA, 16–20 August 2016; Volume 2016. [Google Scholar]
  15. Sun, Y.; Chen, X. [Retracted] Automatic Detection of Epilepsy Based on Entropy Feature Fusion and Convolutional Neural Network. Oxidative Med. Cell. Longev. 2022, 1, 1322826. [Google Scholar]
  16. Ru, Y.; Li, J.; Chen, H.; Li, J. Epilepsy Detection Based on Variational Mode Decomposition and Improved Sample Entropy. Comput. Intell. Neurosci. 2022, 2022, 6180441. [Google Scholar] [CrossRef] [PubMed]
  17. Zazzaro, G.; Pavone, L. Machine Learning Characterization of Ictal and Interictal States in EEG Aimed at Automated Seizure Detection. Biomedicines 2022, 10, 1491. [Google Scholar] [CrossRef] [PubMed]
  18. Islam, S.; Thapa, K.; Yang, S.-H. Epileptic-Net: An Improved Epileptic Seizure Detection System Using Dense Convolutional Block with Attention Network from EEG. Sensors 2022, 22, 728. [Google Scholar] [CrossRef]
  19. Mardini, W.; Yassein, M.M.B.; Al-Rawashdeh, R.; Aljawarneh, S.; Khamayseh, Y.; Meqdadi, O. Enhanced Detection of Epileptic Seizure Using EEG Signals in Combination with Machine Learning Classifiers. IEEE Access 2020, 8, 24046–24055. [Google Scholar] [CrossRef]
  20. Mallick, S.; Baths, V. Novel deep learning framework for detection of epileptic seizures using EEG signals. Front. Comput. Neurosci. 2024, 18, 1340251. [Google Scholar] [CrossRef]
  21. Ying, N.; Li, H.; Zhang, Z.; Zhou, Y.; Chen, H.; Yang, M. ViTDFNN: A Vision Transformer Enabled Deep Fuzzy Neural Network for Detecting Sleep Apnea-Hypopnea Syndrome in the Internet of Medical Things. IEEE Trans. Fuzzy Syst. 2024, 33, 82–93. [Google Scholar] [CrossRef]
  22. Xu, Z.; Wang, Z. MCV-UNet: A modified convolution & transformer hybrid encoder-decoder network with multi-scale information fusion for ultrasound image semantic segmentation. PeerJ Comput. Sci. 2024, 10, e2146. [Google Scholar]
  23. Kanadath, A.; Jothi, J.A.A.; Urolagin, S. CViTS-Net: A CNN-ViT Network with Skip Connections for Histopathology Image Classification. IEEE Access 2024, 12, 117627–117649. [Google Scholar] [CrossRef]
  24. Bhattacharya, A. Applied Machine Learning Explainability Techniques: Make ML Models Explainable and Trustworthy for Practical Applications Using LIME, SHAP, and More; Packt Publishing Ltd.: Birmingham, UK, 2022. [Google Scholar]
  25. Adadi, A.; Berrada, M. Peeking inside the black-box: A survey on explainable artificial intelligence (XAI). IEEE Access 2018, 6, 52138–52160. [Google Scholar] [CrossRef]
  26. Arrieta, A.B.; Díaz-Rodríguez, N.; Del Ser, J.; Bennetot, A.; Tabik, S.; Barbado, A.; Garcia, S.; Gil-Lopez, S.; Molina, D.; Benjamins, R.; et al. Explainable Artificial Intelligence (XAI): Concepts, taxonomies, opportunities and challenges toward responsible AI. Inf. Fusion 2020, 58, 82–115. [Google Scholar] [CrossRef]
  27. Loh, H.W.; Ooi, C.P.; Seoni, S.; Barua, P.D.; Molinari, F.; Acharya, U.R. Application of explainable artificial intelligence for healthcare: A systematic review of the last decade (2011–2022). Comput. Methods Programs Biomed. 2022, 226, 107161. [Google Scholar] [CrossRef]
  28. Saraswat, D.; Bhattacharya, P.; Verma, A.; Prasad, V.K.; Tanwar, S.; Sharma, G.; Bokoro, P.N.; Sharma, R. Explainable AI for Healthcare 5.0: Opportunities and Challenges. IEEE Access 2022, 10, 84486–84517. [Google Scholar] [CrossRef]
  29. Zhang, H.; Guan, C.; Ang, K.K.; Wang, C.; Chin, Z.Y. BCI competition IV–data set I: Learning discriminative patterns for self-paced EEG-based motor imagery detection. Front. Neurosci. 2012, 6, 7. [Google Scholar]
  30. Kunekar, P.; Gupta, M.K.; Gaur, P. Detection of epileptic seizure in EEG signals using machine learning and deep learning techniques. J. Eng. Appl. Sci. 2024, 71, 21. [Google Scholar] [CrossRef]
  31. Schalk, G.; McFarland, D.J.; Hinterberger, T.; Birbaumer, N.; Wolpaw, J.R. BCI2000: A gen-eral-purpose brain-computer interface (BCI) system. IEEE Trans. Biomed. Eng. 2004, 51, 1034–1043. [Google Scholar] [CrossRef] [PubMed]
  32. Obeid, I.; Picone, J. The Temple University Hospital EEG Data Corpus. Front. Neurosci. 2016, 10, 196. [Google Scholar] [CrossRef] [PubMed]
  33. Guttag, J. CHB-MIT Scalp EEG Database, version 1.0.0; PhysioNet. MIT Laboratory for Computational Physiology: Cambridge, MA, USA, 2010. [Google Scholar] [CrossRef]
  34. Ihle, M.; Feldwisch-Drentrup, H.; Teixeira, C.A.; Witon, A.; Schelter, B.; Timmer, J.; Schulze-Bonhage, A. EPILEPSIAE–A European epilepsy database. Comput. Methods Programs Biomed. 2012, 106, 127–138. [Google Scholar] [CrossRef] [PubMed]
  35. Andrzejak, R.G.; Lehnertz, K.; Mormann, F.; Rieke, C.; David, P.; Elger, C.E. Indications of nonlinear deterministic and finite-dimensional structures in time series of brain electrical activity: Dependence on recording region and brain state. Phys. Rev. E 2001, 64, 061907. [Google Scholar] [CrossRef] [PubMed]
  36. Hemdan, E.E.-D.; El-Shafai, W.; Sayed, A. CR19: A framework for preliminary detection of COVID-19 in cough audio signals using machine learning algorithms for automated medical diagnosis applications. J. Ambient. Intell. Humaniz. Comput. 2022, 14, 11715–11727. [Google Scholar] [CrossRef] [PubMed]
  37. Zayed, S.M.; Attiya, G.; El-Sayed, A.; Sayed, A.; Hemdan, E.E.-D. An efficient fault diagnosis framework for digital twins using optimized machine learning models in smart industrial control systems. Int. J. Comput. Intell. Syst. 2023, 16, 69. [Google Scholar] [CrossRef]
  38. Rezk, N.G.; Alshathri, S.; Sayed, A.; Hemdan, E.E.-D.; El-Behery, H. XAI-Augmented Voting Ensemble Models for Heart Disease Prediction: A SHAP and LIME-Based Approach. Bioengineering 2024, 11, 1016. [Google Scholar] [CrossRef] [PubMed]
  39. Alalayah, K.M.; Senan, E.M.; Atlam, H.F.; Ahmed, I.A.; Shatnawi, H.S.A. Effective Early Detection of Epileptic Seizures through EEG Signals Using Classification Algorithms Based on t-Distributed Stochastic Neighbor Embedding and K-Means. Diagnostics 2023, 13, 1957. [Google Scholar] [CrossRef] [PubMed]
  40. Akyol, K. Stacking ensemble based deep neural networks modeling for effective epileptic seizure detection. Expert Syst. Appl. 2020, 148, 113239. [Google Scholar] [CrossRef]
  41. Kode, H.; Elleithy, K.; Almazedah, L. Epileptic Seizure detection in EEG signals using Machine Learning and Deep Learning Techniques. IEEE Access 2024, 12, 80657–80668. [Google Scholar] [CrossRef]
  42. Woodbright, M.; Verma, B.; Haidar, A. Autonomous deep feature extraction based method for epileptic EEG brain seizure classification. Neurocomputing 2021, 444, 30–37. [Google Scholar] [CrossRef]
Figure 1. A typical medical IoT (MIoT) model.
Figure 1. A typical medical IoT (MIoT) model.
Algorithms 18 00077 g001
Figure 2. The block diagram of the proposed system.
Figure 2. The block diagram of the proposed system.
Algorithms 18 00077 g002
Figure 3. Statistical explanation of the dataset.
Figure 3. Statistical explanation of the dataset.
Algorithms 18 00077 g003
Figure 4. The accuracy over epochs.
Figure 4. The accuracy over epochs.
Algorithms 18 00077 g004
Figure 5. The ROC curves for the proposed framework.
Figure 5. The ROC curves for the proposed framework.
Algorithms 18 00077 g005
Figure 6. The local explanation for seizure classification.
Figure 6. The local explanation for seizure classification.
Algorithms 18 00077 g006
Figure 7. The SHAP for feature importance, (a) present the SHAP figure importance in case of using LSTM model only in the detection, while (bd) present the feature importance in cases of using CNN, GRU and proposed model respectively.
Figure 7. The SHAP for feature importance, (a) present the SHAP figure importance in case of using LSTM model only in the detection, while (bd) present the feature importance in cases of using CNN, GRU and proposed model respectively.
Algorithms 18 00077 g007
Figure 8. The confusion between the different deep learning model and the proposed model.
Figure 8. The confusion between the different deep learning model and the proposed model.
Algorithms 18 00077 g008
Figure 9. Cluster bar chart for accuracy, precision, recall, and F-score across the different models.
Figure 9. Cluster bar chart for accuracy, precision, recall, and F-score across the different models.
Algorithms 18 00077 g009
Table 1. A comparative analysis of EEG classification techniques.
Table 1. A comparative analysis of EEG classification techniques.
ReferenceMethodologyKey FeaturesDataset
Jiao et al. [7]Sparse Group Representation Model (SGRM)Uses intersubjective data for BCIBCI Competition IV (64 EEG channels, 1000 Hz sampling rate, 2 classes, and 7 subjects) [29]
Chatterjee et al. [8]Fuzzy Discernibility Matrix (FDM) with SVM and EnsembleExtracts optimal features from EEG signalsBCI Competition-II Dataset-III [30] training and 140 test trials 9 s long each, 3 channels, 128 Hz sampling rate, 2 classes) [29]
Tang et al. [9]Deep CNNApplied for EEG data classificationExperimental dataset (private dataset from 2 subject 28 experiments)
Alomari et al. [11]Coiflets Wavelet and Amplitude EstimationFeature extraction from EEG signalsPhysioNet EEG dataset (1500 two-minute EEG recordings, obtained from 109 subject) [31]
Ward et al. [12] Joint Factor Analysis and I-vectorsFeature extraction with UBM classification
  • PhysioNet’s EEG dataset [31]
  • Temple University Hospital (TUH) (16,986 sessions from 10,874 subjects) [32]
Y. Sun and X. Chen. [13]Multi-feature Fusion with CNNUsed for epilepsy detectionCHB-MIT EEG Dataset (182 records of 23 seizure cases) [33]
Ru et al. [14]Noisy Environment Algorithm with VMDUses sample entropy and phase synchronizationCHB-MIT EEG Dataset (182 records of 23 seizure cases) [33]
G. Zazzaro and L. Pavone [15]Inclusion of Includes preictal/ictal (seizure-related) and interictal (non-seizure) EEGEnabling patient-specific seizure detection and cross-patient model generalizabilityFreiburg Seizure Prediction EEG Database (21 subject of seizure patients using 128 channels, 256 Hz sampling rate) [34]
Islam et al. [16]Epileptic-NetDynamic deep learning model for seizuresBONN EEG Dataset (4096 samples) [29]
Khan et al. [17]Time and Frequency Features with ML modelsLogistic Regression, Decision Trees, SVM on TUH corpusTemple University Hospital (TUH) (16,986 sessions from 10,874 subjects) [34]
Mardini et al. [18]DWT, Genetic Algorithm, ML ClassifiersReduces computation for seizure detectionBONN EEG Dataset (4096 samples) [29]
Zhan et al. [20] Hybrid Deep LearningUsing Bi-LSTM, GRU, and average pooling layerBONN EEG Dataset (4096 samples) [29]
Table 2. Dataset Description.
Table 2. Dataset Description.
Class TypeClasses DescriptionNumber of Cases
1 (Seizure)Recording of seizure activity2300
0 (Normal)Normal activity9200
Table 3. The parameters of the confusion matrix.
Table 3. The parameters of the confusion matrix.
Predicted SeizurePredicted Normal
Actual SeizureTPFP
Actual NormalFNTN
Table 4. A comparison between the proposed system, ML, DL, and our proposed hybrid model with and without SOMTE.
Table 4. A comparison between the proposed system, ML, DL, and our proposed hybrid model with and without SOMTE.
AlgorithmAccuracyPrecisionRecallF1-Score
LR0.62070.650.640.64
DT0.92340.920.920.92
NB0.88910.900.890.89
SVM0.96470.960.960.96
RF0.97070.970.970.97
KNN0.98340.980.980.98
CNN0.9640.9850.9770.981
LSTM0.98480.9860.9880.987
GRU0.97880.9830.9840.983
Proposed Hybrid Model
Without SMOTE
0.97870.97860.97870.9785
Proposed Hybrid Model
With SMOTE
0.99130.99130.99130.9913
Table 5. A comparison between the proposed system with previous studies in the same dataset.
Table 5. A comparison between the proposed system with previous studies in the same dataset.
PaperAccuracy
Alalayah et al. [39]98.98%
Akyol, Kemal [40]97.17
Kunekar et al. [30]97.10
Kode et al. [41]99.00%
Woodbright et al. [42]98.65
Proposed model99.13%
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Torkey, H.; Hashish, S.; Souissi, S.; Hemdan, E.E.-D.; Sayed, A. Seizure Detection in Medical IoT: Hybrid CNN-LSTM-GRU Model with Data Balancing and XAI Integration. Algorithms 2025, 18, 77. https://doi.org/10.3390/a18020077

AMA Style

Torkey H, Hashish S, Souissi S, Hemdan EE-D, Sayed A. Seizure Detection in Medical IoT: Hybrid CNN-LSTM-GRU Model with Data Balancing and XAI Integration. Algorithms. 2025; 18(2):77. https://doi.org/10.3390/a18020077

Chicago/Turabian Style

Torkey, Hanaa, Sonia Hashish, Samia Souissi, Ezz El-Din Hemdan, and Amged Sayed. 2025. "Seizure Detection in Medical IoT: Hybrid CNN-LSTM-GRU Model with Data Balancing and XAI Integration" Algorithms 18, no. 2: 77. https://doi.org/10.3390/a18020077

APA Style

Torkey, H., Hashish, S., Souissi, S., Hemdan, E. E.-D., & Sayed, A. (2025). Seizure Detection in Medical IoT: Hybrid CNN-LSTM-GRU Model with Data Balancing and XAI Integration. Algorithms, 18(2), 77. https://doi.org/10.3390/a18020077

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop