model-based ecg analysis: towards patient...

62
IT 20 020 Examensarbete 30 hp Mars 2020 MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT-SPECIFIC WEARABLE ECG MONITORING Adnan Albaba Institutionen för informationsteknologi Department of Information Technology

Upload: others

Post on 13-Mar-2021

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

IT 20 020

Examensarbete 30 hpMars 2020

MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT-SPECIFIC WEARABLE ECG MONITORING

Adnan Albaba

Institutionen för informationsteknologiDepartment of Information Technology

Page 2: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a
Page 3: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Teknisk- naturvetenskaplig fakultet UTH-enheten

Besöksadress: Ångströmlaboratoriet Lägerhyddsvägen 1 Hus 4, Plan 0

Postadress: Box 536 751 21 Uppsala

Telefon: 018 – 471 30 03

Telefax: 018 – 471 30 00

Hemsida: http://www.teknat.uu.se/student

Abstract

MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT-SPECIFIC WEARABLE ECG MONITORING Adnan Albaba

In this thesis, model-based analysis approach is considered as a possible solution towards a patient-specific point-of-care device for the purpose of electrocardiogram monitoring. Two novel methods are proposed, tested, and quantitatively evaluated. First, a method for estimating the instantaneous heart rate using the morphological features of one electrocardiogram beat at a time is proposed. This work is not aimed at introducing an alternative way for heart rate estimation, but rather illustrates the utility of model-based electrocardiogram analysis in online individualized monitoring of the heart function. The heart rate estimation problem is reduced to fitting one parameter, whose value is related to the nine parameters of a realistic nonlinear model of the electrocardiogram and estimated from data by nonlinear least-squares optimization. The method feasibility is evaluated on synthetic electrocardiogram signals as well as signals acquired from MIT-BIH databases at Physionet website. Moreover, the performance of the method was tested under realistic free-moving conditions using a wearable electrocardiogram and heart monitor with encouraging results. Second, a model-based method for patient-specific detection of deformed electrocardiogram beats is proposed. Five parameters of a patient-specific nonlinear electrocardiogram model are estimated from data by nonlinear least-squares optimization. The normal variability of the model parameters is captured by estimated probability density functions. A binary classifier, based on stochastic anomaly detection methods, along with a pre-tuned classification threshold, is employed for detecting the abnormal electrocardiogram beats. The utility of the proposed approach is tested by validating it on annotated arrhythmia data recorded under clinical conditions.

Handledare: Alexander Medvedev Ämnesgranskare: Hans Rosth Examinator: Phillipp Rummer IT 20 020 Tryckt av: Reprocentralen ITC

Page 4: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a
Page 5: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

I

Acknowledgements

First and foremost, I must thank God for all the blessings in my life.I am extremely grateful to my dear parents for always believing in my dreams andconstantly supporting my ideas in every way possible.I thank Prof. Alexander Medvedev, for accepting to supervise my thesis, for his guidinginputs and vital ideas, and, most of all, for teaching me how to do academic research.I thank Dr. Hans Rosth for his constructive feedback while reviewing my thesis.I thank the academic staff at the department of Information Technology, the departmentof Physics and Astronomy, and the department of Engineering Sciences at UppsalaUniversity, for facilitating my journey during the last two years. Special thanks toLiselott Dominicus, simply for being the most helpful person at our department. Also,thanks to my colleagues at the Embedded Systems master program, and to my SensUs2018 teammates and mentors.In Sweden; Rami, without you, this dream would have never become true. Thank youfor everything. Ammar, thanks for cracking the enigma of the Swedish bureaucracy!Nour, thanks for being a good subject for my experiments, yet a terrible TRIX partner.Ahmad, thanks for being a good TRIX partner. Deyaa and Sofiene, thanks for being suchnice guys. Isabel, thanks for your friendliness and smiles.In Kuwait; Hamza, your support will never be forgotten. Yassino, Sammano, andAlmonther, thank you brothers for listening to my endless stories. Hafez, thanks forthe IELTS. Naif, Bitar, Shurbaji, Morsy, Tahina, Okasha, Alhalaki, Saif, Arafat and Katot,thanks for allways being there for me. Bilal, thanks for being such a FIFA loser bro.In Syria; My family, thanks for always believing in me and praying for me.In Jordan; My Professors and colleagues at JUST, my flatmates, and my dear friends,thanks for the great 5 years. Majd, thanks for keeping in touch. Shimaa, thanks for theunforgettable memories.In Palestine; Farrah, thanks for the long night technology talks and jokes.In UAE; Bisher, thanks for keeping me an overseas company.In Germany; Alhalabi’s, thank you guys for the Physiology talks.In USA; Thaer, a conversation with you is like traveling to my near future, thank you.In Canada; Mouayad, thanks for the political and spiritual talks.For those who I forgot to mention, last-minute submission guys! Hopefully, you will beacknowledged in my PhD dissertation.

© Uppsala University Adnan Albaba

Page 6: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a
Page 7: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Table of Contents II

Table of Contents

Acknowledgements I

List of Tables IV

List of Figures V

List of Acronyms VIII

