analysis of electrocardiographic patterns for epileptic ... · 4.1 diagram depicting the sequence...

84
Analysis of Electrocardiographic Patterns for Epileptic Seizure Prediction Francisco Sim˜ ao Fernandes Mendes Sargo Thesis to obtain the Master of Science Degree in Biomedical Engineering Supervisor: Prof. Ana Lu´ ısa Nobre Fred Co-Supervisor: Prof. Carla Cristina Paulo Gabriel Bentes Examination Committee Chairperson: Prof. Jo˜ ao Pedro Estrela Rodrigues Conde Supervisor: Prof. Ana Lu´ ısa Nobre Fred Members of the Committe: Prof. Maria Margarida Campos da Silveira November 2018

Upload: others

Post on 05-Jul-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Analysis of Electrocardiographic Patterns for

Epileptic Seizure Prediction

Francisco Simao Fernandes Mendes Sargo

Thesis to obtain the Master of Science Degree in

Biomedical Engineering

Supervisor: Prof. Ana Luısa Nobre FredCo-Supervisor: Prof. Carla Cristina Paulo Gabriel Bentes

Examination Committee

Chairperson: Prof. Joao Pedro Estrela Rodrigues CondeSupervisor: Prof. Ana Luısa Nobre Fred

Members of the Committe: Prof. Maria Margarida Campos da Silveira

November 2018

Page 2: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the
Page 3: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Le coeur a ses raisons que la raison ignore.

Blaise Pascal

Page 4: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the
Page 5: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Acknowledgments

The work presented in the following pages could not be produced without many invaluable contri-

butions.

First and foremost, I would like thank both Professor Ana Fred and Professor Hugo Silva for the

invaluable input in the form of new creative ideas, corrections, and knowledge. Their contributions

proved to be absolutely fundamental to the development of the processing tools and conclusions pre-

sented in this thesis.

I would also like to thank the relentless guidance from Dr. Carla Bentes and Dr. Rita Neves

for the vital insights into the physiological dynamics behind epileptic seizures, and for providing the

high-quality datasets used to develop this work.

iii

Page 6: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the
Page 7: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Abstract

The gold standard for the diagnosis, automatic detection, and prediction of epileptic seizures is

based on data gathered by long term Electroencephalography (EEG). This modality requires highly

intrusive hardware setup, with limiting aspects such as a great number of electrodes placed on the

subject’s scalp, usually 64 to 128. For this reason, it is typically performed in clinical settings, and it

is often seen as too intrusive by the users.

There is therefore, a need for an ambulatory and comfortable monitoring system to manage seizures,

consisting of a seizure prediction method and possibly a monitoring application based on single lead

Electrocardiography (ECG) , which can be performed with a more user-friendly hardware, and which

can easily be integrated into a wearable system.

The purpose of this work is to evaluate some of the required methodologies to support the develop-

ment of a seizure prediction algorithm based on ECG data from signals acquired in a lead-I setup. It

involves the application of noise and baseline wander removal techniques, detection of fiducial points

and robust computation of morphological and rhythmical features. The work culminates in the at-

tempt to distinguish between inter-ictal and pre-ictal moments, with the use of supervised learning

classifiers such as Support Vector Machines (SVM), K-Nearest Neighbours (KNN), and Gaussian Naive

Bayes (GaussNB). This study comprises N=25 seizures acquired from 5 patients admitted at Santa

Mari a’s Hospital (SMH) in Lisbon.

Keywords

Epilepsy, ECG, Seizure Prediction, Inter-ictal, Pre-ictal, Noise removal, Outlier removal, SVM,

KNN, GaussNB

v

Page 8: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the
Page 9: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Resumo

O Gold standard para o diagonostico, e detecao e previsao automatica de crises epilepticas e baseado

em dados adquiridos por acquisicao EEG(Electroencefalografia) de longa duracao. Esta modalidade

requer um hardware altamenter intrusivo, com aspectos limitativos como um numero elevado de electro-

dos posicionados no couro cabeludo do paciente. Por esta razao, e tipicamente elaborado em ambiente

clınico, e e frequentemente visto como demasiado intrusivo pelos utilizadores. Existe, por isso uma

necessidade para uma solucao em ambulatorio e mais confortavel para controlar as crises, consistindo

number metodo preditivo acquisicao por ECG (Electrocardiografia). E um metodo que reune a apli-

cacao de tecnicas de remocao de ruıdo, detecao de pontos fiduciais e computacao robusta de padroes

morfologicos e rıtmicos. O trabalho culmina na aplicacao de algoritmos de classificacao supervisionados

como SVM’s (Support Vector Machines), KNN (K-Nearest Neighbours) e GaussNB (Gaussian Naive

Bayes). O estudo compreende 25 crises adquiridas de 5 pacientes admitidos no hospital de Santa Maria

em Lisboa.

Palavras-Chave: Epilepsia, ECG, Previsao de Crises, Inter-ictal, Pre-ictal, Remocao de Ruıdo,

Remocao de Outliers, SVM, KNN, GaussNB

vii

Page 10: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Contents

1 Introduction xviii

1.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

1.2 Goals and Proposed Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

1.3 Contributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

1.4 Thesis Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

2 Theory and Underlying Concepts 21

2.1 A Primer on Epilepsy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

2.1.1 Concepts and definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

2.1.2 Etiology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

2.1.3 Classification of seizures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

2.2 Electrocardiography (ECG) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

2.2.1 Cardiovascular Dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

2.2.2 The heartbeat waveform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

2.3 The Cardiovascular properties of epilepsy . . . . . . . . . . . . . . . . . . . . . . . . . . 28

2.3.1 Pre-ictal changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

2.3.2 Underlying mechanisms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

2.3.3 Basis for ECG-based automatic epileptic seizure prediction . . . . . . . . . . . . 31

2.4 ECG Rhythmic Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

2.4.1 Heart rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

2.4.2 Statistical Heart Rate Variability (HRV) features . . . . . . . . . . . . . . . . . . 32

2.4.3 Spectral HRV features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

2.5 ECG Morphological Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

2.5.1 Heartbeat waveform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

2.5.2 Distance between heart-waves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

2.6 Supervised Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

2.6.1 K-nearest neighbors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

2.6.2 Support vector machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

3 State-of-the-art 42

3.1 Electroencephalography based prediction . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

3.2 Cardiac based prediction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

viii

Page 11: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

3.2.1 Use of heart rate features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

4 Methodology 47

4.1 Overall Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

4.2 Data Gathering, Structuring and Database Creation . . . . . . . . . . . . . . . . . . . . 49

4.2.1 Data retrieval from the hospital’s system . . . . . . . . . . . . . . . . . . . . . . 49

4.2.2 Format and building of the raw database . . . . . . . . . . . . . . . . . . . . . . 50

4.2.3 Dataset restructuring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

4.3 Baseline Wander Removal and Denoising . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

4.3.1 Median filters and 11-th order FIR . . . . . . . . . . . . . . . . . . . . . . . . . . 53

4.3.2 Noise and baseline removal examples . . . . . . . . . . . . . . . . . . . . . . . . . 53

4.4 Feature Extraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

4.4.1 ECG heartbeat waveform segmentation . . . . . . . . . . . . . . . . . . . . . . . 57

4.4.2 Segmentation examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

4.4.3 Instantaneous heart rate computation and heart wave extraction . . . . . . . . . 59

4.4.4 Outlier removal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

4.4.5 Computation of features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

4.4.6 Extraction of statistical HRV features . . . . . . . . . . . . . . . . . . . . . . . . 60

4.4.7 Spectral analysis of HRV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

4.4.8 Extraction of morphological features . . . . . . . . . . . . . . . . . . . . . . . . . 62

4.5 Identification of pre-ictal states . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

4.5.1 Leave-one-seizure-out nested cross-validation . . . . . . . . . . . . . . . . . . . . 64

4.5.2 Sample-by-sample classification . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

4.5.3 Features Categorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

5 Experimental Results and Discussion 67

5.1 Dataset Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

5.2 General structure of the results presentation and discussion . . . . . . . . . . . . . . . . 69

5.3 Noise and baseline removal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

5.4 Evaluation of impact on data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

5.5 Patient-specific classification results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

6 Conclusions And Future Work 77

6.1 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

6.2 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

Bibliography 78

ix

Page 12: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the
Page 13: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

List of Figures

2.1 Seizure classification scheme. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

2.2 Electrophisiology of the heart. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

2.3 Depiction of the basic structure of the ECG waveform. . . . . . . . . . . . . . . . . . . . 27

2.4 Representation of the Einthoven triangle. . . . . . . . . . . . . . . . . . . . . . . . . . . 28

2.5 Autonomic symptoms in epilepsy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

2.6 Depiction of the HRV spectrum. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

2.7 Illustration of the process for fixed length heart-wave extraction. . . . . . . . . . . . . . 34

2.8 Illustration of the decision boundary of a support vector machine with radial kernel. . . 40

4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . . 48

4.2 Ilustration of the creation of fixed duration time frames of analysis called seizure sessions

from the raw, continuous data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

4.3 Schematic of the nested processing tree, depicting each group of identified seizure ses-

sions as a combination of processing steps with different hyper-parameters, organized in

a directory-like fashion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

4.4 Diagram depicting the process of baseline removal and denoising. . . . . . . . . . . . . . 53

4.5 General view of a seizure session, with the depiction of denoising and the removal of

baseline wandering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

4.6 View of the denoising of the signal, well before the EEG onset. . . . . . . . . . . . . . . 55

4.7 View of the denoising of the signal, close to the EEG onset. . . . . . . . . . . . . . . . . 55

4.8 View of the denoising of the signal, right after the EEG onset. . . . . . . . . . . . . . . . 56

4.9 Change in signal distribution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

4.10 Depiction of the sequence of steps employed by the Hamilton Algorithm. . . . . . . . . . 57

4.11 General view of the results of R-peaks (RP) detection with the Hamilton algorithm, the

results are seizure session 0 from patient 3. . . . . . . . . . . . . . . . . . . . . . . . . . 58

4.12 View of the signal from seizure session 0 from patient 3, well before the EEG onset. . . 59

4.13 View of the signal close to the EEG onset of the epileptic seizure. . . . . . . . . . . . . . 59

4.14 View of the signal right after the EEG onset of an epileptic seizure. . . . . . . . . . . . . 59

4.15 Comparison of the different methods for power spectral density estimation of the HRV

signal. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

4.16 Process of computation of morphological patterns. . . . . . . . . . . . . . . . . . . . . . 63

xi

Page 14: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

4.17 Figure depicting the labeling criteria of the data within each seizure occurrence. . . . . 64

4.18 Schematic depicting the nested cross-validation scheme used for the training phase. . . . 65

5.1 Depiction of the mean SQI for the application of noise and baseline removal methods in

patient-specific processing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

5.2 Depiction of the classification for the data of Patient 3, results as measured by the

F1-score and as function of the feature groups. . . . . . . . . . . . . . . . . . . . . . . . 71

5.3 Depiction of the classification for the data of Patient 5, results as measured by the

F1-score and as function of the feature groups. . . . . . . . . . . . . . . . . . . . . . . . 71

5.4 Depiction of the classification for the data of Patient 8, results as measured by the

F1-score and as function of the feature groups. . . . . . . . . . . . . . . . . . . . . . . . 72

5.5 Depiction of the classification for the data of Patient 10, results as measured by the

F1-score and as function of the feature groups. . . . . . . . . . . . . . . . . . . . . . . . 72

5.6 Depiction of the classification for the data of Patient 13, results as measured by the

F1-score and as function of the feature groups. . . . . . . . . . . . . . . . . . . . . . . . 72

xii

Page 15: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

List of Tables

4.1 Summary of the extracted features grouped under bi-dimensional patterns with corre-

sponding labels. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

5.1 General description of the data set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

5.2 Description of the Events in the dataset . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

5.3 F1-score Patient-specific classification results for the GaussNB classifier. . . . . . . . . . . . . 74

5.4 F1-score Patient-specific classification results for the KNN classifier. . . . . . . . . . . . . . . 75

5.5 F1-score Patient-specific classification results for the SVC classifier. . . . . . . . . . . . . . . 76

xiii

Page 16: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the
Page 17: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Abbreviations

ANS Autonomic Nervous System

AV Atrio-Ventricular

basSQI Baseline Signal Quality Index

bpm Beats per minute

CAN Central Autonomic Network

CNN Convolutional Neural Networks

ECG Electrocardiography

EDF+ European Data Format

EEG Electroencephalography

EMG Electromyography

FFT Fast Fourier Transform

FPR False Positive Rate

GaussNB Gaussian Naive Bayes

SVC Soft-margin Support Vector Machine

HDF5 Hierarchical Data Format

HF High Frequency

HFnu Normalized High Frequency

HR Heart Rate

HRI Heart Rate Increase

HRR Heart Rate Reduction

HRV Heart Rate Variability

IB Ictal Bradycardia

xv

Page 18: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

iEEG Intracranial Electroencephalography

ILAE International League Against Epilepsy

IT Ictal Tachicardia

KNN K-Nearest Neighbours

kSQI Kurtosis Signal Quality Index

LF Low Frequency

LF/HF Low Frequency/High Frequency ratio

LFnu Normalized Low Frequency

meanNN Mean Normal-to-Normal intervals

MRMR Minimum Redundancy Maximum Relevancy

MVSPC Multi-Variate Statistical Process Control

NN Normal-to-Normal intervals

NN50 Number of pairs of adjacent NN intervals differing by more than 50 ms

PCA Principal Component Analysis

pNN50 Proportion of pairs of adjacent NN intervals differing by more than 50 ms

PSD Power Spectral Density

pSQI QRS Signal Quality Index

QRS QRS complex

QT QT interval

QTc QT corrected interval

RMSSD Root Mean Square of Sucessive Differences

RP R-peaks

RR R-peak to R-peak

SA Sino-Artrial

SD1 Standard Deviation of the projection of the Poincare plot on the line perpendicular to the line

of identity

SD1/SD2 SD1/SD2 features ratio

SD2 Standard Deviation of the projection of the Poincare plot on the line of identity

xvi

Page 19: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

SDNN Standard Deviation of Normal-to-Normal intrevals

SFS Sequential Foward Search

SMH Santa Mari a’s Hospital

SOP Seizure Occurence Period

SPH Seizure Prediction Horizon

SQI Signal Quality Index

ST ST interval

STFT Short Time Fourrier Transform

SVM Support Vector Machines

TP Total Power

vEEG Video-Electroencephalograhy

VLF Very Low Frequency

FIR Finite Impulse Response

FFT Fast Fourrier Transform

xvii

Page 20: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

1Introduction

Contents1.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

1.2 Goals and Proposed Approach . . . . . . . . . . . . . . . . . . . . . . . . . 19

1.3 Contributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

1.4 Thesis Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

xviii

Page 21: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Introduction to the dissertation text.

1.1 Motivation

Epilepsy is an important cause of disability and mortality, affecting almost 70 million people world-

wide and with a median incidence of 0.0005% per year and more common in children than adults Ngugi

