Two-layer LSTM network-based prediction of epileptic seizures using EEG spectral features

Epilepsy is a chronic nervous disorder, which disturbs the normal daily routine of an epileptic patient due to sudden seizure onset. In this era of smart healthcare, automated seizure prediction techniques could assist the patients, their family, and medical personnel to control and manage these seizures. This paper proposes a spectral feature-based two-layer LSTM network model for automatic prediction of epileptic seizures using long-term multichannel EEG signals. This model makes use of spectral power and mean spectrum amplitude features of delta, theta, alpha, beta, and gamma bands of 23-channel EEG spectrum for this task. Initially, the proposed single-layer and two-layer LSTM models have been evaluated for EEG segments having durations in the range of 5–50 s for 24 epileptic subjects, out of which EEG segments of 30 s duration are found to be useful for accurate seizure prediction using two-layer LSTM model. Afterwards, to validate the performance of this classifier, the spectral features of 30 s duration EEG segments are fed to random forest, decision tree, k-nearest neighbour, support vector machine, and naive Bayes classifiers, which are empowered with grid search-based parameter estimation. Finally, the iterative simulation results and comparison with recently published existing techniques firmly reveal that the proposed two-layer LSTM model with EEG spectral features is an effective technique for accurately predicting seizures in real time with an average classification accuracy of 98.14%, average sensitivity of 98.51%, and average specificity of 97.78%, thereby enabling the epileptic patients to have a better quality of life.


Introduction
Epilepsy is a commonly occurring chronic nervous disorder characterized by the occurrence of spontaneous and sudden seizures [1]. This neurological disorder affects the lives of all age groups from infants to old age persons, covering approximately 50 million people around the world [2]. This count is getting worse in developing countries like India. As per statistical figures of Indian Epilepsy Centre, New Delhi, approximately 10 million Indian population is suffering from this disorder and this number is increasing to determine different stages of epilepsy like ictal (on-going seizures), preictal (just before seizure onset), post-ictal (after seizure onset period), and interictal (in-between seizures) [6]. However, this process is arduous and time-consuming, which leads to the need for an automatic epileptic seizure prediction system [7,8].
Nowadays, Internet of things (IoT) technologies have started playing a key role in providing solutions to various health-related problems with the help of machine learning algorithms being deployed at cloud-based servers. These healthcare solutions may include elderly care [9], remote healthcare [10], fitness programs [11], detection and prognosis of neurological and mental disorders like Alzheimer, epilepsy, autism spectrum disorder and schizophrenia, etc. [12][13][14][15][16][17]. Deep learning [18] is another paradigm in this regard, which is capable of handling the large volume of signal data generated by wearable IoT sensing devices like EEG headsets for epilepsy [19]. The algorithms based on deep learning techniques overcome the limitations of traditional machine learning algorithms by offering less processing time and capability of handling big data of multichannel biomedical signals [20]. Consequently, these techniques play a promising role in providing real-time solutions in healthcare sector.
To provide a smart solution to the patients with epilepsy, the present paper proposes a spectral feature-based two-layer long short-term memory (LSTM) model [21] for automated prediction of epileptic seizures. This approach makes use of long-term CHB-MIT [22] EEG database of 24 cases of epilepsy, collected at Children's Hospital, Boston. First of all, the raw 23 channel EEG signals being recorded from the patient's scalp are pre-processed, filtered, and segmented into short-duration segments in the range of 5-50 s. Then, these segments are converted into frequency domain using Fast Fourier transform (FFT), and are separated into five frequency bands for accurate interpretation of functional and behavioural features of a complex structure of the brain during epileptic seizures [23]. The given frequency bands of 23 channel EEG signals are characterized by extracting two distinct features-spectral power and mean spectrum amplitude. Initially, this work proposes single-layer LSTM (1L-LSTM) and two-layer LSTM (2L-LSTM) models for seizure prediction, which utilizes spectral features of various sub-bands of given EEG segments. This analysis of 1L-LSTM and 2L-LSTM for different duration values of EEG segments reveals the effectiveness of 30 s duration EEG segments for seizure prediction using 2L-LSTM. Furthermore, to ensure the effectiveness of the proposed 2L-LSTM model, its performance has been compared with that of decision tree, random forest, k-nearest neighbour (kNN), support vector machine (SVM), naive Bayes, and 1L-LSTM classifiers for EEG segments of 30 s. These traditional machine learning classifiers make use of grid-search technique for estimating hyperparameters to improve their performance. The overall analysis of simulation results of given classifiers and comparison with existing methods confirm the utility of the proposed spectral features based two-layer LSTM model (2L-LSTM) for accurate and real-time seizure prediction in epileptic patients. This paper has been divided into different sections. Section 1 gives the introduction of the problem of epileptic seizures, the use of modern technologies to predict seizures, and the proposed model for automatic prediction of seizures. The related work done by various researchers in the field of automatic prediction of seizures has been discussed in Sect. 2. In addition, the methodology implemented for seizure prediction using the proposed approach has been explained step-by-step in Sect. 3. Moreover, Sect. 4 provides analysis and discussion of the results obtained after the implementation of the proposed model. Finally, the conclusions are made in Sect. 5.

