Automatic Seizure Detection Based on Time-Frequency Analysis and Artificial Neural Networks

The recording of seizures is of primary interest in the evaluation of epileptic patients. Seizure is the phenomenon of rhythmicity discharge from either a local area or the whole brain and the individual behavior usually lasts from seconds to minutes. Since seizures, in general, occur infrequently and unpredictably, automatic detection of seizures during long-term electroencephalograph (EEG) recordings is highly recommended. As EEG signals are nonstationary, the conventional methods of frequency analysis are not successful for diagnostic purposes. This paper presents a method of analysis of EEG signals, which is based on time-frequency analysis. Initially, selected segments of the EEG signals are analyzed using time-frequency methods and several features are extracted for each segment, representing the energy distribution in the time-frequency plane. Then, those features are used as an input in an artificial neural network (ANN), which provides the final classification of the EEG segments concerning the existence of seizures or not. We used a publicly available dataset in order to evaluate our method and the evaluation results are very promising indicating overall accuracy from 97.72% to 100%.


INTRODUCTION
Epilepsy is one of the most common neurological disorders with a prevalence of 0.6-0.8% of the world's population. Two-thirds of the patients achieve sufficient seizure control from anticonvulsive medication, and another 8-10% could benefit from resective surgery. For the remaining 25% of patients, no sufficient treatment is currently available [1]. The epilepsy is characterized by a sudden and recurrent malfunction of the brain, which is termed "seizure." Epileptic seizures reflect the clinical signs of an excessive and hypersynchronous activity of neurons in the brain. Depending on the extent of the involvement of other brain areas during the course of the seizure, epilepsies can be divided into two main classes. Generalized seizures involve almost the entire brain, while focal (or partial) seizures originate from a circumscribed region of the brain (epileptic focus) and remain restricted to this region. Epileptic seizures may be accompa-nied by impairment or loss of consciousness: psychic, autonomic or sensory symptoms, or motor phenomena [2,3].
Traditionally, suspected seizures are evaluated using a routine electroencephalogram (EEG), which is typically a 20minute recording of the patient's brain waves. Because a routine EEG is of short duration, it is unlikely that actual events are recorded. Routine EEGs may record interictal hallmarks of epilepsy, including spikes, sharp waves, or spike-and-wave complexes. However, diagnostic difficulties arise when a person has a suspected seizure, or a neurological event of unclear etiology, not obvious in the routine EEG. The current gold standard is the continuous EEG recording along with video monitoring of the patient, which usually requires inpatient admission. This is a costly endeavour, which is not always available. The patient is away from his environment and routine, which may be associated with factors that provoke the patient's events [4]. The introduction of portable recording systems (ambulatory EEG), however, has allowed 2 Computational Intelligence and Neuroscience out-patient EEG recording to become more common. This has the advantage that patients are monitored in their normal environment without the reduction in seizure frequency usually occurring during in-patient sessions [4,5].
Clinical neurophysiologists can then periodically review the EEG recordings and analyze the seizures that may have occurred during the monitoring session. However, reviewing a continuous EEG recording lasting several days can be a time-consuming process. In practice, the patient can indicate that a seizure occurs through the use of an alarm button, so that only the recording sections around the use of the button need to be analyzed. Unfortunately, in many cases, patients are not aware of the occurrence of their own seizures. An automated seizure detection system can thus be of great interest in identifying EEG sections that need to be reviewed. The main difficulty with it lies in the wide variety of EEG patterns that can characterize a seizure, such as "low-amplitude desynchronization, polyspike activity, rhythmic waves for a wide variety of frequencies and amplitudes, and spikes and waves" [6]. In extracranial recordings, EMG, movement, and eye blink artefacts often obscure seizures. Thus, from the pattern recognition point of view, the problem is extremely complex.
In addition, to seizure detection systems, warning systems have also become increasingly valuable since detection of seizures at an early stage can warn the patient that a seizure is occurring. Also, they alert medical staff, and allow them to perform behavioral testing to further assess which specific functions may be impaired as a result of a seizure and help them in localizing the source of the seizure activity. Techniques used to forecast seizures include time-domain analysis [38], frequency-based methods [39], nonlinear dynamics and chaos [31,40], methods of delays [41], and intelligent systems [42]. Advances in seizure prediction promise to give rise to implantable devices able to warn of impending seizures and to trigger therapy to prevent clinical epileptic attacks [2]. Treatments such as electrical stimulation of focal drug infusion could be given on demand and might eliminate side effects in some patients taking antiepileptic drugs.
Consequently, epileptic seizures give rise to changes in certain frequencies bands. Recent works have focused on the analysis of the δ (0.4-4 Hz), θ (4-8 Hz), α (8)(9)(10)(11)(12), β (12-30 Hz) rhythms, and their relation to epilepsy. An epileptic signal is nonstationary, having time-varying frequency components. Time-frequency (TF) representations combine both time and frequency information into a single representation and have proven to be powerful tools for the analysis of nonstationary signals [43], and have been used for neonatal seizure detection [44,45].
In this work, we use TF analysis in order to extract several features from EEG segments, and subsequently use these features to classify the segments concerning epileptic seizures. The method is divided into three stages. Initially, TF analysis is performed for each EEG segment and its spectrum is acquired. Then, several features are extracted from it, measuring the fractional energy on specific TF windows. For this purpose, several partitions on the time axis and the frequency axis are tested. Finally, these features are used as inputs in an ANN, which provides the final classification according to the specified number of categories. A dataset of 500 EEG segments is used, while the method is evaluated for four different classification problems, each of them addressing a different interpretation of the medical problem and thus different selection of EEGs from the whole EEG segment dataset is required for each classification problem. TF analysis and feature extraction, reflecting the energy distribution over the TF plane, have been employed only for neonatal epileptic seizure detection and have not been previously applied in general epileptic seizure detection. In addition, no work addresses all four classification problems, which are directly related to the diagnosis provided by an expert. The obtained results indicate high accuracy compared to other existing approaches.
The rest of the paper is structured as follows. In Section 2, the dataset used in our work along with the employed methodology is described in detail. Then, the evaluation procedure and the obtained results are presented (Section 3), followed by an extensive discussion regarding them (Section 4). Finally, some concluding remarks are included in Section 5.