et al. (2011). A person with epilepsy would be affected by abnormal brain activity, causing seizures

that may vary in degree from hardly noticeable, to severe, threatening their own life and possibly the

life of others.

Common symptoms of these seizures are disturbance of consciousness and sudden loss of motor

control, which typically occur without any type of warning. Thus, the ability to predict epileptic

seizures, can reduce patient anxiety and alleviate the immeasurable constraints and secondary behav-

ioral disturbances posed by this disorder.

Another key advantage to predict an incoming seizure is the widening of therapeutic options,

meaning that long-term treatment with anti-epileptic drugs, with cognitive or other neurological side

effects, could be reduced to a targeted and short-acting intervention, thus improving quality of life and

safety Winterhalder et al. (2003).

The gold standard in the detection, diagnosis and automatic prediction of epileptic seizures is

prolonged Video-Electroencephalograhy (vEEG). This modality not only requires intrusive hardware,

like great number of electrodes and complex acquisition systems, but relies also on constant monitoring

for integrity and safety of the devices, besides being extremely uncomfortable and unsightly. For these

reasons it is typically performed in a clinical setting, and it is not suitable for use in the daily life

activities. Even though treatment through anti-epileptics has success with most patients, a significant

portion still experiences attacks Masse et al. (2013), reinforcing the need for ambulatory monitoring

mechanisms to predict seizures onset that should minimally affect comfort.

The Electrocardiography (ECG) signal is a notable example of easily acquired physiological in-

formation, which according to recent research may provide valuable insights in seizure prediction

Behbahani et al. (2016), K. Fujiwara et al. (2016), Varon et al. (2013). Single-lead ECG data acquisi-

tion involves only 2 to 3 minimally intrusive surface electrodes resorting to simple, miniaturized and

inexpensive electronics, which means the setup can be implemented in highly comfortable, concealable

and cost-effective hardware.

1.2 Goals and Proposed Approach

The main purpose of this master thesis is to lay-out and validate a signal processing workflow that

could be used to create a seizure prediction system based on single Lead ECG acquisition.

By using data gathered from admitted patients in Santa Mari a’s Hospital (SMH) in Lisbon, this

master thesis explores the application of noise and artifact removal techniques to the raw signals,

experiments with the extraction of relevant features concerning rhythmic and morphological aspects of

the ECG and from these computed metrics, tests the use of different supervised learning algorithms to

19

Page 22: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

model the difference between known patterns from pre-ictal periods and inter-ictal periods, as a basis

for automatic classification.

Succinctly, the main contributions of this thesis are:

• Creation of prototypical wearable for long-term multi-modal acquisition;

• Development of software for long-term acquisition;

• Development of software for the analysis of the acquired signals;

• Extraction of patterns based on morphology of the cyclic heartbeat waves from the ECG signal;

• Extraction of patterns based on the derivation of the Heart Rate Variability (HRV) signals derived

from the ECG;

• Classification of the extracted patterns into 2 classes (pre-ictal and inter-ictal) based on temporal

proximity of the sample to the onset.

1.3 Contributions

The original contributions from this thesis are:

• Performance evaluation of morphological patterns in seizure prediction.

1.4 Thesis Outline

This thesis is structured in six chapters. The present chapter provided the motivation and objectives

to the thesis at hand; the general outline of the remainder of this work is as follows:

Chapter 2 discusses the fundamentals of Epilepsy, of the ECG and the relationship between the

pathology and this type of biosignal, elucidating some of the cardiac manifestations of the disorder

and how those manifestations can be measured by ECG.

Chapter 3 reviews the available literature on automatic seizure prediction and detection with biosig-

nals, describing and discussing discussing and evaluating a variety of different methodologies found in

the state-of-the-art.

Chapter 4 presents the proposed methodology, outlining the use of noise and outlier removal tech-

niques, and elaborating on the time series computation from the ECG, proposing the use of classification

schemes, useful for automatic prediction.

Chapter 5 presents the results, evaluating the process of noise and outlier removal, performing

statistical analysis of the computed patterns, discussing the separation of the patterns belonging to

different classes, and analyzing the classification results.

Finally Chapter 6, exposes the main conclusions of this work, proposing improvements and future

work possibilities based on the presented methods.

20

Page 23: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

2Theory and Underlying Concepts

Contents2.1 A Primer on Epilepsy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

2.2 Electrocardiography (ECG) . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

2.3 The Cardiovascular properties of epilepsy . . . . . . . . . . . . . . . . . . . 28

2.4 ECG Rhythmic Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

2.5 ECG Morphological Features . . . . . . . . . . . . . . . . . . . . . . . . . . 34

2.6 Supervised Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

21

Page 24: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Theory and underlying concepts behind Electrocardiography and Epilepsy.

2.1 A Primer on Epilepsy

2.1.1 Concepts and definitions

A conceptual definition of epilepsy, introduced by the International League Against Epilepsy (ILAE)

Fisher et al. (2005), defines the pathology as a disorder of the central nervous system, which manifests

itself mainly in the form of transient, recurrent and unprovoked seizures resulting from an abnor-

mal, excessive and hyper-synchronous discharge of a population of cortical neurons, so called epileptic

seizures.

A practical, clinical definition of epilepsy, as established in Fisher et al. (2014) by the ILAE, states

that epilepsy is a neurological disease defined by any of the following conditions:

• Occurrence of two unprovoked (or reflex) seizures separated >24 h

• One unprovoked (or reflex) seizure, and a probability of further seizures similar to the general

recurrence risk (at least 60 %) after two unprovoked seizures, occurring over the next 10 years;

• Diagnosis of an epilepsy syndrome.

The definition further specifies that epilepsy is considered to be resolved for individuals who had

an age-dependent epilepsy syndrome, but are now past the applicable age or those who have remained

seizure-free in the previous 10 years, lacking any use of anti-epileptics for at least 5 years.

2.1.2 Etiology

Seizures are initiated by high-frequency bursts of action potentials, as well as hyper-synchronization

of a neuronal population; as a result there is a spike discharge on the Electroencephalography (EEG),

originated by these synchronized bursts from a high number of neurons that follow a paroxysmal

depolarizing shift sequence. The seizure may start in an individual region of the cortex, propagating

to neighboring regions as there is sufficient activation, favouring the loss of surround inhibition and

spreading of the seizure into contiguous and distant areas.

Normally, there is the prevention of the bursting activity by intact hyper-polarization, together with

inhibitory neurons in a surrounding region, but with sufficient activation and repetitive discharges,

surrounding neurons are recruited. Seizures usually last for seconds or minutes, and the mechanisms

that lead to their conclusion are not as well understood as their onsets.

Etiologically speaking, the disorder holds at least four different classifications: idiopathic epilepsy, if

it is predominately genetic or of presumed genetic origin, and in which there is no gross neuroanatomic

or neuropathologic abnormality; symptomatic epilepsy, if it results from an acquired or genetic cause,

associated with gross anatomic or pathologic abnormalities, and/or clinical features, indicative of

underlying disease or condition; provoked epilepsy, if a specific systemic or environmental factor is

the predominant cause of the seizures, and in which there are no gross causative neuroanatomic or

neuropathologic changes; and cryptogenic epilepsy, defined as an epilepsy of presumed symptomatic

22

Page 25: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

nature in which the cause has not been identified. The number of the latter cases is diminishing, but

currently this is still an important category, accounting for at least 40 of adult-onset cases of epilepsy

as stated by Engel (2011).

2.1.3 Classification of seizures

As developed in Scheffer et al. (2017) and Fisher et al. (2017), the lateralization and location of

a seizure onset and its resulting clinical manifestations are important factors to determine, since it

affects the choice of seizure medication, possibilities for epilepsy surgery, outlook, and possible causes.

As of April 2017, the official classification of epileptic seizures was redefined by the ILAE Fisher

et al. (2017). With this method (depicted in Figure 2.1), seizure classification is fundamentally based

on the determination of the type of onset, which pertains to whether the initial manifestations of the

seizure are focal or generalized. The onset may also be missed or obscured, in which case the seizure is

of unknown onset. For that reason, the terms “focal” and “generalized” at the start of a seizure name

are assumed to mean of focal or generalized onset.

In the case of focal seizures, the level of awareness may also be included in the seizure type. In many

settings, awareness is of sufficient practical importance to merit its use as a classifier. A focal aware

seizure means the that the patient is aware of the self and the environment during the seizure, even if

immobile. Perception or knowledge of events occurring during a seizure determines the classification,

not the knowledge of whether a seizure occurred or the ability to respond to questions (responsiveness).

In practical terms, awareness usually assumes that the person can, after the episode, recall and

validate having retained awareness during the seizure, impaired awareness being assumed otherwise.

Awareness is not a classifier for generalized-onset seizures, since the large majority of generalized

seizures occur with impaired awareness or full loss of consciousness, although in a small fraction of

these seizures, awareness and responsiveness can be at least partially retained.

The classification can optionally be extended to reflect the first prominent symptoms of an epileptic

seizure: the involuntary motor or non-motor manifestations. It should be based on the earliest motor

onset signs such as automatism, spasms or myoclonia, or on the non-motor onset features, such as

cognitive and emotional symptoms or behavior arrest. In the event of the presence of both motor

and non-motor signs at the seizure start, the motor signs will usually dominate, unless non-motor

symptoms and signs are more notorious.

Generalized seizures can be divided into motor and non-motor (absence) seizures. If the onset

is not observed, in the event that the patient is asleep, alone, or observers were distracted by the

manifestations of the seizure to notice the presence of focal features, the seizure can be classified as

having an unknown onset, which can be in turn further subdivided according to the motor or non-

motor observations. If none of these characteristics can be accurately described, then the seizure can

be unclassified.

23

Page 26: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Figure 2.1: A representation of the structure of seizure classification, with the light gray areas representing thefundamental types of seizures and the possible subclassifications below.

2.2 Electrocardiography (ECG)

2.2.1 Cardiovascular Dynamics

Broadly speaking, the heart is a hollow muscular organ with a paramount responsibility: assure the

rhythmic circulation of blood throughout the body, and deliver appropriate quantities of oxygen and

nutrients to all the cells in the body. It is constituted by four chambers, two atria and two ventricles,

and by four valves that control the blood flow within.

The circulation initiates when oxygenated blood leaves the heart to irrigate the cells of the body,

by the contraction of the left ventricle that pumps the fluid through the Aorta, the main artery in the

human body. The fluid then travels in a complex and intricate system of progressively smaller vessels,

which diverge into a capillary network containing very thin vessels, that promote wide-spread blood

perfusion.

These structures promote a vital exchange of substances with an adjacent interstitial fluid. Oxygen

and nutrients from the blood are exchanged for cellular metabolic waste. The resulting fluid, then

deoxygenated blood, continues its journey through the veins, which become increasingly larger and

convergent closer to the heart.

The blood returns to the heart via the superior vena-cava into the right atrium, completing a process

dubbed as systemic circulation. The next stage of the process involves the right atrium emptying its

blood content into the right ventricle. The subsequent contraction of the right ventricle expels the

blood through the pulmonary artery, in the direction of the lung capillaries, where oxygen molecules

diffuse into the blood fluid. The resulting oxygenated blood returns to the left atrium through the

24

Page 27: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

pulmonary vein, completing the pulmonary circulation.

All of this fluid dynamics are mainly orchestrated by the synchronized succession of valve openings

and muscle contractions from the heart, which arises from a range of electrical stimuli. In fact, besides

the prominent muscular tissue that supports most of the mechanical features of the heart, it also

encloses a complex network of nervous fibers that mediate the production and propagation of stimuli

leading to the heart beat.

An important example of such tissues is the Sino-Artrial (SA) node, which is frequently referred to

as the pacemaker of the heart. In normal conditions, this group of specialized cells sets the pace of the

heart beat, by generating impulses 60 to 100 times per minute (while in rest). Electrical stimulation

(depolarization) and subsequent contraction of the left and right atria is caused by the conduction of

the SA’s node generated impulses along Bachmann’s bundle and inter-nodal tracts, resulting in almost

simultaneous contraction of the two atria due to the fast impulse transmission.

As the atria contract and empty their respective contents into the ventricles, the electro-chemical

impulses continue their transmission through the pathways that form the Atrio-Ventricular (AV) node.

As the process must occur seamlessly in a optimal cadence, the transmission is delayed by approxi-

mately 0.04 seconds or can even be blocked in the event of an abnormally high atrial rate Iaizzo (2005).

In addition, a multitude of adjacent AV node cells can also serve as backup pacemakers being able to

generate impulses at a rate of 40 to 60 per minute.

The propagation of the impulses continues, eventually reaching the bundle of His, a bifurcated

nervous structure that assures the conduction of the stimuli to the right and left ventricles, where

vigorous contractions from the ventricular muscles eject the blood from the heart cavity into the

respective vessels.

This entire process continuously creates a separation of charge between polarized and depolarized

tissue as impulses propagate. As illustrated in Figure 2.2, this creates an electric current between both

ends of the heart in the surrounding fluids, fluctuating the local electrical field, a disturbance that is

transmitted through the entire body, reaching the surface of the skin Iaizzo (2005).

25

Page 28: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Figure 2.2: After conduction begins at the SA node, cells in the atria begin to depolarize. This creates an electricalwave front that moves down towards the ventricles, with polarized cells at the front, followed by depolarized cells behindadapted from Malmivuo et al. (1995).

2.2.2 The heartbeat waveform

A measurement through time of the electric potential difference on the surface of the skin, cap-

tures the electrical field fluctuations caused by the heart electrodynamics. This quasi-periodic, non-

stationary and non-linear signal is the ECG as illustrated in Figure 2.3.

The quasi-periodicity of this time series allows for the identification of a common ECG complex

with 5 basic components as depicted in Figure 2.3. Although there is a great deal of variation in the

morphology of the ECG-waveform across different patients, they are often identifiable as P, Q, R, S

and T waves.

As previously stated, the heart cycle begins with the impulse generation by the SA node. As

the mass of depolarized tissue is very small, this initial disturbance is hardly detected by the surface

electrodes. But as more and more tissue depolarizes, the difference of potential becomes noticeable.

As the depolarization spreads from the SA node through to the atria, the first deflection, the P-wave

occurs in the signal. The ending of such deflection marks the complete depolarization of the atria and

their subsequent contraction. The deflection is succeeded by a return to baseline, which corresponds

to a period where action potentials spread to atrioventricular node and bundle of His. Next, 160 ms

after the beginning of the heart cycle, the right and left ventricles begin to depolarize, marking the

event measured in the QRS complex (QRS). As this occurs simultaneously with the repolarization

of the atria and since the repolarization mass is considerably inferior to the much larger ventricular

depolarization mass, the effect is masked by the QRS, and it is not usually detected by the ECG.

The ensuing repolarization of the ventricles after contraction, causes the last normally detected

deflection in the ECG beat, which is followed by the P-wave of the next cardiac cycle. It is very

important to note that deflections in the ECG wave do not correspond to the actual contractions from

the heart, which although being the result of the initial depolarization, occur in a longer time-scale.

26

