Convolutional Neural Network for Seizure Detection of Nocturnal Frontal Lobe Epilepsy

,


Introduction
Nocturnal frontal lobe epilepsy (NFLE) is a rare form of epilepsy, typically inherited, which affects both sexes from 1 to 60 years, and is associated with cognitive decline.Crises are characterized by frequent and brief hypermotor sleep seizures, which may range from a simple awakening from sleep to more focused motor movements, with dystonic and tonic postures, grimaces, screams or groans, episodic nocturnal wanderings, and stereotyped agitated somnambulism, among others [1,2].In this paper, the problem of detecting NFLE seizures, using Electroencephalographic (EEG) signals as inputs to an original Convolutional Neural Network (CNN) prediction model, is addressed.e use of EEG signals is corroborated by most of the literature on epileptic seizure detection, which considers indeed the EEG the gold standard to analyse the electrical activity of the brain [3].
In the literature, there is a wide range of proposals for the identification of general epileptic seizures [4][5][6][7][8][9][10][11][12][13], mostly based on the machine-learning approach, which support the doctors in the time-consuming manual labelling [4].However, very few contributions specifically dealing with NFLE are present, and they reach lower performance indices.In [14], a detection system for NFLE seizures has been proposed, which is based on accelerometer signals, obtaining a value of sensitivity of 91.67% and specificity of 84.19% on three pediatric patients.
e accelerometers were already proposed in [15,16] to detect epileptic seizures with pros and cons; even if they are more comfortable to wear, they can only reveal seizures associated to motor activity.Moreover, high false-positive rates are often possible due to motion artifacts that cannot be readily distinguished from convulsions.In [17], a machine-learning technique has been proposed to classify NFLE seizures and nonseizures using the C4/A1 EEG channel (according to the International 10-20 System [18]), which is one of the monopolar derivations currently used for the conventional sleep staging and arousal scoring [19], obtaining a value of specificity of 82.4%.In [20], the Self-Organizing Maps (SOMs) are used to develop patient-specific seizure detection systems for NFLE.
e proposed method allows the construction of maps that contain important information on the current brain state, showing the potential of the map to correctly cluster data from seizure and nonseizure patterns.In addition, it also suggests the use of SOMs for early crisis detection by projecting the EEG trace onto it.Following the trajectory of this projection on the map, it is possible to activate an alarm depending on the composition of the cluster where the current EEG sample is projected.
e method has been tested on nine patients obtaining a mean value of sensitivity equal to 80.5% and a mean value of specificity equal to 90.2%.
Despite these quite good results, the cited literature shows that the feature engineering phase is crucial for the success of the machine-learning predictive models and the identification of proper seizure indicators is a preliminary due diligence.In fact, it highly influences the performance of the classifier and it is often conditioned to a specific knowledge and competencies on the pathophysiology under study.Moreover, extracting features is usually carried out by hand and it is very time consuming, requiring a high number of scenarios simulations in order to choose the best combination of features.To avoid this challenging phase, in the present paper, CNNs have been used.In fact, CNNs are able to automatically learn relevant low-dimensional features from high-dimensional data by successively applying convolutional and downsampling operations.
CNNs, which belong to the so-called deep neural networks [21][22][23], are now affirming themselves for the automated detection of epileptic seizures from EEG signals.In [24], Acharya et al. proposed a one-dimensional (1-D) CNN with 13 layers: 5 convolutional layers, 5 max-pooling layers, and 3 fully connected layers.e CNN has been trained to classify EEG epochs in three classes: normal, preictal, and seizure.Using 100 single channel EEG traces of five patients from the Bonn EEG database [25], an accuracy of 88.67%, a sensitivity of 95%, and a specificity of 90% are obtained with a ten-fold crossvalidation.Even if the results are promising, comparison with the literature on the same database revealed that the proposed detection system could be improved provided that more EEG data are available.In [26], Ullah et al. proposed an ensemble of pyramidal 1-D CNNs (P-1D-CNN) to solve the same three classes' detection problem addressed in [24] on the same University of Bonn database.Each P-1D-CNN has three convolutional layers and two fully connected layers.Several simulations have been performed to select the best model parameters.In order to overcome the lack of data, already highlighted in [24], two data augmentation schemes have been introduced.A majority voting strategy has been adopted to fuse the decisions of the ensemble of CNNs, reaching an average accuracy of 96.1%.In [27], the authors exploited the attitude of the CNNs to process images, rather than 0-D temporal sequences.For this purpose, the raw EEG multichannels data have been firstly filtered, then segmented using a prefixed time window, and finally converted into a series of EEG-plot images.e proposed CNN, which is based on the VGG-16 architecture of [28], has been trained to classify each image into seizure or nonseizure class.e results, presented in terms of median true positive rate labelling by seconds is 74%, which the authors claimed to be higher than that of commercially available seizure detection software.In [29], each single-channel EEG signal is converted into a 2D plot and the plots corresponding to 22 different EEG channels are combined in 3D images depending on the mutual correlation of the intensities between the electrodes.en, using 3D kernels, a 3D CNN, with 4 convolutional layers, 3 max pooling layers, and 2 fully connected layers, has been built to detect interictal, preictal, and ictal stages in 13 epileptic patients.An accuracy of 90%, a sensitivity of 88.9%, and a specificity of 93.8% is obtained using a ten-fold crossvalidation procedure.
As shown in the cited references, training CNN models requires a huge amount of EEG records manually labelled by skilled neurologists, which may be a tedious and timeconsuming task.Hence, as highlighted by most of the authors, the major issues limiting the performance of these deep-learning seizure detection methods are the amount of training data, which may not be enough, and the feature space of seizures, which may vary significantly across different patient EEG recordings and even for the same patient.To overcome these limitations, in the present paper, a transfer-learning strategy, which can significantly reduce the quantity of data needed for training, is adopted.A survey on the transfer learning is reported in [30], where it is defined as "the ability of a system to recognize and apply knowledge and skills learned in previous tasks to novel tasks."Transfer learning proved to be particularly useful in training deep neural networks that can share some lower layers of a network previously trained with data from other tasks, while the upper layers are retrained and fine-tuned using taskdependent data [31].Transfer-learning techniques are still largely unexplored although they seem to have a great potential to overcome the issue of lack of data available for epileptic seizure detection.
In the present paper, the CNNs have been firstly used to build patient-specific seizure detection systems for three patients affected by NFLE.e detection problem has been modelled as a seizure and nonseizure classification problem, obtaining performances that overcome those of other methods presented in [20] for the same patients.e patientspecific CNN model has been used also to find the seizure onset, limiting the time-consuming manual labelling for doctors.
en, a transfer-learning technique has been adopted, allowing to fine tune one of the CNN models, trained with data from one patient, to obtain a detection predictor for a different patient.e results obtained in the present work indicate that even just a seizure is enough to customize the CNN to the new patient.
2 Complexity e rest of this paper is organized as follows.e database used, the data augmentation schema, and CNN model architecture are discussed in Section 2. Section 3 presents and discusses the results obtained by the patient-specific and the cross-patient detection systems.Section 4 concludes the findings of the study.