MATERIALS AND METHODS
The flowchart of the proposed method is shown in Figure 1. Below the dataset and its partitions used are briefly discussed and the three stages (time-frequency analysis, feature extraction, and classification) of the method are explained in detail.

Dataset
An EEG dataset, which is available online [46] and includes recordings for both healthy and epileptic subjects, is used.   two sets have been measured in seizure-free intervals from five patients in the epileptogenic zone (set F) and from the hippocampal formation of the opposite hemisphere of the brain (set N). Finally, subset S contains seizure activity, selected from all recording sites exhibiting ictal activity. Subsets Z and O have been recorded extracranially, using standard electrode positioning (according to the international 10-20 system [47]), whereas subsets N, F, and S have been recorded intracranially. More specifically, depth electrodes are implanted symmetrically into the hippocampal forma-tion. EEG segments of subsets N and F were taken from all contacts of the relevant depth electrode [46]. In addition, strip electrodes are implanted onto the lateral and basal regions (middle and bottom) of the neocortex. EEG segments of the subsets S were taken from contacts of all electrodes (depth and strip). All EEG signals were recorded with the same 128-channel amplifier system, using an average common reference. The data were digitized at 173.61 samples per second using 12 bit resolution and they have the spectral bandwidth of the acquisition system, which varies from 0.5 Hz to 85 Hz. Typical EEG segments (one from each category of the dataset) are shown in Figure 2.
In our analysis, we use the above-described dataset to create four different classification problems and then we tested our method with all of them.
(1) In the first, all the EEG segments from the dataset were used and they were classified into three different classes: Z and O types of EEG segments were combined to a single class, N and F types were also combined to a single class, and type S was the third class. This set is the one closest to real medical applications including three categories; normal (i.e., types Z and O), seizurefree (i.e., types N and F) and seizure (i.e., type S). (2) In the second, again all the EEG segments from the dataset were used and they were classified into two different classes: Z, O, N, and F types are included in the first class and type S in the second class. This is also close to real medical applications, being slightly simpler than the previous, classifying the EEG segments into nonseizures and seizures. (3) The third has similar classes with the first, that is, normal, seizure-free and seizure, but not all the EEG segments from the dataset were employed. The normal class includes only the Z-type EEG segments, the seizure-free class the F-type EEG segments, and the seizure class the S-type. (4) The fourth has similar classes with the second, that is, normal and seizure, but again not all the EEG segments from the dataset were employed. The normal class includes only the Z-type EEG segments while the seizure class includes the S-type.
The above classification problems are shown in detail in Table 1.