Page 29: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Figure 2.3: Depiction of the basic structure of an ECG waveform, a quasi-periodic of the variation of the surfacepotential in volts over time. It outlines the existence of the 5 major complexes: the P, Q, R, S, and T waves. Adaptedfrom Iaizzo (2005).

Typical configurations for measuring this signal usually rely on the positioning of electrodes on

opposite sides of the heart, on different limbs in the upper torso, conventionally called Lead I, Lead II,

Lead III setups, in a placement named the Einthoven triangle, as shown in Figure 2.4. The difference of

charge in heart tissue can be seen as a net heart-dipole, and in a typical bipolar montage, the resulting

signal is the acquisition of voltage over time which can be seen as a projection of the three-dimensional

dipole vector in the axis performed by the two electrodes, meaning that each of these lead placements

provide different perspectives on the heart dipole. The signals explored in this work were acquired

with a Lead-I configuration.

27

Page 30: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Figure 2.4: Representation of the Einthoven triangle, illustrating the common configuration used to measure theelectrocardiogram.

2.3 The Cardiovascular properties of epilepsy

2.3.1 Pre-ictal changes

The literature is rich with different sources reporting cardiac changes relative to a considered ’base-

line’ activity in the pre-ictal, ictal, and post-ictal periods, with a great majority of sources reflecting

on alterations of the Heart Rate (HR), while a small number of works evaluate morphological changes

according to Jansen & Lagae (2010).

An important problem concerning the publicly available works is the lack of normalization of results

according to different factors such as epilepsy and seizure type, age groups, use of anti-epileptic drugs

(AEDs), the lobe of seizure onset and presence of cardiac comorbidities.Bruno et al. (2018).

Furthermore, motor manifestations occur during particular types of epileptic seizures (mainly a

subtype that involves tonic-clonic manifestations), which consequently implies that significant changes

secondary to the tonic-clonic phase in the ECG are expected (muscular artifacts, increased HR etc.),

with no significant correlation with the underlying neuronal hyper-synchronization. Meaning that not

only variations in noise and artifact removal produce plenty of different results, but also that the

distinction between plainly neurological and motor changes must be taken into account.

There is also the possibility of cardiac induced seizures, as conditions traditionally considered

28

Page 31: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

cardiac in nature may result in seizure genesis. Additionally, methodological issues can also contribute

to potential ECG changes, including methods used to assess seizure onset and more importantly the

definitions of such changes Jansen & Lagae (2010).

An example concerning HR manifestations, is the frequency of seizures associated with these

changes, which varies considerably across studies. A common feature evaluated in the literature is

the rise or decrease of the HR which can be related with Ictal Tachicardia (IT) and Ictal Bradycar-

dia (IB) respectively. Estimates range between 38 and 100 % for IT and 5 and 66.7 % for IB. This

great disparity of results reflects the vast number of variables to correct for, across multiple studies

Jansen & Lagae (2010).

Needless to say, caution is required when exploring different available works and extrapolating

the results. A thorough and reasonable analysis of the different peri-ictal cardiovascular changes

is important to shed light into some of the underlying neurological mechanisms responsible for those

manifestations, which can ultimately result in the development of a robust automatic method of seizure

prediction.

A relevant meta-analysis of HR changes in the pre-ictal period conducted by Bruno et al. (2018),

reviewing thirty studies, including 1110 participants and 2957 seizures, showed a pooled incidence of

pre-ictal Heart Rate Increase (HRI) of 36/100 seizures (95% CI 22–50). The pre-ictal HRI incidence

was 44/100 seizures (95% CI 33–55) in studies including temporal lobe epilepsy, 55/100 seizures (95%

CI 41–68) in studies enrolling adults and 35/100 seizures(95 CI% 16–58) when patients on antiepileptic

drugs were included, with a median onset of HR manifestations of 10.7 (IQR 5–60)s prior the clinical

or EEG signs. In addition, a meta-regression showed that the age group, the length of the pre-ictal

period, the incidence of ictal tachycardia and the time of onset of the pre-ictal HRI had a significant

impact on the estimates variability.

The same meta-analysis investigated the presence of pre-ictal Heart Rate Reduction (HRR). IB was

reported in 88/2346 seizures (3.7%) and was observed in 13 studies. One study reported pre-ictal HR

reduction without commenting about subsequent IB, and six studies did not observe any IB. The mean

baseline HR was 76.2 Beats per minute (bpm) (range 69.5–86.4), and the mean ictal HR minimum was

62.2 bpm (range 50.0–76.5), demonstrating a mean decrease of 18.4% as compared to the baseline.

One important fact is that temporal lobe seizures have been more often associated with pre-ictal

HR alterations as compared to seizures of extra-temporal origin Eggleston et al. (2014). Furthermore,

autonomic features conventionally tend to precede other clinical presentations in temporal seizures and

this might well apply to HR manifestations.

As morphology goes, in interictal periods, a commonly reported ECG abnormality is a decrease of

the QT interval (QT) interval. In a study on 70 patients with epilepsy, Teh et al. (n.d.) found that

QT corrected interval (QTc) was shorter in these patients (0.40 s) than in the control group (0.42

s), and half of them had a mean QTc shorter than 0.40 s. In this study, QTc was calculated using

Bazett’s formula, which overcorrects QT intervals at higher HR. Considering that HR in patients with

epilepsy is generally higher than normal, the calculated QTc shortening may be somewhat exaggerated

in those patients. ECG morphologic changes were not identified in IB, but were observed in IT. More

29

Page 32: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

frequently, IT was associated with ST interval (ST) changes. For example, in a another study performed

on 23 patients with refractory epilepsy found that ST depression occurred in 40% of these patients

and was associated with higher HR increase during seizures. Although ST depression combined with

a higher increase of HR may indicate myocardial ischemia, those patients were monitored using 2-lead

recordings, which does not offer a complete picture whether the supporting mechanisms. ST depression

was also evidenced by Opherk et al in 3 of 41 patients with IT, and several other articles report ST

depression or elevation associated with IT.

2.3.2 Underlying mechanisms

As of now, there is little understanding about the mechanisms behind cardiovascular changes in

epilepsy Bruno et al. (2018). Despite this, a growing number of evidence supports the involvement

of cortical structures that constitute the Central Autonomic Network (CAN) (including the amygdala

and the insular cortex), and the involvement of adaptive cardiovascular reflexes triggered by ictal

manifestations Eggleston et al. (2014). As of now, there is little understanding about the mechanisms

behind cardiovascular changes.

A well-known dynamic of the Autonomic Nervous System (ANS) is that parasympathetic and sym-

pathetic systems act in concerted manner to maintain homeostasis and regulate key visceral functions

such as the HR. In particular, the anterior cingulate, insular, posterior orbito-frontal, and the pre-

frontal cortices play key roles in influencing the ANS, at the cortical level along with the amygdala

and hypothalamus, as depicted in Figure 4.5.

A proposed explanation found in Jansen & Lagae (2010) is that, in patients suffering with epilepsy,

ictal discharges that occur in or propagate to these structures which leads to increased sympathetic

outflows, impacting autonomic function. In fact, research involving experimental stimulation of differ-

ent neural structures suggests that the propagation of epileptic discharges to the right insular cortex is

a primary driver of sympathetic-parasympathetic changes that influence HR . A common effect is IT,

but parasympathetic responses such as decrease in HR can also occur, if the ictal discharges propagate

to cortical regions governing depressor responses. This activation of central autonomic nervous system

is thought to be responsible for the acute cardiac changes.

30

Page 33: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Central Autonomic Nervous System Hemispheric specific organization

Peripheral autonomic nervous system

sensory motor enteric

ortho / para

Effector Organs Heart rate

Respiration Micturition

Pupillary reactions Gastro-intestinal system

Clinical Autonomic symptoms

Seizures/Epileptic discharges Acute-chronic

Lateralizationand Locationinformation

Figure 2.5: Origin of autonomic symptoms in epilepsy (adapted from Jansen & Lagae (2010)).

Peripheral effects combined with autonomic alterations triggered by seizures may explain some of

the morphologic ictal ECG changes. As an example, the ictal ST elevation/depression and T-wave

inversion most likely reflect cardiac ischemia due to a mismatch between myocardial oxygen demand

and supply in IT. This situation may be amplified further when IT is associated with hypoxia.

2.3.3 Basis for ECG-based automatic epileptic seizure prediction

As the available literature makes a clear explanation of the influence exerted on cardiac activity

by the hyper-synchronous firing of cortical neurons in the epileptic seizure onset, there is little doubt

whether ECG could be a successful vector of information to perform seizure prediction.

The subjective evaluation of bio-signals, such as EEG and ECG, makes automatically extracted

parameters (computer-based) highly useful for diagnostics. Moreover, due to the difficulty of visual

investigation of multi-parametric recordings (in this case time-synchronous EEG and ECG) and in

combination with the progress of signal processing and pattern recognition methodologies, many ap-

proaches for automatic detection of seizures have been proposed in the literature.

Another clear advantage is that ECG acquisition can be minimally invasive and easily adaptable

to simple wearable devices,

A portable, highly flexible and robust ECG-based predictive system of epileptic seizures could

ideally be coupled with a reactive seizure avoidance tactic forming a so-called closed-loop seizure

system.

31

Page 34: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

2.4 ECG Rhythmic Features

2.4.1 Heart rate

The classical measurement of the number of heart cycles per interval of time is the HR. The

time difference between 2 adjacent QRS, that is all intervals between QRS resulting from sinus node

depolarization can be referred as the Normal-to-Normal intervals (NN) sequence, which is a sequence

of instantaneous measurements of the heart rate. The oscillation between consecutive instantaneous

heart rates is defined as HRV, which in turn can be measured by the computation of a number of

features.

2.4.2 Statistical HRV features

A common framework of analysis of the HRV is the statistical description of the signal in particular

time segments, usually framed as windows. These may be subdivided into two classes, (a) those derived

from direct measurements of the NN intervals or instantaneous heart rate, and (b) those derived from

the differences between NN intervals.

Some examples of (a) can be:

• MeanNN: The mean value of the NN in a given window;

• SDNN: The standard deviation of the NN in a given window;

The Standard Deviation of Normal-to-Normal intrevals (SDNN) being the square-root of variance,

which is mathematically equal to total power of spectral analysis, reflects all the cyclic components

responsible for variability in the period of the signal. In many studies, SDNN is calculated over a 24-h

period and thus encompasses both short-term high frequency variations, as well as the lowest frequency

components seen in a 24-h period.

And in the (b) category, some examples of features are:

• RMSSD: Root Mean Square of Successive Differences

• NN50: Number of pairs of adjacent NN intervals differing by more than 50 ms

• pNN50: Proportion of pairs of adjacent NN intervals differing by more than 50 ms

These metrics estimate high-frequency variations of the signal and thus are highly correlated.

2.4.3 Spectral HRV features

The power spectral analysis of heart rate fluctuations to quantitatively evaluate beat-to-beat cardio-

vascular control is of major importance in the evaluation of the autonomic background of NN interval

fluctuations. Three main spectral components are distinguished in a spectrum calculated from short-

term recordings of 2 to 5 min, which are the Very Low Frequency (VLF), the Low Frequency (LF) and

the High Frequency (HF) bands.

• VLF: Power expressed by the range of frequencies between 0.003Hz − 0.04Hz.

32

Page 35: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

• LF: Power expressed by the range of frequencies between 0.04Hz − 0.15Hz

• HF: Power expressed by the range of frequencies between 0.15Hz − 0.4Hz

There are however some caveats with the physiological explanation of the VLF component, being

much less defined since the existence of any connection to a physiological mechanism is questionable.

The ratio between the two frequency bands can be defined as the Low Frequency/High Frequency

ratio (LF/HF), and expresses the balance between the sympathetic nervous system activity and the

parasympathetic nervous system activity Malik et al. (1996).

Figure 2.6: Depiction of the HRV spectrum on two different signals, acquired at different periods of a patient’s activity,(left) at rest and (right) with head tilt. It is possible to note that with the tilt the LF component becomes dominant but,as total variance is reduced, the absolute power of LF appears unchanged compared to rest. It can also be noted that thedifferent power distribution of both spectrums highlights different contributions of both components of the autonomicnervous system, adapted from Malik et al. (1996).

Figure 2.6 highlights an important problem with these metrics. The evaluation of the HRV spectrum

for the same subject in different types of physical activity, at rest and with a head tilt, creates two

different Power Spectral Density (PSD) profiles, with different contributions from the frequency bands

and different values of total power. Although the relative contribution of the LF band increases with

the head tilt, the absolute value of power remains the same, by virtue of the overall decrease in total

variance.

In order to capture the relative change it is possible to compute the normalized metrics, which

can be defined according to K. Fujiwara et al. (2016) as the ratio between the absolute power of

the bands and the total power, described as Normalized Low Frequency (LFnu), Normalized High

Frequency (HFnu).

The HRV signal is derived from the R-peaks (RP) of the ECG signal, and the sampling of such

derived series is uneven, which means the timing of the RP is dependent on heart rate. This poses a

difficult problem to the spectral analysis, since methods based on the Fast Fourrier Transform (FFT)

require regularly sampled signals.

33

Page 36: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

The typical proposed solution is to resample the signal into a regularly sampled signal by means

of interpolation. The ideal choice is cubic-spline interpolation, since it allows for a smooth estimate of

the signal to a fixed a pre-determined sampling rate K. Fujiwara et al. (2016).

A common value for the sampling frequency is 1 Hz, as it is well over the Nyquist frequency of the

HRV signal, for which an example of the spectrum can be found on Figure 2.6. The computation of

the power spectral density of the then resampled signal can be made resorting to different methods.

The classical periodogram is one non-parametric possibility suffering from severe drawbacks, since

the result of the estimation can be highly inaccurate, given the methods employed in the signal. Another

way to evaluate the power spectral density of the signal, is to use the Lomb-Scargle periodogram

Townsend (2010), which contrary to the classical periodogram estimates the PSD based on a least-

squares regression, thus not requiring the extra step of resampling VanderPlas (2018). Non-parametric

methods are usually more efficient, given the simplicity of the employed algorithms FFT and high-

processing speed. An example of a parametric method is to use an auto-regressive model. Another

alternative, is to use a non-parametric method. The auto-regressive model allows for a smoother

estimation, provided the right order of the model is chosen, which according to Boardman et al. (2002)

can be no less than 16.

2.5 ECG Morphological Features

2.5.1 Heartbeat waveform

To consider potential morphological determinants involved in epiliptogenesis, a common pre-requisite

is to extract the heartbeat waveform the ECG based on a particular set of fiducial points. The extrac-

tion of i-th heart wave segment b is essentially a segmentation of the data points from a predefined

interval, with respect to the detection of the i-th RP according to Equation (2.2) and as depicted in

Figure 2.7:

bi(t) = ECG(t), RP (i) +N1 < t < RP (i) +N2, i = 0, 1, 2, 3, 4, 5... (2.1)

34

Page 37: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Figure 2.7: Illustration of the process for fixed length heart-wave extraction from the ECG based on detection of RP.

2.5.2 Distance between heart-waves