Materials and Methods
A combination of deep learning and transfer learning has been used to build patient-specific and cross-patient seizure detection systems.
e detection problem has been formalized as a two-class classification problem, where the two classes correspond to seizure (SZ) or nonseizure (NS) states during the sleep and has been approached by training Convolutional Neural Network models with long-term EEG recordings including epileptic seizures.

Dataset. Data for this study comes from two epilepsy centers: Unidade de Monitorização em Epilepsia e Sono do
Centro Hospitalar e Universitário de Coimbra, Portugal, Epilepsiezentrum, Universitätsklinikum Freiburg, Germany, on behalf of the EPILEPSIAE project [32].e data concern three patients affected by nocturnal seizures located in the frontal lobe (NFLE).e same patients have been considered also in [20], and the subject numbers refer to those in Table 1 of [20].e relevant information on the patients enrolled in this study is summarized in Table 1.
e initial and final time of a seizure (SZ) have been identified based on the agreement between at least two expert neurologists.For the nonseizure recordings, no information is available about the patient sleeping or awake state.As in [20], also in the present study, it has been hypothesized that the patients were sleeping in the ten minutes preceding a seizure and these ten minutes are considered to characterize a nonseizure state (NS).
e dataset includes eleven scalp EEG channels, placed according to the International 10-20 System [33] with a sampling rate of 256 Hz.According to the neurologists' suggestions, the eleven selected channels, coloured in blue in Figure 1, are those more suitable for the NFLE seizure detection: three central channels (C3, C4, and Cz), two frontal channels (F3 and F4), two frontal-polar channels (Fp1 and Fp2), two parietal channels (P3 and P4), and two occipital channels (O1 and O2).All the channels are unipolar derivations with a common reference electrode.

