scieee AI-readable full text Open interactive document viewer

EEG seizure detection in paediatrics using deep convolutional neural networks

Bauxell Cornet, Joaquim

Abstract

Neonate seizure detection using tools such as machine learning is a well researched topic. However, there is still much to be known about how those detection models perform across different age ranges and if a generalised model is possible. In this project, parting from a state of the art neural network trained to detect seizures in neonates, its adaptability to a paediatrics dataset (from Children's Hospital Boston's EEG database, which consists of EEG scalp recordings from paediatric subjects) is going to be evaluated using different approaches, including transfer learning. At the same time, as it was also required for the development of the project, the setting up of the working environment and the design and training of a simpler convolutional neural network for inference on the edge in an embedded system have also been documented.

Full text

EEG SEIZURE DETECTION IN PAEDIATRICS USING DEEP CONVOLUTIONAL NEURAL NETWORKS A Master's Thesis Submitted to the Faculty of the Escola Tècnica d'Enginyeria de Telecomunicació de Barcelona Universitat Politècnica de Catalunya by Joaquim Bauxell Cornet In partial fulfilment of the requirements for the degree of MASTER IN ADVANCED TELECOMMUNICATION TECHNOLOGIES Advisors: Dr. Emanuel Popovici, Dr. Andriy Temko Tutor: Dr. Climent Nadeu Camprubí Cork, June 2022 Title of the thesis EEG seizure detection in paediatrics using deep convolutional neural networks Author Joaquim Bauxell Cornet Advisors Dr. Emanuel Popovici Dr. Andriy Temko Tutor Dr. Climent Nadeu Camprubí Abstract Neonate seizure detection using tools such as machine learning is a well researched topic. However, there is still much to be known about how those detection models perform across different age ranges and if a generalised model is possible. In this project, parting from a state of the art neural network trained to detect seizures in neonates, its adaptability to a paediatrics dataset (from Children’s Hospital Boston’s EEG database, which consists of EEG scalp recordings from paediatric subjects) is going to be evaluated using different approaches, including transfer learning. At the same time, as it was also required for the development of the project, the setting up of the working environment and the design and training of a simpler convolutional neural network for inference on the edge in an embedded system have also been documented. Acknowledgements I would like to express my gratitude to my mentors Emanuel Popovici and Andriy Temko for taking me into their research group in Cork and also for their guidance. Also to my mentor in Barcelona, Climent Nadeu, for introducing me to them and the opportunity to have this experience. A thank you is due too to Sergi Gomez and Aengus Daly, fellow researchers in Cork, for their insights and previous work that made it possible for me to have a swift adaptation into the project. Finally, to my lab peers and to all the amazing people I met in Ireland. 1 Revision history and approval record Revision Date Purpose 0 01/05/2022 Document creation 1 12/09/2022 Document revision Written by: Reviewed and approved by: Date 01/05/2022 Date 12/09/2022 Name Joaquim Bauxell Cornet Name Emanuel Popovici Position Project Author Position Project Supervisor 2 Table of contents Abstract 1 Acknowledgements 1 Revision history and approval record 2 Table of contents 3 List of Figures 4 List of Tables 5 1. Introduction 6 1.1. Statement of purpose 6 1.2. Methods and procedures 6 1.3. Work plan 7 1.4 Deviations and eventualities 7 2. Seizure detection by EEG signal interpretation 8 2.1. Electroencephalograms and electroencephalography 9 2.2. Types of EEG montages 10 2.3. The brain stethoscope project 12 3. State of the art seizure detection using machine learning 14 3.1. Benchmarking metrics 14 3.2. Machine learning in seizure detection 16 3.2.1. Detection models on CHB-MIT dataset 17 3.2.2. The proposed model 19 3.3. Deeper convolutional networks and transformers 22 4. Project development 23 4.1. Establishing the framework 23 4.2. Data preprocessing 24 4.3. Training procedure 26 4.4. Dummy convolutional network for an embedded system implementation 28 4.5. Pre-trained ResNet domain study 29 4.6. Retraining of the ResNet 29 4.7. Fine-tuning of the ResNet 29 5. Results 31 6. Conclusions and future development 34 Bibliography 35 Glossary 39 3 List of Figures Figure 1. Gantt diagram. 3 Figure 2. Display of an interictal EEG recording of typical hypsarrhythmia in a two year old girl with West syndrome due to genetic mutation [19]. 9 Figure 3. Hypsarrhythmic EEG pattern in an infant with West syndrome. An ictal electrodecremental response (red) is seen during an epileptic spasm [24]. 10 Figure 4. Graphical representation of a referential montage [3]. 11 Figure 5. 8-channel montage (left) and 18-channel montage (right) [3]. 11 Figure 6. Sonification block diagram proposed by Gomez et al. [3]. 12 Figure 7. ROC graph of a binary predictor with an AUC is 79%. The blue line represents the ROC of a random classifier, which will have an AUC of 50%. 16 Figure 8. Proposed fully convolutional architecture. 19 Figure 9. Graphical representation of the input and the first convolutional block. 19 Figure 10. Block representation of a skip connected block. 20 Figure 11. Proposed fully convolutional architecture including residual connections. 21 Figure 12. Diagram of the basic workflow from a local computer using CUDA enabled Docker containers. 23 Figure 13. Block diagram of the preprocessing steps. 25 Figure 14. Segment of an 80 seconds of length EEG recording that contains a seizure [4]. 26 Figure 15. Architecture of the dummy convolutional network. 28 Figure 16. Sensitivity-Specificity curves for each fine-tuned fold. 31 Figure 17. Zoomed Sensitivity-Specificity curves for each fine-tuned fold with its average curve and variance compared to the state of the art models. 33 4 List of Tables Revision history and approval record 2 Table of contents 3 List of Figures 4 List of Tables 5 Table 1. Frequency bands and their respective ranges. 9 Table 2. Confusion matrix. 15 Table 3. State of the art models on CHB-MIT. 17 Table 4. CHB-MIT dataset’s patients gender, age, and seizures. 25 Table 5. AUC and AUC90 obtained for each patient using leave-one-out cross validation for both a full retraining of the network and fine-tuning a neonatal-based model. 32 5 1. Introduction A seizure is a sudden and uncontrolled electrical disturbance in the brain, and epilepsy is a chronic disease of the brain characterised by recurrent seizures. Epilepsy is an issue that affects more than 50 million people worldwide [1] and, at the same time, is a massive challenge for healthcare professionals. While seizures may come with easy-to-recognize symptoms such as involuntary jerking movements of the affected person’s limbs, eye blinking, or difficulty breathing, it’s not uncommon for those same symptoms to not be present, especially in the youngest population. For instance, in the neonatal age group, less than 10% of seizures show physical manifestations. The aim of this project is to create a deep learning model to be used in a fast and accurate way on the edge to ease the task of seizure detection for healthcare professionals across the widest possible range of patients. The project has been conducted at the Embedded Systems Research Group at University College Cork, which has an extensive trajectory through many years of seizure detection using AI tools with many publications in the matter. 1.1. Statement of purpose The scope of the research group is to train a detection model to be fast, accurate, and able to be used on the highest number of patients possible. For this very reason, its design and training should be aimed at being reliable across different age ranges, which is not a trivial task as there are some important changes in the brain in the first years of life. To study if such portability across age ranges is possible, different work packages have been established. - Set up the working environment to remotely send models into training on the department’s new server with GPU compatibility using different approaches. - Build and train a ConvNet with the required design constraints to be able to be loaded onto the board Raspberry Pi 3 Model B+ [2] for inference testing on the edge. - Parting from a state of the art model for seizure detection in neonates, study its portability to paediatrics using three different approaches: evaluate its performance with the original weights, retrain it completely on paediatrics data, and fine-tuning the original weights on paediatrics data. The latest being a novel line of work in EEG seizure detection. 1.2. Methods and procedures The project, from UCC's Embedded Systems Research Group, builds on the extensive work of other researchers and incorporates their findings and designs into a new task, implying the evolution of some methodologies and the implementation of some new approaches on some aspects of different stages of seizure detection processes.The knowledge received at the starting point of the thesis includes: - Sergi Gómez et al. [3] for an introduction to the lab's general approach to seizure detection using deep learning and raw EEG data preprocessing. - Aengus Daly et al. [4] for the state-of-the-art model for neonatal seizure detection. 6 All models have been coded and trained using Python and Bash on a remote server’s GPUs using the following libraries, tools, and frameworks: - Tensorflow [5] as the backbone framework. - Keras [6] API for training the detection model. - PyTorch [7] as the framework for the dummy network. - CUDA [8] for direct access to the GPU's virtual instruction set and parallel computational elements and execution of compute kernels for training. - Docker [9] as a container manager for remote training. 1.3. Work plan The workload was divided into multiple tasks, as described below, which included the different training settings, the evaluation of the models, and the comparison of their performances. The final steps have been evaluating the validity of the premise of the thesis and its writing. Figure 1. Gantt diagram. 1.4. Deviations and eventualities There have been some incidents and circumstances that have extended the length of time of some work packages. Due to the inexperience using CUDA and related settings prior to the project, and some occasional external factors, there have been some training processes getting killed. Combined with the fact that the training took weeks to finalise (leave-one-out cross-validation on 24 patients with enormous volumes of data), there was a significant delay each time the process was unexpectedly finalised. 7 3. State of the art seizure detection using machine learning The study and creation of tools oriented to the automatization of seizure detection is extremely extensive and started decades ago, as it is one of the most priorised topics in modern medicine research. All kinds of methods have been proposed and, in recent years, the massive improvement seen in machine learning has also been translated into seizure detection. In their work presented in 1995, Kalayci et al. [30] fed wavelet transforms to a neural network, which captured some specific characteristics of EEG, such as spikes due to its frequential segmentation. Some other methods used historically include Bayesian classification, Linear Discriminant Analysis, K-Nearest Neighbours, and Support Vector Machines, a combination of the latter two being the chosen models by Garret et al. [31] in 2003 for real-time analysis. In recent years, those methods have been surpassed in performance as standalone models by others such as LSTM and CNNs, even though some are still used in conjunction with newer ones. To benchmark the performances of different models, there are many factors to take into account for it to be a fair comparison. Depending on the main goal of a project, there might be some changes in the training process that could give a boost to the performance metrics on some setups. For instance, in some studies, inter-recordings are included in the training data partition, which means that there is the presence of testing data in training. Other factors could be including different recordings in training and testing of the same patient, or even using only a subset of all patients who share a common characteristic. Those practices increase the bias of the model as a tradeoff, which goes against the objective of this project, which is to create the most robust model possible. To evaluate such a model, a leave-one-out cross-validation has been used, which is a type of cross-validation where each observation (or a patient’s recordings in this case) is considered as the validation set and the rest (N-1) are the training set. This process is repeated N times; one for every patient. For a proper benchmarking only studies that followed the same evaluation structure and on the same dataset are considered. 3.1. Benchmarking metrics In this project, EEG recordings are annotated by experts in such a way that it is known at each instant if a seizure is happening or not. Thus, there are two possible states that would make its state prediction a binary classification: seizure and non-seizure. It is possible for a detection model to directly predict the state given an input, but its output could also be given as a probability that the event is occurring at a certain moment. In such cases, the predicted probability can be thresholded to obtain a binary prediction. There are multiple relevant metrics regarding binary classification, with their importance highly dependent on the context. For the case of seizure detection, the following metrics are going to be used, with them being computed from the different states described in the table below. 14 Predicted condition Total population P + N or PP + PN Positive (PP) Negative (PN) Actual condition Positive (P) True positive (TP) False negative (FN) Negative (N) False positive (FP) True negative (TN) Table 2. Confusion matrix. Sensitivity, also called true positive rate or recall, refers to the test’s ability to properly detect positive samples. In the context of seizure detection, the sensibility of the test is the proportion of positive samples correctly marked as seizures. Specificity, also called true negative rate or selectivity, refers to the test’s ability to correctly mark negative samples, or, in the current context, the proper assessment of non-seizure samples as non-seizure, or in other words, the proportion of correctly predicted non-seizure samples on all non-seizure samples. Accuracy is the metric used to obtain the fraction of correct predictions of a model over the total number of samples. It includes positive and negative predictions. When the output of the model is the probability of a certain state being true, Receiver Operator Characteristics (ROC) are of great help to evaluate its performance as they are a graphical representation used to show the diagnostic ability of binary classifiers. A ROC curve shows the tradeoff between the true positive rate and the false positive rate in a graphical way. Classifiers that give curves with the biggest area below indicate a better performance. As a reference, a random classifier is expected to resemble a line corresponding to a 45º diagonal of the ROC space. Since the curve does not depend on the class distribution, it’s highly useful in skewed data. To compare different classifiers, an important metric that summarises their performance is the area under the ROC curve, or AUC. It is the equivalent of the probability that a randomly selected positive sample is ranked higher than a randomly selected negative one. In contexts with high accuracies, it is possible to truncate the ROC curve at a certain 15 percentage to obtain a more significant metric. For instance, by truncating the curve at 90% and computing the area under it, the obtained metric is called AUC90. In the context of seizure detection models, some of the most commonly used metrics are sensitivity and specificity. To compare those metrics to the performance of a model whose output represents the probability of a certain binary state to be true, it is useful to compute its sensitivity-specificity curve, which shares some properties with ROC curves. Figure 7. ROC graph of a binary predictor with an AUC is 79%. The blue line represents the ROC of a random classifier, which will have an AUC of 50%. Other studies use metrics such as the seizure detection rate (SDR), which indicates the number of detected seizure events against the total number of seizure events. The signal from the start to finish of a seizure is considered an event. There is also the false alarm rate, (FAR) which denotes the number of false alarms reported in an hour. 3.2. Machine learning in seizure detection The most used machine learning approach to tackle seizure detection to date is supervised learning, which is the process of making an algorithm to learn to map an input to a particular output, or target, that will always be given in training. This is achieved by using labelled datasets. In recent years, different supervised learning methods have been developed for seizure detection such as support vector machines (SVM) [32], convolutional neural networks (CNN) [33], Takagi-Sugeno-Kang fuzzy system (TSK) [34], among many others with relative success. More recently, deep learning methods have been a predominant choice among researchers, mainly because of their robustness and capacity of detection even with raw data without requiring an explicit feature extraction external to the main detection algorithm, as it’s commonly the case in simpler machine learning models. 16 To train supervised learning based models large amounts of labelled data are required. When using smaller datasets overfitting would be a common occurrence, damaging the model’s generalizability. A useful approach to deal with this problem is to use an anomaly detection method based on unsupervised learning, which does not require labelled data. Tsiouris et al. [35] designed a system to detect an anomaly seizure epoch using a simple rule-based seizure detection method. You et al. [36] used GAN networks as an anomaly detection method. Even though unsupervised learning shows promising results in seizure detection, its performance is still relatively poor compared to supervised learning methods. To balance this tradeoff Guo et al. [37] proposed a hybrid method of supervised and unsupervised learning, utilising a small amount of labelled data for training and an unsupervised preliminary screening based on the amplitude-integrated EEG, isolation forest and silhouette coefficients. 3.2.1. Detection models on CHB-MIT dataset It’s important to discern which are the state of the art models for a proper benchmarking. Only seizure detection models that are tested in the same dataset, without inter-recordings, and using all patients will be considered. Author (Year) Method Acc (%) Sen (%) Spec (%) SDR (%) FAR (/h) Zabihi et al. (2019) [38] Nullcline analysis, LDA 95.11 91.15 95.16 - - Li et al. (2020) [39] Nested LSTM 95.29 95.43 95.29 94.07 0.66 Tang et al. (2020) [40] PCA, CSP, multivariate multiscale sample entropy and SVM 97.8 - - 97.2 0.64 Guo et al. (2022) [37] aEEG, isolation forest, time-frequency feature and EasyEnsemble 92.62 95.55 92.57 100 1.38 Table 3. State of the art models on CHB-MIT. Zabihi et al. [38] proposed a detection model based on nullcline analysis and LDA (linear discriminant analysis). In mathematical analysis, nullclines represent the focus of points in the solution space where the components of the velocity vectors are zero. The approach achieved 91.15% average sensitivity and 95.16% average specificity over the benchmark. Li et al. [39] proposed an end-to-end automated seizure detection based on the well-known deep learning architecture LSTM. A fully convolutional network is used first as a feature extractor followed by nested LSTM to explore the inherent temporal 17 dependencies in EEG signals. The model achieved a sensitivity of 94.07% on the benchmark. Tang et al. [40] proposed a seizure onset detection method based on the conjunction of multiple algorithms: principal component analysis and common spatial pattern (PCA-CSP), multivariate multiscale sample entropy (MMSE), tree based models, AE and SVM. This study achieved an SDR of 97.2%. Guo et al. [37] proposed a combination of supervised and unsupervised learning methods based on synthesised amplitude-integrated EEG extraction, forest-based anomaly detection, adaptive segmentation, silhouette coefficient-based anomaly detection evaluation and EasyEnsemble. In this work an average accuracy of 92.62%, sensitivity of 95.55% and a specificity of 92.57% was achieved. It is thought to be the first study to achieve state of the art results using unsupervised learning. 18 3.2.2. The proposed model UCC has an extensive experience in the use of fully convolutional neural networks in seizure detection, with many researchers centering their work on the matter in recent years. For instance, O’Shea et al. [41] proposed a CNN architecture designed and tested specifically for neonatal EEG, achieving positive results even with weak labels in the dataset. Daly et al. [4] introduced the concept of residual connections between convolutional blocks to the previous models and obtained an average AUC of 96.4% on a leave-one-out cross-validation on the Helsinki dataset of neonatal EEG. The architecture used in this project originates from the previous work of the aforementioned researchers. The system takes EEG segments from a 16-second window to serve as inputs for the following architecture. Figure 8. Proposed fully convolutional architecture [4]. This distribution of layers is similar to that of the VGG architecture, which was created by Simonyan et al. [42] in 2014, and was developed for image processing applications. One of the key differences between that model and the proposed one is that the latest uses 1-dimensional convolutional filters for an evaluation of channel-specific events. Figure 9. Graphical representation of the input and the first convolutional block. 19 As it is well known, convolutional neural networks are translational equivariant, or in other words, the output of a mapping doesn’t change when the input is translated. In the case in hand, this implies that a CNN should be able to detect a seizure given a positive sample independently of its position in time. For complex contexts such as seizure detection, the depth of the network is key, as the output should be able to capture the information of the whole sample. Thus, a fairly deep architecture and a relatively small filter size have been chosen, with three convolutional blocks with three convolutional layers each. Each of those layers is followed by a ReLU (rectified linear unit) as the activation function, its purpose being to ease the training and to help against a vanishing gradient. Figure 10. Block representation of a skip connected block. The main difference between the latest proposed model and the previous one is the presence of residual connections into the architecture. These residual connections, or skip connections, link the input and the output of a convolutional block to learn a residual mapping, which represents the difference between the desired mapping and the input stack [43]. Residual connections imply more efficient learning with only a marginal increase in the computational cost and no increase in the number of parameters that the architecture has. On top of that, it is of great help to deal with vanishing gradients. 20 Figure 11. Proposed fully convolutional architecture including residual connections. To create a more robust model with an improved performance on new data, a technique called data augmentation has been utilised. The chosen procedure for data augmentation was a dynamic amplitude rescaling during training. The EEG signal is transformed at random by one of four possible transformations, each with equal probability. The four transformations on the recordings are: a vertical flip, a change of amplitude by a random factor between 0.5 and 1.5, a combination of the previous two transformations, or no change at all. The chosen optimizer for the training procedure has been a Rectified Adam (or RAdam) for the proposed model, thought by Liu, Jian, He et al. [44]. It is a new variation of the classic Adam optimizer that provides an automated adjustment to the learning rate based on the variance and momentum during training, meaning that different learning rates often lead to the same result. 21 3.3. Deeper convolutional networks and transformers In 2020 researchers from Facebook AI Research (FAIR) and UC Berkeley published a paper [45] comparing the performance of Vision Transformers and improved deep fully convolutional networks (ConvNeXt). Vision Transformers (ViT) have easily surpassed ConvNets as the state of the art model in image classification, however there are some difficulties when the former are applied to tasks such as object detection and semantic segmentation. In that paper some changes are proposed to the latest ConvNets at the time to obtain a design that can surpass ViTs in some contexts. For instance, a top-1 accuracy of 87.8% was achieved on ImageNet classification, beating state of the art transformer-based models. At a macro level some changes seem to achieve better results when applied to a baseline ResNet model. First, changing the stage compute ratio, the number of blocks at each stage, to a fixed ratio. Then, an update to the stem cell configuration (convolutional kernel shape and step), to mimic transformer models by matching the stride and the kernel size to achieve patch-like steps. Bigger kernel sizes were also included, improving the accuracy but also the computational cost. At a smaller scale some other changes were included: GELU [46] was used instead of ReLU, the use of a single activation after each block, fewer normalisation layers, layer normalisation instead of batch normalisation, and a separate downsampling layer. Some of the proposed updates by FAIR and UC Berkeley were considered to create the fully convolutional network with residual connections used in this project, which achieved state-of-the-art results in neonatal datasets [4]. Some researchers are working on creating transformer-based models for seizure detection using EEG data such as Pedoeem et al. [47] as it’s fair to think that attention mechanisms could perform well in this context due to the nature of EEG signal, however at this point in time EEG transformers haven’t become the state of the art baseline architecture as has happened in other types of signal such as in NLP. 22 4. Project development This section contains the description of the work packages completed during the realisation of the project, starting with a proposal of different approaches for the use of a remote server to train the different models. The description of the training procedures is also described, including the hyperparameters and applied changes in the structure. 4.1. Establishing the framework With the acquisition of a new server for the laboratory, one of the first tasks was to establish a way for everyone to access its resources remotely. Because of its huge RAM, CPU, and GPU capabilities, it’s important for all researchers to have equal access to it for different kinds of individual tasks related to their work, so a procedure that could guarantee that was established. Python, and other programming languages oriented to data science, often require very different kinds of packages that vary with each project. Also, everyone has their own software preferences, so it’s not the best idea to install individualised frameworks on the server as it would take too much space unnecessarily. To solve this problem, Docker [9] was installed, which is an open platform that essentially separates the applications from the infrastructure by creating containers. Each container is a standardised unit that can be created on the fly or pulled from the Docker Hub to deploy a particular application or environment. It could be simply an OS (Ubuntu, Centos, etc.) to fulfil a software need from an operating system point of view, but it could also be an application-oriented container such as the Apache HTTP Server Project for a more specific usage. So, one of the possible workflows is to establish a connection via ssh [48] to the remote server and then run a container with all the necessary tools as described in the following figure. Figure 12. Diagram of the basic workflow from a local computer using CUDA enabled Docker containers. 23 don’t typically have the enormous volumes of data required to train robust enough models. In transfer learning, the already trained model’s knowledge is applied to a different but related context. For instance, in computer vision, often transfer learning is applied to the biggest models of general image classification to a smaller domain such as dog breeds, plant species, etc. Essentially, what a network has learned is exploited to improve generalisation in a different one. The idea is to use the learning from a model for a certain task with a lot of available labelled training data to a new task that doesn't have as much data available. With the case in hand, instead of starting the learning process from scratch on the CHB-MIT dataset, the learned patterns from more extensive neonatal datasets have been used. Fine-tuning is one of the most important transfer learning techniques and can be used in different approaches. Its basic workflow is as follows: 1. Take the layers and weights of a previous model into a new one. 2. There is the possibility of freezing part of the layers. In other words, some layer’s weights can be set to be immutable throughout the whole retraining process. The frozen layers are often the first ones as that part of a neural network usually acts as a feature extractor. 3. Unfreeze some of the layers. Those will be the ones whose weights will be updated and will learn to turn the old features into predictions on a new dataset. 4. Train the model on the new dataset. The CHB-MIT dataset, which consists of paediatric EEG recordings, can’t be considered a subset of the data used in the inherited model. Thus, there is the possibility that some artefacts are present in the dataset that can’t be found in the previous one, that being because of the age of the patients, among other possible causes. For this very reason, it has been decided that the first layers of the new model wouldn’t be frozen in the fine-tuning process, because those layers act as a feature extractor of the input data, and some unlearned artefacts might be present that could be missed otherwise. In transfer learning, there is the concept of fine-tuning, which consists of unfreezing the entire model you obtained above (or part of it), and re-training it on the new data with a very low learning rate. This can potentially achieve meaningful improvements by incrementally adapting the pretrained features to the new data. The starting weights were obtained from a training process of the same base model from a previous study [4] on a dataset which consisted of EEG recordings taken at the Neonatal Intensive Care Unit of Cork University Hospital from 72 neonates. For optimal performance, a balance had to be found between a smaller learning rate and a smaller number of epochs to not override the knowledge from the previous model but also to obtain a satisfactory detection accuracy on the new domain. Using LOOCV on the CHB-MIT dataset, an average AUC of 91.62% has been obtained from all available patients, which results in an improvement of 1% regarding the full retraining experiment. The AUC90 obtained using this method was 83.53%. 30 5. Results This section contains a summary of the outcome from all the work packages described previously; starting with the establishment of the framework, the creation of a dummy convolutional neural network for testing purposes, and finally an analysis of the performance of the ResNet without any retraining, with a full retraining, and with a fine-tuning of the weights obtained for training it in neonatal data. Finally, a comparison will be made between the obtained results and the current state-of-the-art models. The establishment of a sustainable workflow for multiple researchers to have access to the remote server has been successful. The processes conducted to train the multiple LOOCV models took between one day and two for each fold. Since for each experiment there were 24 folds to train, one for each leave-one-out patient, the remote server was running training processes for well over two months in total. The design and training of one of the simplest fully convolutional models possible that provided a positive detection rate was achieved. The proposed architecture and weights were used for a fellow researcher’s work with the objective of assessing its performance on an embedded system. A state-of-the-art seizure detection model for neonates was received with the objective of studying its behaviour on paediatric data, and to assess if training it on this new domain can also achieve state-of-the-art accuracy. This fully-convolutional model had been documented to achieve an average AUC of 96.4% on the Helsinki dataset of neonatal EEG. However, after testing its original weights on the CHB-MIT paediatrics dataset an AUC of 68.30% was obtained. The possible causes of such a decrease in the performance are a low sensitivity as a consequence of differences between neonate and paediatric seizures, making some of the latest to go undetected, and also to a high number of false positives caused by the presence of artefacts unseen by the network while being trained in neonatal data which are now marked as positive. Two LOOCV trainings were conducted. The first one was a full retrain with the initial weights set at random. This method obtained an average AUC of 90.787% and an AUC90 of 82.038%. With the fine-tuning, the average AUC and AUC90 were 91.623% and 83.527%, respectively. Figure 16. Sensitivity-Specificity curves for each fine-tuned fold. 31 The blue lines from the previous figure represent the sensitivity and specificity curve of a single patient using the fine-tuned model. As it can be seen, there are some outliers that worsen the average performance. Fully retrained model Fine-tuned model Gender Age AUC (%) AUC90 (%) AUC (%) AUC90 (%) chb01 F 11 99.251 96.283 99.103 95.401 chb02 M 11 99.960 99.789 99.938 99.676 chb03 F 14 99.329 96.469 99.054 95.023 chb04 M 22 98.018 89.926 98.231 90.689 chb05 F 7 85.153 87.018 83.105 89.806 chb06 F 1.5 95.784 87.639 96.486 85.726 chb07 F 14.5 97.494 86.812 97.258 85.566 chb08 M 3.5 98.458 91.886 99.245 96.028 chb09 F 10 79.437 64.225 85.295 73.308 chb10 M 3 64.181 55.680 81.055 66.507 chb11 F 12 98.803 93.698 98.550 92.370 chb13 F 3 90.492 66.799 94.131 74.406 chb14 F 9 71.260 61.936 63.524 60.069 chb15 M 16 93.775 86.730 93.505 83.894 chb16 F 7 86.090 61.210 81.696 63.514 chb17 F 12 99.207 95.825 99.394 96.812 chb18 F 18 99.472 97.220 99.113 95.403 chb19 F 19 99.957 99.774 99.649 98.153 chb20 F 6 76.496 59.541 75.871 53.577 chb21 F 13 73.243 55.968 77.624 59.514 chb22 F 9 99.980 99.896 99.976 99.871 chb23 F 6 99.416 96.941 99.596 97.874 chb24 F 6 82.839 55.619 85.934 67.943 Average 90.787 82.038 91.623 83.527 Table 5. AUC and AUC90 obtained for each patient using leave-one-out cross validation for both a full retraining of the network and fine-tuning a neonatal-based model. The improvement in the performance of the fine-tuned model over the fully retrained one is approximately 1%. At the same time it can be observed that the inclusion of the knowledge of a previous network does contribute to better results, especially in certain patients such as chb10. To compare the obtained results with state of the art models, the scores of the best performing ones on CHB-MIT with equal validation processes are shown on top of the zoomed sensitivity and specificity curves. A higher placement on both axis in the following figure indicates a better performance. 32 Figure 17. Zoomed Sensitivity-Specificity curves for each fine-tuned fold with its average curve and variance compared to the state of the art models. As it can be seen from the previous figure, although the average performance of the fine-tuned ResNet on the CHB-MIT dataset is inferior to that of the current state of the art models, it can achieve state of the art performances for a significant number of patients. 33 6. Conclusions and future development This project contained different work packages and each had their own outcome and a possible line of future improvements. Starting with the establishment of the framework, it was set up successfully, although in the future it would be helpful to build a standardised Docker container with all the Python and CUDA libraries needed to train deep learning models using GPUs. To use said pre-built container a researcher would just need to pull it from Docker Hub, or an equivalent platform, without having to spend time creating their own working environment. From testing the ResNet on the CHB-MIT dataset with its original weights obtained after training it on neonatal data it has been found that it performs with much lower accuracies than that of its original domain. So, to obtain a model that performs well on paediatrics recordings, data from patients from the same age range should be used for a full retraining or fine-tuning. It has been demonstrated that a fine-tuning of the ResNet design, although its average performance on CHB-MIT is lower than that of the best scoring models, it can achieve state of the art performance as seen from the variance of the obtained sensitivity and specificity curves. By including some improvements in the training process even better results could be obtained. Feature extraction is a critical issue since it has been found that the neonatal-trained ResNet miss-detects numerous artefacts on CHB-MIT. A future line of work that could carry better results on seizure detection would be to create EEG robustness algorithms. By definition the first layers of a ConvNet act as a feature extraction mechanism, but artefacts unseen in training could lead to detection issues, so a previous filter could be of great benefit. The CHB-MIT dataset is one of the most widely used datasets for seizure detection problems, but it carries the burden of being annotated with weak labels, meaning that its annotations don't show at which specific channels a seizure is occurring at a certain time. Compared to datasets with channel-specific annotations, there is an information loss that could present a drop in training efficiency. The CHB-MIT dataset contains a relatively small number of patients and seizures compared to other EEG datasets (i.e. the neonatal dataset obtained from the Neonatal Intensive Care Unit of Cork University Hospital consists of recordings from 72 different neonates including 1,389 seizure events). So, the inclusion of more data from different sources could carry an improvement in the overall performance of the model. In a situation of having access to an arguably small volume of annotated data, semi-supervised and unsupervised learning could be of great help. Training a model in such a way could reduce the dependency on expert annotations and lead to the creation of much more easily accessible robust detection mechanisms. 34 Bibliography [1] “Epilepsy”. World Health Organization, 2022. [Online] Available: https://www.who.int/news-room/fact-sheets/detail/epilepsy [Accessed: 23 May 2022]. [2] “Raspberry Pi 3 Model B+”. Raspberry Pi, 2022. [Online] Available: https://www.raspberrypi.com/products/raspberry-pi-3-model-b-plus/ [Accessed: 1 June 2022]. [3] S. Gomez-Quintana, A. O’Shea, A. Factor, E. Popovici, A. Temko. "A method for AI assisted human interpretation of neonatal EEG". Sci Rep 12, 10932 (2022). https://doi.org/10.1038/s41598-022-14894-4 [4] Daly A, O'Shea A, Lightbody G, Temko A. “Towards Deeper Neural Networks for Neonatal Seizure Detection”. Annu Int Conf IEEE Eng Med Biol Soc. 2021 Nov;2021:920-923. doi: 10.1109/EMBC46164.2021.9629485. PMID: 34891440. [5] TensorFlow Developers. (2022). TensorFlow (v2.8.2). Zenodo. https://doi.org/10.5281/zenodo.6574269 [6] Gulli, A. & Pal, S., 2017. “Deep learning with Keras”, Packt Publishing Ltd. [7] Paszke, A. et al., 2019. “PyTorch: An Imperative Style, High-Performance Deep Learning Library”. In Advances in Neural Information Processing Systems 32. Curran Associates, Inc., pp. 8024–8035. Available at: http://papers.neurips.cc/paper/9015-pytorch-an-imperative-style-high-performance- deep-learning-library.pdf. [8] NVIDIA, Vingelmann, P. & Fitzek, F.H.P., 2020. “CUDA”, release: 10.2.89, Available at: https://developer.nvidia.com/cuda-toolkit. [9] Merkel, D., 2014. “Docker: lightweight linux containers for consistent development and deployment”. Linux journal, 2014(239), p.2. [10] Litt, B. and Echauz, J., 2002. “Prediction of epileptic seizures”. The Lancet Neurology, 1(1), pp.22-30. [11] Murray, D. M. et al. “Defining the gap between electrographic seizure burden, clinical expression and staff recognition of neonatal seizures”. Archives of Disease in Childhood-Fetal and Neonatal Edition 93, F187–F191 (2008) Boylan, G. B., Stevenson, N. J. & Vanhatalo, S. Monitoring neonatal seizures. Seminars in Fetal and Neonatal Medicine 18, 202–208 (2013)] [12] Subha, D.P., Joseph, P.K., Acharya, R. and Lim, C.M., 2010. “EEG signal analysis: a survey”. Journal of medical systems, 34(2), pp.195-212. [13] Boylan, G. B., Burgoyne, L., Moore, C., O’Flaherty, B. & Rennie, J. M. “An international survey of EEG use in the neonatal intensive care unit”. Acta Paediatrica, International Journal of Paediatrics 99, 1150–1155 (2010) 35 [14] Stevenson, N. J. et al. “Interobserver agreement for neonatal seizure detection using multichannel EEG”. Annals of Clinical and Translational Neurology 2, 1002–1011 (2015) [15] “Normal EEG in children”. ICNApedia, 2022. [Online] Available: https://icnapedia.org/wiki/content/normal_eeg_in_children [Accessed: 3 May 2022]. [16] Agarwal, M. and Fox, S.M., 2013. “Pediatric seizures”. Emergency Medicine Clinics, 31(3), pp.733-754. [17] Saxena, A., Jones, L., Shankar, R., McLean, B., Newman, C.G. and Hamandi, K., 2018. “Sudden unexpected death in epilepsy in children: a focused review of incidence and risk factors”. Journal of Neurology, Neurosurgery & Psychiatry, 89(10), pp.1064-1070. [18] Brigo, F., Trinka, E., Lattanzi, S., Bragazzi, N.L., Nardone, R. and Martini, M.,2018. “A brief history of typical absence seizures—Petit mal revisited”. Epilepsy & Behavior, 80, pp.346-353. [19] Wong-Kisiel, Lily & Nickels, Katherine. (2013). “Electroencephalogram of Age-Dependent Epileptic Encephalopathies in Infancy and Early Childhood”. Epilepsy research and treatment. 2013. 743203. 10.1155/2013/743203. [20] Olejniczak, P., 2006. “Neurophysiologic basis of EEG”. Journal of clinicalnneurophysiology, 23(3), pp.186-189. [21] Gommer, Erik. (2014). Re: What is the frequency range of epilepsy seizures? Retrieved from: https://www.researchgate.net/post/What_is_the_frequency_range_of_epilepsy_seiz ures/533e9d09cf57d7a82b8b462d/citation/download. [22] “Normal EEG in children”. ICNApedia, June, 2022 [Online] Available: https://icnapedia.org/wiki/content/normal_eeg_in_children?rev=1582478894. [23] Mesbah, M., O’ Toole, J.M., Colditz, P.B. et al. “Instantaneous frequency based newborn EEG seizure characterisation”. EURASIP J. Adv. Signal Process. 2012, 143 (2012). https://doi.org/10.1186/1687-6180-2012-143 [24] Britton JW, Frey LC, Hopp JLet al. “Electroencephalography (EEG): An Introductory Text and Atlas of Normal and Abnormal Findings in Adults, Children, and Infants” St. Louis EK, Frey LC, editors.Chicago: American Epilepsy Society; 2016. [25] Brigo, F., Trinka, E., Lattanzi, S., Bragazzi, N.L., Nardone, R. and Martini, M., 2018. “A brief history of typical absence seizures—Petit mal revisited. Epilepsy & Behavior, 80, pp.346-353. [26] Laennec, R. & Forbes, J. A “Treatise on the Diseases of the Chest, and on Mediate Auscultation” (1838) [27] Parvizi J, Gururangan K, Razavi B, Chafe C. “Detecting silent seizures by their sound”. Epilepsia. 2018 Apr;59(4):877-884. DOI: 10.1111/epi.14043. PMID: 29558565. [28] Purves, D., et al. (2001) “Neuroscience”. 2nd Edition, Sinauer Associates, Sunderland, MA. 36 [29] Temko, A., Marnane, W., Boylan, G., O’Toole, J. M. & Lightbody, G. “Neonatal EEG audifcation for seizure detection” 2014 36th Annual International Conference of the IEEE Engineering in Medicine and Biology Society, EMBC 2014 4451–4454 (2014). [30] Kalayci, T. and Ozdamar, O. (1995) “Wavelet preprocessing for automated neural network detection of EEG spikes”. IEEE Engineering in Medicine and Biology Magazine, 14, 160-166. [31] Garrett D, Peterson D, Anderson C, Thaut M. “Comparison of linear and nonlinear methods for EEG signal classification”. IEEE Transactions on Neural Systems and Rehabilitative Engineering 2003;11(2):141–4. [32] A. Zarei and B. M. Asl, “Automatic seizure detection using orthogonal matching pursuit, discrete wavelet transform, and entropy based features of EEG signals,” Comput. Biol. Med., vol. 131, Apr. 2021, Art. no. 104250 [33] X. Tian et al., “Deep multi-view feature learning for EEG-based epileptic seizure detection,” IEEE Trans. Neural Syst. Rehabil. Eng., vol. 27, no. 10, pp. 1962–1972, Oct. 2019. [34] Y. Jiang et al., “Recognition of epileptic EEG signals using a novel multiview TSK fuzzy system,” IEEE Trans. Fuzzy Syst., vol. 25, no. 1, pp. 3–20, Feb. 2017. [35] K. M. Tsiouris, S. Markoula, S. Konitsiotis, D. D. Koutsouris, and D. I. Fotiadis, “A robust unsupervised epileptic seizure detection methodology to accelerate large EEG database evaluation,” Biomed. Signal Process. Control, vol. 40, pp. 275–285, Feb. 2018. [36] S. You et al., “Unsupervised automatic seizure detection for focal-onset seizures recorded with behind-the-ear EEG using an anomaly-detecting generative adversarial network,” Comput. Methods Programs Biomed., vol. 193, Sep. 2020, Art. no. 105472. [37] Guo, Y., Jiang, X., Tao, L., Meng, L., Dai, C., Long, X., Wan, F., Zhang, Y., Dijk, J. V., Aarts, R. M., Chen, W., & Chen, C. (2022). “Epileptic seizure detection by ascading isolation forest-based anomaly screening and EasyEnsemble”. IEEE Transactions on Neural Systems and Rehabilitation Engineering, 30(99), 915-924. https://doi.org/10.1109/TNSRE.2022.3163503 [38] M. Zabihi, S. Kiranyaz, V. Jäntti, T. Lipping, and M. Gabbouj, “Patientspecific seizure detection using nonlinear dynamics and nullclines,” IEEE J. Biomed. Health Informat., vol. 24, no. 2, pp. 543–555, Feb. 2020 [39] Y. Li et al., “Automatic seizure detection using fully convolutional nested LSTM,” Int. J. Neural Syst., vol. 30, no. 4, Apr. 2020, Art. no. 2050019. [40] F.-G. Tang, Y. Liu, Y. Li, and Z.-W. Peng, “A unified multi-level spectral–temporal feature learning framework for patient-specific seizure onset detection in EEG signals,” Knowl.-Based Syst., vol. 205, Oct. 2020, Art. no. 106152. [41] O’Shea, A., Lightbody, G., Boylan, G. and Temko, A., 2020. “Neonatal seizure detection from raw multi-channel EEG using a fully convolutional architecture”. Neural Networks, Volume 123, 2020, Pages 12-25, ISSN 0893-6080, https://doi.org/10.1016/j.neunet.2019.11.023. 37 [42] K. Simonyan and A. Zisserman, “Very Deep Convolutional Networks for Large-Scale Image Recognition,” ArXiv14091556 Cs, Apr. 2015, Accessed: Mar. 30, 2021. [Online]. Available: http://arxiv.org/abs/1409.1556. [43] K. He, X. Zhang, S. Ren, and J. Sun, “Deep Residual Learning for Image Recognition,” ArXiv151203385 Cs, Dec. 2015, Accessed: Feb. 05, 2020. [Online]. Available: http://arxiv.org/abs/1512.03385. [44] L. Liu et al., “On the Variance of the Adaptive Learning Rate and Beyond,” ArXiv190803265 Cs Stat, Apr. 2020, Accessed: Mar. 30, 2021. [Online]. Available: http://arxiv.org/abs/1908.03265. [45] Liu, Zhuang and Mao, Hanzi and Wu, Chao-Yuan and Feichtenhofer, Christoph and Darrell, Trevor and Xie, Saining, “A ConvNet for the 2020s”, 2022, [Online]. Available: https://arxiv.org/abs/2201.03545 [46] Dan Hendrycks and Kevin Gimpel. “Gaussian error linear units (gelus)”. arXiv:1606.08415, 2016. [47] Pedoeem, J., Bar Yosef, G., Abittan, S., Keene, S. (2022). “TABS: Transformer Based Seizure Detection”. In: Obeid, I., Picone, J., Selesnick, I. (eds) Biomedical Sensing and Analysis. Springer, Cham. [48] Tatu Ylonen: “SSH - Secure Login Connections over the Internet”. Proceedings of the 6th USENIX Security Symposium, pp. 37-42, USENIX, 1996. [49] Goldberger, A., Amaral, L., Glass, L., Hausdorff, J., Ivanov, P. C., Mark, R., ... & Stanley, H. E. (2000). PhysioBank, PhysioToolkit, and PhysioNet: Components of a new research resource for complex physiologic signals. Circulation [Online]. 101 (23), pp. E215–e220. [50] Ali Shoeb. “Application of Machine Learning to Epileptic Seizure Onset Detection and Treatment”. PhD Thesis, Massachusetts Institute of Technology, September 2009. [51] Karen, Simonyan., Andrew, Zisserman. (2015). “Very Deep Convolutional Networks for Large-Scale Image Recognition”.Available at: https://arxiv.org/pdf/1409.1556.pdf [52] N. J. Stevenson, K. Tapani, L. Lauronen, and S. Vanhatalo, “A dataset of neonatal EEG recordings with seizure annotations,” Sci. Data, vol.6, no. 1, Art. no. 1, Mar. 2019, doi: 10.1038/sdata.2019.39. [53] “AWS Snowball”. Amazon, 2022. [Online] Available: https://aws.amazon.com/es/snowball/ [Accessed: 2 June 2022]. [54] “AWS Pricing Calculator”. Amazon, 2022. [Online] Available: https://calculator.aws/ [Accessed: 2 June 2022]. 38 Glossary AE Autoencoder AI Artificial Intelligence API Application Programming Interface AUC Area Under the Curve AWS Amazon Web Services CHB-MIT Children's Hospital Boston-Massachusetts Institute of Technology CNN Convolutional Neural Network CPU Central Processing Unit CSP Common Spatial Pattern CUDA Compute Unified Device Architecture DSP Digital Signal Processing ECG Electrocardiogram EEG Electroencephalogram FAIR Facebook AI Research FAR False Alarm Rate GAN Generative Adversarial Networks GELU Gaussian Error Linear Units GPU Graphics Processing Unit HPF High-Pass Filter LDA Linear Discriminant Analysis LOOCV Leave-One-Out Cross-Validation LPF Low-Pass Filter LSTM Long Short-Term Memory ML Machine Learning MMSE Multivariate Multiscale Sample Entropy 39