The extraction of morphological patterns of the ECG can be done with the computation of a

similarity coefficient between heart-wave bi and bl. The most basic measurement is the euclidean

distance between the two templates. Another more useful notion of distance is the pearson correlation

coefficient ρ, which stands as a covariance of the two templates bi and bl, divided by the product of

their standard deviations, formally:

ρbi,bl =cov(bi, bl)

σbiσbl(2.2)

Varying from 1 to -1, the metric is robust to linear changes in the heart-waves, and thus it is

particularly sensible to non-linear differences between the two.

2.6 Supervised Learning

As outlined in section 2.3.1, the cardiovascular manifestations of epilepsy can be measured in the

ECG, in a number of different morhphologic and rythmic changes (changes in HR) of the signal, with

some of the sourced refering alterations before the onset of the seizure.

As most fields in the current day and age, the seizure prediction field benefits a great deal from

supervised learning, in this case, as means to automatically detect those manifestations. The majority

of the works uses these type of classifiers to discern between different time zones within the biosignal

source in reference to the seizure onset. A common framework of analysis, and one also used in this

work, is to model the separation between data points captured just before the onset, labeled pre-ictal

in line to what is defined in the clinical nomenclature, and data points captured from more stable

periods of the acquisition, labeled inter-ictal, a problem that can be modelled as a binary classification

problem, with some authors extending the problem to accommodate the existence of more classes, such

as considering the period just after the onset, typically labeled ictal points Teixeira et al. (2011).

35

Page 38: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

The goal with the use of these algorithms is to estimate a sufficient good model f(x) that based on

a p-dimensional input pattern x can generate an appropriate output G, which can take for example

the values of inter-ictal or pre-ictal, generally coded with values such as -1 for inter-ictal, and 1 for

pre-ictal, and from this response automatically classify the pattern as indicative of an incoming seizure.

The hypothesis is that the model f(x) is a good enough approximation of a true function f(x) that

mediates the relationship between the extracted pattern x and the possibility of an incoming seizure.

In order to reach a good approximation of the model f , the algorithms uses a subset of the total

pattern dataset typically defined as the training set (x0, y0), (x1, y1), (x2, y2), (x3, y3)...(xN , yN ), with

N training samples xi ∈ IRp and N corresponding responses or labels yi ∈ {−1, 1}, and test the

constructed model by evaluating the resulting decision function G(x) on unseen samples x, which

usually belongs to a another portion of the total dataset called the test set, based on some pre-defined

metric.

2.6.1 K-nearest neighbors

The K-Nearest Neighbours (KNN) algorithm is one of the most simple methods for classification.

In essence the estimated decision function produced by this algorithm can be defined by the following

equation:

G(x) = sign(f(x)) = sign(1

k

∑xi∈Ng(x)

yi) (2.3)

Where Ng(x) is the neighborhood of x defined by the K closest training samples, as measured with

the outputs of particular distance function d(x, xi) computing the distance between x and each xi.

The sign function selects the appropriate response −1 or 1 from the average responses of the training

samples in the neighborhood, which amounts to a majority vote of the K nearest neighbors.

The downside of the majority vote method can be that if the number of samples for both classes

is highly unequal it creates a skew in the classification criteria, being the classification with the most

represented class the most probable. A possible step to overcome some possibility of labeling imbalance

to evaluate the classifier with different sets of hyper-parameters, in this work, typically varying the

number of neighbors K.

36

Page 39: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

2.6.2 Support vector machines

Support Vector Machines (SVM)’s, like the KNN’s are another a type of supervised learning clas-

sifiers.

Having a set of training samples, (x0, y0), (x1, y1), (x2, y2), (x3, y3)...(xN , yN ), with xi ∈ IRp and

yi ∈ {−1, 1}, this type of classifier is based on the assumption that the classification rule for an unseen

pattern x is in the form of:

G(x) = sign(f(x)) = sign(xTβ + β0) (2.4)

Where β is a p-dimensional vector, and β0 is the intercept coefficient.

The training of the model is intended to find the best p − 1 dimensional hyper-plane separating

both classes, and is based on the principle that such surface is the plane that maximizes the distance to

the closest training samples of both classes, assuming both classes are linearly separable. The intuition

behind the use of this principle is to assume that a decision function designed to maximize separation

between the training data samples, will lead also to good separation in the test samples Hastie et al.

(2009). The concept can best described in the following optimization problem:

maxβ,β0,‖β‖=1

M (2.5)

subject to yi(xTi β + β0) >M (2.6)

Being M the signed distance from the optimal plane to the closest points from either class, also

known as the margin.

The constrain on the norm of β can be rid of, by reformulating equation (2.16) into:

yi(xTi β + β0) >M ‖β‖ (2.7)

Furthermore, by noticing that for any β and β0 satisfying both inequalities, any positively scaled

multiple for both elements will also do the same. Consequently, arbitrarily setting ‖β‖ =1

Mreformu-

lates the problem into:

minβ,β0

1

2‖β‖2 (2.8)

subject to yi(xTi β + β0) > 1 (2.9)

A valid alteration, since1

Mis a valid multiple, and maximizing M is now equivelent to minimizing

1

2‖β‖. This also means that the margin around the linear decision boundary has thickness

1

‖β‖, and

the choice of β, β0 must be one to maximize it. This a convex optimization problem, which can be

solved by minimizing w.r.t β and β0, the Langrange primal function:

Lp =1

2‖β‖2 −

N∑i=1

αi[yi(xTi β + β0)− 1] (2.10)

And setting both partial derivatives to zero yields:

37

Page 40: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

β =

N∑i=1

αiyixi (2.11)

0 =

N∑i=1

αiyi (2.12)

Plugging both results in equation (2.10), leads to the so-called Wolfe dual problem, for which the

solution is obtained by the maximization of the:

LD =

N∑i=1

αi −1

2

N∑i=1

N∑k=1

αiαkyiykxTi xk (2.13)

A simpler convex optimization problem, subject to the constraints (2.11) and (2.12), along with:

αi > 0 (2.14)

αi[yi(xTi β + β0)− 1] = 0,∀i (2.15)

The preceding equations expose a fundamental dynamic of the problem, that the determination of

the optimal parameters, β and β depends only on certain training samples. If αi > 0 then yi(xTi β +

β0) = 1, i.e. the sample xi is on the boundary of the margin, and if yi(xTi β + β0) > 1 then αi = 0.

This means that the solution vector β is a linear combination of the so-called support points xi.

Yet, the training samples cannot (in most cases) be linearly separable. One way to deal with this

problem is to allow for some points to be on the wrong side of the margin. In order to this, a number of

slack variables ξ = (ξ1, ξ2, ξ3, ..., ξN ) must be considered, one for each training sample. The constrain

defined in Equation (2.16) can be then to:

yi(xTi β + β0) >M(1− ξi) (2.16)

According to Hastie et al. (2009), the basic idea behind this formulation is that quantity ξi is the

proportional amount by which the prediction f(xi) is on the wrong side of the margin, therefore the

bounding of the sum∑ξi lead bounding of the total number of samples in the wrong side of the

margin.

The minimization expressed by (2.8) and (2.9) can now be stated as:

minβ,β0

1

2‖β‖2 + C

N∑i=1

ξi (2.17)

subject toξ > 0, yi(xTi β + β0) > 1 (2.18)

This is in fact a generalization of the problem, being equal to separable case when C =∞ In this

case, the Lagrange primal function to assumes the form:

LD =1

2‖β‖2 + C

N∑i=1

ξi −N∑i=1

αi[yi(xTi β + β0)− (1− ξi)]−

N∑i=1

µiξi (2.19)

A function that can be minimized w.r.t β, β0 , ξ by setting the partial derivatives to 0:

38

Page 41: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

β =

N∑i=1

αiyixi (2.20)

0 =

N∑i=1

αiyi (2.21)

αi = C − µi,∀i (2.22)

αi, µi, ξi > 0 (2.23)

And the dual Lagrangian objective function, which takes the same form:

LD =

N∑i=1

αi −1

2

N∑i=1

N∑k=1

αiαkyiykxTi xk (2.24)

Being now subject to the additional constraints:

αi[yi(xTi β + β0)− (1− ξi)] = 0 (2.25)

µiξi = 0 (2.26)

yi(xTi β + β0)− (1− ξi) > 0 (2.27)

The previous equations, (2.20) - (2.27) uniquely characterize the solution vector β. Which has the

form:

β =

N∑i=1

αiyixi (2.28)

With non-zero coefficients αi for the samples xi, the support vectors. Among these support points

some lie in the edge of the margin (ξi = 0), consequently with 0 < αi < C, and the remaining ones

(ξi > 0) with α = C. The intercept β0 can be determined by any of the margin points (0 < αi)

Given the estimations β and β0, the estimation decision function fine-tuned by the imposition of

the parameter C, can be written as:

G(x) = sign[f(x)] = sign[xT β + β0] (2.29)

All of these procedures are specifically tailored to find linear boundaries in the input feature space.

As with other linear methods, the classification rule can become more flexible by enlarging the feature

space using basis expansions such as polynomials or splines. The intuition behind the idea is that

linear boundaries in the high dimensional enlarged space achieve better training-class separation, which

translate to nonlinear boundaries in the original space.

This different type of fit is based on a set of basis functions h(xi) = (h1(xi), h2(xi), ..., hM (xi)) and

is intended to model the non-linear function f(x) = h(x)Tβ+β0 with the response G(x) = sign(f(x)).

39

Page 42: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

The Lagrange dual function, from which the maximization subject to constraints yields the optimal

parameters β and β0, now has the form:

LD =

N∑i=1

αi −1

2

N∑i=1

N∑k=1

αiαkyiyk〈h(xi), h(xk)〉 (2.30)

And from (2.29), the solution function becomes:

f(x) =

N∑i=1

αiyi〈h(xi), h(xk)〉+ β0 (2.31)

In fact, in this new derivation, the model only requires knowledge of the inner products of h, and

doesn’t explicitly needs the determination of function h(x). The computation of the inner products in

the transformed space is performed by the so-called kernel function:

K(x, xk) = 〈h(x), h(xk)〉 (2.32)

A function that should be a symmetric positive semi-definite function. One popular choice for

kernel function in the SVM literature, and in the seizure prediction field is the radial basis function,

which can be defined as:

K(x, xk) = exp(−γ ‖x− xk‖2) (2.33)

Figure 2.8: Illustration of the decision boundary of a trained SVM with radial kernel in a binary non-linearly separabledataset. The two classes are colored blue and orange, the support vectors can be seen in dark circles, and the decisionin the dark solid line, with the margins in dashed lines. The linear decision boundary in the transformed space becomesnon-linear in the feature space. To note also the existence of violation of the margin, as the regularization parameter Callows for some slack in the determination of the margins.

A large value of C will discourage any positive xi and lead to an overfitted wiggly boundary in the

original feature space, in the other hand a small value of C will produce a more smoother function.

The final solution, fine-tuned by the parameter C and γ has the form:

40

Page 43: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

f(x) =

N∑i=1

αiyiK(xi, xk) + β0 (2.34)

41

Page 44: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

3State-of-the-art

Contents3.1 Electroencephalography based prediction . . . . . . . . . . . . . . . . . . . 43

3.2 Cardiac based prediction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

42

Page 45: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

The task of automatic seizure prediction from biosignals is an extensively studied subject in the

literature. The basic structure of the methodology, common to all publicly available methods is the

extraction of patterns from contiguous acquisitions of from signal records that can manifest some

indicative epiliptogenic variations before the seizure onset. A logical conceptual subdivision of the

types of patterns is to group them into either morphological, concerning the morphology of the cyclic

heart wave, or as rhythmic pattern capturing the rhythm of the cyclic heart beat, which is commonly

described as HR.

3.1 Electroencephalography based prediction

Much of the theory behind the automatic epileptic seizure prediction was developed in works with

EEG signals. Since these constitute the most commonly used signals by physicians to effectively

evaluate and diagnose epileptic seizures, And since the signals provide a more direct representation

of the cortical physiological phenomena of the seizure onset, they constitute a primary area of focus

for the development of algorithms for automated prediction. Given the density of works that exploit

this kind of information, the following paragraphs succinctly expose some of the most relevant works,

whose methodologies are similar to the procedures proposed in this work, enabling a potential reader

to get some sense of the used techniques in literature.

In a work by Rasekhi et al. (2015), the extraction of bivariate features from the multiple channels of

the EEG allowed for the quantification of the relation between different brain regions. Differences and

ratios of 22 linear univariate features such a the Hjorth parameter, the accumulated energy, statistical

moments, the auto-regressive error, the decorrelation time and the wavelet coefficients were calculated

using pairwise combination of 6 EEG channels, to create 330 differential, and 330 relative features.

The feature subsets were classified using SVM’s separately, as one of the two classes of pre-ictal and

non pre-ictal. Using Minimum Redundancy Maximum Relevancy (MRMR) to reduce the feature set,

the author were able to improve the predictions and reduce the number of false alarms. The studies

were carried out on features obtained from 10 patients. For reduced subset of 30 features and using

differential approach, the method achieved a sensitivity of 60.9% of the cases and a low false prediction

rate False Positive Rate (FPR) of 0.11/hour.

Bandarabadi et al. (2015) followed a similar methodology in their paper again in a pair-wise com-

bination of extracted time-series of relative power bands of the a multi-channel EEG, in a dataset

of continuos 183 seizures (3565 hours of data) of a long-term multichannel scalp and invasive EEG

Intracranial Electroencephalography (iEEG) recordings. The authors selected a set of best features by

using MRMR and achieved a sensitivity of 75.8% and a false prediction rate of 0.1/hour .

Another example of the use of the EEG is the work by Truong et al. (2017). In this paper the

application of Convolutional Neural Networks (CNN) on different intracranial and scalp electroen-

cephalogram (EEG) datasets is used to create a generalized retrospective and patient-specific seizure

prediction. By computing the Short Time Fourrier Transform (STFT) on 30-second EEG windows

with 50 % overlapping to extract information in both frequency and time domains, and by standardiz-

ing the STFT components across the whole frequency range to prevent high frequencies features being

43

Page 46: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

influenced by those at lower frequencies. the authors fed these time-series to a convolutional neural

network model, which was used for both feature extraction and classification to separate pre-ictal seg-

ments from inter-ictal ones. The proposed approach achieves sensitivity of 81.4 %, 81.2 %, 82.3 % and

false prediction rate (FPR) of 0.06/hour, 0.16/hour, 0.22/hour on Freiburg Hospital iEEG dataset,

Children’s Hospital of Boston-MIT scalp EEG (sEEG) dataset, and Kaggle American Epilepsy Society

Seizure Prediction Challenge’s dataset, respectively. Being the prediction method also statistically

better than an unspecific random predictor for most of patients in all three datasets.

In a more recent work by Kiral-Kornek et al. (2018), the authors were able to use a prototype of

an implantable seizure advisory system the ”neuromorphic TrueNorth chip” to deploy a trained deep

neural network. This neural network was fed the spectrograms of pre-recorded 16.29 years and 2817