EEG Segmentation and Data
Augmentation.Data, coming from the continuous 11 recordings, each one corresponding to an EEG channel, have been segmented using an overlapping sliding window of 5 seconds.In this way, each time window, or segment, has 1280 data points in the 11D space.
e data segmentation allows to increase the number of training samples, which is mandatory, especially in deep learning [26,29].For the training of the network, the data from seizures were segmented with an overlap with the previous window of 0.1484 s, 0.5508 s, 1 s, for patient #5, patient #6, and patient #9, respectively.e overlap times during seizures for the three patients have been differently chosen in order to reduce the class unbalance due to different total seizure times (see Table 1).As the mean seizure time is about 10% of the nonseizure recordings, the length of the nonseizure segments is still equal to 5 seconds without overlapping, whereas, for the seizure segments, the overlap time has been dynamically set to produce a balanced number of segments within the two classes.
is operation can produce windows with very similar data, so with few novelties for the CNN training; however, in our opinion, it seems to be the most effective way to balance the classes while maintaining a high quantity of data for deep learning.During testing, a sliding window of 5 s with an overlap of 1 second, for all patients and both phases (seizure/nonseizure), has been used.
In order to improve the quality of the raw EEG signals, a preprocessing step has been performed.After discarding the windows with missing data, a standard thresholding of potential values has been performed.Here, data have been labelled as artifacts if the absolute value of any data point in the trial exceeded a fixed threshold.is method is currently the most widely used artifact detection method in the EEG community.It is most effective for detecting gross eye blinks or eye movement artifacts.Since even a small number of these extreme values can lead to inaccurate results, the segments including these extreme values have been discarded.Furthermore, filtering has been a necessary step due to the presence of 50 Hz line noise and DC offset (removal of the 0 Hz).us, a Notch filter at 50 Hz with bandwidth 1 Hz has been applied to remove 50 Hz line noise, and the average value of each electrode along the preseizure phase has been removed as DC offset.e cleaned dataset for each patient has been then partitioned, in order to randomly assign the different seizures to the training, validation, and test sets.In this architecture, each channel of the input image is filtered separately, obtaining a set of 64 features per electrode.Features coming from different electrodes are combined in the fully connected layer, i.e., only after the convolutional units, for classification.
Dropout layers with dropout probability of 20% have been included inside CU 1 , CU 2 , and CU 3 convolutional units in order to reduce overfitting on the training set and improve generalization.e algorithm used to train the network is the stochastic gradient descent with momentum [35].

Results and Discussion
e performance of the deep models has been evaluated using some metrics employed in most of the literature on epilepsy and, in general, in classification by machine learning, such as Accuracy, Specificity, Sensitivity, and Gmean: Figure 2: CNN architecture, where I is the image input layer; CU k is the k th convolutional unit; MP and AP are the max pooling and average pooling layers, respectively; FC is the fully connected layer; and SM and CO are the SoftMax and classification output layer, respectively.In the k th convolutional unit, C kj , N kj , R kj , and D k are the j th convolutional layer, the j th batch normalization layer, the j th ReLu layer, and the dropout layer, respectively.® Core ™ i7 CPU with 16 GB memory has been used, with the help of a Nvidia GeForce GTX 960M with 4 GB memory.
As an example, Figure 3 shows the performance for patient #9, in terms of accuracy on training, validation, and test sets, against training epochs.
e training procedure continues epoch after epoch only if the validation performance increases with respect to the previous epoch.If not, the training is interrupted.is very strong constraint helps avoiding overfitting on the training set, which would occur if the usual crossvalidation procedure is adopted, due to the big size of the network.As shown in Figure 3, for patient #9, the training has been stopped at the 8 th epoch since no better performance has been obtained on the validation set.e training time of the patient-specific models range from approximately 1 hour to 5 hours depending on the seizures in the training and validation sets.
Table 3 reports the performance in terms of Accuracy, Specificity, and Sensitivity for the three patients.
Values greater than 94% have been achieved for all the performance indices of all the patients with mean values higher than 93%, except for sensitivity related to patient #9 which is equal to 83.94%.From Table 3, it can be seen that patient #6 presents very high values for all the indices, reaching even 100% of specificity.Patient #5 still has quite high-performance values, even if it is less than the previous case, due to relatively low value of specificity, whereas patient #9 presents an opposite behaviour with a high value of specificity and the lowest value of sensitivity, showing that EEG features vary from one patient to the other.
For each patient, the obtained results, in terms of geometric mean of specificity and sensitivity (Gmean), have been compared with those in [20], where SOM and SVM have been used as classifiers.is last method is widely used in epileptic seizure detection systems [4,36].
e results reported in Table 4 show that CNN improves the performance of both the methods by several percentage points.
ese patient-specific models can be used to support the neurologists in the time-consuming identification of the seizure onset time.In particular, during the evolution of the EEG recordings, the condition derived from the CNN model is used to trigger the alarm (i.e., the seizure onset) when the sliding window is classified as SZ for at least d consecutive seconds.e assertion time d has been optimized on the same set used to train the model.As an example, Table 5 reports the difference Δt in seconds between the alarm time given by the algorithm (t alarm ) and the seizure onset time provided by the neurologists (t SZ ) for the EEG recordings of the patient #9.As it can be noted, in 87% of cases, the alarm time differs from the seizure onset time by less than 10 s.In the other two cases, this difference is at most 17 s.Figure 4 reports the cumulative alarm time     Complexity distribution for patient #9.In the same figure, the seizure onset time provided by the neurologists is reported.Note that, because in each EEG recordings the first 10 minutes correspond to nonseizure states (NS), t SZ is always equal to 600 s. Figure 5 shows, as an example, the testing seizure #14 of patient #9 and the preceding 10 min.
e three top plots in Figure 5 report the raw signals of the channels FP2, F4, and C4, which have been colored in blue for the NS state and in red for the SZ state.e bottom plot in Figure 5 shows a bar graph where each bar, corresponding to one second, is colored depending on the answer of the CNN: a blue bar represents a pattern classified as NS, whereas a red bar characterizes a SZ pattern.By comparing the bars with the raw signals during the temporal evolution of the EEG recording a very good correspondence is found.
ese results, showing a good performance of the CNN, are obtained from models that have been trained using a number of seizures.However, in case of a new patient, instead of collecting a sufficient number of seizures to customize a new patient-specific model from scratch (which sometimes is difficult) transfer-learning capabilities can be used.Starting from a model already trained for other patients, it may be retrained with new seizures of the new patient, obtaining a cross-patient seizure detection system with transfer learning among the patients.