Related work
This section discusses research work done by various researchers during recent years in the field of automatic prediction of epileptic seizures. The publications, in which CHB-MIT EEG database has been employed for seizure prediction using traditional machine learning and deep learning techniques, are given the key focus.
A traditional machine learning-based approach presented by Usman et. al. [24] discusses the empirical mode decomposition method for extraction of time-and frequency-domain features from 2 s duration EEG segments. These features include features of power spectral density such as spectral centroid, variational coefficient, spectral skew, and combined feature set consisting of four statistical moments and three frequency moments of intrinsic mode functions. It provides classification results using SVM for prediction of epileptic seizures with a sensitivity of 92.23%. A similar approach [25] makes use of graph theory, and time-domain and frequencydomain features of 5 s duration EEG segments to train SVM algorithm for the classification of preictal and interictal EEG stages in epileptic patients. This approach provides satisfactory results of seizure prediction with a sensitivity of 87.75% and specificity of 87.75%.
In an effort to employ unsupervised learning techniques for automatic epileptic seizure prediction, Kitano et al. [26] have presented a self-organising map (SOM) algorithm along with a polling-based decision process for EEG segments of 4 s, which are pre-processed using wavelet transform. This method has obtained classification results with an accuracy of 91%, sensitivity of 98%, and specificity of 88%. In addition to this approach, an extreme learning machine (ELM) approach [27] has been employed for prediction of seizures, which takes into account bag-of-wave feature extraction technique, and achieves classification of seizure stages with sensitivity of 88.24%.
Furthermore, some researchers have started harnessing the power of deep learning algorithms for prediction of epileptic seizures. In this regard, Truong et al. [28] have proposed a convolutional neural network (CNN)-based generalized epileptic seizure prediction approach with short-time Fourier transform-based pre-processing of 30 s duration EEG segments and have achieved the results of seizure prediction with a sensitivity of 81.2%. A similar approach presented by Hu et al. [29] makes use of CNN for feature extraction from the mean amplitude spectrum of 19 frequency bands taken from 15-channel EEG segments of 2 s, which classifies seizure stages using SVM classifier with a sensitivity of 86.25%. A bidirectional long-term memory network (LSTM) model is another deep learning-based seizure prediction system [30], in which a two-dimensional stacked convolutional autoencoder has been employed for spatial feature extraction. This model provides seizure prediction results with sensitivity of 94.6%.
In the same concern, Duan et al. [31] present an idea of using bi-direction gated recurrent unit (Bi-GRU), which is also a type of recurrent neural network, to predict seizure states effectively. This model employs CNN algorithm for extracting features from correlation coefficients among electrodes for eight distinct sub-bands of multi-time scale EEG segments having segment duration of 1 s, 2 s, and 3 s. It provides classification results with an accuracy of 94.8%, sensitivity of 91.7%, and specificity of 97.7%. In addition, Usman et al. [32] make use of a CNN model for extraction of features from EEG segments of 29 s duration, which are decomposed using empirical mode decomposition. It performs classification using a single-layer LSTM classifier and provides classification results with a sensitivity of 93% and specificity of 92.5%. Similarly, Zhang et al. [33] also employs a CNN model fed with synchronization features such as Pearson correlation coefficients to predict epileptic seizures. These features are obtained from EEG segments of 8 s, which provides classification results with an accuracy of 89/98%.
The comprehensive review of existing seizure prediction techniques reveal that most of these techniques are dependent upon complex feature extraction and pre-processing methods and classification using traditional machine learning as well as deep learning techniques. Also, some of these existing techniques show relatively poor classification performance with low values of accuracy, sensitivity, or specificity. Hence, there exists an extreme requirement of providing accurate seizure prediction, which could be achieved by applying deep learning-based models fed with simple spectral domain features. Therefore, the present work utilizes an LSTM-based approach in the field of epileptic seizure prediction, which makes use of spectral power and mean spectrum amplitude features of five frequency bands taken from 23-channel EEG segments of shorter durations. This model tends to predict seizure stages more accurately for its effective utilization in real-time scenarios.