seizures of multi-channel iEEG data, in order to extract patient-specific features and try to model

the separation of equal samples of pre-ictal samples, defined as data from 15 minutes before onset,

from non pre-ictal samples, data that did not belong to an ictal nor a pre-ictal period, to produce

alarms based on the output of an artificial leaky integrate-and-fire neuron, adding the date and time

as a separate feature in order to capture the variation with circadian-rhythm of seizure onsets. By

deploying the network into this implantable chip, the authors were able to test the algorithm on live

data from 10 admitted patients. Additionally, the step of alarm generation with the use of a leaky

integrate-and-fire neuron the firing threshold the duration of alarms and the leak of the neuron to be

not only defined by the deep neural network, but also fine-tuned by the patient and or clinician.

3.2 Cardiac based prediction

The available literature is rich with meaningful examples of cardiac data exploitation for the study

of epileptic seizures.

Evidently, a significant body of works focus heavily in the design of automatic procedures for

prediction and detection of epileptic seizures, often focusing extensively on prior statistical analysis of

potential cardiac markers extracted from ECG data within pre-ictal, ictal, post-ictal and inter-ictal

time-frames. In fact, the number of systems fashioned for such purposes is rapidly increasing, with

some notable examples already commercially available.

The majority of the works exposed in this section describe acquisition setups identical to the ones

employed in the context of this thesis. The data is collected from admitted patients submitted to

vEEG monitoring with simultaneous ECG acquisition, which allows for at least, the labelling of the

onsets of ictal activity by EEG specialists. In the interest of repeatability assessment and to gauge

for possible modifications to increase performance, many of the discussed and tested techniques are

further explored in this work, and therefore, a concise but hopefully clear exposition of such procedures

and devices is thus presented in this chapter.

3.2.1 Use of heart rate features

Since pre-ictal, ictal and post-ictal heart rate alterations have been reported by a variety of different

sources, with a well documented relationship between these variations and the autonomic disruption

44

Page 47: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

caused by seizure onset, there is a significant number of authors exploring techniques that build upon

HRV features to support seizure prediction.

Jansen et al. (2013) evaluated data points split into 2 segments: baseline (3 min before seizure)

and ictal (2 min after seizure onset). In the time domain features, such as the heart rate, for both

segments was computed using Mean Normal-to-Normal intervals (meanNN), SDNN reflecting all the

cyclic components responsible for variability in the period of recording, and the Root Mean Square

of Sucessive Differences (RMSSD), estimating high frequency variations in heart rate. Serial auto-

correlation was used as another method to show how the samples of the RR interval time series

cross-correlate at different time points. In the frequency domain, the power spectra of the RR intervals

were calculated. Statistical differences were determined by the Kruskal–Wallis test, and p < 0.001 was

considered statistically significant.

Another notable example is the process described by K. Fujiwara et al. (2016). ECG data acquired

from patients admitted into epilepsy monitoring units for vEEG long-term acquisition was used to

extract a set of different HRV features. By detecting the RP from each beat, and afterwards obtaining

an equally-sampled estimation of the R-peak to R-peak (RR) time-series, the authors were able to

extract several time-domain features such as Number of pairs of adjacent NN intervals differing by

more than 50 ms (NN50), Proportion of pairs of adjacent NN intervals differing by more than 50

ms (pNN50), meanNN, SDNN, Total Power (TP), and several spectral features as well: LF, HF

and LF/HF. The team was also able to rely on the labeling made by EEG specialists which allowed

distinction between control and pre-ictal moments. From this it was possible to model control/baseline

data in principal component space with reduced dimensions Principal Component Analysis (PCA). Any

sample deviation from the baseline subspace, measured by Multi-Variate Statistical Process Control

(MVSPC) statistics was readily denoted as a pre-ictal data point, with a possible prediction of seizure

made within a time threshold for consecutive occurrence of such anomalous points. The proposed

method yielded 91 % sensitivity and 0.7/hour FPR.

Another study by K. Hoyos-Osorio et al. (2016), demonstrated that the same HRV features com-

puted from ECG data retrieved from patients admitted into a video-EEG monitoring, could be used to

perform binary supervised classification using a KNN algorithm. Noise-removal was performed using

wavelet-based filtering and feature selection using Sequential Foward Search (SFS) demonstrated an

optimal feature space comprising pNN50 and NN50 dimensions, resulted in an average classification

accuracy of 76%, a sensitivity of 86% and a FPR of 0.23/hour.

Behbahani et al. (2016) analyzed the same HRV feature of sixteen epileptic patients with a total of

170 seizures, to predict the occurrence of seizures based on the dynamic changes of the ECG during the

pre-ictal period. Moreover, by recognizing the non-linear nature of physiological signals quantitative