Time-frequency analysis
In the proposed method, the smoothed pseudo-Wigner-Ville distribution (SPWVD) [48,49] is applied to each EEG segment, defined as where x(·) is the signal, t is the time, ω is the frequency, and g(·) and h(·) are time and frequency smoothing window functions, respectively. SPWVD can substantially suppress the cross terms, which is a major limitation of the timefrequency analysis. The time smoothing window was selected to be a Hamming 64-point length window, which was the same for all tests performed for evaluation. The length of the frequency smoothing window is not always the same; we have selected several different frequency resolutions (64, 128, 256, and 512 points length window), and we tested the method for all of them. Time-frequency (TF) analysis is used to calculate the spectrum of the signal. Figure 3 shows the spectrum of five EEG segments, one of each of the original dataset categories (Z, O, N, F, and S), using a 512-point length window.

Feature extraction
The spectrum of the signals, computed using TF analysis, is used to extract several features. To do that, a grid is used, based on a time and a frequency partition. In the time domain, two different partitions were used, having three and five equal-sized windows, respectively, while in the frequency domain, four different partitions were used, which divide the frequency domain in 4, 5, 7, and 13 subbands. These subbands, which are not always equal, are shown in Table 2 and they are created using medical knowledge about the EEG and the features that are expected to be found in certain frequency bands for the specific types of EEG segments included in the original dataset. All the combinations between these time and frequency partitions are used, in order to extract several sets of features. The result of the application of TF analysis in an EEG segment for different combinations of time windows and frequency subbands is shown in Figure 4.
Each feature, f (i, j), is calculated as where t i is the ith time window and ω j is the jth frequency band. Each feature represents the fractional energy of the signal in a specific frequency band and time window; thus the total feature set depicts the distribution of the signal's energy over the TF plane. Therefore, it is expected that each feature set carries sufficient information related to the nonstationary properties of the signal and thus, it can be useful for the classification process. The feature set initially is represented as an N × M matrix, where N is the number of time windows and M is the number of frequency subbands, and then it is reshaped into an N·M size vector. The length of the feature vector is not the same in all cases and it depends only on the time and frequency partitions. In all cases, an additional feature is used, which is the total energy of the signal. Thus, in each case the total number of features is N·M + 1.

Classification
The Half of the patterns of the dataset were randomly selected to be used for training, while the rest were used for testing. The network is trained using a standard backpropagation algorithm [50]. Ten different training-test sets were created for each classification problem and thus ten different neural networks were optimized. The final result is obtained as the average of their results.