Materials and methods
This section discusses the procedure adopted for the implementation of automatic epileptic seizure prediction. This procedure primarily involves two phases: pre-processing and classification. The pre-processing phase consists of filtering and segmentation of raw multichannel EEG signals followed by transformation into frequency domain using Fast Fourier transform (FFT), frequency band separation, and feature extraction. The extracted features are used for training and testing of the proposed LSTM models as well as other wellknown models in classification phase. The whole process is depicted in Fig. 1. The dataset applied and various implementation steps are discussed in the following subsections.

Dataset
The proposed model takes into account long-term CHB-MIT EEG dataset [22] of 24 cases taken from subjects with intractable seizures. This dataset has been collected at Children's Hospital, Boston, and is openly available at online web portal PhysioNet [34]. As per information provided on this portal, out of 24 EEG recordings, the recordings of the first 23 cases are taken from 22 subjects having 5 males with an age group of 3-22 years and 17 females with an age group of 1.5-19 years. These EEG signals are collected from the patient's scalp using EEG electrodes positioned with an international 10-20 system of electrode placement [35] and are sampled at a sampling rate of 256 samples per second having 16-bit resolution. Most of the samples contain 23 channels with some exceptions of 24 or 26 channels.
The present research work considers 23 channels of EEG signals for all 24 cases. The long sequence of EEG samples contains seizure intervals, which are mentioned in the annotation files of the dataset. These seizure intervals are termed as ictal stages. The signals after the ictal stage are termed as post-ictal stage. The proposed model assumes an intervention period (IP) of 5 min just before the seizure onset, which could be used for the generation and transmission of alert messages to epileptic patients, their family members, and hospitals. In this work, a preictal period of 30 min has been considered before IP [36]. The interictal stages are assumed at least 4 h before and/or after the ictal stage. A multichannel EEG signal labelled with different seizure stages is shown in Fig. 2.
The given dataset after time-domain segmentation into different seizure class labels produces an unbalanced dataset having a large number of interictal classes followed by pre- Fig. 1 Automatic epileptic seizure prediction: a procedural overview ictal and post-ictal classes, and very few classes for ictal stage. Since the prediction of epileptic seizures is primarily dependent upon detection of preictal stage among interictal or normal EEG samples. Therefore, a balanced dataset consisting of an equal number of interictal and preictal class labels only has been taken into consideration in the present work.

Band-pass filtering
The scalp EEG signals sensed from epileptic patients are required to be free from different kinds of artefacts and noises before its processing for seizure prediction [37], which leads to the need for precise filtering. Therefore, given multichannel EEG signals are filtered using Butterworth bandpass filter [38] with a lower cut-off frequency of 0.1 Hz and higher cutoff frequency of 127 Hz. This method is a widely popular filtering technique for the analysis of biomedical signals due to its flat and ripple-free frequency response in passband [39].