analyses of Poincare plot features (Standard Deviation of the projection of the Poincare plot on the line

perpendicular to the line of identity (SD1), Standard Deviation of the projection of the Poincare plot

on the line of identity (SD2), and SD1/SD2 features ratio (SD1/SD2) were performed. Such features

were computed for consecutive time windows with a length of five minutes. An adaptive decision

threshold method was used for raising alarms. Predictions were made when selected features exceeded

45

Page 48: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

the decision thresholds. The work produced an algorithm with a Seizure Occurence Period (SOP) of

4:30 minutes, and Seizure Prediction Horizon (SPH) of 110 seconds, the presented method showed

an average sensitivity of 78.59%, and average FPR of 0.21/hour, which indicates that the system has

superior performance, when compared to the random predictor.

Moridani & Farhadi (2017) studied 11 epilepsy patients to assess the possibility of seizure prediction.

Extracting the same features from HRV signals in time-intervals of 5 minutes as proposed and by using

the same adaptive threshold-based classifier the authors were able not only to discern that in pre-ictal

events, mean HR, LF/HF, and SD1/SD2 ratio significantly increased while RRI! (RRI!) significantly

decreased in comparison with control data, but also were able to employ the mentioned classifier to

achieve a sensitivity of 88.3% and a specificity of 86.2%.

46

Page 49: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

4Methodology

Contents4.1 Overall Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

4.2 Data Gathering, Structuring and Database Creation . . . . . . . . . . . . 49

4.3 Baseline Wander Removal and Denoising . . . . . . . . . . . . . . . . . . . 53

4.4 Feature Extraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

4.5 Identification of pre-ictal states . . . . . . . . . . . . . . . . . . . . . . . . . 63

47

Page 50: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Description of the methods and techniques employed in this project

4.1 Overall Procedure

The methodology proposed in this work is depicted in the following schematic:

ECG DataCollection

Noise andBaseline Removal

SegmentationRythmic andMorpholgical

Feature Extraction

Labeling andclassification

Figure 4.1: Diagram depicting the sequence of the proposed methodology.

The methodology pipeline starts with the collection of the ECG data from the SMH servers, com-

prehending extraction and conversion of the raw files present in the hospital’s system, creation of the

appropriate annotations for the data, primary division of the contiguous data into fixed time-frames

of analysis called ’seizure sessions’ and building of the final database with every seizure session.

This is followed by a step of baseline wander removal and denoising to reduce the corruption by

noise and artifacts The process of signal segmentation is next, with the detection of the RP by means

of the algorithm proposed by Hamilton (2002a). Based on this detection, an approximation of RR

signal can be derived from the time difference between detections, and heart-beat wave templates from

the ECG extracted. In order to remove aberations from the derived signal, originated from fiducial

point misdetection and from anomalous heart-beats, and in order to approximate the NN time-series,

an algorithm for outlier removal is employed.

From the NN signal and the series of templates, the feature extraction is performed resorting to a

moving window of 5 minutes with a 98 % overlap, to compute the time series used for this analysis. The

previous computation is followed by a labeling of the samples into pre-ictal and inter-ictal, which groups

data from two different time-zones of the acquisition, labels relevant to the production of an alarm

or prediction. On these computed profiles, and the labeled samples, supervised binary classification

algorithms can be trained and tested to evaluate the possibility to distinguish and model the separation

of the two classes.

48

Page 51: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

4.2 Data Gathering, Structuring and Database Creation

The raw dataset is composed of data captured by a Neurofax EEG-1200 system used by the SMH

to record multimodal biosignal data from the admitted patients. From the complete dataset, the

source we work with are Lead-I ECG recordings acquired with 2 electrodes placed on the left and right

collarbones with reference electrode on vertebrae C3. The signals were acquired at 1000Hz sampling

rate.

At least two vEEG specialists produced a report, detailing the evolution of the EEG wave mor-

phology and frequency bands throughout the peri-ictal period. The reports included a description of

the set of channels involved in the onset of epileptoform patterns in the EEG wave, setup according to

the international 10-20 system, a description of the lobes of propagation and an exhaustive account of

the symptoms and reactions from the patient throughout the entire seizure. These reports were made

via the analysis of the recorded EEG signals and vEEG by the specialists.

The elaboration of accurate metadata concerning seizure type and location was derived from a

careful reading of these reports for each seizure. Also, the precise determination of the seizure onset

was based on the interpretation of these reports.

To protect the integrity of the acquired signals, the data was stored in a single secure private

terminal with a custom-made interface. The access could only be made through that computer and

was conditional on the possession of the correct credentials. The access to the data was mediated by

the interface, which allowed for the introduction of a patient’s last name or age.

The Neurofax EEG-1200 system creates segments of acquired data with a maximum duration of

2 hours, hereinafter designated as chunks, organized by the software on the terminal according to the

date and time of acquisition start, with indicators of events within each block added by the specialist.

In order to access the data from a particular patient, it was required to input the patient’s last name,

and then select the relevant chunks.

A list of patients whose data has been made accessible to this work is described in Chapter 5. Each

patient information such as age, gender and last name was retrieved from the written paper notebooks

produced by the unit’s staff. These characteristics could then be introduced in the system to access

the data.

4.2.1 Data retrieval from the hospital’s system

The workflow of data retrieval reflects the premature conceptions about the problem in the earlier

stages of this work. The raw output data from the Neurofax acquisition channels (64-128 EEG + 2

ECG) included information from the entire week of the admission period. This volume of data per

patient was deemed excessive in the earlier stages of the work, containing irrelevant data for the design

purposes of an ECG-based predictor of ictal episodes. The selection of relevant chunks was made by

firstly retrieving the chunk holding the seizure onset, and afterwards retrieving the previous 2 chunks

and the next 2.

The process of downloading a chunk was very cumbersome; furthermore, the software in this system

49

Page 52: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

only allows for the download of the complete set of channels used in the acquisition. The complete

channel list includes every EEG channel used in the setup, 64 to 128, depending on the patient, plus

the video captured by a camera inside the patient’s room. This enormous amount of data meant

that the download of each acquisition chunk took around 1 hour. For an entire group of seizures the

retrieval, following the criteria outlined above could take several days. The downloaded data was saved

to a separate file-system in another terminal of the hospital, as a set of disparate files with different

extensions. The .EEG files were selected and corresponding identification of the channels in the .21E

files, which were copied to an external hard drive for transportation to IT’s servers.

4.2.2 Format and building of the raw database

As the initial .EEG data-structure, native to the NeuroFax system, holds as metadata the complete

patient information and is additionally difficult to manipulate with a Python-API, a decision was made

to initially convert the files into the European Data Format (EDF+) format, simultaneously anonymiz-

ing the data and transforming it into a more amenable structure for implementation with Python’s

pyEDFReader package. This conversion was achieved by making use of the nk2edf (converting .EEG

to edf) utility available for Unix-based systems, which converts .EEG files into the EDF+ format.

The successive rounds of signal-processing underlying the implemented methodology, required an

efficient IO substract on which the data could be rapidly loaded and saved without significant overhead.

It was found that the EDF+ format lacks the efficiency of other, more modern formats to deal with

these operations.

The format of choice for this work was thus the Hierarchical Data Format (HDF5) format, which

gathers the efficiency necessary for the following processing steps, but also the ability to organize the

data into a hierarchical structure.

4.2.3 Dataset restructuring

To create a common time frame of analysis for each seizure, it was necessary to divide the continuous

ECG time-series into fixed time frames of analysis called ’seizure sessions’. These seizure sessions were

extracted having as a reference the time instant of the EEG onset. The rationale for this division,

besides the standardization of the temporal analysis across seizures, was also to expedite and ease the

application of the processing tools for the whole dataset. Having multiple blocks of fixed duration with

respect to the seizure onsets allowed for a more ’modular’ and ’segmented’ database, with a single

unitary dataset referring to only one seizure holding either the raw signals from the acquisition or

even the multi-dimensional extracted feature-space relative to that seizure. Another advantage of such

procedure is the possibility to easily parallelize the execution of the data analysis pipeline, since each

seizure can be processed in parallel to each other, thus increasing the speed of processing.

The criteria for the choice of these time intervals was two-fold: firstly to enable fast runs of the

implemented processing and analysis tools, and thus to easily adjust to the eventual mistakes or

misconception of the problem, allowing for faster corrections, and secondly to gather a somewhat

significant time span of the data preceding the seizure onset, with the objective of a sizeable time

50

Page 53: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

analysis of the predictive capabilities of the algorithms. These time intervals were also motivated by

the lack of uninterrupted contiguous ECG data as the process to extract these data files was laborious

and costly in terms of memory.

From the raw data, the selection of the suitable seizure events, and valid time instants for analysis

was performed according to the following rules:

• A maximum time interval of 2 hours preceding the onset was considered for each seizure;

• Events with onset separated from the previous one by a duration of less than 1h and 30 minutes

were discarded;

• Data points for a particular seizure onset within a 30 minute length window with respect to the

previous onset were discarded.

The outlined requirements are a compromise between the amount of gathered data from the hos-

pital, the necessity to have an expressive segment of samples preceding each onset and to guarantee a

considerable separation between different onsets.

A problem to overcome in the process of building these seizure sessions, was the occurrence of data

drop-outs between the acquisition chunks saved by the Neurofax system. As said before the Neurofax

system creates regular chunks with a maximum fixed duration of 2 hours, leading to drop-outs of the

acquisition in-between the chunks. Also, due to the unpredictable and often violent eruptions of the

motor manifestations from the epileptic patient, there is also a number of intervals within some chunks

with no data acquisition and highly artifact corrupted data.

The creation of the session generates a continuous time frame of analysis, including ECG and

missing data. These periods without any acquisition are dealt with in the later stages of feature

extraction by using a rolling window.

Nihon-KhodhenECG Acquisition

SystemDropout

SystemDropoutEEG

onset 1EEG

onset 2

SeizureSession 1

SeizureSession 2

2 Hours 2 Hours

EEGonset 1

EEGonset 2

time

Figure 4.2: Ilustration of the creation of fixed duration time frames of analysis called seizure sessions from the raw,continuous data.

Each seizure event was coded by a primary key composed of an arbitrary patient ID number, and

a seizure ID number unique for that patient’s number. The implementation of the database for the

processing pipelines resorted to the HDF5 format.

51

Page 54: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

HDF5 allows for hierarchical data objects to be expressed in a natural manner (similar to directories

and files), in contrast with the tables in a relational database. Whereas relational databases support

tables, HDF5 supports n-dimensional datasets, and each element in the dataset may itself be a complex

object. Making use of this format capabilities, each processing operation was grouped in HDF5 groups

that functioned as a directory, holding a single multi-dimensional time series for each seizure, identified

by a patient ID and a seizure ID. For each processing method with a particular set of hyper-parameters,

a new group directory was formed with an identification of that methodology along with respective

hyper-parameters. A new processing step requiring the results from the current group would then be

created in-directory resulting in a processing tree with nested levels, as depicted in Figure 4.3.

RAW

RAW/PROC1

RAW/PROC1/PROC2

Patient ID: 3Seizure ID: 0

Patient ID: 3 Seizure ID: 1

Patient ID: 3 Seizure ID: 2

Patient ID: 3Seizure ID 0

Patient ID: 3 Seizure ID: 1

Patient ID: 3 Seizure ID: 2

Patient ID: 3 Seizure ID: 1

Patient ID: 3Seizure ID 0

Patient ID: 3 Seizure ID: 2

Figure 4.3: Schematic of the nested processing tree, depicting each group of identified seizure sessions as a combinationof processing steps with different hyper-parameters, organized in a directory-like fashion.

52

Page 55: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

4.3 Baseline Wander Removal and Denoising

As a first step in the data processing, the removal of the baseline wander allows for the detrending

of the ECG data for analysis. This is followed by filtering using a low-pass filter with a specified cutoff

frequency as a method to reduce high-frequency noise, and possibly powerline interference (which in

Europe is at 50Hz).

4.3.1 Median filters and 11-th order FIR

Closely following De Chazal et al. (2004), each ECG signal was processed with a median filter of

200 millisecond width, to remove QRS and P-waves. The filtered signal was then again processed

with a median filter of 600 ms width to remove T-waves. The resultant auxiliary signal contained

an approximation of the baseline wandering of the ECG signal, which was then subtracted from the

original data to produce corrected ECG signal. Unwanted powerline and high-frequency noise were

then removed by making use of a 12-tap low-pass filter with ’flat-top’ window, with a cut-off frequency

of 40 Hz. This is standard procedure, and it is depicted in the following diagram.

Median Filter 200 ms: (Removal of QRS-complex and P-waves)

Median Filter 600 ms Removal T-waves 

BaselineWander

Raw ECG

Stationary Noisy ECG

12-tap low-pass filter 'flat-top' window

-

StationaryDenoised

ECG

Figure 4.4: Diagram depicting the process of baseline removal and denoising.

4.3.2 Noise and baseline removal examples

The filtration of some the high frequencies of the signal and the removal of baseline wandering

is fundamental for a successful segmentation of the signal and posterior pattern extraction. The

application of the filtering techniques can be more clearly evaluated on a particualr set of examples

seen in the following figures, on which a red signal shows the original raw ECG, clearly corrupted with

artifacts of movement and a blue signal represents the result of the filtering application.

In order to better illustrate the processing tools used in this work, an archetypal example of a

seizure session, a window of acquisition of signal before and after the event can be used. In this case

a seizure with focal onset and with motor manifestation was used, as it is the most common type of

seizure in the dataset.

Firstly, in Figure 4.5, a general view of a seizure session is presented. In this view of the signal it

can be noted that it becomes much more irregular after the mark of the EEG onset (Black vertical

53

Page 56: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

line). This is to be expected since the seizure was marked by motor manifestations, which increase

the likelihood of Electromyography (EMG) corruption of the signal and artifacts of movement which

results in baseline wandering. In this figure it is also possible to perceive some denoising of the signal,

as the plot of the signal becomes less irregular and more centered on the 0mV .

Figure 4.5: General view of a seizure session, with the depiction of denoising and the removal of baseline wandering.

In order to really grasp the results of the procedure, a smaller time-scale must be used. In these

Figures 4.6 - 4.8, it can more clearly be seen the removal of the baseline wandering and the stabilization

of the signal around 0mv.

54

Page 57: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Figure 4.6: View of the signal from a seizure session, well before the EEG onset, with the depiction of denoising andremoval of baseline wandering.

In Figure 4.13, a section of signal depicting the time instants just before the onset and just after

the onset is shown. In this figure, the occurrence of the seizure onset can be immediately perceived by

the apparent changes in the signal morphology. Before the onset, the signal appears much more noisy

and unstable.

Figure 4.7: View of the signal close to the EEG onset of the epileptic seizure.

After the onset, as shown in Figure 4.8 the signal appears to be more irregular, with increased

55

Page 58: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

corruption by noise, enough to hide the basic components of the ECG heart wave. As the seizure in

question resulted in motor manifestations, the possibility of EMG corruption is high after the onset.

Figure 4.8: View of the signal right after the EEG onset of an epileptic seizure.

A useful visualization of the signal is its amplitude histogram, as shown in Figure 4.9. An analysis

of the figure clearly reveals a loss of gaussianity from the original signal. As indicated by the central

limit theorem, random uncorrelated processes tend to have Gaussian distributions, such as thermal

noise, in contrary to correlated signals, which tend to exhibit nonGaussian distributions Zhao & Zhang

(2018).

Figure 4.9: Change in the signal amplitude histogram, clearly demonstrating the loss of gaussianity from the raw signal(a) to the filtered signal (b), as white noise and artifacts are reduced.

56

Page 59: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

4.4 Feature Extraction

4.4.1 ECG heartbeat waveform segmentation

The detection of fiducial points in ECG was employed using the algorithm proposed by Hamilton

(2002a), in which the main steps are outlined in the schematic shown in Figure 4.16.

The fiducial point of choice in this work is the R-peak, which stands as the highest peak in the

QRS. The method relies on an initial filtering stage of the ECG data, with the sequential application

of a 4th order low pass and high pass filters, with a resultant passing band between 6 and 18Hz. This

modal filtering technique targets the removal of high frequency components that may misguide the

detection of the RP.

A moving average filter with a width of 80 milliseconds, is then computed on the absolute value

of the first derivative of the filtered signal. This pipeline of linear operations ensures a final signal

that contains small ”lumps” (Hamilton 2002b) in the place of the QRS. Afterwards, in a effort to

discriminate between true RP and outliers, a set of simple detection rules is used:

1. Ignore all peaks that precede or follow larger peaks by less than 200 milliseconds;

2. If a peak is detected, check to see whether the raw signal contained both positive and negative

slopes. If not, the peak represents a baseline shift;

3. If the peak occurred within 360 milliseconds of a previous detection check to see if the maximum

derivative in the raw signal was at least half the maximum derivative of the previous detection.

If not, the peak is assumed to be a T-wave.

4. If the peak is larger than the detection threshold, select a RP otherwise consider it noise;

5. If no RP has been detected within 1.5 RR intervals, there was a peak larger than half the detection

threshold, and the peak followed the preceding detection by at least 360 milliseconds, classify

that peak as a RP.

Low-pass Filter (~16 Hz)

High-pass Filter (~8 Hz)

80ms MovingAverage

Peak Detection

Detection Rules

QRSDetection 

Figure 4.10: Depiction of the sequence of steps employed by the Hamilton Algorithm.

57

Page 60: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

The detection threshold used in steps 4 and 5 is computed based on estimates of the RP and noise

peak heights. If a peak is indeed part of a QRS, it is added to a buffer containing the eight most recent

RP. When a peak is not classified as a RP, it is added to a buffer containing the eight most recent

non-RP. The detection threshold is set between the mean or median of the noise peak, and QRS peak

buffers according to the equation:

Detection Threshold = Average Noise Peak + TH (Average QRS Peak - Average Noise Peak) (4.1)

The Python implementation of the algorithm used in this work is contained within the open-source

Biosppy package. From the QRS the time instants of the RP are kept and the detection of the RP is

then used to compute the HRV signal and to extract different templates from the ECG signal.

4.4.2 Segmentation examples

To demonstrate the results of the application of the Hamilton algorithm , it is useful to demonstrate

some examples of the detection.

As depicted in Figure 4.11, the detection as marked by the yellow points, is less erratic before the

onset of the epileptic seizure (black vertical line), and progressively worsens over time after the onset,

as the signal becomes more noisy and irregular.

Figure 4.11: General view of the results of RP detection with the Hamilton algorithm, the results are seizure session0 from patient 3.

In a smaller time-scale 4.12, the robustness of the algorithm is tested on a noisy segment of the

ECG which occurs from the second 4410 to 4412. As indicated by the yellow markers in this segment

of the signal, the algorithm is able to detect some remaining peaks that are still part of the morphology

of the signal, and successfully avoids the marking of presumably artifactual peak around second 4412,

a misdetection that would result in an abrupt variation of the HRV.

58

Page 61: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Figure 4.12: View of the signal from seizure session 0 from patient 3, well before the EEG onset.

In the time period just before the seizure onset, and just after the onset, a moment shown in

Figure 4.13, the performance of the algorithm can be evaluated periods of the signal that are more

problematic.

Figure 4.13: View of the signal close to the EEG onset of the epileptic seizure.

Figure 4.14, shows a different a portion of the signal captured after the onset, clearly depicting a

signal corrupted with more noise and more susceptible of misdetections.

Figure 4.14: View of the signal right after the EEG onset of an epileptic seizure.

4.4.3 Instantaneous heart rate computation and heart wave extraction

Following previous segmentation of the data with fiducial point detection, the time differences

between adjacent peaks were computed. The easy derivation of the signal has popularized its use in

cardiac analysis and it is now a wide-spread metric in several devices in the market for different purposes

Malik et al. (1996). The acquisition of ECG data at a sampling frequency of 1000Hz(> 500Hz) was

ideal to engage in HRV analysis, since this sampling rate is well above the lower bound value of 500Hz

bellow which the error rate of RP detection in patients with low HR is highly significant.

In order to determine morphological changes potentially involved in the genesis of epileptic seizure

59

Page 62: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

two types of heart waves were extracted, fixed segments bQRSi containing the QRS (N1 = −0.05s and

N2 = 0.05s) and bbeati for the entire heart beat (N1 = −0.2s and N2 = 0.4s) were extracted and moved

along the processing pipeline for further analysis.

4.4.4 Outlier removal

A common problem in the analysis of ECG signals is the occurrence of outliers. In a continuous ECG

time series, critical to the HRV analysis is the definition and computation of the so-called NN intervals,

that is, all intervals between adjacent QRS complexes resulting from sinus node depolarization. This

means that the computation of the time series must be robust to the occurrences of RP misdetections.

As explicited in the previous subsection, the method by Hamilton already employs a set a threshold-

based rules to minimize the occurrence of misdetected peaks. Yet, in the presence of heavily corrupted

signals (for example with EMG artifacts) there is so much this set of rules can do, and often the detector

still produces misclassifications. In that spirit, a posterior step of outlier removal is an appropriate

solution to deal with this kind of unwanted signal. This work relies on the method and implementation

developed by Miguel Martinho at IT Lisbon, which detects outliers based on an time-wise adaptive

threshold that takes into account not only the NN sequence, but also the amplitudes of the detected

fiducial points. The method can be summarilly described by the following heuristic for acceptance of

a peak (and corresponding heart-wave) labeled as x:

x ∈ [40, 170] bpm

xamp ∈ AMPrange

αhrY hr ≤ xhr ≤ βhrY hrαampY amp ≤ xamp ≤ βampY amp

(4.2)

Where the xhr and xamp are the instantaneous heart rate and amplitude of the detected fiducial

point, respectively, AMPrange is the fixed amplitude range for the amplitude values of the fiducial

points, specific for each signal, Y hr and Y amp are the average values of instantaneous heart rate and

fiducial point amplitude of the last n accepted peaks, and α and β being parameters are coefficients

that weight the average values.

4.4.5 Computation of features

The computation of features is done resorting to a sliding window with a predefined overlap. In this

work the considered length of the window was 5 minutes: the minimum duration for signifficant HRV

spectral analysis according to Malik et al. (1996), with an overlap (98% - 4 minutes and 94 seconds)

which is important to increase temporal resolution of the subsequent time-series.

4.4.6 Extraction of statistical HRV features

The statistical features described in section 2.4.2 in Chapter 3, were extracted from the series of

time windows consistent with the process outlined above.

However, It is important to note that the rhythmic features are heavily specific to each patient,

each emotional state and dependent on the circadian rhythm, which means that the absolute values of

such time profiles may be difficult to compare across seizures and patients.

60

Page 63: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

One possible work-around to this problem, and one tested in this work was to consider a 10 minute

length initial window defined as the first 10 minutes of the seizure session to serve as control, and

instead of the calculation of the absolute values for each feature, the computation of the ratio between

the metric computed on a posterior 5 minute length window and the metric computed on the control

window.

4.4.7 Spectral analysis of HRV

The spectral analysis of HRV is a difficult problem. The main problem comes from the fact that the

signal is unevenly sampled, a considerable drawback to the use of methods based on the computation

of the FFT. To address this problem, interpolation of the signal to a fixed frequency in the considered

window for analysis is a solution. Cubic spline interpolation was used, which produces a more smooth

interpolation result, increasing the sampling frequency of the signal as well.

As detailed in section 2.4.3, the PSD of the derived HRV signal can be estimated resorting to a

number of different methods, usually parametric or non-parametric. The implemented non-parametric

methods to assess this spectral dimension of the signal were the classical Periodogram, the Welch

method and the Lomb-Scargle periodogram and the implemented parametric methods was the auto-

regressive model by the Yule-Walker derivation. Figure 4.15 demonstrate the resulting PSD in a

defined window of the signal, clearly depicting the estimation of an auto-regressive model as the

smoother alternative, superior to the estimation with the classical Peridogram and the Lomb-Scargle

Periodogram.

The different estimations, which pertain to computations in different 5 minute windows of the NN

sequence, obtained from different periods of the seizure session, clearly show the 3 elevations in the

density function, corresponding to the frequency bands predicted by the literature. The first in the

frequencies across the results of different estimations of the the PSD.

Figure 4.15: Comparison of the different methods for power spectral density estimation of the HRV signal.

61

Page 64: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

4.4.8 Extraction of morphological features

Following the procedure outlined in 4.4, the extraction of morphological features from the ECG

signal in each seizure session proceeded with the computation of the metrics treated in section 2.5, in

defined windows of time in the seizure session.

Both metrics were computed between adjacent beats for each window, then a set of statistical

moments (mean, standard deviation, skewness, kurtosis) and percentiles (median, 25th percentile, 75th

percentile, maximum and minimum) of the distance were calculated for each window, generating a

feature space of 16 dimensions.

The computation of the morphological distances in this way can, however, lead to misleading values.

The statistical description of the distances between adjacent templates is referent to the variation of

the morphology of the heartbeat waveform solely on the window, a clear problem when comparing two

different windows referring to 2 different time zones in the seizure session. The heartbeat waveforms

can manifest a particular variation that produces similar values between the 2 windows, although the

morphology of the group is quite different from window to window.

A simple solution is to consider a control time period, similarly to what is done for the rythm-

related HRV features (described in section 4.4.5), defined to be the window between the beginning

of the seizure session and first 10 minutes of the acquisition. From this period, the mean heartbeat

waveform was computed, and instead of the statistical description of the distances between adjacent

heart beat waveforms in a window, the description was made for distances between each template and

the control mean. In this way, the variability of the morphology of the templates can be measured

having as reference period the time zone that most likely does not have any epileptoform pattern.

This procedure allows for the synchronization of the morphological features with the HRV features

into a single pattern time-series holding both morphological and rythmical characteristics of the signal.

62

Page 65: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

2 Hours Filtered and Segmented ECG

EEG Onset10 min 5 min

5 min 5 min

EEG Onset

Derived pattern time-series from each window 

Compute Mean and Median of similarity coefficient in window

CONTROLWindow

Compute CONTROLMean Heart Wave 

Compute similarity betweeneach Heart Wave in the window

and CONTROL mean Heart Wave

Feature Extraction Window

5 min

EEG Onset

Mean

Median

Figure 4.16: Illustration of the sequence of steps used in the computation of the time series of morphological patterns.

4.5 Identification of pre-ictal states

A simple and straightforward method to predict seizures is to identify a pre-ictal (close to onset)

state within a pattern time-series of a seizure session (a state that could serve as a basis for an alarm).

63

Page 66: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

This identification can be reduced to the problem of distinguishing between samples of two different

classes. A possible labeling criteria is to say that, for each seizure, the samples within 30 minutes before

the EEG-onset belongs to pre-ictal class (red), and the points lying within the time period from the

beginning of the seizure session with a duration of 30 minutes, belong to inter-ictal class (red) as

depicted in Figure 4.17. The points in-between the time-periods belong to an unspecific non-labeled

group, that is points that do not belong to any class.

This particular labeling scheme allows for the classifiers to learn from samples from two different

time-periods considerably far apart from each other within the seizure session, likely maximizing the

separation between pattern samples from different classes, which in turn will result in a more optimized

classification task.

Inter-ictal

EEG onset

Pre-ictal

30 min 30 min

2 Hours

Figure 4.17: Figure depicting the labeling criteria of the data within each seizure occurrence.

4.5.1 Leave-one-seizure-out nested cross-validation

In order to get a good sense of the generalization performance, the models are trained based on

leave-one-seizure-out (LOSO) N-fold nested cross-validation scheme, as represented by Figure 4.18.

Following this paradigm, each seizure of the N total in the dataset is chosen to evaluate the predictive

performance on unseen seizures, and the remaining N-1 seizures are left for training. The training set

is further sub-divided, again leaving one seizure for validation and N - 2 for the training of the model

with a particular set of hyper-parameters. Each seizure is chosen once to serve as validation. In this

nested fold, the algorithms are trained with different sets of hyper-parameters, and the set producing

the highest mean validation score is chosen, the set of hyper-parameters is then used to retrain the

classifier on the training set. For each seizure an optimized model is trained on the data from other

seizures.

As referenced in Korjus et al. (2016) using different sub-sets of the data to optimize a given clas-

sifier’s hyper-parameters than the one used to evaluate the classifier’s performance is important to

prevent information leakage from training set and thus overfitting.

4.5.2 Sample-by-sample classification

Typical measures to assess classification performance Flach & Kull (2015) are accuracy, precision

(positive predictive value) and recall (sensitivity), which can be expressed as functions of true positives

(TP), false positives (FP), true negatives (TN) and false negatives (FN):

64

Page 67: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Figure 4.18: Schematic depicting the nested cross-validation scheme used for the training phase.

Accuracy =TP + TN

TP + FP + TN + FN(4.3)

Precision =TP

TP + FP(4.4)

Recall =TP

TP + FN(4.5)

A given algorithm can be used to fit a specific model based on the maximization of one of these

scores. Yet, for a particular choice of labeling criteria, the resulting datasets can be heavily impacted

by class imbalance (much more inter-ictal data points). For this reason, care must be taken on the

choice of the metric to maximize, as for example maximizing accuracy could simply result in a decision

function favoring the over-represented class.

A better solution is to optimize for recall or precision. Ideally a ponderation of both. A single

metric comprising both these dimensions is the F-score, which is the harmonic mean of the scores:

F1 =2.TP

2.TP + FP + FN(4.6)

4.5.3 Features Categorization

In order to succinctly evaluate the results from each type of feature, appropriate codes must be

given to the features. The computed features can be divided into 2 main groups: feature-set M and

feature-set R.

65

Page 68: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Feature-set M, comprises the morphological features computed from the extracted fixed length

heartbeat waveforms, based on the previous RP fiducial point detection. Metrics referring to the Eu-

clidean distance belong to the feature group M.1, metrics referring to the Pearson correlation coefficient

are grouped under the group M.2, subdividing each group in (a) for metrics computed on the beat and

(b) for metrics computed on the QRS.

Feature-set R, comprises the features related to heart-rate variability, which entails also the ratios

between statistical computations on the NN intervals such as the meanNN and the SDNN, belonging to

feature group R.1, together with spectral considerations of the epochs, which belong to feature group

R.2. The summary of the extracted features can be found on Table 4.1

Table 4.1: Summary of the extracted features grouped under bi-dimensional patterns with corresponding labels.

66

Page 69: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

5Experimental Results and

Discussion

Contents5.1 Dataset Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

5.2 General structure of the results presentation and discussion . . . . . . . 69

5.3 Noise and baseline removal . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

5.4 Evaluation of impact on data . . . . . . . . . . . . . . . . . . . . . . . . . . 69

5.5 Patient-specific classification results . . . . . . . . . . . . . . . . . . . . . . 70

67

Page 70: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

5.1 Dataset Description

A list of patients made accessible to this work is described in 5.1. Each patient information such

as age, gender and last name was retrieved from the written paper notebooks produced by the unit’s

staff. These characteristics could then be introduced in the system to access the data.

Table 5.1: General description of the data set

Patient 3 Patient 4 Patient 5 Patient 7 Patient 8 Patient 10 Patient 13Age 30 40 42 31 28 43 13Gender f f f m m m fNumber of events 3 3 8 2 10 4 11

Table 5.2 presents the events considered for analysis in this work. Each entry corresponds to the

description of a seizure block, a common time-frame of analysis introduced in Chapter 4, which serves

as session or as a series of data containing only one seizure. It also holds a description of seizure type

and location. As explained in Chapter 4, the information in the table concerns information present in

the written reports by the EEG specialists at SMH, and describes for each event the type of seizure

following the ILAE convention. This represents a reduced dataset since it only presents the seizures

that respect the segmentation rules described before.

Table 5.2: Description of the Events in the dataset

Type of Seizure Location Data without drop-outs [Hours]Patient ID Seizure ID

3 0 G - A - M L-R (F, T) 1.9964991 F - NA - M L (F, T) 1.9962222 F - A - M L (F, T) 1.996222

5 0 F,SG - NA - M L (C, FC) 1.9964991 F - NA - NM L (C, FC) 1.9959442 F,SG - NA - M L (C, FC) 1.9959443 F,SG - NA - M L (C, FC) 1.7733614 F,SG - NA - M L (C, FC) 1.4750276 F,SG - NA - M L (C, FC) 1.232805

8 0 F - A - NM R (FT, T) 1.9964991 F - NA - NM R (FT, T) 1.9962222 F - A - NM R (FT, T) 1.9964993 F - NA - M R (T) 1.9962224 F - A - M R (T) 1.9962228 F - NA - Mr R (T, TP) 1.6717779 G - NA - M R (T, P, F) 1.99622210 F,SG - A - M R (T, P, F) 1.995944

10 0 F,SG - A - M L (F, FT, F, FC) 1.9959441 F,SG - NA - M L (FT, T) 0.9463052 F,SG - NA - M L (F, FT) 1.0715833 F,SG - NA - M F (F, FT) 1.996222

13 0 F - NA - NM R (P, O, PO) 0.0463051 F,SG - A - NM R (P, O, PO) 1.9964993 F,SG - A - NM R (P, O, PO) 1.9962224 F,SG - A - M R (P, O, PO) 1.823638

Event classification: G-Generalized, F-Focal, A-Aware, NA-Not Aware, M-Motor, NM-Non MotorEvent Location: R-Right Hemisphere, L-Left Hemisphere, F-Frontal , FT-Fronto-temporal,

68

Page 71: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

5.2 General structure of the results presentation and discus-sion

5.3 Noise and baseline removal

The filtration of some the high frequencies of the signal and the removal of baseline wandering is

fundamental for a successful segmentation of the signal and posterior pattern extraction. In this work

this is achieved by the application of 12-th order Finite Impulse Response (FIR) filter and a median

filter. The application of such methodology can be seen in the following figures, on which a red signal

shows the original raw ECG, clearly corrupted with artifacts of movement and a blue signal marks

represents the result of the filters application.

5.4 Evaluation of impact on data

In order to fully appreciate the impact of the processing tools on the non-stationarity and the noise

of the ECG data, it is important to compute certain metrics, called Signal Quality Index (SQI), on

the relevant aggregates of data. Without too great expansion on the theory behind the used metrics,

measurements of stationarity can be done resorting to the standard deviation and on the relative

power of the baseline, defined as the Baseline Signal Quality Index (basSQI) Zhao & Zhang (2018).

To quantify noise reduction one possible metric to use is the Kurtosis Signal Quality Index (kSQI),

which figures as fourth standardized moment of a distribution, measuring the relative peakedness of

a distribution with respect to a Gaussian distribution, being highly correlated with the SNR of the

signal. Another useful metric is the QRS Signal Quality Index (pSQI) which is relative power of the

QRS complex, a highly sensitive metric to noise, since it the QRS holds 99 % of the energy of the

signal.

The mean of these metrics is computed to evaluate the performance of the methods on aggregates

of data. By analyzing the patient-specific data, as shown in figure 5.1, it can be stated the the method

results in increased mean basSQI for all patients and a decrease in the standard deviation of the signal,

indicating the reduced variability and non-stationarity of the filtered data specific to the patient. In

fact, it can be seen that mean basSQI rises to a value considered to be optimal for an ECG signal,

which is around 0.95-1, a marked improvement from the values well beyond 0.8 characteristic of the

median filtered signal.

The figure also demonstrates the increase in the mean pSQI of the filtered datasets demonstrating

the increase in the relative power of the QRS complex, an indication of reduced noise. The same

reasoning can be made by analyzing the results for the kSQI. The filters result in signals with decreased

kurtosis, indicative of an increasingly correlated signal less influenced by noise and artifacts.Another

variant of this analysis can be made based on the hemisphere of origin of the onset. It can be seen

that the described metrics show the same pattern of variation as the results specific to the patient.

69

Page 72: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Figure 5.1: Depiction of the mean SQI for the data of each patient, illustrating the performance of the denoising andthe baseline removal method. In (a) the values for the mean basSQI are plotted, in (b) the mean pSQI, in (c) the valuesfor mean kSQI. In red are illustrated the raw signals and in blue for the filtered signals.

5.5 Patient-specific classification results

In order to evaluate the predictive capabilities of the proposed algorithms, one possible scenario

is to restrict the data to a single patient. Following the cross-validation schematic presented on the

previous section, the step of restricting the data to a single patient results in several implications.

Since there is stage of optimization a set of hyper-parameters only patients with more than 3 seizures

are considered, and thus the final database for analysis only contemplates the patients listed in section

5.1.

The restriction of the training set to only patient-specific data, may outline some intrinsic variability

characteristic of the patient. In fact, it is highly likely that a particular set of neurophysiological

determinants may result in a highly specific disorder which may be characterized by a particular

frequency and severity of outbursts. Nevertheless, the reduced amount of events per patient may be a

heavily impactful factor in this type of classification, leading to poor and unexpressive results.

The labeling criteria presented in section 4.5, for the pre-ictal period is in line to what is traditionally

considered in seizure prediction works Teixeira et al. (2011). The decision to label the two time-periods

with an intermediate unspecific zone is to increase the separability between points of the extracted

features.

Given the discussed cross-validation scheme, the capability of the classifier to distinguish a pre-ictal

zone from each seizure session (each one belongig to the test set) can be measured by the F1-score.

The folowing tables and plots present the mean and standard deviation of the F1-score evaluated in

each test seizure. The results are grouped per relevant pattern comprising a a bi-dimensional feature

space.

70

Page 73: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Evaluating the results individually by patient resorting to the following plots evidences the impos-

sibility to draw meaningful conclusions.

Figure 5.2: Depiction of the classification for the data of Patient 3, results as measured by the F1-score and as functionof the feature groups.

Figure 5.3: Depiction of the classification for the data of Patient 5, results as measured by the F1-score and as functionof the feature groups.

71

Page 74: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Figure 5.4: Depiction of the classification for the data of Patient 8, results as measured by the F1-score and as functionof the feature groups.

Figure 5.5: Depiction of the classification for the data of Patient 10, results as measured by the F1-score and as functionof the feature groups.

Figure 5.6: Depiction of the classification for the data of Patient 13, results as measured by the F1-score and as functionof the feature groups.

72

Page 75: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Aditionally, tables 5.3, 5.4, 5.5, present the results for the statistics across seizures of a single

patient, that is patient-specific classification, using (respectively) the KNN, the Gaussian Naive-Bayes

Gaussian Naive Bayes (GaussNB), and Soft-margin Support Vector Machine (SVC) classifiers.

Theoretically, as discussed in subsection 2.3.1, a primal indicator of pre-ictal change is the IT, a

manifestation which would be reflected on the rhythmical features R.1.a and R.2. By evaluating the

results of the classifier trained on seizures from different brain hemispheres one can percieve that the K-

nearest Neighbour classifier produces the Gaussian Naive Bayes produces the best results. Considering

the Patient-specific classification results, and evaluating the performance of different feature groups in

the classification task, one can state that across different classifiers, the best results are consistently

produced by the same feature groups, with the few exceptions. This suggests that irresceptively of the

trained model, the classifier can perform best on the same characteristics of the patient’s signals.

Yet there is no clear distinction on which feature group performs the best irrespective of the Patient.

For different Patients the best feature group varies, which indicates that for some patients, for example

Patient 3, 5 and 8 the best feature group is a morphological feature group, suggesting that there is a

more pronounced modification in morphology for these patients which is indicative of the the pre-ictal

sample. In other patients the best performance is brought about by ryhtmic feature groups, which

suggests pre-ictal rythmic alterations.

The best results in terms of best patient are also consistent across classifiers: Patient 13 and 8

produce the best overall F1-scores. This is not unexpected, since these patients have the best quality

data (that is less drop-outs) and the highest number of seizures (in the case of Patient 8).

Comparing the different classifiers one can notice that there is little difference between the 3. It

is important to note the high values of standard-deviation of the metric, which indicates that there is

high variation of the score across seizures from the patient (in the case of patient-specific classification)

or across seizures from a particular location. This value becomes much smaller in patients with a

greater number of seizures or in greater groups of seizures.

73

Page 76: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Table 5.3: F1-score Patient-specific classification results for the GaussNB classifier.

mean stdModel Patient ID Feature Group

GaussNB 3 M.1.a 0.353563 0.324501M.1.b 0.267756 0.332114M.2.a 0.207458 0.181678M.2.b 0.419585 0.307479R.1.a 0.587264 0.151001R.2 0.505716 0.028552

5 M.1.a 0.547318 0.474455M.1.b 0.058043 0.100534M.2.a 0.186603 0.323206M.2.b 0.297862 0.285670R.1.a 0.410145 0.410823R.2 0.441436 0.382296

8 M.1.a 0.656926 0.332435M.1.b 0.740897 0.228679M.2.a 0.619074 0.324936M.2.b 0.537145 0.277085R.1.a 0.581088 0.214933R.2 0.057063 0.098927

10 M.1.a 0.261559 0.453033M.1.b 0.263298 0.456045M.2.a 0.414241 0.396358M.2.b 0.267930 0.464068R.1.a 0.359520 0.311817R.2 0.403191 0.356979

13 M.1.a 0.676272 0.135595M.1.b 0.656394 0.054692M.2.a 0.661765 0.478337M.2.b 0.684332 0.446422R.1.a 0.672452 0.126219R.2 0.666935 0.122772

74

Page 77: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Table 5.4: F1-score Patient-specific classification results for the KNN classifier.

mean stdModel Patient ID Feature Group

KNN 3 M.1.a 0.531194 0.241979M.1.b 0.287303 0.250320M.2.a 0.179850 0.175632M.2.b 0.130800 0.111028R.1.a 0.397879 0.247313R.2 0.386656 0.126639

5 M.1.a 0.473298 0.418639M.1.b 0.451321 0.468124M.2.a 0.331064 0.335386M.2.b 0.424336 0.461310R.1.a 0.289989 0.252221R.2 0.457251 0.397088

8 M.1.a 0.714236 0.188940M.1.b 0.692189 0.242288M.2.a 0.666027 0.167079M.2.b 0.618642 0.177675R.1.a 0.515765 0.203572R.2 0.379306 0.128348

10 M.1.a 0.274637 0.441271M.1.b 0.256954 0.445057M.2.a 0.370516 0.341329M.2.b 0.264706 0.458484R.1.a 0.338130 0.293325R.2 0.408131 0.353475

13 M.1.a 0.667472 0.022325M.1.b 0.530074 0.037077M.2.a 0.674886 0.250036M.2.b 0.538327 0.485116R.1.a 0.483854 0.194945R.2 0.542955 0.056255

75

Page 78: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Table 5.5: F1-score Patient-specific classification results for the SVC classifier.

mean stdModel Patient ID Feature Group

SVC 3 M.1.a 0.536220 0.271074M.1.b 0.263510 0.390587M.2.a 0.120203 0.138596M.2.b 0.025974 0.044988R.1.a 0.581087 0.391706R.2 0.394412 0.103132

5 M.1.a 0.541246 0.470426M.1.b 0.353514 0.333052M.2.a 0.220467 0.381859M.2.b 0.334011 0.330749R.1.a 0.361461 0.335237R.2 0.441187 0.382080

8 M.1.a 0.743098 0.276632M.1.b 0.783972 0.152307M.2.a 0.628229 0.337939M.2.b 0.509941 0.263873R.1.a 0.594860 0.162840R.2 0.385773 0.164180

10 M.1.a 0.265772 0.460330M.1.b 0.000000 0.000000M.2.a 0.409449 0.402622M.2.b 0.270123 0.467866R.1.a 0.282314 0.251124R.2 0.411668 0.356584

13 M.1.a 0.665231 0.180029M.1.b 0.640059 0.028009M.2.a 0.472789 0.264564M.2.b 0.660249 0.000544R.1.a 0.660249 0.000544R.2 0.769179 0.120422

76

Page 79: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

6Conclusions And Future Work

Contents6.1 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

6.2 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

77

Page 80: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

6.1 Conclusions

Despite the unclear results, the use of patterns from ECG signals is promising. The fundamental

steps of implementation were employed sucessfully to produce the preceding results. In fact, the levels

of precision and recall for the detection of pre-ictal patterns for some of the seizure sessions, and

particularly for some of the morphologic features show promise.

For the reasons outlined in the discussion, the results suffered greatly from the lack of appropriate

and sufficient data-points. This lack of results, is no doubt the consequence from premature conceptions

about the problem in the sense that continuous data acquisition was not possible.

There is however, no clear distinction on which feature group performs the best irrespective of

the Patient, with some patients demonstrating better performances for different patterns, possibly

evidencing some patient-specific pre-ictal alterations better percieved with different types of features.

It is important to refer the sucessful use of morphological features, resulting in 12 out 15 best

classification performances. The use of morphological features in the seizure prediction literature is,

at best, rare, and this work shows some possibility of use of these features for prediction, or at least

to distinguish pre-ictal samples from inter-ictal, although the reduced volume and diminished quality

of the data negatively affect the strength of such conclusions.

6.2 Future Work

A possible route to explore for future works is first and foremost to gather more data. The increase

the number of data points is fundamental to improve the classifiers precision and recall and in turn

better identify possible pre-ictal samples.

Another possible way to improve, linked to the need to increase data volume is to ultimately

improve the quality of acquired signals, with less noise and artifacts. This in turn, will surely improve

the quality of the classification results, since as discussed in the previous chapters a number of seizure

sessions are also corrputed by missing values.

Another more hands-on-approach to improve on these methodologies is to implement a system of

alarm generators that builds on the decision function of the classifiers to detect the crossing of certain

thresholds and produce automated warnings.

This implementation would in turn allow for the algorithms to be trained on the patient’s data

gathered from the hospital system and to use these algorithms to predict seizures based on real-time

data acquisition by the wearable’s system acquisition.

78

Page 81: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Bibliography

Bandarabadi, M., Teixeira, C. A., Rasekhi, J. & Dourado, A. (2015), ‘Epileptic seizure prediction using

relative spectral power features’, Clinical Neurophysiology 126(2), 237–248.

Behbahani, S., Dabanloo, N. J., Nasrabadi, A. M. & Dourado, A. (2016), ‘Prediction of epileptic

seizures based on heart rate variability’, Technology and Health Care 24(6), 795–810.

Boardman, A., Schlindwein, F. S., Rocha, A. P. & Leite, A. (2002), ‘A study on the optimum order of

autoregressive models for heart rate variability’, Physiological Measurement 23(2), 325–336.

Bruno, E., Biondi, A. & Richardson, M. P. (2018), ‘Pre-ictal heart rate changes: A systematic review

and meta-analysis’, Seizure 55, 48–56.

De Chazal, P., O’Dwyer, M. & Reilly, R. B. (2004), ‘Automatic classification of heartbeats using

ecg morphology and heartbeat interval features’, IEEE Transactions on Biomedical Engineering

51(7), 1196–1206.

Eggleston, K. S., Olin, B. D. & Fisher, R. S. (2014), ‘Ictal tachycardia: The head–heart connection’,

Seizure 23(7), 496–505.

Engel, J. (2011), ‘The etiologic classification of epilepsy: GRAY MATTERS’, Epilepsia 52(6), 1195–

1197.

Fisher, R. S., Acevedo, C., Arzimanoglou, A., Bogacz, A., Cross, J. H., Elger, C. E., Engel, J., Forsgren,

L., French, J. A., Glynn, M., Hesdorffer, D. C., Lee, B., Mathern, G. W., Moshe, S. L., Perucca, E.,

Scheffer, I. E., Tomson, T., Watanabe, M. & Wiebe, S. (2014), ‘ILAE Official Report: A practical

clinical definition of epilepsy’, Epilepsia 55(4), 475–482.

Fisher, R. S., Boas, W. v. E., Blume, W., Elger, C., Genton, P., Lee, P. & Engel, J. (2005), ‘Epileptic

Seizures and Epilepsy: Definitions Proposed by the International League Against Epilepsy (ILAE)

and the International Bureau for Epilepsy (IBE)’, Epilepsia 46(4), 470–472.

Fisher, R. S., Cross, J. H., D’Souza, C., French, J. A., Haut, S. R., Higurashi, N., Hirsch, E., Jansen,

F. E., Lagae, L., Moshe, S. L., Peltola, J., Roulet Perez, E., Scheffer, I. E., Schulze-Bonhage, A.,

Somerville, E., Sperling, M., Yacubian, E. M. & Zuberi, S. M. (2017), ‘Instruction manual for the

ILAE 2017 operational classification of seizure types’, Epilepsia 58(4), 531–542.

Flach, P. & Kull, M. (2015), ‘Precision-Recall-Gain Curves: PR Analysis Done Right’, p. 9.

79

Page 82: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Hamilton, P. (2002a), Open source ecg analysis, in ‘Computers in Cardiology, 2002’, IEEE, pp. 101–

104.

Hamilton, P. (2002b), Open source ecg analysis, in ‘Computers in Cardiology, 2002’, IEEE, pp. 101–104.

Hastie, T., Tibshirani, R. & Friedman, J. (2009), The Elements of Statistical Learning: Data Mining,

Inference, and Prediction, Second Edition (Springer Series in Statistics), Springer, New York.

Iaizzo, P. A., ed. (2005), Handbook of Cardiac Anatomy, Physiology, and Devices, Current clinical

oncology, Humana Press, Totowa, N.J. OCLC: 990296487.

Jansen, K. & Lagae, L. (2010), ‘Cardiac changes in epilepsy’, Seizure 19(8), 455–460.

Jansen, K., Varon, C., Van Huffel, S. & Lagae, L. (2013), ‘Peri-ictal ECG changes in childhood epilepsy:

Implications for detection systems’, Epilepsy & Behavior 29(1), 72–76.

K. Fujiwara, M. Miyajima, T. Yamakawa, E. Abe, Y. Suzuki, Y. Sawada, M. Kano, T. Maehara,

K. Ohta, T. Sasai-Sakuma, T. Sasano, M. Matsuura & E. Matsushima (2016), ‘Epileptic Seizure

Prediction Based on Multivariate Statistical Process Control of Heart Rate Variability Features’,

IEEE Transactions on Biomedical Engineering 63(6), 1321–1332.

K. Hoyos-Osorio, J. Castaneda-Gonzaiez & G. Daza-Santacoloma (2016), Automatic epileptic seizure

prediction based on scalp EEG and ECG signals, in ‘2016 XXI Symposium on Signal Processing,

Images and Artificial Vision (STSIVA)’, pp. 1–7.

Kiral-Kornek, I., Roy, S., Nurse, E., Mashford, B., Karoly, P., Carroll, T., Payne, D., Saha, S.,

Baldassano, S., O’Brien, T., Grayden, D., Cook, M., Freestone, D. & Harrer, S. (2018), ‘Epileptic

Seizure Prediction Using Big Data and Deep Learning: Toward a Mobile System’, EBioMedicine

27, 103–111.

Korjus, K., Hebart, M. N. & Vicente, R. (2016), ‘An Efficient Data Partitioning to Improve Classifi-

cation Performance While Keeping Parameters Interpretable’, PLOS ONE 11(8), e0161788.

Malik, M., Bigger, J. T., Camm, A. J., Kleiger, R. E., Malliani, A., Moss, A. J. & Schwartz, P. J.

(1996), ‘Heart rate variabilityStandards of measurement, physiological interpretation, and clinical

use’, European Heart Journal 17(3), 354–381.

Malmivuo, J., Plonsey, R. et al. (1995), Bioelectromagnetism: principles and applications of bioelectric

and biomagnetic fields, Oxford University Press, USA.

Masse, F., Bussel, M. V., Serteyn, A., Arends, J. & Penders, J. (2013), ‘Miniaturized wireless ECG

monitor for real-time detection of epileptic seizures’, ACM Transactions on Embedded Computing

Systems 12(4), 1.

Moridani, M. K. & Farhadi, H. (2017), ‘Heart rate variability as a biomarker for epilepsy seizure

prediction’, Bratislava Medical Journal 118(01), 3–8.

80

Page 83: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

Ngugi, A. K., Kariuki, S. M., Bottomley, C., Kleinschmidt, I., Sander, J. W. & Newton, C. R. (2011),

‘Incidence of epilepsy: A systematic review and meta-analysis’, Neurology 77(10), 1005–1012.

Rasekhi, J., Mollaei, M. R. K., Bandarabadi, M., Teixeira, C. A. & Dourado, A. (2015), ‘Epileptic

Seizure Prediction based on Ratio and Differential Linear Univariate Features’, 5(1), 11.

Scheffer, I. E., Berkovic, S., Capovilla, G., Connolly, M. B., French, J., Guilhoto, L., Hirsch, E., Jain,

S., Mathern, G. W., Moshe, S. L., Nordli, D. R., Perucca, E., Tomson, T., Wiebe, S., Zhang, Y.-H. &

Zuberi, S. M. (2017), ‘ILAE classification of the epilepsies: Position paper of the ILAE Commission

for Classification and Terminology’, Epilepsia 58(4), 512–521.

Teh, H., Loo, C., Tan, H. & Raymond, A. (n.d.), ‘The QT interval in epilepsy patients compared to

controls’, p. 1.

Teixeira, C., Direito, B., Feldwisch-Drentrup, H., Valderrama, M., Costa, R., Alvarado-Rojas, C.,

Nikolopoulos, S., Le Van Quyen, M., Timmer, J., Schelter, B. & Dourado, A. (2011), ‘EPILAB: A

software package for studies on the prediction of epileptic seizures’, Journal of Neuroscience Methods

200(2), 257–271.

Townsend, R. H. D. (2010), ‘Fast Calculation of the Lomb-Scargle Periodogram Using Graphics Pro-

cessing Units’, The Astrophysical Journal Supplement Series 191(2), 247–253.

Truong, N. D., Nguyen, A. D., Kuhlmann, L., Bonyadi, M. R., Yang, J. & Kavehei, O. (2017),

‘A Generalised Seizure Prediction with Convolutional Neural Networks for Intracranial and Scalp

Electroencephalogram Data Analysis’, arXiv:1707.01976 [cs] .

VanderPlas, J. T. (2018), ‘Understanding the Lomb-Scargle Periodogram’, The Astrophysical Journal

Supplement Series 236(1), 16.

Varon, C., Jansen, K., Lagae, L. & Huffel, S. (2013), Detection of Epileptic Seizures by Means of

Morphological Changes in the ECG, Vol. 40.

Winterhalder, M., Maiwald, T., Voss, H., Aschenbrenner-Scheibe, R., Timmer, J. & Schulze-Bonhage,

A. (2003), ‘The seizure prediction characteristic: A general framework to assess and compare seizure

prediction methods’, Epilepsy & Behavior 4(3), 318–325.

Zhao, Z. & Zhang, Y. (2018), ‘SQI Quality Evaluation Mechanism of Single-Lead ECG Signal Based

on Simple Heuristic Fusion and Fuzzy Comprehensive Evaluation’, Frontiers in Physiology 9.

81

Page 84: Analysis of Electrocardiographic Patterns for Epileptic ... · 4.1 Diagram depicting the sequence of the proposed methodology. . . . . . . . . . . . . . . .48 4.2 Ilustration of the

82