
Bachelor Thesis Project Electrocardiographic deviation detection - Using long short-term memory recurrent neural networks to detect deviations within electrocardiographic records Author: Michael Racette Olsén Supervisor: Anders Haggren Semester: VT2017 Subject: Computer Engineering Abstract Artificial neural networks have been gaining attention in recent years due to their impressive ability to map out complex nonlinear relations within data. In this report, an attempt is made to use a Long short-term memory neural network for detecting anomalies within electrocardiographic records. The hypothesis is that if a neural network is trained on records of normal ECGs to predict future ECG sequences, it is expected to have trouble predicting abnormalities not previously seen in the training data. Three different LSTM model configurations were trained using records from the MIT-BIH Arrhythmia database. Afterwards the models were evaluated for their ability to predict previously unseen normal and anomalous sections. This was done by measuring the mean squared error of each prediction and the uncertainty of over- lapping predictions. The preliminary results of this study demonstrate that recurrent neural networks with the use of LSTM units are capable of detecting anomalies. Keywords: ECG, LSTM, RNN, Neural Network, Deeplearning4j, Time Series i Preface I would like to thank HIQ and KIWOK for providing me the opportunity to do research in a field I find very interesting. ii Contents 1 Introduction1 1.1 Background.................................1 1.2 Hypothesis.................................2 1.3 Problem formulation............................2 1.4 Objectives..................................2 1.5 Scope/Limitations..............................2 1.6 Target group.................................2 1.7 Outline...................................3 2 Theory4 2.1 Electrocardiography (ECG).........................4 2.2 Supervised learning with features and labels................4 2.3 Artificial Neural Network..........................5 2.3.1 Artificial neuron..........................5 2.3.2 Hidden Layers...........................6 2.3.3 Gradient descent..........................7 2.3.4 Recurrent neural network (RNN)..................8 2.3.5 Long short-term memory (LSTM).................8 2.4 Preparing the data..............................9 2.5 Training the network............................9 2.5.1 Hyper-parameter optimization...................9 2.5.2 Generalization and overfitting................... 10 3 Method 11 3.1 Collecting data for training......................... 11 3.2 Evaluation.................................. 12 3.3 Reliability and Validity........................... 12 4 Implementation 13 4.1 Preparing the data.............................. 13 4.2 Structuring the neural network....................... 16 4.3 Preventing overfitting by using early stopping............... 17 4.4 Evaluation.................................. 17 5 Results 18 5.1 Sequence to One.............................. 20 5.2 Sequence to Vector............................. 21 5.3 Sequence to Sequence............................ 22 6 Analysis 23 7 Discussion 24 8 Conclusion 24 References 25 1 Introduction The eHealth company Kiwok AB has developed a system called BodyKom for remotely monitoring a person’s electrocardiography. The recordings are measured with a soft elec- trode shirt and sent via a cellphone to a server where the recordings can be downloaded by a caregiver for analysis. Kiwok AB has asked HIQ to develop an automatic system for real-time analysis of ECGs. The goal is to be able to report deviations directly to a healthcare provider, working preventively to avoid future cardiac complications. Kiwok has stated that they are particularly interested in finding a solution that involves machine learning. 1.1 Background Studies show that better screening methods are becoming increasingly important as the older population continuous to grow. In a mass screening performed on individuals in the age 75 to 76 it was revealed that a significant proportion of the participants had untreated atrial fibrillation [1]. T. Lindberg et al. later confirmed these findings with the use of BodyKom. In their conclusion they state: ...many older outpatients have undiagnosed and thus untreated persistent and paroxysmal AF. This is a challenge for health care providers, and it is essen- tial to develop more effective strategies for the detection, treatment, and pre- vention of arrhythmias. This study confirms that the long-term wireless ECG recorder BodyKom has good feasibility for arrhythmia screening in older out- patient populations. [2, p. 1089]. Visually analyzing an ECG is a very time consuming job. An ECG record of 72 hours contains approximately 300 thousand heartbeats. Being able to detect anomalies and identify people within risk zones from a distance with the use of machine learning would make ECG monitoring available to far more people. The goal of the requested system is twofold; general deviation detection and individually adapted deviation detection. The second system is meant to recognize what is normal for a particular individual and detect changes as the individual ages. Long short-term memory neural networks have proven to be exceptionally good at learning long term temporal dependencies within time-series data. In 2015 Malhotra et al. demonstrated how LSTM neural networks can be used to detect anomalies: A network is trained on non-anomalous data and used as a predictor over a number of time steps. The resulting prediction errors are modeled as a multi- variate Gaussian distribution, which is used to assess the likelihood of anoma- lous behavior. The efficacy of this approach is demonstrated on four datasets: ECG, space shuttle, power demand, and multi-sensor engine dataset. [3]. 1 In this report a similar approach is evaluated using three different structures of LSTM neural networks which are trained to predict future sequences of ECG data from the MIT- BIH Arrythmia database. Their prediction accuracy and ability to detect anomalies are compared to each other. Additionally two different metrics for anomaly detection are compared; prediction difficulty through squared error and prediction uncertainty through variance in overlapping predictions. 1.2 Hypothesis When training a neural network model to accurately predict sequential data a few steps a- head of time, it should encounter great difficulties in predicting anomalies not previously seen in the training data. The anomalies can then be identified by either computing an error vector or measuring the uncertainty in overlapping predictions. 1.3 Problem formulation In order for the network to identify anomalous sections of data, it first needs to be able to accurately predict future sequences of non-anomalous ECG data. The three different network compositions need to be reliably evaluated against each other to answer the fol- lowing questions: Which architecture has the most accurate predictions? • Are the trained models, capable of detecting anomalies? • Which architecture has the best performance in terms of analysis speed? • 1.4 Objectives O1 Implement the different architectures using deeplearning4j. O2 Compare the different architectures to each other. O3 Evaluate the effectiveness of the methods. 1.5 Scope/Limitations This report will include a brief explanation of how Recurrent Neural Networks and Long Short-term memory neural networks work and the difference between them. How LSTMs can be implemented on electrocardiographic data and its effectiveness in detecting devia- tions will also be discussed. 1.6 Target group This report is directed mainly for HIQ and KIWOK as an evaluation of a proposed devel- opment path for their live monitoring system. 2 1.7 Outline The report begins with chapter 2 where the theory is outlined. Chapter 3 (Method) describes how the system will be evaluated, the reliability and validity of the results. Chapter 4 (Implementation) describes how the systems were designed and imple- mented. It contains a brief description of the library used, the methods for finding optimal structures and the methods that were used for evaluating the structures. In chapter 5 the results are presented for each of the different models. Chapters 6, 7 and 8, contains the analysis, discussion and conclusion. 3 2 Theory 2.1 Electrocardiography (ECG) Electrocardiography is the process of measuring and recording the electrical activity of the heart over time by attaching small electrodes to the surface of the skin. The elec- trodes measure the small electrical changes in the skin caused by the depolarization and repolarization of the different compartments within the heart muscle. These events form a series of waves, starting with the P-Wave representing the depolarization of the atria, followed by the QRS-complex representing the depolarization of the ventricles and finally the T-wave representing the ventricles being repolarized [4]. Figure 2.1: ECG of a single heartbeat in normal sinus rhythm 2.2 Supervised learning with features and labels Supervised learning is useful when a system’s inputs and outputs are known in advance and can be measured. The measured characteristics of the input data are called "features", and the measurements of the known output data are called "labels". Features and labels are prepared in pairs. By using algorithms for supervised learning the neural network is able to map the relation between features and labels. 4 2.3 Artificial Neural Network Artificial neural networks consist of
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages31 Page
-
File Size-