EEG segmentation
The variation in statistical features of EEG signals over a time interval makes them non-stationary in nature [13]. The solution to this problem is to divide a long sequence of EEG signals into short-duration segments, which are assumed to be pseudo-stationary having similar statistical time and frequency features [40]. The present work also employs this approach by dividing EEG signals of different seizure intervals into shorter duration segments, such as 5 s, 10 s, 15 s, 20 s, 25 s, 30 s, 35 s, 40 s, 45 s, and 50 s duration segments without any over-lapping. Although, the EEG signals provided in CHB-MIT dataset have time durations ranging from several minutes to hours, yet the present work takes into account a maximum EEG segment duration of 50 s only. This is because of the reason that a further increase in segment duration results in the generation of few EEG samples only, which would not be adequate for appropriate training, testing, and validation of the proposed classifiers. Moreover, these shorter duration segments are also advantageous in terms of the requirement of low computational power for processing, lower transmission bandwidth, and lesser storage requirement on local or cloud-based storage.

Fast Fourier transform
The transformation of time-domain EEG signals into frequency domain emphasizes the epileptic spikes in spectral domain [41], which are useful for accurate and speedy prediction of epileptic seizures. Therefore, keeping in view the significance of time-frequency transformation for EEG signals, the present work makes use of fast Fourier transform algorithm (FFT) for converting multichannel time-domain EEG signals into frequency domain.

Feature extraction
The feature extraction is an important step for extracting distinct features from different frequency bands of EEG signal. These features characterize different epileptic stages and act as descriptors for the prediction of epileptic seizures. The present work takes into account two features for different EEG bands, which include spectral power and mean spectrum amplitude [45,46].
For a N -point signal x(n) with discrete Fourier transform X p (k) of its particular frequency band, the spectral power in μV 2 /H z can be expressed by Eq. 1 where X * p (k) is the complex conjugate of X p (k). Similarly, the mean spectrum amplitude (μV /H z) in spectral domain for a signal x(n) can be expressed by Eq. 2.
Spectral power and mean spectrum amplitude for different frequency bands of an EEG signal are shown in Fig. 3. This figure depicts the variation of both features for interictal and preictal stages of an epileptic patient.

Classification using LSTM network
Long short-term memory networks (LSTM) are a special type of recurrent neural networks (RNN), which are capable of learning long term dependencies in given data sequences by memorizing the information for longer period, thus avoiding the vanishing gradient problem of RNN [47]. LSTM networks are initially introduced by Hochreiter and Schmidhuber [21]. These networks are widely used in various classification problems of times series data, speech, audio, text data and biomedical signals, etc. [48,49].
The architecture of LSTM is defined by a basic LSTM cell (Fig. 4), which comprises three gates for controlling the flow of information from one cell state to other. These gates include forget gate, input gate, and output gate [21,50]. All three gates make use of sigmoid activation σ for providing a decision to control the flow of information. The forget gate decides whether a piece of information in the given data sample should be retained or forgotten. It considers current input signal x t and previous output sequence y t−1 in the cell state C t−1 to provide output f t between 0 and 1, where 0 represents completely forgetting the information, and 1 is meant for completely retaining the information. The input gate provides a decision about information being stored in the current cell state C t by multiplying its output i t with the outputC t of tanh activation layer. Similarly, the output gate decides the flow of fraction of information y t in C t at the output of LSTM cell by combining its output o t with the output of another tanh activation layer. Mathematically, the operation of three gates of an LSTM cell to provide output y t in cell state C t has been expressed by the following equations: [50].  In this work, single-layer LSTM (1L-LSTM) and twolayer LSTM (2L-LSTM) models are taken into consideration for the task of seizure prediction. The architectural view of the single-layer LSTM model (1L-LSTM) and two-layer LSTM model (2L-LSTM) employed in this work for automated epileptic seizure prediction have been visualized in Figs. 5, 6. 1L-LSTM architecture consists of a single LSTM layer having 50 LSTM units, a dropout layer with probability p = 0.25, and a dense output layer having 'sigmoid' activation function. Similarly, 2L-LSTM architecture is an upgraded version of 1L-LSTM consisting of two LSTM layers with 128 and 64 LSTM units, respectively, followed by a dropout layer ( p = 0.25), a dense fully connected layer having 16 neurons and a dense output layer with 'sigmoid' activation for binary classification of interictal and preictal stages of seizures. The input layer in both models is presented by an input vector of (10 × 23), where a total of ten features have been extracted from five frequency bands of 23 channel EEG signal. These models utilize a batch size of 32 input instances for training using 'rmsprop' optimizer and a loss function of binary cross-entropy. To achieve optimum accuracy, 1L-LSTM and 2L-LSTM models are trained for 100 and 200 epochs, respectively.
Apart from using the above-mentioned LSTM models, the present work also considers decision tree (DT), random forest (RF), k-nearest neighbour (kNN), support vector machine (SVM), and naive Bayes (NB) classifiers for prediction of seizure activities. These classifiers are empowered with grid search-based parameter estimation [51] for hyper-tuning of different parameters. The input feature map for these classifiers has been modified by concatenating spectral features of different EEG channels.