1 Introduction 11.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Problem Formulation and My Contributions . . . . . . . . . . . . . . . . 21.3 Related Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.4 Structure of The Thesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 Background 52.1 Electrocardiography (ECG) . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2 Heart Rate (HR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.3 Pathophysiology and ECG Patterns . . . . . . . . . . . . . . . . . . . . . . 72.4 Wearable ECG Technology . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

3 Modeling of Electrocardiography 113.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.2 Models for ECG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

3.2.1 ECGSYN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.3 Model-Based ECG Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . 15

4 Online Model-Based Beat-by-beat Heart Rate Estimation 164.1 Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

4.2.1 Preprocessing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174.2.2 Initial Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184.2.3 Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184.2.4 Ground Truth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

4.3 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.3.1 ECGSYN Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214.3.2 MIT-BIH Database . . . . . . . . . . . . . . . . . . . . . . . . . . . 214.3.3 MAX-ECG-MONITOR . . . . . . . . . . . . . . . . . . . . . . . . . 23

© Uppsala University Adnan Albaba

Page 8: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Table of Contents III

4.3.4 Quantitative Evaluation . . . . . . . . . . . . . . . . . . . . . . . . 234.4 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

4.4.1 ECGSYN Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244.4.2 MIT-BIH Database . . . . . . . . . . . . . . . . . . . . . . . . . . . 254.4.3 MAX-ECG-MONITOR . . . . . . . . . . . . . . . . . . . . . . . . . 274.4.4 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

5 Patient-Specific ECG Monitoring by Model-Based Stochastic Anomaly De-tection 305.1 Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

5.2.1 Preprocessing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315.2.2 Period Normalization . . . . . . . . . . . . . . . . . . . . . . . . . 325.2.3 Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335.2.4 Initial Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345.2.5 Stochastic Anomaly Detection . . . . . . . . . . . . . . . . . . . . 345.2.6 Decision Making . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355.2.7 Feature Selection and Classification-Threshold Tuning . . . . . . 375.2.8 Ground Truth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

5.3 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385.3.1 Quantitative Evaluation . . . . . . . . . . . . . . . . . . . . . . . . 39

5.4 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415.4.1 Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415.4.2 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425.4.3 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

6 Conclusion 43

Literature 44

© Uppsala University Adnan Albaba

Page 9: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

List of Tables IV

List of Tables

Table 4.1: Initial values for the parameters of the model . . . . . . . . . . . . . . . 18Table 4.2: RMSE for ECGSYN signals with initial Ehr = 15 . n(t) [mV] and Fs [Hz]

were varied. RMSE for heart rates within the range 15–120, the range120–160 and total RMSE. . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

Table 4.3: Root Mean Squared Error for every MIT-BIH Database individual recordwith initial Ehr = 15 (RMSE15) and 60 (RMSE60). . . . . . . . . . . . . . 24

Table 5.1: Qualitative Evaluation of the Results for the Decisions in the Parameter-Level Using the Training Data . . . . . . . . . . . . . . . . . . . . . . . . 39

© Uppsala University Adnan Albaba

Page 10: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

List of Figures V

List of Figures

Figure 2.1: Normal ECG beat. [25] . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Figure 2.2: (a) and (b) illustrate the incidence of a PVC and PAC episodes re-

spectively, where red (X) mark the abnormal beats and red filled (O)mark the normal beats; (c) and (d) show a segment of AFL and AFIBepisodes, respectively; (e) and (f) illustrate the incidence of a VT andRBBB episodes respectively, where red (X) mark the abnormal beatsand the red filled (O) marks the normal beats. . . . . . . . . . . . . . . 8

Figure 2.3: NUUBO’s wearable ECG platform. [40] . . . . . . . . . . . . . . . . . 10

Figure 3.1: Normal ECG beat generated using ECGSYN tool . . . . . . . . . . . . 12Figure 3.2: (a) depicts the waveform of x, y, and z. (b) depicts the phase plot of x

and y. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13Figure 3.3: Trajectory generated by the ECG dynamical model in three-dimensional

state-space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

Figure 4.1: The effect of the sampling frequency Fs on the performance of the HRestimator. (a) Results for HR estimation using synthetic ECG signalssampled with Fs = 512Hz, (b) Fs = 360Hz and (c) Fs = 60Hz. . . . . . 20

Figure 4.2: The effect of adding uniformly distributed measurement noise n(t) tothe ECG beat data on the performance of the HR estimator, Fs = 360Hz.(a) Results for HR estimation using synthesised ECG signals with n(t)= 0 mV, (b) n(t) = 0.1 mV and (c) n(t) = 0.2 mV. . . . . . . . . . . . . . 20

Figure 4.3: Results of the model-based HR estimation of the beats acquired fromMIT-BIH Normal Sinus Rhythm Database (a) and MIT-BIH Arrhyth-mia Database (b). Points marked with (o) represent the true HR values,while (x) and (+) represent the HR estimates with initial value of Ehr

equal to 15 and 60, respectively. (c) Results of the model-based HR es-timation of the beats acquired from the MAX-ECG-MONITOR. Pointsmarked with (o) represent the true HR values, while (x) represent theHR estimates with initial value of Ehr equal to 60. The tests were per-formed in three different physical statuses which are Sitting, Standing,and Running as illustrated by the vertical lines. (d) The HR estimatesfor a segment of the ECG test signal 106 acquired from the MIT-BIHArrhythmia Database. The correlation coefficient between the HRestimates and true values is 0.6337. . . . . . . . . . . . . . . . . . . . . 22

© Uppsala University Adnan Albaba

Page 11: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

List of Figures VI

Figure 4.4: The MAX-ECG-MONITOR deployed on the chest of the subject forwearable ECG acquisition. . . . . . . . . . . . . . . . . . . . . . . . . . 23

Figure 4.5: The effects of local minima on the performance of the HR estimator.(a) the estimated heart rates for 51 beats with true HR between 96 and101 covered with the step 0.1, the initial value of Ehr was set to 15, Fs =360 Hz, and n(t) = 0 mV. Points marked with (o) represent the true HRvalues, while (x) represent the HR estimates. (b) shows the resultantsquared norm of the residual for optimization procedures in (a). . . . 26

Figure 4.6: Tuning the initial value of Ehr improves the performance of the HRestimator by overcoming local minima issue illustrated in Fig. 4.5. (a)the estimated heart rates for 51 beats with true HR between 96 and101 covered with the step 0.1, Fs = 360 Hz and n(t) = 0 mV. Pointsmarked with (o) represent the true HR values, while (x) representthe HR estimates. (b) the resulting squared norm of the residual foroptimization procedures in (a). . . . . . . . . . . . . . . . . . . . . . . 26

Figure 4.7: The difference in morphology between one ECG beat taken from theMAX-ECG-MONITOR sitting test signal with true HR equals to 86BPM (in Blue), and a synthetic ECG beat with true HR equals to 86BPM generated by the ECGSYN model (in orange). It also shows thesame ECG beat generated by ECGSYN model after being modifiedby tuning its parameters to fit with the MAX-ECG-MONITOR beat(dashed line in yellow). . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

Figure 4.8: (a) A one-minute segment of the ECG record 106 acquired from theMIT-BIH Arrhythmia Database, where the amplitude of the signalchanges during the process of the ECG acquisition. (b) HR estimates vs.true values plot for the test sample shown in (a). A significant changein the performance of the HR estimator after the point where theamplitude of the ECG signal changes which denoted by the black arrowis shown. (c) Amplitude scaling of the ECG segment normalizing theamplitude scale of the ECG segment shown in Fig. 4.8(a) cancels outthe effect of the changing amplitude shown in (b). . . . . . . . . . . . 29

Figure 5.1: A flow chart illustrating the main steps of the proposed period nor-malization technique. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

Figure 5.2: The results for the period normalization method; (a) depicts the stretch-ing of a normal ECG beat with HR = 130 BPM, the resultant ECG beatis equivalent to a normal ECG beat with HR = 60 BPM. (b) depicts theshrinking of a normal ECG beat with HR = 60 BPM, the resultant ECGbeat is equivalent to a normal ECG beat with HR = 40 BPM. Signals inorange represent the original ECG beats, while those in blue representthe scaled ones. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

© Uppsala University Adnan Albaba

Page 12: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

List of Figures VII

Figure 5.3: The ROC curves and their corresponding AUC for three differentcombinations of features of the presented classifier. . . . . . . . . . . . 36

Figure 5.4: The distributions of the features aP, aR, aT, corresponding to P (X-axis),R (Y-axis) and T-waves (Z-axis), for different patients in both normaland abnormal cases; (a), (b) and (c) depict the distribution of the es-timated parameters in normal case, AFIB and AFL respectively; (d)and (e) depict the distribution of the estimated parameters in case ofnormal and PAC beats, respectively; (f) and (g) depict the distribu-tion of the estimated parameters in case of normal and RBBB beats,respectively; (h) and (i) depict the distribution of the estimated valuesparameters in case of normal and PVC beats, respectively. Estimatesfor normal beats (training) are marked with blue (O), and estimationsof normal and abnormal testing beats are marked with orange (X). . . 40

Figure 5.5: (a) and (b) depict The confusion matrices for the PR2T-based classi-fier in both cases of tuning the classification threshold and the finalevaluation of the presented algorithm, respectively. . . . . . . . . . . . 41

© Uppsala University Adnan Albaba

Page 13: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

List of Acronyms VIII

List of Acronyms

CVD Cardiovascular diseaseECG ElectrocardiographEKG ElectrocardiographIoT Internet of ThingsHR Heart RateSA SinoatrialAV AtrioventricularBPM Beat per MinuteBP Blood PressurePPG PhotoplethysmographySVD Singular Value DecompositionPDF Probability Distribution FunctionPVC Premature Ventricular ContractionPAC Premature Atrial BeatAFL Atrial FlutterAFIB Atrial FibrillationVT Ventricular TachycardiaRBBB Right Bundle Branch BlockRMSE Root Mean Square ErrorRESNORM Resultant Squared Norm of the ResidualSNR Signal-to-Noise RatioOSA Orthogonal Series ApproximationAUC Area Under CurveROC Receiver Operating CharacteristicsTP True PositiveFP False PositiveTN True NegativeFN False NegativeRTP True Positive RateRFP False Positive RateACC Accuracy

© Uppsala University Adnan Albaba

Page 14: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Introduction 1

1 Introduction

1.1 Overview

No one can deny the fact that cardiovascular disease (CVD) has recently become oneof the biggest threats for mankind. On top of being the major cause of death globally,patients suffering from CVD are accounting for the highest percentage of hospitalizedpatients [1]. Locally speaking, CVD remains the main cause of death in Sweden [2].CVD is the name for the group of disorders of heart and blood vessels, and include:

• Hypertension (high blood pressure (BP))

• Coronary heart disease (heart attack)

• Cerebrovascular disease (stroke)

• Peripheral vascular disease

• Heart failure

• Rheumatic heart disease

• Congenital heart disease

• Cardiomyopathies.

Electrocardiography (ECG) monitoring is one of the well-known techniques used bythe cardiologists for collecting information about the structure and functionality ofthe cardiovascular system. Early recognition of cardiac-related issues such as angina,dyspnea, and syncope can be critical, and CVD patients need to visit their doctors formedical tests on a regular basis. ECG is frequently used in hospitals and clinics for itsusefulness in diagnosing heart diseases. Monitoring of cardiac electrical activity for longtime intervals can also be useful for detection of arrhythmias. In fact, “The diagnosticyield is increased by 15% to 39% by a 24-hour recording” [3].Conventionally, interpreting the ECG signal is done by a specialist with the help ofan ECG recording machine. This task requires intellect, training, and an organizedapproach. During the past 50 years, extensive research has been devoted to developingalgorithms for computerized and automated ECG processing and analysis. As a result,computerized ECG monitoring is now a well-established approach, and around 100million computerized ECG interpretations are being recorded every year in the UnitedStates alone [4].

© Uppsala University Adnan Albaba

Page 15: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Introduction 2

1.2 Problem Formulation and My Contributions

Computerized monitoring of ECG is now a well established method, thanks to thesignificant progress derived by many proposed algorithms over the years, see Section1.3. Different ECG beat detection and classification techniques were presented in theliterature to support wearable ECG monitors see Section 1.3. Such algorithms caneither be used for processing the ECG signal in real-time or off-line. While the designcriteria may differ between on-line and off-line ECG monitors, one common problemfaced in their development is the inter-patient and intra-patient variation in the ECGmorphology. The QT-interval has a strong inverse relation with the HR. ComparingQT-intervals between different controls with different HR would require the use of aQT-interval rate correction formula [5].Researchers have paid less attention to the inter-patient and intra-patient variations inthe QT-RR relationship. Such variation also limits the reliability as well as the robustnessof any universal clinical decision support algorithm. It also contributes to the errors ofany fixed HR correction formula [6].Therefore, a beat detector and classifier producing good results for a certain trainingdatabase can perform inconsistently, when dealing with a different patient cohort thus ef-fectively preventing reliable solutions for automated ECG processing. Individualizationof the medical solution may be a possible solution to address this problem.In this thesis, Model-Bsaed ECG analysis approach is considered for the previouslymentioned problem. Two novel methods for estimating the HR and detecting theabnormalities in the ECG pattern are introduced, tested, and discussed.The outcome of this work is summarized below:

• Online Model-Based Beat-by-beat Heart Rate Estimation: A novel method forestimating the instantaneous HR using the morphological features of one ECG beatat a time. This tool is not aimed at introducing an alternative way for estimatingthe HR, but rather illustrates the utility of model-based ECG analysis in onlineindividualized monitoring of the heart function, and demonstrates the possibilityof estimating the HR from the data of one single beat.

• Patient-Specific ECG Monitoring by Model-Based Stochastic Anomaly Detection:A novel model-based method for patient-specific detection of deformed ECGbeats. Five parameters of a patient-specific nonlinear ECG model are estimatedfrom data by nonlinear least-squares optimization. The normal variability of themodel parameters is captured by estimated probability density functions. A binaryclassifier, based on stochastic anomaly detection methods, along with a pre-tunedclassification threshold, is employed for detecting the abnormal ECG beats.

Both tools are addressed separately in the following chapters, see Section 1.4.

© Uppsala University Adnan Albaba

Page 16: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Introduction 3

1.3 Related Work

Various methods and techniques were proposed for automatic ECG heartbeat classi-fication in literature. Quantitative ECG analysis was used by D. E. Krummen, et al.to demonstrate that new computerized algorithms can detect heart arrhythmia withrelatively high accuracy [7]. Discrete Wavelet Transform was employed by L. Senhadji,et al. to act as a feature extraction approach and combined it with a linear discriminantclassifier [8], while Shyu, et al. classified PVC beats using a combination of wavelet fea-ture extraction and Fuzzy Neural Network [9]. M. Lagerholm, et al. clustered ECG beatsusing Hermite functions along with Self-Organizing Maps [10]. Hidden Markov modelswere used by R.V. Andreao, et al. for ECG signal analysis [11]. M.I. Owis, et al. used thecorrelation dimension and largest Lyapunov exponent to detect ECG arrhythmia [12]. Anumber of additional ECG beat detection and classification techniques were presentedin the literature to support wearable ECG monitors [13]–[16].Whilst non of the previously mentioned works provides a truly patient-specific approach,Y.H. Hu, et al. brought up the topic of patient-adaptable ECG beat classifiers, by utilizinga mixture of experts approach [17].As for the work been done on ECG mathematical models, A. Ruha, et al. preduced asynthetic ECG waveform generator to test their Real-Time Microprocessor QRS Detectorsystem [18]. However, this generator was not meant to be used for generating highlyrealistic ECG waveform, Moreover, the synthetic ECG does not include P-wave orbeat-to-beat variations.On the other hand, ECG nonlinear dynamical model [19], introduced by P.E. McSharry,et al. and better known as ECGSYN, is based on time-varying differential equations andincludes beat-to-beat variations in morphology as well as inter-beat timing variations,which makes it capable of generating highly realistic synthetic ECG waveform. G.D.Clifford, et al. used the ECGSYN model for filtering, compression and classification ofthe ECG [20].It is worth mentioning that the ECGSYN model was utilized in this work, see Section 3.2.1for more details.The relation between the morphology of the ECG beat and the corresponding HR istaken into consideration especially in articles related to the topic of "ECG as a Biometric".This is because normalization is needed when developing an ECG based identificationsystem [21], [22].Stochastic anomaly detection was proposed in [23] and successfully applied to theanalysis of eye-tracking data in [24].To my knowledge, no previous work was done on the concept of model-based HRestimation using the information of one ECG beat, which supports the novelty of theproposed method in this thesis. Moreover, model-based stochastic anomaly detection fora patient-specific ECG monitor is also a new and novel approach to detect and identifyabnormal ECG beats.

© Uppsala University Adnan Albaba

Page 17: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Introduction 4

1.4 Structure of The Thesis

The rest of this thesis is organized as follows; Chapter 2 presents a theoretical backgroundabout the ECG from physiological and pathological points of view. Chapter 3 gives abrief overview about the ECG modeling approaches and sets up the mathematical modelof the ECG waveform, which is used in this work. Chapter 4 summarizes the theoryand methods for the Online Model-Based Beat-by-beat Heart Rate Estimation method.It also presents the results of algorithm performance evaluation and discusses them.Chapter 5 summarizes the theory and methods for the Patient-Specific ECG Monitoringby Model-Based Stochastic Anomaly Detection method. It also presents the resultsof algorithm performance evaluation and discusses them. Conclusions are drawn inChapter 6.

© Uppsala University Adnan Albaba

Page 18: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Background 5

2 Background

2.1 Electrocardiography (ECG)

An electrocardiogram - abbreviated as EKG or ECG - is a test that measures the electricalactivity of the heartbeat, see Fig. 2.1. With each beat, an electrical impulse travels throughthe heart. This impulse causes the muscle of the heart to squeeze and pump blood fromthe heart.The sinoatrial (SA) node, located in the right atrium, is the natural pacemaker of theheart and initiates the heart beat in normal cases. Electrical impulses originating fromthe SA node spread throughout both atria and stimulate them to depolarize. The atrialdepolarization is represented by the P-wave. The PQ-segment represents the time ittakes for the electrical impulses to travel from the SA node to the atrioventricular (AV)node located near the AV valve. The AV node serves as an electrical gateway to theventricles and delays the electrical impulses, which cause the atria relax or repolarize.The atrial repolarization is masked by the QRS-complex. After that, the AV node passesthe electrical impulses to the bundle of His that is then divided into right and left bundlebranches. Those branches conduct the electrical impulses towards the apex of the heart.The electrical impulses are passed further onto the Purkinje fibers and spread throughoutthe ventricular myocardium, which causes the ventricles to depolarize. The ventriculardepolarization is represented by the QRS-complex. The next step is the contraction of theventricles, which causes a plateau in the myocardium action potential and is representedby the ST-segment. The ventricular repolarization then occurs and is represented by theT-wave.Therefore, a normal ECG signal can be broken down into the following fiducial points:

• P-wave is the depolarization of the atria

• Q-wave is associated with the deflection immediately before ventricular depolar-ization

• R-wave is associated with the peak of the ventricular depolarization

• S-wave is associated with the deflection proceeding the ventricular depolarization

• T-wave is the repolarization of the ventricles

An ECG gives two major kinds of information: First, by measuring time intervals onthe ECG, a doctor can determine how long the electrical wave takes to pass through the

© Uppsala University Adnan Albaba

Page 19: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Background 6

Figure 2.1: Normal ECG beat. [25]

heart. Finding out how long a wave takes to travel from one part of the heart to the nextshows if the electrical activity is normal or slow, fast or irregular. Second, by measuringthe amount of electrical activity passing through the heart muscle, a cardiologist may beable to find out if parts of the heart are too large or are overworked [26].

2.2 Heart Rate (HR)

The HR is the number of times in which the heart contracts or beats per minute [27].Along with body temperature, blood pressure, and breathing rate, HR is one of theprimary vital signs which indicate the status of the body′s life-sustaining functions.On top of clinical applications such as sleep test and stress test, HR is used in fitnessand activity tracking solutions, as it varies according to the body′s physical needs foroxygen. HR can be measured manually by feeling specific points on the body, where theartery’s pulsation is transmitted. It can also be measured electrically by means of ECGand estimated from the electrocardiogram pattern. The most prominent feature in oneECG cycle is the R-wave, which is used as a marker for every beat and the time intervalbetween two R-waves (RR-interval) can be used for estimating the HR.From a physiological point of view, two main types of action potential are the pacemakeraction potential which is generated spontaneously, i.e. the sinoatrial (SA) node locatedin the posterior wall of the right atrium, and the non-pacemaker action potential whichis generated by depolarization current from adjacent cell (the Ventricle muscles). The

© Uppsala University Adnan Albaba

Page 20: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Background 7

HR is normally determined by the pacemaker action potential of the SA node at a ratewhich is determined by the spontaneous changes in conductances of potassium, sodiumand calcium. If not affected by neurohumoral factors, this intrinsic automaticity exhibitsa spontaneous firing rate of 100-115 beats per minute (BPM) and decreases with age[28]. Activating the vagus nerve decreases the HR and results in a normal resting HRbetween 60 and 80 BPM because of the significant vagal tone on the SA node at rest.On the contrary, an activation of sympathetic nerves leads to a HR increase above theintrinsic rate and explains the HR increment during physical exercise because of thereciprocal change in sympathetic and parasympathetic activity [28].There are three main methods that are currently used for obtaining HR information:

1. ECG-based techniques capture the electrical impulses of the heart [29]. The de-tection of QRS-complex is the most direct method for ECG-based heat rate mea-surement. Algorithms based on digital filters [30], derivative-based algorithms[31], wavelet-based algorithms [32], neural network-based approaches [33] andmodel-based methods [34] are used for QRS-complex detection.

2. Photoplethysmography (PPG) relies on the blood perfusion and the change ofits volume. Optical HR monitoring is an example of PPG-based technologiesimplemented in wearable HR monitors [35].

3. Techniques based on arterial blood pressure that utilize the pulsatile waveform ofBP [36].

Since HR measurements are subject to noise and artifact sources, several techniqueshave been developed for improving the process of HR estimation, e.g. by combining thesignal quality indices with a Kalman filter [37].

2.3 Pathophysiology and ECG Patterns

In this Section, six types of arrhythmia (i.e. disorder in heart rhythm), which areinvestigated in this thesis, are briefly introduced:

Premature Ventricular Contraction (PVC)

A PVC occurs when the heart beat is initiated by Purkinje fibers instead of the SA node.ECG monitoring usually makes it possible to distinguish a PVC from a normal heartbeat. According to [27], the specific effects caused by PVCs in the ECG (see Fig. 2.2(a))are:

• Prolongation of the QRS-complex because the impulse is not conducted throughthe Purkinje system, but through the slow conducting muscles of the ventricles.

• High voltage level for the QRS-complex because the impulse travels in one direc-tion unlike in normal case where the depolarization waves of the two sides of theheart partially neutralize each other in the ECG.

© Uppsala University Adnan Albaba

Page 21: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Background 8

(a) (b)

(c) (d)

(e) (f)

Figure 2.2: (a) and (b) illustrate the incidence of a PVC and PAC episodes respectively,where red (X) mark the abnormal beats and red filled (O) mark the normalbeats; (c) and (d) show a segment of AFL and AFIB episodes, respectively; (e)and (f) illustrate the incidence of a VT and RBBB episodes respectively,where red (X) mark the abnormal beats and the red filled (O) marks thenormal beats.

© Uppsala University Adnan Albaba

Page 22: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Background 9

• The T-wave has an electrical potential polarity opposite to that of the QRS-complexbecause of the slow conduction of the impulse causing the muscle fibers to repolar-ize first.

Premature Atrial Beat (PAC)

PAC - and Aberrated Atrial Premature Contraction (APAC) - takes place when a regionother than the atria depolarizes before the SA node and triggers a premature beat.The P-wave of the PAC occurs earlier in the heart cycle. Moreover, the PR-interval isshortened thus indicating that the ectopic origin of the beat is in the atria near the AVnode. The interval between the PAC and the next contraction is slightly prolonged,which phenomenon is called a compensatory pause [38]. Fig. 2.2(b) illustrates a PACepisode.

Atrial Flutter (AFL)

A circus movement in the atria is usually the cause of the AFL condition, in which theelectrical impulse travels as a single large wave in one direction around the atrial muscle.This leads to a rapid contraction rate of the atria at 200–350 BPM. In a typical ECGfeaturing AFL (see Fig. 2.2(c)), the P-waves are strong but a QRST-complex follows aP-wave only once for every two-three cycles of the atria [38].

Atrial Fibrillation (AFIB)

AFIB occurs when the atria beat rapidly and irregularly leading in an abnormal heartrhythm. An ECG during AFIB condition (see Fig. 2.2(d)) shows either no P-waves or onlyvery fine wavy ones. On the other hand, the QRST-complexes are normal but irregularin timing. This irregularity in ventricular rhythm is due to the rapid and irregular arrivalof impulses from the atrial muscle at the AV node [38].

Ventricular Tachycardia (VT)

VT is an arrhythmia which is caused by abnormal impulses in the ventricles. In VT cases,the heart rate is usually 100BPM and out of sync with the atria. VT appears as a series ofPVCs occurring one after another (see Fig. 2.2(e)) without any normal beats interspersed[38].

Right Bundle Branch Block (RBBB)

During an RBBB, the right ventricle is not activated by impulses which travel throughthe right bundle branch. However, the left ventricle is still activated by the left bundlebranch. These impulses travel through the myocardium of the left ventricle to the rightventricle to depolarize them. Since conduction through the Bundle of His-Purkinje fibresis faster than conduction through the myocardium, the QRS-complex is prolonged [38].

© Uppsala University Adnan Albaba

Page 23: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Background 10

Figure 2.3: NUUBO’s wearable ECG platform. [40]

The QRS-complex usually shows extra deflection that reflects the rapid depolarisation ofthe left ventricle followed by the slower depolarisation of the right ventricle. Fig. 2.2(f)illustrates an RBBB episode.

2.4 Wearable ECG Technology

Wearable medical technology can be a practical solution for long term ECG monitoring,see Fig. 2.3 for an example of an industrial wearable solution for ECG monitoring.Wearable ECG monitoring techniques have been a hot area of research for the pastdecade and still. It is worth mentioning that wearable technology has begun dominatingthe market of consumable electronic gadgets along with internet of things (IoT). Thenumber of connected wearable devices worldwide is expected to jump from an estimateof 325 million in 2016 to over 830 million in 2020 [39].The increasing numbers of deployed wearable and IoT systems motivated researchersaround the world to develop new methods which fit with the standards of wearabledevices. However, many barriers are needed to be overcome in order to reach a trueclinical adoption of the wearable medical monitors. Issues like motion artifacts, networkconnectivity, data processing, integration and clinical decision support are among thechallenges faced when considering a wearable solution for medical application [41].The main focus of this thesis is put on the aspect of clinical decision support for wearableECG monitors, see Section 1.2.

© Uppsala University Adnan Albaba

Page 24: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Modeling of Electrocardiography 11

3 Modeling of Electrocardiography

3.1 Introduction

The field of physiological modelling attempts to understand living systems from aqualitative perspective. This is done by building mathematical models of how theseliving systems work.Thanks to the significant advancement in the field of scientific computing over the pastdecades, building highly efficient and detailed models of organ systems has been madepossible.Clinical and biomedical research provide large amount of experimental data which canbe interpreted using mathematical models.Mathematical models can be used for reproducing pathological conditions by alteringthe parameters of these models.Organ systems in the human body are considered to be highly complex in terms ofstructure as well as functionality. They usually interact with other organ systems andbehave non-linearly.Physiological models can be divided into two main categories:

• Large-scale/complex models

• Small/simple models

A major obstacle when it comes to physiological models -especially small models- is todecide the level of granularity. In order to estimate the parameters from clinical data, itis necessary to build models with appropriate order of parameters for that clinical data.Control theory and system dynamics areas propose methods for model order reduction.However, these methods may lack model structure preservation, which is essentialin physiological models as each parameter has a specific interpretability. The processof translating physiological models into clinical applications takes into account theinterpretability of each parameter of the model because clinicians are used to thinkingin terms of certain variables such as BP and HR, and it is important to maintain thisinterpretability.

© Uppsala University Adnan Albaba

Page 25: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Modeling of Electrocardiography 12

Figure 3.1: Normal ECG beat generated using ECGSYN tool

3.2 Models for ECG

Biomedical signals like ECG can be described by nonlinear dynamical systems′ methods.Bio-electrical models of the heart are studied in the following three levels:

1. Single-Cell Model: in this level, the ionic current flow through the membranes ofthe myocardial cell is described [42].

2. Tissue Model: in this level, the tissue, or the cell network, model describes the ioniccurrent flow between different myocardial cells. This process is done in temporaland spatial domains [42].

3. Whole-Heart Model: the whole-heart-model describes three main mechanisms:how the activation currents propagate in the heart, the electrical sources in theheart, and the extracellular electrical potentials on and within the surface of thebody. Such model is capable of relating the ECG waveforms to the conduction ve-locity of heart tissue, the action potential and other electrophysiological propertiesof the cardiac system. This leads to a clinically comparable ECG signals [42].

It is possible to build a mathematical model of the electrical activity of the heart using adifferent approach. This can be done by modeling the morphology of the ECG signalrather than modeling the physiological process behind it. Such models can be usedas a quantitative monitoring tool for the ECG, by studying how the parameters ofthese models change in time in the parameter space. Section 3.2.1 provides a detailedinformation on a nonlinear mathematical model used for ECG.

© Uppsala University Adnan Albaba

Page 26: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Modeling of Electrocardiography 13

(a) (b)

Figure 3.2: (a) depicts the waveform of x, y, and z. (b) depicts the phase plot of x and y.

3.2.1 ECGSYN

"ECGSYN is a dynamical model for generating synthetic ECG signals with arbitrarymorphologies where the user has the flexibility to choose the operating characteristics"[43].Presented in [19], the ECGSYN model is based on three coupled ordinary differentialequations

x = αx−ωy, (3.1)

y = αy + ωx, (3.2)

z = − ∑i∈{

P,Q,R,S,T} ai∆θi exp

(−

∆θ2i

2b2i

)− (z− z0), (3.3)

where

α = 1−√(x2 + y2), (3.4)

∆θi = (θ − θi)mod(2π), (3.5)

−π ≤ θ = tan−1(y, x) ≤ π, (3.6)

z0(t) = Asin(2π f2t), (3.7)

ω represents the angular velocity of the trajectory. A is the amplitude of the baselinewander. The variables x, y and z comprise the state vector of the ECG dynamical modelthat possesses an attracting limit cycle with one period of the solution corresponding toone heart beat, see Fig. 3.3.

© Uppsala University Adnan Albaba

Page 27: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Modeling of Electrocardiography 14

Figure 3.3: Trajectory generated by the ECG dynamical model in three-dimensionalstate-space

The power spectrum S( f ) of the RR-interval is given by Eq (3.8), which takes intoaccount the effects of the respiratory sinus arrhythmia (RSA) as well as the Mayer waves.

S( f ) =σ2

1

2πc21

exp

(( f − f1)

2

2c21

)(3.8)

+σ2

2

2πc22

exp

(( f − f2)2

2c22

),

where f1 and f2 are the means and c1 and c2 are the standard deviations of the distribu-tions.A time series T(t), with S( f ) power spectrum of an RR-interval, can be generated bytaking the inverse Fourier transformation of a sequence of complex numbers, whichhave

√S( f ) as amplitudes and random phases distributed within 0 and 2π. Then, the

time-dependent ω(t) will be given by Eq. (3.10).

T(t) =60Ψ

+ ζ ∗ 60δ

Ψ2 ∗1$

, (3.9)

ω(t) =2π

T(t), (3.10)

where Ψ is the mean HR of the generated ECG, ζ is the inverse Fourier transformation ofa sequence of complex numbers, which have

√S( f ) as amplitudes and random phases

distributed within 0 and 2π, δ is the standard deviation of the HR, and $ is the standarddeviation of ζ.

© Uppsala University Adnan Albaba

Page 28: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Modeling of Electrocardiography 15

The ECG dynamical model reduces every electrocardiogram cycle into a set of fifteenparameters that describe the five fiducial points – P, Q, R, S and T, as shown in Fig. 3.1.Each point is characterized with three parameters ai,bi,θi, i = P, . . . , T, see Table 4.1.

3.3 Model-Based ECG Analysis

Unlike most of the existing techniques, model-based approaches take into account thenature of the underlying dynamics that generate the signal and/or the noise that affectsit. As a result to that, once a model has been fitted to a segment of ECG, it can produce afiltered version of the waveform. Moreover, it can derive wave onsets and offsets usingthe estimated parameters of the model, thus, compressing the ECG and classifying beats.Another advantage for using model-based approaches is that the quality of the fit can beused as a confidence measure with respect to the filtering methods.Existing techniques for filtering and segmenting ECGs are limited by the lack of anexplicit patient-specific model to help isolate the required signal from contaminants.Only a vague knowledge of the frequency band of interest and almost no informationconcerning the morphology of an ECG are generally used [43].

© Uppsala University Adnan Albaba

Page 29: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Online Model-Based Beat-by-beat Heart Rate Estimation 16

4 Online Model-Based Beat-by-beat HeartRate Estimation

This Chapter is dedicated to present a novel method for estimating the instantaneousHR by using the morphological features of one ECG beat at a time. In this work, theutility of the model-based ECG analysis technique is illustrated in online personalizedmonitoring of the HR. The problem of estimating the HR is reduced to fitting oneparameter. The value of this parameter is related to the values of nine parameters ofan ECG realistic nonlinear model. The HR is estimated from information of one ECGbeat using nonlinear least-squares optimization. The feasibility of the presented methodis evaluated on synthetic ECG signals and signals acquired from MIT-BIH databasesat Physionet website. In addition, the performance of the presented method is testedunder realistic free-moving conditions using a wearable ECG and heart monitor.

4.1 Theory

It is believed that the morphological features of the ECG beats are influenced by thechange in the HR. This is because of the relation between the HR and the intra-ventricularconduction [44], also see Section 1.2. By analyzing the ECG signals, which were acquiredfrom healthy subjects at different values of HR, it is notable that the width of the QRS-complex decreases when the HR increases. These results are expected as the speedof the conduction across the ventricles increases together with an augmented HR asthe sympathetic tone increases. Therefore, the time for the ventricular depolarization,represented by the QRS complex of the ECG, will become shorter [43].

4.2 Methods

The ECGSYN model, presented in Section 3.2.1, is considered in this Chapter.Based on the fundamental relation between the width of the QT-interval and the changein the HR [44], also see Section 1.2, it is assumed that the coordinate z of each fiducialpoint (i.e. ai) is independent of the change in HR and can be assigned a fixed value in theparameter estimation procedure. Moreover, since the parameter set {θi} describes thedisplacement of each fiducial point from the R-peak, the parameter {θR} is set to zero.Therefore, the parameters are reduced to nine parameters that can be estimated frommeasured data using a nine-dimensional gradient descent in the parameter space.

© Uppsala University Adnan Albaba

Page 30: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Online Model-Based Beat-by-beat Heart Rate Estimation 17

The complexity along with the computational time of the optimization problem werefurther reduced by introducing a new parameter Ehr, representing the estimated HR,that is mathematically related to the nine parameters (i.e. bP, θP, bQ, θQ, bR, bS, θS, bT,and θT), see (4.3)–(4.5)

b0 =[bP bQ bR bS bT

], (4.1)

θ0 =[θP θQ θR θS θT

], (4.2)

β =√

60/Ehr, (4.3)

bβ = β ∗ b0, (4.4)

θβ = θ0 �[

β12 β 1 β β

12

], (4.5)

Note the element-wise product in Eq. (4.5). The estimated HR (EHR) is used in Eq. (4.3)–(4.5) to updated the parameters b0 and θ0 to bβ and θβ. The updated parameters are thenused to generate synthetic ECG cycle z(Ehr). Next, z(Ehr) is compared with the observedECG cycle s(t) by computing the loss function using Eq. (4.6)–(4.7).This parametrization, along with appropriate upper and low bounds, drastically reducesthe computational overhead and is inspired by the initial settings recommended in [20].The described ECG dynamical model is implemented in MATLAB by the functionecgsyn.m [45]. The MATLAB function ode45.m is used for numerically integratingthe set of the ordinary differential equations in (3.1)–(3.3), producing a simulated ECGwaveform in Fig. 3.1.

4.2.1 Preprocessing

The first step before estimating the model parameters is to segment the ECG data andisolate every cycle with the corresponding main features, i.e. P, Q, R, S, and T-waves. Thenumber of samples in the isolated cycle does not matter as it can be easily compensatedfor in a later step by zero padding or truncation. Then, RR-intervals are calculated bysubtracting the occurrence times of every two consecutive R-peaks. The next step isto perform beat isolation by considering the starting point for one beat cycle to be thenumber of samples equal to a half of the corresponding RR-interval before the R-peakand vise-versa.All isolated beats are then be de-trended to set the baseline and comply with the assump-tion of zero z-offset. Lastly, to eliminate the parameter θR, the R-peak of the observedECG cycle and the R-peak of the estimated model output are centered at the same point(say at the point zero).

© Uppsala University Adnan Albaba

Page 31: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Online Model-Based Beat-by-beat Heart Rate Estimation 18

Table 4.1: Initial values for the parameters of the model

P Q R S T

ai 1.2 -5.0 30.0 -7.5 0.75

bi 0.25 0.1 0.1 0.1 0.4

θi -1.2217 -0.2618 0 0.2618 1.7453

4.2.2 Initial Settings

Before starting the optimization process, the initial value for the HR needs to be specified.It is recommended to use an initial value that corresponds to the lower or higher boundwhich have been set for the algorithm (see Section 4.2.3 for more details). The samplingfrequency is set according to the input signal while the internal sampling frequency isdouble of the ECG sampling frequency Fs. The means f1 and f2 are set to 0.1 and 0.25,respectively. The standard deviations c1 and c2 are both set to 0.01 in Eq. (3.8). The ratioσ2

1 /σ22 (the LF/HF ratio) is set to 0.5 in Eq. (3.8). A is set to 0.15. Ψ is Ehr, and δ is set to 1

in Eq. (3.9).The initial values for the fifteen model parameters are summarized in Table 4.1.In this application, it is assumed that z-offset of the ECG signal is eliminated, which canbe achieved by setting (z− z0) = 0. Both x and y are set to one.

4.2.3 Optimization

Nonlinear least-squares method solving the optimization problem (4.6), (4.7) is utilizedfor model parameter estimation

minEhr‖ f (Ehr)‖2

2 = minEhr

( f 21 (Ehr) + f 2

2 (Ehr) + · · ·+ f 2n(Ehr)), (4.6)

f (Ehr) =

s1(t1)− z1(Ehr)

s2(t2)− z2(Ehr)...

sn(tn)− zn(Ehr)

, (4.7)

where s(t) is the observed ECG beat, z(Ehr) is the ECGSYN model fit to the ECG signal,and n is the number of samples. The MATLAB function lsqnonlin.m is employedfor solving this problem. Choosing the trust-region-reflective algorithm and specifyingproper constraints for the optimizer (e.g. upper and lower bounds) appears to be criticalfor obtaining acceptable performance. It is noticed that setting the maximum andminimum change in variables for finite-difference gradients in a proper way resulted ina significant performance improvement of the optimizer. Adding a feedback from theprevious iterations to influence the initial values of the parameters, see Section 4.3, alsoenhances the performance of the optimization process.

© Uppsala University Adnan Albaba

Page 32: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Online Model-Based Beat-by-beat Heart Rate Estimation 19

4.2.4 Ground Truth

Both MIT-BIH Arrhythmia Database [46] and the MIT-BIH Normal Sinus RhythmDatabase [47] contain RR-intervals information as part of their annotation files. MIT-BIHArrhythmia Database Directory provides HR ranges for every entire individual recordbut not on beat-by-beat basis.To construct a set of true values of the heart rates, the RR-intervals information are usedto calculate the HR for beat i according to

Hi = 60FsR−1int , (4.8)

where Hi is the HR for beat i and Rint is the difference between the incidence time of theR-peak for beat i and the incidence time of the R-peak for beat i + 1.For the ECG signals acquired using the MAX-ECG-MONITOR, the true HR values areestablished using the RR-interval information. This was done by applying the R-peaksdetector in [48]. Moreover, five HR measurements of the subject were taken before eachtest using a Samsung S8 plus mobile phone to measure the resting HR.

4.3 Results

In order to evaluate the performance of the presented method, the algorithm is firsttested on realistic synthetic ECG signals at different HRs produced by the ECGSYN tool.The next step is to test the method on real-life ECG signals, and, for that end, the largeonline bank of physiological signal datasets, provided at Physionet website [47], is used.Finally, ECG signals acquired using the MAX-ECG-MONITOR were used to evaluatethe performance of the presented method. Each ECG cycle was isolated to perform abeat-by-beat HR estimation test in order to capture the HR variability.

© Uppsala University Adnan Albaba

Page 33: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Online Model-Based Beat-by-beat Heart Rate Estimation 20

Figure 4.1: The effect of the sampling frequency Fs on the performance of the HRestimator. (a) Results for HR estimation using synthetic ECG signalssampled with Fs = 512Hz, (b) Fs = 360Hz and (c) Fs = 60Hz.

Figure 4.2: The effect of adding uniformly distributed measurement noise n(t) to theECG beat data on the performance of the HR estimator, Fs = 360Hz. (a)Results for HR estimation using synthesised ECG signals with n(t) = 0 mV,(b) n(t) = 0.1 mV and (c) n(t) = 0.2 mV.

© Uppsala University Adnan Albaba

Page 34: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Online Model-Based Beat-by-beat Heart Rate Estimation 21

4.3.1 ECGSYN Signals

ECGSYN tool gives the researcher the control over several parameters such as the meanHR and the standard deviation of HR. the method was tested using ECG signals withHR in the interval 15–160 BPM.Every test suite consists of a series of 25 ECG beats (averaged to one beat in laterstep) per every specific heart rate from 15 to 160 BPM. For every test suite, one ofthe two parameters (the sampling frequency Fs or the additive uniformly distributedmeasurement noise n(t)) is varied, and the other one is fixed. The standard deviation ofHR was set to zero, and the initial value of Ehr was set to 15 for all tests.Results are illustrated graphically in Fig. 4.1 and Fig. 4.2, with the numerical valuessummarized in Table 4.2, and discussed in Section 4.4.

4.3.2 MIT-BIH Database

The method is tested on real-life ECG signals by using the MIT-BIH Arrhythmia Database[46] that contains 48 recordings of two-channel ambulatory ECG obtained from 47different subjects for around 30 minutes long and studied by the BIH ArrhythmiaLaboratory. The MIT-BIH Normal Sinus Rhythm Database [47] was also used for testingthe method. It includes 18 recordings of long-term ECG obtained from subjects whowere found to have had no significant arrhythmia.Beats with morphological defects, e.g. left and right bundle branch block beats, prema-ture beats, ectopic beats and premature ventricular contractions, were excluded fromthe test suites. Moreover, beats with arrhythmia, such as atrial fibrillation, were alsoexcluded from the test suites. On the other hand, beats with rate abnormalities, such astachycardia or bradycardia, were included. Tests were performed on the modified LeadII ECG signals only, as the morphologies in the used ECG model are modeled after LeadII. It is worth mentioning that ECG Lead II is widely used in wearable ECG solutions asit gives a good view of the P-wave and it is most commonly used to record the rhythmstrip [49].Thanks to the provided annotation files, every beat was isolated, segmented, and pre-processed, as described in Section 4.2.1, before undergoing a beat-by-beat HR estimation.For every heart beat, the model-based HR estimation was performed twice, with differentinitial values for the parameter Ehr.Overall, a total number of 1171 individual beats acquired from 17 different patientswere processed. HR estimation results for signals acquired from MIT-BIH Normal SinusRhythm Database are depicted in Fig. 4.3(a), while Fig. 4.3(b) illustrates the results forsignals acquired from MIT-BIH Arrhythmia Database. Results for both databases areillustrated numerically in Table 4.3 and discussed in Section 4.4.

© Uppsala University Adnan Albaba

Page 35: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Online Model-Based Beat-by-beat Heart Rate Estimation 22

(a) (b)

(c) (d)

Figure 4.3: Results of the model-based HR estimation of the beats acquired fromMIT-BIH Normal Sinus Rhythm Database (a) and MIT-BIH ArrhythmiaDatabase (b). Points marked with (o) represent the true HR values, while (x)and (+) represent the HR estimates with initial value of Ehr equal to 15 and60, respectively. (c) Results of the model-based HR estimation of the beatsacquired from the MAX-ECG-MONITOR. Points marked with (o) representthe true HR values, while (x) represent the HR estimates with initial value ofEhr equal to 60. The tests were performed in three different physical statuseswhich are Sitting, Standing, and Running as illustrated by the vertical lines.(d) The HR estimates for a segment of the ECG test signal 106 acquired fromthe MIT-BIH Arrhythmia Database. The correlation coefficient between theHR estimates and true values is 0.6337.

© Uppsala University Adnan Albaba

Page 36: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Online Model-Based Beat-by-beat Heart Rate Estimation 23

Figure 4.4: The MAX-ECG-MONITOR deployed on the chest of the subject for wearableECG acquisition.

4.3.3 MAX-ECG-MONITOR

The MAX-ECG-MONITOR evaluation and development platform is a wearable solutionfor analyzing and accurately tracking ECG signals to provide valuable insight for clinicaland fitness applications [50]. Fig. 4.4 illustrates the wearable setup of MAX-ECG-MONITOR.Three tests were performed on one subject while sitting, standing-up, and running, byrecording the ECG signals for one minute per test. A total number of 294 ECG beatswere processed for HR estimation using the model-based method. The ECG signalswere acquired with a sampling frequency Fs = 128Hz. Fig. 4.3(c) illustrates the results ofthe three ECG tests.

4.3.4 Quantitative Evaluation

As for the approach of the performance evaluation, the performance indices in thiswork are not compatible to the positive predictability and sensitivity parameters [51].Therefore, to quantify the performance of the presented method, the Root Mean SquareError (RMSE) was used:

V =

√∑n

i=1(Ei −Oi)2

n(4.9)

as performance index. In (4.9), E refers to the estimates, O refers to the observations orthe true values of the heart rates, and n refers to the total number of beats.Table 4.2 and Table 4.3 show the RMSE values for ESGSYN signals as well as MIT-BIHdatabase records, respectively. In the MAX-ECG-MONITOR tests, the RMSE values forthe sitting, standing-up, and running tests are V = 6.9174, V = 3.7804, and V = 9.5156,respectively.

© Uppsala University Adnan Albaba

Page 37: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Online Model-Based Beat-by-beat Heart Rate Estimation 24

Table 4.2: RMSE for ECGSYN signals with initial Ehr = 15 . n(t) [mV] and Fs [Hz] werevaried. RMSE for heart rates within the range 15–120, the range 120–160 andtotal RMSE.

ECGSYN Signals

Sampling rate Fs n(t) RMSE15−120 RMSE120−160 RMSET

512 0 1.2907 1.3733 1.3257

360 0 2.1831 2.0798 2.1506

360 0.1 2.9516 46.0554 24.8495

360 0.2 3.9610 54.6491 29.4973

60 0 2.3542 4.5238 3.0929

Table 4.3: Root Mean Squared Error for every MIT-BIH Database individual record withinitial Ehr = 15 (RMSE15) and 60 (RMSE60).

Arrhythmia Database Normal Sinus Rhythm Database

Record RMSE15 RMSE60 Record RMSE15 RMSE60

103 20.2833 25.2434 16272 12.0266 11.2904

105 28.3592 18.3208 16483 12.5322 7.2598

106 8.9791 13.9306 16539 11.4925 7.6650

113 21.3918 21.4623 16773 7.7009 8.7237

116 5.9964 6.2839 16786 3.7392 -

119 14.9614 16.8384 16795 11.8204 -

123 15.1424 20.5047 18184 13.1047 10.1677

209 8.8182 7.6326 - - -

215 23.2076 11.3170 - - -

220 33.3000 37.4901 - - -

4.4 Discussion

4.4.1 ECGSYN Signals

The test results of the HR estimation algorithm on the ECGSYN signals, illustratedgraphically in Fig. 4.1 and Fig. 4.2 and numerically in Table 4.2, show an accurate andstable performance for the simulated HR within the range 15–160 BPM with V ≤ 2.4 inall cases, when additive uniformly distributed measurement noise n(t) is zero.Fig. 4.1, as well as Table 4.2, show that a decrease in the ECG sampling frequency leadsto a slight drop in the performance of the HR estimator. Moreover, introducing additiveuniformly distributed measurement noise n(t) into the ECG data results in a significantdrop in the performance of the HR estimator, especially for the HR values higher than120 BPM, as shown in Fig. 4.2 and Table 4.2.

© Uppsala University Adnan Albaba

Page 38: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Online Model-Based Beat-by-beat Heart Rate Estimation 25

It is worth mentioning that the optimization method used for the model-based HRestimation was found to be highly susceptible to local minima. Fig. 4.5 illustrates theeffect of local minima on the performance of the model-based HR estimation, and how aslight change in the HR of the input ECG signal can result in a poor HR estimate.However, the problem of local minima can be overcome by carefully choosing the initialvalue of the parameter Ehr. To do that, the initial value of the parameter Ehr is changedcontinuously to be equal to the arithmetic mean of the previous HR estimates for thetest input ECG signal.Fig. 4.6 confirms the significant improvement in the HR estimates as well as a hugereduction in the resultant squared norm of the residual (RESNORM) for the same testECG input as in Fig. 4.5.Continuously setting the initial value of Ehr to be equal to the arithmetic mean of theprevious HR estimates might not produce the best estimates, as the effect of previouspoor estimates might accumulate and affect the following estimation process over time.

4.4.2 MIT-BIH Database

The results of MIT-BIH Arrhythmia Database, illustrated graphically in Fig. 4.3(b) andnumerically in Table 4.3, show inter-subject variation in performance while maintaininga strong correlation with the true HR values. Fig. 4.3(d) illustrates a part of the ECGtest signal 106 acquired from the MIT-BIH Arrhythmia Database, where the HR of thepatient increases gradually. It is notable that the results of the HR estimator, althoughnot very accurate, correlate with the true values of HR with the correlation coefficient of0.6337.On the other hand, the results of MIT-BIH Normal Sinus Rhythm Database ECG signals,illustrated graphically in Fig. 4.3(a) and numerically in Table 4.3, show higher accuracyas well as robustness to inter-subject variability compared to the MIT-BIH ArrhythmiaDatabase test signals.One factor that affects the performance of the HR estimator is the amplitude scale ofthe ECG signal. Different signal acquisition units may produce results with differentamplitude levels defined by the amplifier gain. While the gain is included in thedescription of each record within the MIT-BIH Databases, a deviation of the amplitudegain may occur within the same record as illustrated in Fig. 4.8(a). Fig. 4.8(b) shows howa variation in the amplitude gain affects the performance of the HR estimator. However,this effect can be neutralized by normalizing the amplitude scale of the ECG beat asdemonstrated in Fig. 4.8(c).

© Uppsala University Adnan Albaba

Page 39: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Online Model-Based Beat-by-beat Heart Rate Estimation 26

Figure 4.5: The effects of local minima onthe performance of the HRestimator. (a) the estimatedheart rates for 51 beats with trueHR between 96 and 101 coveredwith the step 0.1, the initialvalue of Ehr was set to 15, Fs =360 Hz, and n(t) = 0 mV. Pointsmarked with (o) represent thetrue HR values, while (x)represent the HR estimates. (b)shows the resultant squarednorm of the residual foroptimization procedures in (a).

Figure 4.6: Tuning the initial value of Ehrimproves the performance of theHR estimator by overcominglocal minima issue illustrated inFig. 4.5. (a) the estimated heartrates for 51 beats with true HRbetween 96 and 101 coveredwith the step 0.1, Fs = 360 Hzand n(t) = 0 mV. Points markedwith (o) represent the true HRvalues, while (x) represent theHR estimates. (b) the resultingsquared norm of the residual foroptimization procedures in (a).

© Uppsala University Adnan Albaba

Page 40: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Online Model-Based Beat-by-beat Heart Rate Estimation 27

Figure 4.7: The difference in morphology between one ECG beat taken from theMAX-ECG-MONITOR sitting test signal with true HR equals to 86 BPM (inBlue), and a synthetic ECG beat with true HR equals to 86 BPM generated bythe ECGSYN model (in orange). It also shows the same ECG beat generatedby ECGSYN model after being modified by tuning its parameters to fit withthe MAX-ECG-MONITOR beat (dashed line in yellow).

4.4.3 MAX-ECG-MONITOR

The results of the HR estimation tests on data from the MAX-ECG-MONITOR, seeFig. 4.3(c) and numerical values in Section 4.3.4, show a good accuracy, especially in thestand-up position with an RMSE value V = 3.7804. However, the level of accuracy dropsin both sitting and running tests, scoring V = 6.9174 and V = 9.5156, respectively.While this drop can be attributed to the presence of motion artifacts in the case of therunning test and the lack of digital denoising, it does not hold in the case of the sittingtest.A combination of the following two points could explain the accuracy drop:

• As illustrated in Fig. 4.4, the MAX-ECG-MONITOR uses a ground-free ECG elec-trodes configuration. This means that the produced ECG waveform is differentfrom the conventional ECG Lead II waveform. The ground-free ECG setup resultsin an ECG waveform with suppressed P and T-waves, as illustrated in Fig. 4.7.

• The parameters ai, i = P, . . . , T related to the amplitude of the ECG fiducial pointsare assigned fixed values and not estimated in the model-based HR estimator.Consequently, the algorithm will attribute a change in the amplitude to a changein HR.

© Uppsala University Adnan Albaba

Page 41: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Online Model-Based Beat-by-beat Heart Rate Estimation 28

A possible solution would be to personalize the model metrics by assigning relativevalues to the parameters ai, i = P, . . . , T as illustrated in Fig. 4.7 by the ECG signal indashed line. Unfortunately, this was proven inefficient for the following two reasons:

• As explained in Section 4.1, the QT-interval is related to the change in HR. However,the QRS complex tends to be least affected by the HR and therefore, shows smallchanges with the change in HR. This is due to the relatively short time that ittakes for the action potential to travel through the Purkinje fibers between theendocardium and the epicardium, which is represented by the QRS complex. Thiswas further investigated in [21].

• The sampling frequency of the MAX-ECG-MONITOR is Fs = 128Hz, which isrelatively low and narrows the bandwidth of the HR-related QRS changes inmorphology. This leads to the optimization procedure mostly diverging to thelower or the upper bounds of the fitted parameters, which in this case is the HR.

To address this issue, a model-based HR estimation method, tailored to the MAX-ECG-MONITOR by utilizing all the 15 parameters grouped in a suitable way, can be exploredin a future work.

4.4.4 Limitations

Currently, the model-based HR estimation method, as presented, is limited by thefollowing factors:

1. Lead configuration: the performance of the presented method is highly dependenton the ECG morphology represented by a specific lead configuration. Therefore,different lead configurations, as well as different lead placement relative to theheart, would lead to different HR estimates. The method was tested on modifiedLead II ECG signals only. Moreover, the ECGSYN tool generates ECG signalssimilar to those acquired using Lead II configuration illustrated in Fig. 3.1.

2. Noise component: the signal-to-noise ratio (SNR) was found to be inversely pro-portional to the RMSE, as shown in Table 4.2.

3. Abnormal morphology: since the model-based HR estimation method makes useof the slight variations in the morphological features of the tested ECG beat, it isbasically assumed that these features are not affected by any source other thanthe change in HR. Therefore, pathological-related abnormalities are not taken intoaccount so far.

4. Beat isolation: it is essential to isolate every ECG beat before performing the mea-surements. Isolation process can be performed using the RR-interval informationor ECG segmentation methods [52].

© Uppsala University Adnan Albaba

Page 42: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Online Model-Based Beat-by-beat Heart Rate Estimation 29

(a)

(b) (c)

Figure 4.8: (a) A one-minute segment of the ECG record 106 acquired from the MIT-BIHArrhythmia Database, where the amplitude of the signal changes during theprocess of the ECG acquisition. (b) HR estimates vs. true values plot for thetest sample shown in (a). A significant change in the performance of the HRestimator after the point where the amplitude of the ECG signal changeswhich denoted by the black arrow is shown. (c) Amplitude scaling of theECG segment normalizing the amplitude scale of the ECG segment shown inFig. 4.8(a) cancels out the effect of the changing amplitude shown in (b).

© Uppsala University Adnan Albaba

Page 43: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Patient-Specific ECG Monitoring by Model-Based Stochastic Anomaly Detection 30

5 Patient-Specific ECG Monitoring byModel-Based Stochastic AnomalyDetection

This Chapter is dedicated to present a novel model-based stochastic anomaly detectionapproach to ECG monitoring. The utility of the presented method is demonstrated onpatient data recorded in clinical setting.A beat detector and classifier producing good results for a certain training database canperform inconsistently, when dealing with a different patient cohort thus effectivelypreventing reliable solutions for automated ECG processing. Individualized detection ofECG beat morphology deformation addresses this issue and can be implemented usinga combination of model-based techniques and stochastic anomaly detection methods.

5.1 Theory

In order to individualize the ECG analysis process, patient-specific profiles are required.Given a mathematical model, these profiles comprise the estimated parameter distribu-tions corresponding to normal ECG beats. The calibration of these profiles is done byestimating the amplitude-related parameters of the ECG dynamical model, see Section 3,by fitting it to the ECG beats registered under normal conditions. A probability distri-bution function (PDF) is then estimated for the specific patient describing how thoseparameters vary.Initial estimates of time and amplitude-related parameters as well as HR are requiredfor generating synthetic ECG signals, see Section 3.2.1. To reduce the overhead of theoptimization problem, only the amplitude-related parameters are fitted and tested foranomaly detection. This was made possible by assigning the time-related parametersfixed values. However, fixing the HR value renders the fitting process inefficient due tothe relation between the HR and the width of the ECG cycle, see Section 4.1, hence thetrue z coordinates for each fiducial point will be shifted from the model-based ones. Toovercome this issue, period normalization is employed, see Section 5.2.2.Given a patient-specific profile, isolated ECG beats can be tested to decide whetherthey are normal or not by utilizing an anomaly detection algorithm. Anomaly detectionis the process of identification of rare items (anomalous observations) in a data set,i.e. data points that are suspicious as being significantly different from the majorityof the data [53], [54]. Typically, the detected anomaly will correspond to some kind of

© Uppsala University Adnan Albaba

Page 44: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Patient-Specific ECG Monitoring by Model-Based Stochastic Anomaly Detection 31

problem which in the present case is a pathological condition. In this work, a stochasticanomaly detection algorithm proposed in [23] and successfully applied to the analysisof eye-tracking data in [24] is utilized.

5.2 Methods

The ECGSYN model, presented in Section 3.2.1, is considered in this Chapter.The ECG signal provides direct information on the conduction of the electrical impulsesin the heart. In other words, the incidence of any type of abnormality in the ECGindicates either an artifact or a pathological episode, see Section 2.3. The timing andamplitude features of ECG beats are used as indicators for such abnormal activities.In this study, the coordinate z of each fiducial point (i.e. ai) is utilized to capturethe morphological changes in the ECG beat. Therefore, the model individualizationis reduced to estimating five parameters from the measured ECG by means of five-dimensional gradient descent in the parameter space. The complexity and, consequently,the computational time of the optimization problem are further reduced by assigning thetime-related parameters of each fiducial point (i.e. bi and θi) to fixed values, which opera-tion is performed through period normalization, see Section 5.2.2. This parametrization,along with appropriate upper and lower bounds, drastically reduces the computationaloverhead.As mentioned in the previous Chapter, the described ECG dynamical model is imple-mented in MATLAB by the function ecgsyn.m [45]. The MATLAB function ode45.m isused to numerically integrate the set of the ordinary differential equations in (3.1)–(3.3),producing a simulated ECG waveform in Fig. 3.1.

5.2.1 Preprocessing

The first step before estimating the model parameters is to segment the ECG data andisolate every cycle with the corresponding main features, i.e. P, Q, R, S, and T-waves.The number of samples in the isolated cycle is of minor importance as it can easily becompensated for in a later step by zero padding or truncation. Then, RR-intervals arecalculated by subtracting the occurrence times of every two consecutive R-peaks.The next step is to perform beat isolation by considering the starting point for one beatcycle to be the number of samples equal to a half of the corresponding RR-interval beforethe R-peak and vise-versa. All isolated beats must then be de-trended to set the baselineand comply with the assumption of zero z-offset. Lastly, the R-peak of the observedECG cycle and the R-peak of the estimated model output must be centered at the samepoint, e.g. at zero.Now the isolated ECG beats undergo both amplitude and period normalization. Theamplitude normalization step results in each isolated ECG beat having the peak-to-peakvoltage Vpp equal to 1.573V, which is the Vpp value for an ECG beat generated by the

© Uppsala University Adnan Albaba

Page 45: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Patient-Specific ECG Monitoring by Model-Based Stochastic Anomaly Detection 32

Figure 5.1: A flow chart illustrating the main steps of the proposed periodnormalization technique.

ECGSYN model at a HR equal to 60BPM. The period normalization step is discussed inthe next Section.It is worth noting that the amplitude-related morphological features of the ECG beatsare preserved after applying the amplitude scaling.

5.2.2 Period Normalization

The morphology of the ECG beat is related to the change in HR [44], which means thateach HR requires its own PDF of the model parameters. To overcome this issue, all ECGbeats are normalized to a HR equal to 60BPM using period normalization.A simplified version of the scheme presented in [55] was developed for the purpose ofnormalizing the time scale of the tested ECG beats. The flow chart in Fig. 5.1 illustratesthe proposed period normalization technique, which is based on the following steps:

1. Perform Singular Value Decomposition (SVD) on a column vector Y ∈ RN rep-resenting the ECG beat segment. Let ‖Y‖2 , 0,u = Y/‖Y‖2, and U ∈ RN×(N−1)

be a matrix with orthonormal columns such that UᵀY = 0. With U = [u,U],Σ = [‖Y‖2,0, . . . ,0]ᵀ, and V = 1, it applies that Y = UΣ.

2. The desired scaling factor is decided according to the length of the ECG beat Y.The next step will be either:

• Zero padding of Σ ∈RN×1: in case of positive scaling factor (i.e. stretching),resulting in Σ1 ∈RM×1, where N < M

• Truncation of Σ ∈ RN×1: in case of negative scaling factor (i.e. shrinking),resulting in Σ1 ∈RM×1, where M < N.

3. The left singular vectors U ∈RN×N will undergo either:

• Increase in dimension N: in case of positive scaling factor (i.e. stretching),resulting in U1 ∈RM×M, where N < M.

• Reduction in dimension N: in case of negative scaling factor (i.e. shrinking),resulting in U1 ∈RM×M, where M < N.

© Uppsala University Adnan Albaba

Page 46: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Patient-Specific ECG Monitoring by Model-Based Stochastic Anomaly Detection 33

Figure 5.2: The results for the period normalization method; (a) depicts the stretching ofa normal ECG beat with HR = 130 BPM, the resultant ECG beat is equivalentto a normal ECG beat with HR = 60 BPM. (b) depicts the shrinking of anormal ECG beat with HR = 60 BPM, the resultant ECG beat is equivalent toa normal ECG beat with HR = 40 BPM. Signals in orange represent theoriginal ECG beats, while those in blue represent the scaled ones.

4. The scaled ECG beat Y1 is then produced by performing the matrix multiplicationY1 = U1Σ1.

Fig. 5.2 illustrates the results for testing the proposed period normalization procedure.

5.2.3 Optimization

Define the model parameter vector as

κ=[

aP aQ . . . aT

]ᵀ, (5.1)

Nonlinear least-squares method is utilized for solving the optimization problem

κ= argminκ

‖g(κ)‖22, (5.2)

g(κ) =

s1(t1)− z1(κ)

s2(t2)− z2(κ)...

sn(tn)− zn(κ)

, (5.3)

where s(t) is the observed ECG beat and z(κ) is the ECGSYN model fit to the ECG signal.The MATLAB function lsqnonlin.m is employed for solving this problem. Choosingthe trust-region-reflective algorithm and setting proper constraints for the optimizer (e.g.upper and lower bounds) appears to be critical for obtaining acceptable performance. It isnoticed that setting the maximum and minimum change in variables for finite-difference

© Uppsala University Adnan Albaba

Page 47: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Patient-Specific ECG Monitoring by Model-Based Stochastic Anomaly Detection 34

gradients in a proper way resulted in a significant performance improvement of theoptimizer. Moreover, adding a feedback from the previous iterations to influence theinitial values of the parameters enhances the performance of the optimization process.

5.2.4 Initial Settings

Before solving (5.2), the initial values for the parameters to be estimated, i.e. ai, i =P, . . . , T, need to be specified. Moreover, the remaining parameters, i.e. bi,θi, i = P, . . . , T,are assigned fixed values. Table 4.1 summarizes the initial values for the ECGSYN modelparameters used further in this work.The sampling frequency is selected equal to that of the input ECG sampling frequencyFs, while the internal sampling frequency is the double of that. The means f1 and f2 areset to 0.1 and 0.25, respectively, while the standard deviations c1 and c2 are both set to0.01. The LF/HF ratio is σ2

1 /σ22 = 0.5 in Eq. (3.8). A is set to 0.15. Ψ is set to 60, and δ is

set to 1 in Eq. (3.9). In this application, It is assumed that z-offset of the ECG signal iseliminated, which can be achieved by setting (z− z0) = 0. Both x and y are set to one.

5.2.5 Stochastic Anomaly Detection

The parameter estimates, obtained from a set of normal ECG beats for a specific individ-ual, are used together with orthogonal series approximation (OSA) to estimate the PDFdescribing the distribution in the ’healthy’ condition. After that, the parameter estimatesof the ECG beats originating from the same subject are tested against the estimated PDFfunctions to statistically determine whether they lie in or outside the ’healthy’ region.OSA offers a non-parametric method for obtaining smooth estimates of the PDF of anunknown distribution [56], [57].Let fX be the PDF of a vector of random variables X. A square-integrable fX ( fX ∈ L2)can be approximated to an arbitrary accuracy by a truncated orthogonal series

fX = ∑i∈J

ci ϕi(x), x ∈ D, (5.4)

where,ci =

∫D

fX(x)ϕi(x) dx, (5.5)

ϕi(x) are the L2 basis functions, and J is a finite set of integers. Since fX is a probabilitydensity, the coefficients in (5.4) are given by

ci = E{ϕi(X)}, (5.6)

and, therefore, estimated as

ci =1

Ns

Ns

∑j=0

ϕi(xj), xj ∈RN , (5.7)

© Uppsala University Adnan Albaba

Page 48: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Patient-Specific ECG Monitoring by Model-Based Stochastic Anomaly Detection 35

where x1, . . . , xNs are observations of the underlying stochastic variable.The complete set of orthonormal Hermite functions is comprised by

{ϕn(x)} ={√

det(Γ)φn(Γ(x− µ))

}, x ∈RN . (5.8)

ϕn is the complete set of one-dimensional Hermite function, the matrix Γ ∈RN×N andthe vector µ ∈RN are the parameters for scaling and translating the basis functions. TheHermit functions, {ϕn(x)}, are given by

φn(x) =1√

2nn!πe−(xT x)/2Hn, (5.9)

where the physicists’ Hermite polynomials [58] are

Hn = 2n2 Hen(

√2x). (5.10)

and the probabilists’ Hermite polynomials [58] are

Hen = (−1)ne(xT x)/2 ∂n

∂xn e−(xT x)/2. (5.11)

By choosing the vector µ to be the sample mean of the observations xi, as in (5.12), thenumber of the Hermit functions, required in the truncated series to achieve a givenestimation error, is reduced [56]

µ =1

Ns

Ns

∑i=1

xi. (5.12)

The diagonal elements of Γ, when defined as a diagonal matrix, dictate the width ofthe functions in the corresponding dimension. Choosing Γ so that the functions are toonarrow will increase the required function order for accurate estimation. On the otherhand, choosing Γ so that the functions are too wide will reduce the significance of singleobservations [24].

5.2.6 Decision Making

The decision on whether a heart beat is normal or abnormal is made based on a two-levelscheme:

1. Parameter-level: In this step, the algorithm decides whether the estimated value ofa parameter, i.e. ai, i = P, . . . , T, corresponds to an abnormal feature morphology(i.e. an outlier) or not. This is done by testing the hypothesis {H0: x is an observa-tion of X}, where x ∈RN is the estimated parameter value. Generally, finding theoutlier region K of the random variable, i.e. all x for which H0 is rejected, can be a

© Uppsala University Adnan Albaba

Page 49: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Patient-Specific ECG Monitoring by Model-Based Stochastic Anomaly Detection 36

Figure 5.3: The ROC curves and their corresponding AUC for three differentcombinations of features of the presented classifier.

way for making such decision.The probability that x lies in K is calculated as

P(X ∈ K) =∫

KfX(x) dx, (5.13)

The method used for deciding if x is an outlier or not, is presented in [59].Finding K of a PDF e, can be achieved using the following steps:

• Evaluate e for the finite set of grid points {hi}Li=1, uniformly spaced, to obtain

{ei}Li=1, where L is the length of e.

• Sort {ei}Li=1 in ascending order.

• Find B such that ∑Bi=1 e(i) ≤

P(X∈K)A < ∑B+1

i=0 e(i), where the area of the gridelement is denoted by A.

• Equation (5.14) results in an approximation of K, K

K = hi : e(hi) ≤ e(B) = γT, (5.14)

where, γT equals to the largest term in the sum ∑Bi=1 e(i) ≤

P(X∈K)A .

The result for the Parameter-level test will then be a 5-elements logical array Λ,i.e. Λ = (True/False, True/False, True/False, True/False, True/False), where eachelement corresponds to a parameter, i.e. ai, i = P, . . . , T. True indicates that the

© Uppsala University Adnan Albaba

Page 50: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Patient-Specific ECG Monitoring by Model-Based Stochastic Anomaly Detection 37

estimated value for the corresponding parameter was found abnormal, and vice-versa.

2. Beat-level: Here, the algorithm decides whether the morphology of a certain heartbeat is normal or abnormal. To do this, Λ is first converted into a numericalvector Λ ∈ R1×5, where True is 1 and False is 0, i.e. Λ = (1/0,1/0, . . . ). Next, theWeighted Average of the entries of Λ is tested against the classification threshold,see Section 5.2.7, for classifying the ECG beat.

5.2.7 Feature Selection and Classification-Threshold Tuning

The receiver operating characteristics curve (ROC), along with the area under the curve(AUC), are used for selecting the most relevant features as well as deciding the classi-fication threshold. The ROC is the graphical plot of the true positive rate RTP againstthe false positive rate RFP that characterizes the performance of a binary classificationsystem as a function of the classification threshold value. After selecting the optimalclassification threshold, it is used by the algorithm to classify the ECG beats.To come up with a set of features that optimizes the performance of the presentedmethod, each feature (i.e. ai, i = P, . . . , T) is evaluated individually. Table 5.1, whichshows the qualitative evaluation of the results for a Parameter-Level test using 678 ECGbeats, indicates that the features aP, aR, aT corresponding to P, R and T-waves yield thebest trade-off between the hits and the misses in both normal and abnormal cases. It isalso clear that the feature aT, corresponding to the T-wave, produces the best results.Hence, the influence of the feature aT in decision-making is doubled by a weightingfactor. The resulting feature combination is called PR2T and comprises the sum of thelogical values that correspond to the features aP, aR, aT, with feature aT multiplied bytwo. Note that the feature aS corresponding to the S-wave was ignored as it exhibits toohigh RFP, i.e. Type II error, and is not suitable for early detection of ECG abnormalities.On the other hand, the feature aQ corresponding to the Q-wave was also ignored as itresulted in the lowest accuracy among all features.The ROC curves for three different combinations of features in Fig. 5.3 support the choiceof the feature combination PR2T and shows that it produces the highest AUC.To tune the classification threshold, the ROC curve method was used. The point with theoptimal trade-off between RTP and RFP, denoted with a black dot in Fig. 5.3, correspondsto a threshold of 0.25, which value is selected as the classification threshold.In conclusion, Λ will be a 3-elements numerical vector, i.e. Λ = (lP, lR, 2lT). The WeightedAverage of Λ, i.e. (lP+lR+2lT)

4 , is then compared with the classification threshold 0.25, sothat if it is less than or equal to 0.25, the ECG beat will be classified as normal beat, orabnormal if the Weighted Average of Λ is greater than 0.25.

© Uppsala University Adnan Albaba

Page 51: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Patient-Specific ECG Monitoring by Model-Based Stochastic Anomaly Detection 38

5.2.8 Ground Truth

The MIT-BIH Arrhythmia Database [46] provides RR-intervals information as part of itsannotation files. It also contains detailed information about the selection criteria, ECGlead configuration, digitization process, annotations and symbols used in the records,which can be found in the MIT-BIH Arrhythmia Database Directory. Equally, the MIT-BIH Atrial Fibrillation Database [60] provides annotation files for all the records. Usingthe annotation files, each ECG beat can be marked according to its pathological state.Sets of normal and abnormal beats, grouped per type of abnormality, are then used asthe ground truth for the evaluation process.

5.3 Results

In order to evaluate the performance of the presented method, the algorithm is testedon real-life ECG signals, and, for that end, the large online bank of physiological signaldatasets, provided at Physionet website [47], was used. Specifically, the MIT-BIHArrhythmia Database [46] as well as the MIT-BIH Atrial Fibrillation Database [60].As mentioned in the previous Chapter, the MIT-BIH Arrhythmia Database contains 4830-minutes-long recordings of two-channel ambulatory ECG obtained from 47 differentsubjects at the BIH Arrhythmia Laboratory. On the other hand, The MIT-BIH AtrialFibrillation Database includes 25 long-term ECG recordings of human subjects withatrial fibrillation (mostly paroxysmal).Tests were performed on the modified Lead II ECG signals only, as the morphologies inthe used ECG model are modeled after Lead II. It is worth mentioning that ECG Lead IIis widely applied in wearable ECG solutions as it gives a good view of the P-wave andit is most commonly used to record the rhythm strip [49].The total number of ECG beats that were involved in this work is 2275 ECG beats. Ofthose, 677 ECG beats were utilized for the calibration steps. The total number of normalECG beats that were used to tune the classification threshold is 678. The total number ofabnormal ECG beats that were used to tune the classification threshold is 457, dividedas follows: 156 PVC beats, 127 PAC beats, 15 APAC beats, 42 AFL beats, 64 AFIB beats, 3VT beats, and 50 RBBB beats. The total number of normal ECG beats that were used forthe final evaluation of the algorithm with the tuned constant classification threshold, is201, while the total number of abnormal ECG beats that were used for this purpose is262, divided as follows: 86 PVC beats, 86 AFIB beats, and 90 RBBB beats. The ECG beatswere acquired from 13 patients.Based on the provided annotation files, every beat was isolated, segmented, and pre-processed, as described in Section 5.2.1, before estimating the amplitude-related parame-ters for each fiducial point.Fig. 5.4 depicts the distributions of the estimated parameters ai,i = R,S, T, correspondingto the most characteristic and prominent features (R, S and T-waves), in case of both

© Uppsala University Adnan Albaba

Page 52: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Patient-Specific ECG Monitoring by Model-Based Stochastic Anomaly Detection 39

Table 5.1: Qualitative Evaluation of the Results for the Decisions in the Parameter-LevelUsing the Training Data

Feature TP FN TN FP ACC

P 254 203 583 95 73.7%

Q 221 236 579 99 70.4%

R 303 154 521 157 72.5%

S 344 113 499 179 74.2%

T 344 113 603 75 83.4%

normal and abnormal ECG beats for different patients. Only three features are shown tofacilitate the visual presentation.

5.3.1 Quantitative Evaluation

In this study, the following metrics were used for evaluating the performance of thealgorithm quantitatively:

• True positives (TP): Indicates the number of correctly detected abnormal ECGbeats.

• False positives (FP): Indicates the number of incorrectly detected abnormal ECGbeats, i.e. a missed normal ECG beats.

• True negatives (TN): Indicates the number of correctly detected normal ECG beats.

• False negatives (FN): Indicates the number of incorrectly detected normal ECGbeats, i.e. a missed abnormal ECG beats.

• Area under curve (AUC): Is the area under the ROC curve.

• True positive rate (RTP) = (TP)(TP)+(FN)

.

• False positive rate (RFP) = (FP)(FP)+(TN)

.

• Accuracy (ACC) = (TP)+(TN)(TP)+(TN)+(FP)+(FN)

.

Table 5.1 summarises the qualitative results for the parameter-level decisions made on678 ECG beats, which were used for tuning the classification threshold. The (accuracy,sensitivity, and specificity) for each parameter respectively are: P (73.7%, 55.6%, 86.0%),Q (70.4%, 48.3%, 85.4%), R (72.5%, 66.3%, 76.8%), S (74.2%, 75.3%, 73.5%), and T (83.4%,73.5%, 88.9%).Fig. 5.5(a) presents the confusion matrix for the PR2T classifier on the same data thatwere used for tuning the classification threshold, which scored accuracy, sensitivity,and specificity equal to 84.0%, 84.7%, and 82.9%, respectively. Fig. 5.5(b), on the otherhand, depicts the confusion matrix for the final setup, PR2T classifier along with the 0.25

© Uppsala University Adnan Albaba

Page 53: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Patient-Specific ECG Monitoring by Model-Based Stochastic Anomaly Detection 40

(a) (b) (c)

(d) (e) (f)

(g) (h) (i)

Figure 5.4: The distributions of the features aP, aR, aT, corresponding to P (X-axis), R(Y-axis) and T-waves (Z-axis), for different patients in both normal andabnormal cases; (a), (b) and (c) depict the distribution of the estimatedparameters in normal case, AFIB and AFL respectively; (d) and (e) depict thedistribution of the estimated parameters in case of normal and PAC beats,respectively; (f) and (g) depict the distribution of the estimated parameters incase of normal and RBBB beats, respectively; (h) and (i) depict thedistribution of the estimated values parameters in case of normal and PVCbeats, respectively. Estimates for normal beats (training) are marked withblue (O), and estimations of normal and abnormal testing beats are markedwith orange (X).

© Uppsala University Adnan Albaba

Page 54: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Patient-Specific ECG Monitoring by Model-Based Stochastic Anomaly Detection 41

(a) (b)

Figure 5.5: (a) and (b) depict The confusion matrices for the PR2T-based classifier inboth cases of tuning the classification threshold and the final evaluation ofthe presented algorithm, respectively.

classification threshold, on the validation data. The accuracy, sensitivity, and specificityare 89.0%, 77.6%, and 97.7%, respectively.

5.4 Discussion

5.4.1 Methodology

The main objective of this work was to develop and investigate the utility of the model-based stochastic anomaly detection method for ECG monitoring. Hence, less focus wasput on other aspects, e.g. the feature selection step. In this work, a heuristic approachwas used for selecting the features. The performance of each feature was evaluatedindividually and, based on the results shown in Table 5.1, the set of features to use inthe algorithm was decided. It is worth noting that there are several methods for featureselection, in which every possible combination of features is tested (i.e. sub-set selectionusing wrapper method).While choosing the classification threshold, the priority was reducing the number of FN(or the missed abnormal beats) as well as maximizing the RTP (or the correctly detectedabnormalities). Tuning the classification threshold to 0.25, so that all the ECG beats withcorresponding classification merit larger than or equal to 0.25 are classified as abnormalbeats and vise-versa, was found to be an optimal choice to serve the mentioned priority.When choosing the ECG records to be tested, it was found that all the records from theMIT-BIH Arrhythmia Database with Left Bundle Branch Block episodes do not includeany normal ECG beats. Hence, these records could not be used in the tests.

© Uppsala University Adnan Albaba

Page 55: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Patient-Specific ECG Monitoring by Model-Based Stochastic Anomaly Detection 42

5.4.2 Results

The results for the qualitative evaluation of the final setup (PR2T classifier along withthe 0.25 classification threshold), see Fig. 5.5(b), show high potential of the model-basedstochastic anomaly detection classifier. Out of 262 abnormal ECG beats, the algorithmsuccessfully detected 256 abnormal ECG beats, and missed only 6. On the other hand,the algorithm mistakenly classified 45 normal ECG beats out of 201 as abnormal ECGbeats. As mentioned in the previous subsection, this is due to the trade-off between thetolerated number of FN and FP. The presented algorithm scored a precision (positivepredictive value) = 89%.It is notable in Fig. 5.4 that the estimated values of the parameters (i.e. ai,i = P, . . . , T)for normal and abnormal ECG beats are well separated in the parameter space. Thisindicates that the underlying dynamics that generate the ECG waveform are well cap-tured, thanks to the model-based approach using a dynamical ECG model. It alsoraises the chances that a supervised model-based classifier can be built for classifyingabnormalities in any given ECG segment.

5.4.3 Limitations

Currently, the model-based stochastic anomaly detection method, as presented, is limitedby the following factors:

1. Lead configuration: the performance of the presented method is highly dependenton the ECG morphology represented by a specific lead configuration. Therefore,different lead configurations, as well as different lead placement relative to theheart, would lead to different parameter estimates. The method was tested onmodified Lead II ECG signals only. Moreover, the ECGSYN tool generates ECGsignals similar to those acquired using Lead II configuration illustrated in Fig. 3.1.

2. Noise component: estimated parameters will be highly effected by noise, especiallygiven that the parameters to be estimated (i.e. ai,i = P, . . . , T) correspond to thevariations in the coordinate z of each fiducial point.

3. Beat isolation: an essential step in the presented scheme is to isolate every ECGbeat before performing the measurements, see 5.2.1.

© Uppsala University Adnan Albaba

Page 56: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Conclusion 43

6 Conclusion

Model-based ECG analysis is considered and demonstrated on synthetic signals as wellas patient data recorded in clinical and wearable setups.Unlike most of the existing techniques, model-based ECG analysis takes into accountthe nature of the underlying dynamics that actually generate the ECG waveform as wellas the disturbances that may affect it. Once fitted to a segment of ECG signal, the modeloutput provides a filtered version of that signal. Moreover, it can detect wave onsetsand offsets using the estimated parameters allowing to switch from analyzing datapoints to capturing the complete signal waveform, which is highly suitable in wearableapplications.To illustrate the utility of the proposed approach, a novel model-based method forinstantaneous HR estimation has been introduced, tested, and discussed in this the-sis. Moreover, a novel model-based stochastic anomaly detection approach to ECGmonitoring has been introduced, tested, and discussed in this thesis.While not being as accurate as the conventional HR estimation methods, the model-basedmethod for instantaneous HR estimation method needs only one ECG cycle insteadof two or more utilized by the conventional methods. The model-based ECG analysisshows thus promise in early detection of cardiac rhythm conditions and is especiallysuitable in wearable applications.As for the model-based stochastic anomaly detection approach, the proposed methoddoes not require large sets of training data and a one-minute train of normal ECG beatswill be enough for the algorithm to build the necessary PDFs for each fiducial point.Another advantage for this method is that it does not require a set of abnormal ECGbeats for the training phase.Unlike most of the relevant methods available in the literature, see Section 1.3, thismethod provides a truly patient-specific approach with less needed resources and timeof computations, making it especially suitable for early detection of heart abnormalitiesin point-of-care medical applications.This work can possibly be extended in the future as following; tailor-made model-basedHR estimation algorithm for a wearable ECG monitor, e.g. MAX-ECG-MONITOR, canbe investigated and implemented. Moreover, model-based ECG analysis can be utilizedfor new range of related applications such as ECG signal quality indices.

© Uppsala University Adnan Albaba

Page 57: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Literature 44

Literature

[1] WHO. (2019). ’About cardiovascular diseases’, [Online]. Available:https://www.who.int/cardiovascular_diseases/about_cvd/en/.

[2] H. L. Brooke et al., “The Swedish cause of death register”, European Journal ofEpidemiology, 2017.

[3] R. Kamal and B. Sawyer. (2017). ’What do we know about cardiovascular diseasespending and outcomes in the United States?’, [Online]. Available:https://www.healthsystemtracker.org/chart-collection/know-cardiovascular-disease-spending-outcomes-united-states/#item-start.

[4] H. Smulyan, “The computerized ecg: Friend and foe”, The American journal ofmedicine, vol. 132, no. 2, pp. 153–160, 2019.

[5] P. Davey, “A new physiological method for heart rate correction of the qtinterval”, Heart, vol. 82, no. 2, pp. 183–186, 1999.

[6] V. N. Batchvarov, A. Ghuran, P. Smetana, K. Hnatkova, M. Harries, P. Dilaveris,A. J. Camm, and M. Malik, “Qt-rr relationship in healthy subjects exhibitssubstantial intersubject variability and high intrasubject stability”, AmericanJournal of Physiology-Heart and Circulatory Physiology, vol. 282, no. 6, H2356–H2363,2002.

[7] D. E. Krummen, M. Patel, H. Nguyen, G. Ho, D. S. Kazi, P. Clopton,M. C. Holland, S. L. Greenberg, G. K. Feld, M. N. Faddis, et al., “Accurate ecgdiagnosis of atrial tachyarrhythmias using quantitative analysis: A prospectivediagnostic and cost-effectiveness study”, Journal of cardiovascular electrophysiology,vol. 21, no. 11, pp. 1251–1259, 2010.

[8] L. Senhadji, G. Carrault, J. Bellanger, and G. Passariello, “Comparing wavelettransforms for recognizing cardiac patterns”, IEEE Engineering in Medicine andBiology Magazine, vol. 14, no. 2, pp. 167–173, 1995.

[9] L.-Y. Shyu, Y.-H. Wu, and W. Hu, “Using wavelet transform and fuzzy neuralnetwork for vpc detection from the holter ecg”, IEEE Transactions on BiomedicalEngineering, vol. 51, no. 7, pp. 1269–1273, 2004.

© Uppsala University Adnan Albaba

Page 58: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Literature 45

[10] M. Lagerholm, C. Peterson, G. Braccini, L. Edenbrandt, and L. Sornmo,“Clustering ecg complexes using hermite functions and self-organizing maps”,IEEE Transactions on Biomedical Engineering, vol. 47, no. 7, pp. 838–848, 2000.

[11] R. V. Andreao, B. Dorizzi, and J. Boudy, “Ecg signal analysis through hiddenmarkov models”, IEEE Transactions on Biomedical engineering, vol. 53, no. 8,pp. 1541–1549, 2006.

[12] M. I. Owis, A. H. Abou-Zied, A.-B. Youssef, and Y. M. Kadah, “Study of featuresbased on nonlinear dynamical modeling in ecg arrhythmia detection andclassification”, IEEE transactions on Biomedical Engineering, vol. 49, no. 7,pp. 733–736, 2002.

[13] B. Ribeiro, A. Marques, J. Henriques, and M. Antunes, “Premature ventricularbeat detection by using spectral clustering methods”, in 2007 Computers inCardiology, IEEE, 2007, pp. 149–152.

[14] Q. Zhao and L. Zhang, “Ecg feature extraction and classification using wavelettransform and support vector machines”, in 2005 International Conference on NeuralNetworks and Brain, IEEE, vol. 2, 2005, pp. 1089–1092.

[15] E. Zellmer, F. Shang, and H. Zhang, “Highly accurate ecg beat classification basedon continuous wavelet transformation and multiple support vector machineclassifiers”, in 2009 2nd International Conference on Biomedical Engineering andInformatics, IEEE, 2009, pp. 1–5.

[16] E. D. Übeyli, “Ecg beats classification using multiclass support vector machineswith error correcting output codes”, Digital Signal Processing, vol. 17, no. 3,pp. 675–684, 2007.

[17] Y. H. Hu, S. Palreddy, and W. J. Tompkins, “A patient-adaptable ecg beat classifierusing a mixture of experts approach”, IEEE transactions on biomedical engineering,vol. 44, no. 9, pp. 891–900, 1997.

[18] A. Ruha, S. Sallinen, and S. Nissila, “A real-time microprocessor qrs detectorsystem with a 1-ms timing accuracy for the measurement of ambulatory hrv”,IEEE Transactions on Biomedical Engineering, vol. 44, no. 3, pp. 159–167, 1997.

[19] P. E. McSharry, G. D. Clifford, L. Tarassenko, and L. A. Smith, “A dynamicalmodel for generating synthetic electrocardiogram signals”, IEEE transactions onbiomedical engineering, vol. 50, no. 3, pp. 289–294, 2003.

[20] G. Clifford, A. Shoeb, P. McSharry, and B. Janz, “Model-based filtering,compression and classification of the ecg”, International Journal ofBioelectromagnetism, vol. 7, no. 1, pp. 158–161, 2005.

© Uppsala University Adnan Albaba

Page 59: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Literature 46

[21] M. M. Tawfik and H. S. T. Kamal, “Human identification using qt signal and qrscomplex of the ecg”, Online J Electron Electr Eng (OJEEE), vol. 3, pp. 1–5, 2011.

[22] S. A. Israel, J. M. Irvine, A. Cheng, M. D. Wiederhold, and B. K. Wiederhold, “Ecgto identify individuals”, Pattern recognition, vol. 38, no. 1, pp. 133–142, 2005.

[23] O. Rosen and A. Medvedev, “An on-line algorithm for anomaly detection intrajectory data”, in 2012 American Control Conference (ACC), IEEE, 2012,pp. 1117–1122.

[24] D. Jansson, A. Medvedev, H. Axelson, and D. Nyholm, “Stochastic anomalydetection in eye-tracking data for quantification of motor symptoms inparkinson’s disease”, in Signal and Image Analysis for Biomedical and Life Sciences,Springer, 2015, pp. 63–82.

[25] Wikipedia. (2019). ’Electrocardiography’, [Online]. Available:https://en.wikipedia.org/wiki/Electrocardiography.

[26] American Heart Association. (2015). ’Electrocardiogram (ECG or EKG)’, [Online].Available: https://www.heart.org/en/health-topics/heart-attack/diagnosing-a-heart-attack/electrocardiogram-ecg-or-ekg.

[27] J. E. Hall, Guyton and hall textbook of medical physiology, 13th. Philadelphia, PA:Elsevier, 2016.

[28] R. Klabunde, Cardiovascular physiology concepts. Lippincott Williams & Wilkins,2011.

[29] B.-U. Kohler, C. Hennig, and R. Orglmeister, “The principles of software qrsdetection”, IEEE Engineering in Medicine and Biology Magazine, vol. 21, no. 1,pp. 42–57, 2002.

[30] P. O. Borjesson, O. Pahlm, L. Sornmo, and M.-e. Nygards, “Adaptive qrs detectionbased on maximum a posteriori estimation”, IEEE Transactions on BiomedicalEngineering, vol. 29, no. 5, pp. 341–351, 1982.

[31] J. Fraden and M. Neuman, “Qrs wave detection”, Medical and BiologicalEngineering and computing, vol. 18, no. 2, pp. 125–132, 1980.

[32] M. Bahoura, M. Hassani, and M. Hubin, “Dsp implementation of wavelettransform for real time ecg wave forms detection and heart rate analysis”,Computer methods and programs in biomedicine, vol. 52, no. 1, pp. 35–44, 1997.

[33] Z. Dokur, T. Ölmez, E. Yazgan, and O. K. Ersoy, “Detection of ecg waveforms byneural networks”, Medical engineering & physics, vol. 19, no. 8, pp. 738–741, 1997.

© Uppsala University Adnan Albaba

Page 60: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Literature 47

[34] D. A. Coast, R. M. Stern, G. G. Cano, and S. A. Briller, “An approach to cardiacarrhythmia analysis using hidden markov models”, IEEE Transactions onbiomedical Engineering, vol. 37, no. 9, pp. 826–836, 1990.

[35] T. Valencell. (2015). ’Optical heart rate monitoring’, [Online]. Available:https://valencell.com/blog/2015/10/optical-heart-rate-monitoring-what-you-need-to-know/.

[36] W. Zong, T. Heldt, G. Moody, and R. Mark, “An open-source algorithm to detectonset of arterial blood pressure pulses”, in Computers in Cardiology, 2003, IEEE,2003, pp. 259–262.

[37] Q. Li, R. G. Mark, and G. D. Clifford, “Robust heart rate estimation from multipleasynchronous noisy sources using signal quality indices and a kalman filter”,Physiological measurement, vol. 29, no. 1, p. 15, 2007.

[38] P. Nickolls, R. M. Lu, K. A. Collins, R. M. McCulloch, L. M. Cheatle, andB. Cleland, Apparatus and method for antitachycardia pacing using a virtual electrode,US Patent 5,181,511, January 1993.

[39] Statista. (2019). ’Number of connected wearable devices worldwide from 2016 to2022 (in millions)’, [Online]. Available: https://www.statista.com/statistics/487291/global-connected-wearable-devices/.

[40] Nuubo. (2019). ’Nuubo wearable ECG’, [Online]. Available:https://www.nuubo.com/.

[41] M. M. Baig, H. GholamHosseini, A. A. Moqeem, F. Mirza, and M. Lindén, “Asystematic review of wearable patient monitoring systems–current challenges andopportunities for clinical adoption”, Journal of medical systems, vol. 41, no. 7, p. 115,2017.

[42] B. He, Modeling & imaging of bioelectrical activity: Principles and applications.Springer Science & Business Media, 2010.

[43] G. D. Clifford, F. Azuaje, P. McSharry, et al., Advanced methods and tools for ecg dataanalysis. Artech house Boston, 2006.

[44] J. W. Mason, F. Badilini, M. Vaglio, R. L. Lux, B. Aysin, T. E. Moon, B. Heinz, andI. Strachan, “A fundamental relationship between intraventricular conductionand heart rate”, Journal of electrocardiology, vol. 49, no. 3, pp. 362–370, 2016.

[45] I. Silva and G. B. Moody, “An open-source toolbox for analysing and processingphysionet databases in matlab and octave”, Journal of open research software, vol. 2,no. 1, 2014.

© Uppsala University Adnan Albaba

Page 61: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Literature 48

[46] G. B. Moody and R. G. Mark, “The impact of the mit-bih arrhythmia database”,IEEE Engineering in Medicine and Biology Magazine, vol. 20, no. 3, pp. 45–50, 2001.

[47] A. L. Goldberger, L. A. Amaral, L. Glass, J. M. Hausdorff, P. C. Ivanov, R. G. Mark,J. E. Mietus, G. B. Moody, C.-K. Peng, and H. E. Stanley, “Physiobank,physiotoolkit, and physionet: Components of a new research resource for complexphysiologic signals”, Circulation, vol. 101, no. 23, e215–e220, 2000.

[48] Adnan Albaba. (2019). ’Group 1 report: Pulse2.0: Wearable system for ecgmonitoring, by adnan albaba’, [Online]. Available:http://www.it.uu.se/edu/course/homepage/projektsystek/2018-395/Kod.

[49] S. Meek and F. Morris, “Introduction. i—leads, rate, rhythm, and cardiac axis”,Bmj, vol. 324, no. 7334, pp. 415–418, 2002.

[50] Maxim Integrated. (2019). ’Maxim integrated analog, linear, and mixed-signaldevices’, [Online]. Available: https://www.maximintegrated.com.

[51] A. R. P. N. Standard. (1998). ’Ansi/aami ec57: Testing and reporting performanceresults of cardiac rhythm and st segment measurement algorithms’, [Online].Available: http://www.aami.org.

[52] I. Beraza and I. Romero, “Comparative study of algorithms for ecg segmentation”,Biomedical Signal Processing and Control, vol. 34, pp. 166–173, 2017.

[53] V. Hodge and J. Austin, “A survey of outlier detection methodologies”, Artificialintelligence review, vol. 22, no. 2, pp. 85–126, 2004.

[54] A. Zimek and E. Schubert, “Outlier detection”, Encyclopedia of Database Systems,pp. 1–5, 2017.

[55] H. Baali, R. Akmeliawati, M. J. Salami, M. Aibinu, and A. Gani, “Transform basedapproach for ecg period normalization”, in 2011 Computing in Cardiology, IEEE,2011, pp. 533–536.

[56] S. C. Schwartz, “Estimation of probability density by an orthogonal series”, TheAnnals of Mathematical Statistics, pp. 1261–1265, 1967.

[57] M. Tarter, R. Kronmal, et al., “On multivariate density estimates based onorthogonal expansions”, The Annals of Mathematical Statistics, vol. 41, no. 2,pp. 718–722, 1970.

[58] F. W. Olver, D. W. Lozier, R. F. Boisvert, and C. W. Clark, Nist handbook ofmathematical functions hardback and cd-rom. Cambridge university press, 2010.

[59] D. Jansson, O. Rosén, and A. Medvedev, “Non-parametric analysis ofeye-tracking data by anomaly detection”, in 2013 European Control Conference(ECC), IEEE, 2013, pp. 632–637.

© Uppsala University Adnan Albaba

Page 62: MODEL-BASED ECG ANALYSIS: TOWARDS PATIENT ...uu.diva-portal.org/smash/get/diva2:1424986/FULLTEXT01.pdfAdnan Albaba In this thesis, model -based analysis approach is considered as a

Literature 49

[60] G. Moody, “A new method for detecting atrial fibrillation using rr intervals”,Computers in Cardiology, pp. 227–230, 1983.

© Uppsala University Adnan Albaba