RESULTS
The four classification problems, described above, are used to evaluate the proposed method. For each of them, all combinations between frequency resolutions (64, 128, 256, or 512), time windows (3 or 5), and frequency bands (4, 5, 7, or 13) were tested; totally 32 different combinations for each classification problem. For each problem, half of the EEG segments, randomly selected, were used for the training of the neural network, while the other half for testing. The size of the confusion matrix depends on the classification problem: 3 × 3 for problems (1) and (3), 2 × 2 for problems (2) The results for the classification problems (1)-(4) are shown in Tables 3-6, respectively. The accuracy (Acc), defined as where cm is the confusion matrix, defined as cm i, j = number of patterns belonging to class i and classified to class j, is calculated for each confusion matrix. The computed accuracies, along with the standard deviations are presented in Table 7. Additionally, the initial number of features and the reduced number of features after the PCA application are presented. For each classification problem, overall results have been derived, that is, the maximum and minimum accuracies (for all combinations between frequency resolutions, time windows, and frequency subbands) as well as the average accuracy and the standard deviation. For the first classification problem, the best obtained accuracy is 97.72%, achieved for 512 frequency resolution, 3 time windows, and 13 frequency subbands. For the second classification problem, the best obtained accuracy is 97.73%, achieved for 512 frequency resolution, 3 time windows, and 5 frequency subbands. For the third classification problem, the best obtained accuracy is 99.28%, achieved for 128 frequency resolution, 3 time windows, and 4 frequency subbands. Finally, for the fourth classification problem, the best obtained accuracy is 100%, achieved in most of the cases; in 28 out of 32 different evaluations of the fourth classification problem we obtained accuracy 100%. For the first two classification problems, the obtained accuracies of the different evaluations varied significantly; almost 6.5% (max-min) for both of them, with average 95% and standard deviation 1.7%. For the third classification problem, the max-min difference is 3% and the average 97.94%, with 0.75% standard deviation. Finally, for the fourth classification problem, the max-min difference is 1.3% and the average 99.92%, with 0.26% standard deviation.