Transfer Learning for Cross-Patient Seizure Detection.
Transfer learning is a technique consisting of pretraining a model on one set of data and then fine-tuning it on another.In this case, the deep cross-patient transfer learning framework is applied to classify EEG data of a patient using the CNN trained with the EEG of another subject.In particular, starting from a patient-specific CNN model, its weights are used as the initial values for a second phase of training using seizures of another patient.is could provide many advantages when few seizures are available.
As an example, the patient-specific CNN model of patient #9 (CNN9) has been assumed as the starting model.
is choice has been done because on one hand patient #9 has the highest number of seizures and on the other its model achieves the lowest performance in terms of Gmean.
Table 6 shows the results of the cross-patient seizure detection procedure applied to detect the seizures of patient #5 starting from the network pretrained on patient #9; Figure 6 reports the trends of Sensitivity and Specificity during the temporal occurrence of the five seizures of patient #5, for the training set (blue line) and for the validation set (red line).e green squares in the same figure represent the performance obtained on the test seizures.
Starting from the CNN9 model, the first of the five seizures of patient #5 are used as a test case.As expected, the performance is quite low because the model has not been yet customized to the new patient.In particular, the CNN9  Complexity model performs a low specificity (about 28%), whereas the value of sensitivity is very high (100%).is suggests refining the starting model by using patient-specific information.Hence, in the next step, two-thirds of the EEG segments of the first seizure have been used as the training set and the other one-third as validation set, whereas the performance of the customized model has been tested on the second seizure, showing an improvement of specificity that increases to 85.92%, while sensitivity is not degraded.In the subsequent steps, the last seizure has been used to test the model customized on the preceding seizures.As it can be noted, during the testing of the subsequent seizures, Specificity and Sensitivity values fluctuate keeping always above 80% and providing an ever high Gmean value up to the value of about 99% in the last tested seizure.
For each step of the procedure, Table 7 reports a summary of the cross-patient seizure detection process: the seizures used for training, validation, and test, the number of epochs performed during the training, and the total CPU time in seconds.If the number of epochs is zero, it means that, during the training, no network configuration has been found that improves the prediction accuracy on the validation step.Note that the process took less than 30 minutes to fine-tuning the model with each new data pattern.
Table 8 and Figure 7 reports the same results of Table 6 and Figure 6 but referring to patient #6, starting again from the CNN9 model.
In this case, the cross-patient seizure detection system performs very well since the first seizure, especially concerning the specificity, which always takes values above about 95%.
is fluctuating trend, especially concerning the sensitivity, demonstrates the diversity of seizures not only among patients but also within the same patient, which challenges all classifiers, whatever deep they may be.8 Complexity In Table 9, the transfer-learning process from CNN9 to patient #6 is shown, with the same information reported in Table 7. Also, in this case, retraining the CNN9 with a new seizure takes no more than 20 minutes.