Results and discussion
This section discusses the simulation results of the proposed LSTM models for automatic prediction of epileptic seizures. The proposed approach for seizure prediction has been implemented on a laptop having a configuration of Intel i7 8th generation processor, 16 GB RAM, Nvidia GEFORCE GTX 1060 graphics processing unit (GPU) of 6 GB and Windows 10 operating system using Python programming language.
In this work, EEG signals are segmented into various short-duration segments with duration in the range of 5-50 s. Then, spectral power and mean spectrum amplitude features are extracted from five frequency bands of each EEG segment, leading to a total of 10 features from each of 23 channels of these segments. Thus, this pre-processing provides an input feature map of 10 × 23 for a single EEG segment. In the process of training and testing of the proposed LSTM models, the given datasets for each subject are divided into two subsets, consisting of 90% instances for The present work makes use of different performance measures like classification accuracy, sensitivity, specificity, and F1 score [12,52] to analyze the performance of given classifiers. It involves the performance evaluation of the proposed LSTM classifiers for EEG segments of different duration to visualize the impact of EEG segment duration on their classification accuracy for effective classification of interictal and preictal seizure stages. This work takes into account a tenfold validation approach for seizure stage classification in each of 24 epileptic patients to ensure the statistical viability of the proposed classification models. Also, the effectiveness of the proposed models has been analyzed by taking the average values of results obtained from 24 patients for EEG segments of different durations.   Afterwards, another LSTM model, i.e., two-layer LSTM model (2L-LSTM), has been taken into consideration using the spectral feature maps of different duration EEG segments. Table 2 depicts the performance analysis of 2L-LSTM model for EEG segments of different durations in terms of average values of various performance measures obtained from the classification results of 24 epileptic patients. As shown in this table, 2L-LSTM classifier provides maximum average classification of 98.14% with standard deviation of ± 2.5%, average sensitivity of 98.51% ± 2.55%, average specificity of 97.78% ± 3.37%, and average F1 score of 98.23% ± 2.3% for 24 epileptic patients in case of EEG segment duration of 30 s. Moreover, this classifier gives average accuracy of 97.45% ± 2.5%, average sensitivity of 97.6% ± 3.5%, average specificity of 97.5% ± 3.6%, and average F1 score of 97.26% ± 2.8% for EEG segments of 50 s duration. Furthermore, the classification performance of 1L-LSTM and 2L-LSTM models has been compared for EEG segments of different durations in terms of average classification accuracy of 24 patients, which is visible in Fig. 7. From this figure, it is evident that 2L-LSTM model achieves maximum average classification accuracy of 98.14% for segment duration of 30 s for 24 epileptic patients.
In addition, the performance of the proposed 2L-LSTM model has also been compared with 1L-LSTM, decision tree (DT), random forest (RF), kNN, SVM, and naive Bayes (NB) classifiers for EEG segment duration of 30 s. This performance analysis is illustrated in Fig. 8 for average values of performance measures obtained from 24 patients with epileptic seizures. This figure clearly demonstrates that the modified architecture of LSTM, i.e., 2L-LSTM, surpasses all other classifiers with a maximum classification accuracy of 98.14%, sensitivity of 98.51%, specificity of 97.78%, and F1 score of 98.23%. On the other hand, random forest, 1L-LSTM, SVM, decision tree, kNN, and naive Bayes classifiers have attained classification accuracies of 97.3%,  Thus, it has been proved from this analysis that the proposed two-layer LSTM model provides highly accurate results for the prediction of epileptic seizures as compared to other classifiers for spectral features of 30 s duration EEG segments.
Moreover, Table 3 depicts the performance of the proposed two-layer LSTM model for seizure prediction in case of 24 individual patients or subjects by employing 30 s duration segments. This table shows the range of classification accuracy for 93.02% for subject ID 4-100% for 14 different subjects. The results of sensitivity range from 92% for subject ID 4-100% for 17 different subjects. Similarly, specificity values range from 91.66% for subject ID 10-100% for 16 different subjects out of 24 subjects, and the F1 score ranges from 93.88% for subject ID 4-100% for 14 different subjects.
To ensure the stability of the proposed LSTM models for prediction of epileptic seizures, the performance of these models has also been illustrated in terms of loss and accuracy curves with respect to epochs used during the training process (refer to Fig. 9). As shown in Fig. 9a, c, loss curves for 1L-LSTM and 2L-LSTM decrease exponentially with increasing epochs and converge to the least value of loss for training and validation datasets. Similarly, Fig. 9b, d illustrates an exponential rise in classification accuracy with respect to epochs, which attain a flat response with an increase in the number of epochs for same datasets. However, it is also evident from these curves that 2L-LSTM exhibits more stable characteristics with low variations in accuracy and loss curves than those in 1L-LSTM model. Thus, this analysis assures the stable performance of 2L-LSTM model over 1L-LSTM model for accurate seizure prediction.
Furthermore, the results of the proposed model for prediction of epileptic seizures are also compared with other techniques discussed in recently published research papers, as shown in Table 4. This table shows the performance of existing seizure prediction techniques in terms of various performance measures, and also provides a brief overview of signal processing and feature extraction methods, EEG segment duration, and classifiers employed for the desired task. As shown in this table, some researchers have made use of traditional machine learning algorithms in association with complex feature extraction techniques to obtain seizure stage classification. These algorithms include SVM [24,25,29], ELM [27], and self-organising maps (SOM) [26].    After the thorough analysis of the existing techniques mentioned in Table 4, it is quite apparent that the proposed two-layer LSTM model provides better classification results for epileptic seizure prediction among given techniques for EEG segments of 30 s duration in terms of various performance measures. The overall analysis of simulation results and their comparative study with the latest techniques published in the recent literature evidently portrays the usefulness of the proposed two-layer LSTM architecture for accurate and real-time prediction of epileptic seizures using spectral power and mean spectrum amplitude features of short-duration EEG segments.

Conclusion
The present paper proposes a two-layer LSTM model, which takes into account spectral features of multichannel EEG signal segments for seizure prediction in epileptic patients. The spectral features, including spectral power and mean spectrum amplitude, are extracted from delta, theta, alpha, beta, and gamma sub-bands of EEG segments having different duration. Initially, the performance of the proposed single-layer and two-layer LSTM models has been analyzed for input EEG segments of different duration values in the range of 5-50 s. This analysis shows that the given models perform optimally for EEG segments of different durations and a maximum accuracy has been achieved by a two-layer LSTM model at a segment duration of 30 s. Then, the results of the proposed two-layer LSTM model are validated by comparing its performance with that of random forest, decision tree, SVM, kNN, Naive Bayes, and single-layer LSTM classifiers fed with spectral features of 30 s duration EEG segments. Also, the performance of the proposed two-layer LSTM model has been evaluated through its comparison with other state-of-the-art techniques mentioned in the recent literature. To conclude, it is obvious that the proposed two-layer LSTM network model with spectral features inputs of 30 s duration multichannel EEG segments is a suitable technique for accurate and real-time prediction of epileptic seizures.
Funding The authors of this manuscript have not received any financial support to carry out the present research.