DISCUSSION
We have proposed an automated method for seizure detection in EEG recordings. The method is based on TF analysis of the EEG segments and extraction of several features from the spectrum of the signal. These features are fed into neural networks, which provide the final classification of the EEG segments. The method is evaluated using four different classification problems originated from the type of medical diagnosis, which can be obtained. The effect of different parameters of the method on the classification accuracy is exam-ined. Those parameters are the frequency resolution of the TF analysis, the length of the time window, and the width of the frequency subbands used in the feature extraction. The different combinations among all the afore-mentioned parameters result in a large number of different experimental settings (32) for each classification problem (4) and 10 different realizations (selections of training/test datasets) for each of them-totally 1280 optimized and evaluated ANNs-and results are presented for all of them. This is considered an extensive validation procedure, which can sufficiently exploit the potentials of the proposed method.
In this method, the SPWVD has been employed for the TF analysis of the EEG signals. Other distributions have been also tried but the better results were obtained for SPWVD.
The frequency resolution, used in the TF analysis, does not greatly affect the accuracy of the proposed method; the average accuracies of all different combinations of time windows and frequency subbands, for the four classification problems, are 96.71%, 97.13%, 96.7%, and 96.87% for 64, 128, 256, and 512 points length windows, respectively. It is obvious that the use of 128 points length window slightly improves the results. On the other hand, the number of the time windows is important for the analysis; in the case of three 8 Computational Intelligence and Neuroscience Table 5: Results for the third classification problem, in terms of sensitivity (Sens), specificity (Spec), and selectivity (Sel) in % values. Those are given for all TF resolutions (64, 128, 256, and 512), time windows (3 and 5), and frequency subbands (4, 5, 7, and 13 time windows, the average accuracy of all different combinations between the frequency resolutions and frequency subbands, for all four classification problems, is 97.52%, while the accuracy in the case of five time windows is 96.2%. This means that analyzing EEG segments of approximately 8-second length reveals more information for the epileptic seizures than having 5-second windows. Other statistical measurements lead to the same conclusion; in the case of three time windows, the minimum accuracy of all cases is 93.04% and the standard deviation 1.8%, while the accuracy for five time windows is 91.08% and the standard deviation 2.9%, respectively. Finally, concerning the number of frequency subbands, again the reported average accuracies for all combinations among the frequency resolutions and the time windows, for all classification problems, are 97.07%, 96.87%, 96.84%, and 96.62% for 4, 5, 7, and 13 frequency subbands, respectively. This gives indications that the separation in δ, θ, α, and β rhythms is the one that mostly detects the TF components that characterize the signal regarding epileptic seizures, compared to 5 and 7, which have been used in other methods [20,22], and 13, which is defined in this work to examine if a frequency resolution with a large number of frequency subbands improves the classification accuracy. The results indicate that all selections for frequency subbands result in similar high-average accuracies-the difference between the best and worst age accuracy is 0.45%. This can be justified since they are generated either based on expert knowledge or have been previously proposed in the literature. Concerning the frequency subbands, the higher their number, is the lower (slightly) the average accuracy obtained. To our knowledge, TF analysis and feature extraction, which reflect the energy over the TF plane, have been only applied in the analysis of neonatal EEG signals (and mainly for neonatal epileptic seizure detection) and not EEG signals in general. Moreover, the quality of the proposed method can be proved from the obtained results. The accuracy achieved by our method for the epileptic seizure detection is more than satisfactory and also its automated nature makes it suitable to be used in real clinical conditions. Besides the feasibility of a real-time implementation of the proposed method, the diagnosis can be made more accurate by increasing the number of parameters. A system that may be developed as a result of this study may provide feedback to the experts for classification of the EEG signals quickly and accurately by examining the EEG signal. Table 6: Results for the fourth classification problem, in terms of sensitivity (Sens), specificity (Spec), and selectivity (Sel) in % values. Those are given for all TF resolutions (64, 128, 256, and 512), time windows (3 and 5), and frequency subbands (4, 5, 7, and 13 Table 8 presents a comparison between our method and other methods proposed in the literature. Only methods evaluated in the same dataset are included so that a comparison between the results is feasible. For the two classes' problem, using only the Z and S types of EEG segments, the results obtained from the evaluation of our method are the best presented for this dataset. The difference between our result and all other results proposed in the literature varies from 0.4% to 10%. The second two classes' problem that we used to evaluate our method also presents high-accuracy results (97.73%). It is worth to mention here that a method that discriminates EEGs into nonseizure and seizure is much closer to the expert needs.
Regarding the three classes' problem, the results obtained from our method are the best presented for this dataset, either using only the Z, F, and S types or all the available dataset. In the case of using the third problem to evaluate our method (i.e., only the Z, F, and S types), the difference between our results and all others' results varies from 2.5% to 13.4%. In the case of using the first classification problem to evaluate our method (i.e., the Z and O, F and N, S types), the difference between our results and all others' results ranges from 1% to 12%. The second case has also the advantage of being a more realistic classification, dividing the dataset to normal, seizure-free, and seizure EEGs, and thus being closer to clinical conditions. Still, however, there are several other aspects either technical or medical which must be addressed. From the technical point of view, although we have examined the effect of various parameters (frequency resolution, number of time windows, and frequency bands), some other, like timefrequency distributions (e.g., reduced interference distributions), have not been explored. Furthermore, we mainly focused on the effects of the parameters related to frequency analysis, either for the calculation of the spectrum of the signal or for the frequency resolution for feature extraction. More detailed examination of the time resolution for feature extraction may also reveal important information regarding the seizure detection; this feature will be addressed in feature communications. From the medical point of view, the most important feature is that currently the method is used to characterize predetermined (with respect to their length) EEG segments. An important aspect is also the modification of the proposed method in order to be able to automatically detect highly suspicious segments (regardless of their length) into long time EEG recordings and classify them.

CONCLUSIONS
In this paper, we explored the ability of the TF analysis to classify EEG segments which contain epileptic seizures. We have extracted several time-frequency features and we examined the effect of the parameters entering the problem, that is, the frequency resolution of the time-frequency analysis and the number of time windows and frequency subbands used for feature extraction. Promising results have been re-ported after the evaluation of the proposed method in four different classification problems, derived from a well-known database. However, several types of artefacts have been removed from this database after visual inspection. This is a limitation of the evaluation of our method and thus further evaluation under real clinical conditions is required in order to fully exploit its potential. Another limitation is that in the current study high-frequency components (over 40 Hz) were not measured and thus taken under consideration; the employment of high-frequency components, such as gamma activity, and their importance concerning epileptic seizure detection will be addressed in a future communication. Finally, several technical aspects can be further investigated, such as different techniques for feature reduction and alternative classification algorithms.