Conclusions
A CNN architecture has been deployed, by adapting the ResNet structure to the problem of seizure detection from EEG traces in nocturnal frontal lobe epilepsy (NFLE).e adjustment in the architecture consisted mainly in using 1D filters in the convolutional layers, to filter separately the information coming from different electrodes, and including dropout layers to reduce overfitting on the training set and improve generalization.An advantage of the deep-learning approach is that the complex and time-consuming feature engineering step is not required.Moreover, the developed patient-specific detection systems have demonstrated to be superior to those in the literature towards all the performance indexes, with accuracy above 94% for all the considered patients.In our knowledge, this is the first of deep learning to NFLE seizure detection.Moreover, using the potentiality of the transfer learning, the lack of an extensive EEG database has been overcome and the possibility to develop a cross-patient seizure detection system has been demonstrated.Indeed, a patient-dependent system can be fine-tuned to a new patient with few data and limited computational effort.

2. 3 .
CNN Architecture.For the development of the CNN architecture, the deep residual network (ResNet) structure[34] has been adapted for the problem of seizure detection.eCNN architecture is shown in Figure2.A first convolutional unit (CU 0 ), made up of three layers, transforms the input image of size 1280 × 11 into a 4channels image of size 320 × 11. e responsible of the size reduction is the convolutional layer, having filters of size 5 × 1 and stride 4 × 1.A max pooling layer (MP), with pool size 5 × 1 and stride 4 × 1, follows the first convolutional unit, reducing again the image dimension to a 4-channel image of size 80 × 11.A second convolutional unit (CU 1 ) made up of seven layers filters the 4-channel image of size 80 × 11 by means of a residual connection.Two following convolutional units (CU 2 and CU 3 ), each one made up of nine layers, filter out the 4-channel image of size 80 × 11 by means of a residual connection, reducing the image dimension first to a 16-channel image of size 20 × 11 and then to a 64-channel image of size 5 × 11.An average pooling layer (AP), with pool size 5 × 1, reduces the image dimension to a 64-channel image of size 1 × 11, producing a set of 704 features.Finally, a fully connected layer (FC) processes the 704 features, output Complexity of the average pooling layer, and feeds a SoftMax layer (SM) for classification (CO).

Figure 3 :
Figure 3: Accuracy on training, validation, and test set for patient #9 against training epochs.

Figure 4 :Figure 5 :
Figure 4: Cumulative alarm time distribution for patient #9. e dashed vertical line refers to the seizure onset time provided by the neurologists.

Figure 6 :
Figure 6: Results of the cross-patient seizure detection procedure in terms of Specificity (a) and Sensitivity (b), starting from the seizure detection model of patient #9 and fine-tuning it for patient #5. Figure shows the trend of Specificity and Sensitivity during the temporal occurrence of the 5 seizures of patient #5.Blue line: trend on the training set; red line: trend on the validation set; green squares: results on the test set.

Figure 7 :
Figure 7: Results of the cross-patient seizure detection procedure in terms of Specificity (a) and Sensitivity (b), starting from the seizure detection model of patient #9: trend of Specificity and Sensitivity during the temporal occurrence of the 8 seizures of the patient #6.Blue line: trend on the training set; red line: trend on the validation set; green squares: results on the test set.

Table 1 :
Patients from European epilepsy database.
[33]ONFigure1: e International 10-20 System[33]with the 11 selected channels (in blue).3.1.Patient-Specific Seizure Detection.Firstly, patient-specific seizure detection systems have been developed for each of the three patients.Table2reports the number of seizures and the number of segments used for training, validating, and testing.MATLAB R2018b deep-learning library has been used to develop the CNN models.To train the models an Intel

Table 2 :
Dataset composition for training, validation, and test.

Table 3 :
Test performance (%) of the patient-specific models.

Table 4 :
Comparison of Gmean (%) with some state-of-the-art techniques.

Table 5 :
Difference Δt (s) between the alarm time given by CNN and the seizure onset time provided by the neurologists for the three patients.

Table 6 :
Test Performance (%) of the cross-patient seizure detection system of patient #5.

Table 7 :
Steps of the cross-patient seizure detection process for patient #5.

Table 8 :
Test Performance (%) of the cross-patient seizure detection system on patient #6.

Table 9 :
Steps of the cross-patient seizure detection process for patient #6.