analysis and classification of ecg signal using neural network

112
This final year project report is submitted to Faculty of Engineering Multimedia University in partial fulfilment for Bachelor of Engineering FACULTY OF ENGINEERING MULTIMEDIA UNIVERSITY APRIL 2010 ANALYSIS and CLASSIFICATION of EEG SIGNALS using NEURAL NETWORK by LAM ZHENG YAN (1061108486) B.Eng.(Hons) Electronics Majoring in Nanotechnology Session 2009/2010

Upload: zheng-yan-lam

Post on 08-Aug-2015

30 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Analysis and Classification of ECG Signal using Neural Network

This final year project report is submitted to

Faculty of Engineering

Multimedia University

in partial fulfilment for

Bachelor of Engineering

FACULTY OF ENGINEERING

MULTIMEDIA UNIVERSITY

APRIL 2010

ANALYSIS and CLASSIFICATION of EEG

SIGNALS using NEURAL NETWORK

by

LAM ZHENG YAN

(1061108486)

B.Eng.(Hons) Electronics Majoring in

Nanotechnology

Session 2009/2010

Page 2: Analysis and Classification of ECG Signal using Neural Network

ECG

ANALYSIS and CLASSIFICATION of

SIGNALS using NEURAL

NETWORK

LAM ZHENG YAN

1061105869

2009/2010

FACULTY OF ENGINEERING

MULTIMEDIA UNIVERSITY

APRIL 2010

Page 3: Analysis and Classification of ECG Signal using Neural Network

The copyright of this report belongs to the author under the

terms of the Copyright Act 1987 as qualified by Regulation 4(1) of

the Multimedia University Intellectual Property Regulations. Due

acknowledgement shall always be made of the use of any material

contained in, or derived from, this report.

Page 4: Analysis and Classification of ECG Signal using Neural Network

DECLARATION

I hereby declare that this work has been done by myself and no portion of thework contained in this report has been submitted in support of any applicationfor any other degree or qualification of this or any other university or institute oflearning.

I also declare that pursuant to the provisions of the Copyright Act 1987, I havenot engaged in any unauthorised act of copying or reproducing or attempt to copy/ reproduce or cause to copy / reproduce or permit the copying / reproducingor the sharing and / or downloading of any copyrighted material or an attemptto do so whether by use of the Universitys facilities or outside networks / facil-ities whether in hard copy or soft copy format, of any material protected underthe provisions of sections 3 and 7 of the Act whether for payment or otherwisesave as specifically provided for therein. This shall include but not be limited toany lecture notes, course packs, thesis, text books, exam questions, any works ofauthorship fixed in any tangible medium of expression whether provided by theUniversity or otherwise.

I hereby further declare that in the event of any infringement of the provisionsof the Act whether knowingly or unknowingly the University shall not be liablefor the same in any manner whatsoever and undertakes to indemnify and keepindemnified the University against all such claims and actions.

Signature: .............................................Name: LAM ZHENG YANStudent ID: 1061108486Date: APRIL 2010

Page 5: Analysis and Classification of ECG Signal using Neural Network

Acknowledgements

I would like to express my most sincere thanks to my project supervisor Dr. Khaz-

aimatol Shima Subari for her constant guidance, endless support and encourage-

ment. Her vast technical knowledge, unique insight and experience have inspired

and motivate me during my research on this project.

Special thanks to the research officer namely Mr. Justin Leo Cheang Loong and

Mr. Muhammad Kamil bin Abdullah for giving their technical assistance on the

Matlab computing software.

I extend my thanks to all my course mates and friends for their fruitful discussion

and suggestion on doing this project. In particular, Im grateful to Veren Teoh

Chin Lai, Yeong Kai Bin, Faliq Rizal Madzri and Noorain Ismail for sharing with

me their knowledge. On top of that, special thanks to Ko Shao Peng for helping

me to proof read this thesis.

Finally, I would like to thank my parents for their care and love which keep me

going strong throughout the entire process of doing this project. Their words of

wisdom and encouragement have provided me with optimism and hope in life.

Page 6: Analysis and Classification of ECG Signal using Neural Network

Abstract

This project presents the study and analysis of electrocardiogram classified by

neural network known as biometrics system. The first part of this project describes

the basic theory of the electrocardiogram (ECG) and setup the experiment of ECG

signal acquisition. Three test subjects have involved in first part of experiment

which will modify the procedure of experiment for large number of test subjects.

Preprocessing of ECG signal such as filtering, segmentation and feature extraction

will be done before classification. The moving average filter is used to remove the

noise of ECG. Signal frequency spectrum has shown the frequency range from 0

Hz to 45 Hz which presented the characteristic of ECG. The design of IIR filter

is according to the cutoff frequency that given by 45 Hz.

In second part of this project, we setup two experiments which is experiment A

and experiment B. Experiment A was 11 test subjects recorded 10 set of ECG

data in one day. Experiment B was 4 subject recorded 30 set of ECG data in

three days. We segment the ECG into 15 pieces per period of signal and extract

the features by wavelet decomposition for each segment. We designed a systematic

and flexible data structure which will help us in analysis and discussion. Feed-

forward backpropagation neural network is used to classify our test subjects. The

recognition rate of experiment A and B are 80.89% and 93.75%. We concluded

that larger set of training data has a better recognition rate and test subject must

follow certain rules to provide better quality of ECG signal.

Page 7: Analysis and Classification of ECG Signal using Neural Network

Contents

DECLARATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I

Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I

Abstract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I

1 Project Overview 1

1.1 Motivation and Objective . . . . . . . . . . . . . . . . . . . . . . . 1

1.2 Scope of Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.3 Thesis Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Introduction 4

2.1 Heart Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2.2 Electrocardiogram (ECG) . . . . . . . . . . . . . . . . . . . . . . . 6

2.3 ECG Signal Acquisition . . . . . . . . . . . . . . . . . . . . . . . . 10

2.4 Characteristics of ECG . . . . . . . . . . . . . . . . . . . . . . . . . 11

2.5 Artifacts of ECG . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

2.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

IV

I

II

Page 8: Analysis and Classification of ECG Signal using Neural Network

CONTENTS V

3 Classification 14

3.1 Concepts of Pattern Recognition . . . . . . . . . . . . . . . . . . . . 14

3.2 Brief History of Neural Networks . . . . . . . . . . . . . . . . . . . 15

3.3 Neural Network-based Classifier . . . . . . . . . . . . . . . . . . . . 16

3.4 Firing Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

3.5 Architecture of Neural Networks . . . . . . . . . . . . . . . . . . . . 18

3.5.1 Feed-forward Network . . . . . . . . . . . . . . . . . . . . . 18

3.5.2 Feedback Network . . . . . . . . . . . . . . . . . . . . . . . 18

3.5.3 Perceptrons . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

3.6 Applications of Neural Network . . . . . . . . . . . . . . . . . . . . 21

3.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

4 Experimental Setup and Methodology 23

4.1 Experimental Layout . . . . . . . . . . . . . . . . . . . . . . . . . . 23

4.2 Test Subject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

4.3 Filtering Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

4.4 Features Extraction . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

4.5 Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

4.5.1 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . 30

4.5.2 Classifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

4.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

Page 9: Analysis and Classification of ECG Signal using Neural Network

CONTENTS VI

5 Result and Discussion 40

5.1 Result of Experiment A . . . . . . . . . . . . . . . . . . . . . . . . 40

5.2 Result of Experiment B . . . . . . . . . . . . . . . . . . . . . . . . 44

5.3 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

5.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

5.5 Recommendation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

Appendix:

A Experiment Setup i

A.1 Procedure of ECG Acquisition . . . . . . . . . . . . . . . . . . . . . i

A.2 Experiment Result . . . . . . . . . . . . . . . . . . . . . . . . . . . iii

A.3 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix

A.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix

B Program Validation xi

B.1 Data Construction . . . . . . . . . . . . . . . . . . . . . . . . . . . xi

B.2 Filtering Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii

B.3 Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii

B.4 Features Extraction . . . . . . . . . . . . . . . . . . . . . . . . . . . xviii

B.5 Classification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviii

C Source Code xxxi

Bibliography l

Page 10: Analysis and Classification of ECG Signal using Neural Network

List of Figures

2.1 Structure of the heart . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2.2 Propagation of ECG . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.3 The leads and Einthoven’s triangle. . . . . . . . . . . . . . . . . . . 9

2.4 The location of chest electrodes. . . . . . . . . . . . . . . . . . . . . 9

2.5 A sample of an ECG signal. . . . . . . . . . . . . . . . . . . . . . . 11

3.1 A three input of and one output neuron unit . . . . . . . . . . . . . 15

3.2 Simple neural network structure . . . . . . . . . . . . . . . . . . . . 16

3.3 Feed-forward neural network . . . . . . . . . . . . . . . . . . . . . . 19

3.4 Feedback neural network . . . . . . . . . . . . . . . . . . . . . . . . 19

3.5 Perceptron network . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

4.1 Layout of laboratory . . . . . . . . . . . . . . . . . . . . . . . . . . 24

4.2 Noise in ECG signal . . . . . . . . . . . . . . . . . . . . . . . . . . 25

4.3 Frequency response of an IIR filter . . . . . . . . . . . . . . . . . . 27

4.4 Wavelet transform . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

4.5 Features of subject: MH . . . . . . . . . . . . . . . . . . . . . . . . 31

VII

Page 11: Analysis and Classification of ECG Signal using Neural Network

LIST OF FIGURES VIII

4.6 Features of subject: YN . . . . . . . . . . . . . . . . . . . . . . . . 32

4.7 The algorithm of biometrics system. . . . . . . . . . . . . . . . . . . 33

4.8 Matrix of data structure in 2D . . . . . . . . . . . . . . . . . . . . . 34

4.9 Matrix of data structure in 3D . . . . . . . . . . . . . . . . . . . . . 34

4.10 Wavelet decomposition level 4 . . . . . . . . . . . . . . . . . . . . . 35

4.11 Complete data structure in 3D . . . . . . . . . . . . . . . . . . . . . 36

4.12 Complete data structure for classification . . . . . . . . . . . . . . . 37

4.13 Target data matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

4.14 Structure of neural network . . . . . . . . . . . . . . . . . . . . . . 39

5.1 Confusion matrix of experiment A . . . . . . . . . . . . . . . . . . . 41

5.2 Error rate of experiment A . . . . . . . . . . . . . . . . . . . . . . . 43

5.3 Error rate of experiment B . . . . . . . . . . . . . . . . . . . . . . . 44

5.4 Feature comparison from set 5, 6, 10 . . . . . . . . . . . . . . . . . 47

A.1 Default electrode configuration . . . . . . . . . . . . . . . . . . . . . ii

A.2 MH ECG signal with noise . . . . . . . . . . . . . . . . . . . . . . . iv

A.3 FQ ECG signal with noise . . . . . . . . . . . . . . . . . . . . . . . v

A.4 YN ECG signal with noise . . . . . . . . . . . . . . . . . . . . . . . vi

A.5 ECG signal without noise . . . . . . . . . . . . . . . . . . . . . . . vii

A.6 ECG signal frequency spectrum . . . . . . . . . . . . . . . . . . . . viii

A.7 Two different ECG comparison . . . . . . . . . . . . . . . . . . . . ix

B.1 Experiment A data matrix . . . . . . . . . . . . . . . . . . . . . . . xii

Page 12: Analysis and Classification of ECG Signal using Neural Network

LIST OF FIGURES IX

B.2 Experiment B data matrix . . . . . . . . . . . . . . . . . . . . . . . xii

B.3 Comparison of ECG with and without noise - FQ . . . . . . . . . . xiv

B.4 Comparison of ECG with and without noise - AR . . . . . . . . . . xv

B.5 ECG before segmentation . . . . . . . . . . . . . . . . . . . . . . . xvi

B.6 ECG after segmentation . . . . . . . . . . . . . . . . . . . . . . . . xvii

B.7 ECG after wavelet decomposition . . . . . . . . . . . . . . . . . . . xix

B.8 15 peaks of feature coefficient . . . . . . . . . . . . . . . . . . . . . xx

B.9 1 peaks of feature coefficient . . . . . . . . . . . . . . . . . . . . . . xxi

B.10 11 subject feature coefficient . . . . . . . . . . . . . . . . . . . . . . xxii

B.11 Confusion plot for the trained neural network - correct data . . . . xxiii

B.12 Confusion plot for the trained neural network - incorrect data . . . xxiv

B.13 Features of subject AR - set 6 . . . . . . . . . . . . . . . . . . . . . xxv

B.14 Features of subject AR - set 5 . . . . . . . . . . . . . . . . . . . . . xxvi

B.15 Features of subject AR - set 5 . . . . . . . . . . . . . . . . . . . . . xxvii

B.16 Features of subject AA - set 6 . . . . . . . . . . . . . . . . . . . . . xxviii

B.17 Features of subject AA - set 5 . . . . . . . . . . . . . . . . . . . . . xxix

B.18 Features of subject AA - set 5 . . . . . . . . . . . . . . . . . . . . . xxx

C.1 The program tree of biometrics system. . . . . . . . . . . . . . . . . xxxii

Page 13: Analysis and Classification of ECG Signal using Neural Network

List of Tables

3.1 Truth table of firing rules . . . . . . . . . . . . . . . . . . . . . . . . 18

3.2 Truth table after trained by firing rules . . . . . . . . . . . . . . . . 18

4.1 Data acquisition detail from test subjects . . . . . . . . . . . . . . . 25

5.1 Table of subjects name for experiment A . . . . . . . . . . . . . . . 41

5.2 Recognition rate for experiment A . . . . . . . . . . . . . . . . . . . 42

5.3 Table of subjects name for experiment B . . . . . . . . . . . . . . . 43

5.4 Recognition rate of experiment B . . . . . . . . . . . . . . . . . . . 45

A.1 Summary of test subject details. . . . . . . . . . . . . . . . . . . . . i

A.2 Dissimilarity of ECG peak . . . . . . . . . . . . . . . . . . . . . . . iii

X

Page 14: Analysis and Classification of ECG Signal using Neural Network

Chapter 1

Project Overview

This thesis studies the ECG signal and to use the signal as a classification tool.

This is achieved by extracting the features of the signal according to Cvetkovic

paper [UCC07] and those features are classified using a neural network algorithm

[AM01]. In this chapter, we describe the motivation and objective of biometrics

system using ECG signal.

1.1 Motivation and Objective

Electrocardiogram (ECG) had recently been used to recognize a person. The ap-

plication of ECG mostly used in biomedical detection [FC08]. The ECG of a

person can represent health condition or disease. A person should have unique-

ness ECG when he is still alive. That would be an advantage compare to other

biometrics signal such as finger print or pattern of a retina. So ECG can be one of

the biometrics’s key. This is a novel ideal to use ECG in the biometrics’s system.

There is a large demand on the security system which can detect a person in the

database. Some places like airport or restricted area were really just allowing a

small amount of people to access. ECG might be the efficient key for them. Other

than allow a small amount of people to access, we can have a blacklist of criminal

or terrorist to recognize them without their finger print or face. The finger print or

1

Page 15: Analysis and Classification of ECG Signal using Neural Network

1.2. SCOPE OF PROJECT 2

face can be removed and face-lifting. So ECG has the advantages like universality,

uniqueness, acceptability and circumvention.

Hence, the objective of this project include:

1. To study and analysis electrocardiogram.

2. To record the ECG signal from peoples.

3. To extract the features from electrocardiogram.

4. To classify ECG signal.

1.2 Scope of Project

Basically, this project is divided into two parts. The first part of this project is to

do theoretical research on ECG signal used in human classification. This part of

the project primarily deals with the signal acquisition method and pre-processing

method. Pre-processing such as filtering, segmentation and feature extraction

will be done before classification. The experimental testing has been done for a

standard procedure before signal acquisition. Filtering process will be done in the

first part.

As for the second part of this project, the data acquisition experiment has done,

which is following the procedure from the previous experiment in first part. The

feature extraction has done by the wavelet decomposition method in MatLab.

Classification used the feed-forward back propagation neural network to classify

the ECG. The quality of ECG signal is being investigated when low accuracy

occur. The features of ECG are also being studied.

Page 16: Analysis and Classification of ECG Signal using Neural Network

1.3. THESIS OVERVIEW 3

1.3 Thesis Overview

Chapter 1 provides a brief introduction of this project, which is to study and

design of the biometrics’s system.

Chapter 2 explains the electrocardiogram characteristics and the ECG signal ac-

quisition from standard experiment. Artifacts of ECG have been studied from

other literatures.

Chapter 3 introduces the concept of neural network. The working principles of

neural network will be explained in this chapter. What are the applications for

neural network?

Chapter 4 describes the experimental setup for data acquisition. The detail of

all experiment subjects will produce in this chapter. The pre-processing such as

filtering and feature extraction will be explained into detail.

Chapter 5 introduces the novel way to construct data structure for this project.

The input data set and train data set for neural network classifier is created. The

structure of neural network will discuss in that chapter.

Chapter 6 summarized the whole project and provides some recommendation for

future works.

Page 17: Analysis and Classification of ECG Signal using Neural Network

Chapter 2

Introduction

Electrocardiogram (ECG) signal has been used in many medical applications for

the few decades. There are few models and novel applications by using ECG for

biometrics’s recognition. In this chapter, we will discuss about the heart structure,

ECG signal and features of the ECG signal.

2.1 Heart Structure

The heart is made up of four powerful muscles called Myocardium. The My-

ocardium is composed of cardiac muscle fibers that contract and cause a pumping

type of action. The size of your heart is a little larger than the size of your fist.

The location of the heart is about the left-center of your chest. The heart consists

of two separate pumps that continuously send the blood throughout our body and

carrying nutrients and oxygen. The right side of the heart receives blood low in

oxygen. The left side of the heart receives blood that has been oxygenated by

the lungs. The blood is then pumped out into the Aorta and to all parts of the

body. The Heart Diagram below and the information that follows will give a better

understanding of the heart structure see Figure 2.1.

The heart is divided into several components, described below:

4

Page 18: Analysis and Classification of ECG Signal using Neural Network

2.1. HEART STRUCTURE 5

Figure 2.1: The component of the heart. The arrow directions show of blood flow(Robert Hall from CMA, 1989).

Right Atrium: The right atrium is larger than the left atrium. It has two major

veins that return blood to the heart from all parts of the body. Both veins are

returning the blood to the heart are the superior vena cava that returns the de-

oxygenated blood from the upper part of the body and the inferior vena cava that

returns the blood from the lower part of the body. After the blood is collected in

the right atrium it is pumped into the right ventricle through the tricuspid valve

also known as three leaf valve [Ran02].

Left Atrium: The left atrium receives blood from four pulmonary veins. The

blood received from the lungs has been oxygenated. The oxygenated blood that

is collected in the left atrium is then pumped into the left ventricle through the

mitral valve[Ran02].

Right Ventricle: The right ventricle receives blood from the right atrium. When

the heart contract the blood is forced out through the pulmonary valve into the

pulmonary artery. The pulmonary valve is a three flap valve that stops the back

flow of blood. The walls of the right ventricle are a little thicker than the right

atrium[Ran02].

Left Ventricle: The chamber of the left ventricle has walls that are three times the

thickness of the right ventricle. This is important because the oxygenated blood

that it receives from the left atrium has to be pump throughout the body. The

Page 19: Analysis and Classification of ECG Signal using Neural Network

2.2. ELECTROCARDIOGRAM (ECG) 6

mitral valve closes and the blood is collected in the left ventricle. The closing

of the mitral valve stops the back flow of blood. When the heart muscle con-

tracts the blood is forced through the aortic valve which has the same features

as the pulmonary valve. The blood then passes through the aortic valve into the

aorta[Ran02].

Aorta: The aorta is the largest blood vessel in the body. The inner diameter of

the aorta is about 1 inch. The aorta carries oxygenated blood to every other part

of the body. The aorta receives its blood from the left ventricle[Ran02].

Septum: The septum is a partition that separates the right and left sides of the

heart. There are two separate regions of the septum. They are the interatrial

septum that separates the atriums and the interventricular septum that separates

the ventricles. The interatrial septum is only present in the fetal period and is open

during this period. The interatrial septum closes at the time of birth. [Ran02].

2.2 Electrocardiogram (ECG)

The ECG is the electrical manifestation of the contraction activity of the heart.

It can be recorded by surface electrodes on the limbs or chest. The ECG is the

most commonly known and used in biomedical signal. The rhythm of the heart in

terms of beats per minute (bpm) may be easily estimated by counting the readily

identifiable waves [Ran02].

The electric system of the heart is a cycle of electrical current flow. Coordinated

electrical events and a specialized conduction system intrinsic and unique to the

heart play major roles in the rhythmic contractile activity of the heart. The sino-

artrial (SA) node is the basic, natural cardiac pacemaker that triggers its own

train of action potential.[Ran02].

Figure 2.2 showed the sequence of events (a to d) and waves in a cardiac cycle is

as follows:

Page 20: Analysis and Classification of ECG Signal using Neural Network

2.2. ELECTROCARDIOGRAM (ECG) 7

Figure 2.2: Propagation of the ECG through the heart [Rus76].

Page 21: Analysis and Classification of ECG Signal using Neural Network

2.3. ECG SIGNAL ACQUISITION 8

1. The SA node fires.

2. Electrical activity is propagated through the atrial musculature at compar-

atively low rates, causing slow-moving depolarization (contraction) of the

atria. This result in the P wave in the ECG. Due to the slow contraction

of the atria and their small size, the P wave is a slow, low-amplitude wave,

with an amplitude of about 0.1 to 0.2 mV and a duration of about 60 to 80

ms [Ran02].

3. The excitation wave faces a propagation delay at the atrio-ventricular (AV)

node, which result in a normally iso-electric segment of about 60-80ms after

the P wave in the ECG, known as the PQ segment. The pause assists in

the completion of the transfer of the blood from the atria to the ventricles

[Ran02].

4. The wave of stimulus spreads rapidly from the apex of the heart upwards is

causing rapid depolarization (contraction) of the ventricles. The QRS wave

of the ECThe wave of stimulus spreads rapidly from the apex of the heart

upwards is causing rapid depolarization (contraction) of the ventricles. QRS

wave of the ECG signal with a sharp biphasic or triphasic wave of about 1mV

amplitude and 80 ms duration [Ran02].G with a sharp biphasic or triphasic

wave of about 1mV amplitude and 80 ms duration [Ran02].

5. Ventricular muscle cells possess a relatively long action potential duration of

causes a normally iso-electric segment of about 100-200 ms after the QRS,

known as the ST segment [Ran02].

6. Repolarization (relaxation) of the ventricles causes the slow T wave, with an

amplitude of 0.1 to 0.3 mV and duration of 120 to 160 ms [Ran02].

7. The PQRST wave is explained in more detail in section 1.4.

Page 22: Analysis and Classification of ECG Signal using Neural Network

2.3. ECG SIGNAL ACQUISITION 9

Figure 2.3: The leads and Einthoven’s triangle.

Figure 2.4: Location of chest electrodes in 4th and 5th intercostal spaces. V1:right 4th intercostal space. V2: left 4th intercostal space. V3: halfway betweenV2 and V4. V4: left 5th intercostal space, mid-clavicular line. V5: horizontalto V4, anterior axillary line. V6: horizontal to V5, mid-axillary line (cardionet,2009).

Page 23: Analysis and Classification of ECG Signal using Neural Network

2.3. ECG SIGNAL ACQUISITION 10

2.3 ECG Signal Acquisition

The standard 12-channel ECG is obtained using four limb leads and chest leads in

six positions. The right leg is used to place the reference electrode. The left arm,

right arm, and left leg are used to get, I, II, III. A combined reference known as

Wilson’s central terminal is formed by combining the left arm, right arm, left leg

leads, and is used as the reference for the chest leads. The augmented limb leads

known as aVR, aVL, aVF (aV for the augmented lead, R for the right arm, L for

the left arm, and F for the left foot) are obtained by using the reference being

Wilson’s central terminal without the exploring limb lead.

The hypothetical equilateral triangle formed by leads, I, II, III is known as the

Einthoven’s triangle sees Figure 2.3. The heart is assumed to be placed at the

center of the triangle. The six leads measure projections of the 3D cardiac elec-

trical vector onto the axes illustrated above. The six axes sample the 0 degree

to 180 degree range in steps of approximately 30 degrees. The projections facili-

tate viewing and analysis of the electrical activity of the heart and from different

perspectives in the frontal plane.

The six chest leads (V1 to V6) are obtained from six standardized positions on the

chest with Wilson’s central terminal as the reference sees Figure 2.4. The positions

for placement of the precordial (chest) leads are indicated in figure above. The V1

and V2 leads are placed at the fourth intercostal space just to the right and left

of the midclavicular line. The V3 lead is placed half-way between the V2 and V4

leads. The V5 and V6 leads are located at the same level as the V4 lead, but at

the anterior axillary line and the midaxilla line, respectively. The six chest leads

permit viewing and V6 are most sensitive to leave ventricular activity; V3 and V4

depict the septal activities best; V1 and V2 reflect well activity in the right-half

of the heart.

The experiment of record ECG signal will take place at the laboratory. The

details while take the measurement will represent at appendix A. Four subjects

are recorded by the same experiment procedure and the signal will also show in

Page 24: Analysis and Classification of ECG Signal using Neural Network

2.4. CHARACTERISTICS OF ECG 11

Figure 2.5: The sample of ECG signal and various peaks in the ECG (virtualmed-icalcentre.com).

appendix A. This will be the first part experiment in this project.

2.4 Characteristics of ECG

A full cycle of ECG signal divided into several parts that show in Figure 2.5:

P wave: Contraction of the atria is triggered by the SA-node impulse. The atria

do not possess any specialized conduction nerves as the ventricles do; as such,

contraction of the atria muscles takes place in a slow squeezing manner, with the

excitation stimulus being propagated by the muscle cells. The P wave is the epoch

related to the event of atria contraction.

PQ segment : The AV node provides a delay to facilitate completion of atrial

contraction and transfer of blood to the ventricles before ventricular contraction

is initiated. The resulting PQ segment, of about 80 ms duration, is thus a non-

event; however, it is important in recognizing the base-line as the interval is almost

always iso-electric.

QRS wave: The specialized system of Purkinje fiber stimulated contraction of

ventricular muscles in a rapid sequence from the apex upwards. The almost-

Page 25: Analysis and Classification of ECG Signal using Neural Network

2.5. ARTIFACTS OF ECG 12

simultaneous contraction of the entire ventricular results in a sharp and tall QRS

complex of about 1 mV amplitude and 80 to 100 ms duration. The event of

ventricular contraction is represented by the QRS epoch.

ST segment : The normally flat (iso-electric) ST segment is related to the plateau

in the action potential of the left ventricular muscle cells. The ST segment may

also be termed as a non-event. However, myocardial ischemia or infarction could

change the action potentials of a portion of the left ventricular musculature, and

cause the ST segment to be depressed or elevated. The PQ segment serves as a

useful reference when the iso-electric nature of the ST segment needs to be verified.

T wave: The T wave appears in a normal ECG signal as a discrete wave separated

from the QRS by an iso-electric ST segment. However, it relates to the phase of

the action potential of ventricular muscle cells, when the potential returns from

the plateau of the depolarized state to the resting potential through the process

of repolarization. The T wave is commonly referred to as the wave corresponding

to ventricular relaxation.

2.5 Artifacts of ECG

The ECG signal contains information of the heart conditions. However, it also

contains noise due to the sensitivity of the electrodes, any movement of the leads

or clips will make the noise signal to the ECG signal. The ECG machine and the

main power supply also have to be create grounded on floor and such movement

should be kept to a minimum. There are several methods to filter the noise signal

to get a more accurate ECG signal to analysis. The testing filter has done in first

part of project which can refer to appendix A.

Page 26: Analysis and Classification of ECG Signal using Neural Network

2.6. SUMMARY 13

2.6 Summary

In this chapter, we have explained how the heart generated ECG signal and the

characteristics of ECG signal. The ECG is unique biometrics’s information to

identify a person. The main challenges of this project are the classifier to produce

an accurate and fast reaction of ECG signal matching. The following chapter will

discuss the introduction of classifier that will be used in this project.

Page 27: Analysis and Classification of ECG Signal using Neural Network

Chapter 3

Classification

In previous chapter, we have introduced the ECG signal and the characteristic

of ECG signal. Now, classification of ECG signal is the main objective in this

project, to identify an input ECG signal to match with our ECG databases. So,

an accurate classifier should be designed and tested. In this chapter, we will discuss

about neural network-based classifier. The algorithm and example will also discuss

in this chapter.

3.1 Concepts of Pattern Recognition

Before we start to discuss about the neural network, pattern recognition is to

recognize a class of objects, the data about those objects is gathered and then a set

of feature measurements are extracted from those data. Most of the features that

we will consider are the numerical feature, act as input to a mathematical pattern

recognizer. The availability of high speed computers and efficient algorithms make

use in computer-aided tomography (CAT) for image editor or image processing.

14

Page 28: Analysis and Classification of ECG Signal using Neural Network

3.2. BRIEF HISTORY OF NEURAL NETWORKS 15

Figure 3.1: Three input of and one output neuron unit [?].

3.2 Brief History of Neural Networks

The neural network (NN) is invented from the idea of network of the biological

neuron model see Figure 3.1. NN start from simple logic function and computer

simulation. The researchers continue to improve the solution of NN-based compu-

tational problems such as pattern recognition. Currently, the NN found in many

applications on pattern recognition and data classification.

When 1943, in principle, Warren McCulloch and Walfer Pitts showed that net-

works of the artificial neurons could compute any arithmetic or logical function.

This is the origin of neural network field. Donald Hebb (1949) proposed that clas-

sical conditioning is present because of the properties of an individual neurons.

The invention of the perception network and associated learning rule by Frank

Rosenblatt (1958), but the basic perception network could solve only a limited

class of a problem. Although Bernard Widrow and Ted Hoff (1960) invent a new

learning algorithm and to train an adaptive linear neural network, the problem and

limitation of neural network still exist. So Martin Minsky and Seymour Papert

(1969) claimed that further study on neural network is a dead end and for a decade

neural network research was largely suspended. This condition is changed, when

Teuvo Kohonen and James Anderson (1972) invent new neural network that could

act as memories separately to solve the limitation. Stephen Grossberg (1976) had

investigated on the self-organizing network. Most of the limitations or problems

are solved by powerful computer and new ideal.

Page 29: Analysis and Classification of ECG Signal using Neural Network

3.3. NEURAL NETWORK-BASED CLASSIFIER 16

Figure 3.2: Simple neural network structure that output compare with the targetand feedback to the NN until the output matches the target (Matlab R2006b &Mathworks, 2006).

3.3 Neural Network-based Classifier

Neural network is the model of information processing. The key element of this

model is the structure of the information processing system. NN can compose

a large number of interconnected elements (neurons) working parallel to solve

a problem, through a learning process. Learning in biological systems involves

adjustments to the synaptic connection that exist between the neurons, which

applied to NN as well [SSB96].

The remarkable ability of NN is to derive meaning from complicated or inaccurate

data, which are complex for human or other computer techniques. Trained NN

can easily analysis specify the category of information and data. Another ability of

NN can be defined as the ability to learn how to do tasks based on the data given

for training and create its own organization of the information it receives during

learning time. NN is also able carried out parallel computing, which improve the

hardware design.

A neural network is consisted of units (neurons), arranged in order, which convert

input vector into output. Each unit is taken an input, often is applying a non-linear

function to it and transfer the output to the next order of units see Figure 3.2

Page 30: Analysis and Classification of ECG Signal using Neural Network

3.4. FIRING RULES 17

3.4 Firing Rules

The important concept of NN is the firing rule. It decided the calculation of a

neuron, whether it should fire for any input data. Not only one node, but all the

input and the neuron unit are related.

A simple firing rule can be implemented by Hamming distance technique. In

Figure 3.1, there are three inputs to neuron and one output from a neuron. The

neuron takes a collection of training pattern, 1-taught set of pattern cause it to fire,

others, which prevent it to fire are 0-taught set of pattern. Some of the patterns

not in the collection also cause the neuron fire by comparison, which more input

data with the nearest pattern in the 1-taught set. If there is a tie, the output will

remain in an undefined state.

For an example, three inputs are given that X1, X2, X3, 000 and 001 have 0s as

the output, therefore, 101 and 111 have 1s as the output. The Table 3.1 is the

truth table after apply the firing rules. As an example of applied the firing rules,

taking the pattern of 010 to compare with 000, 001, 101, and 111. When 000 is the

nearest pattern as it is 1 element different from 010, 001 is 2 elements different,

101 is 3 elements different. So according to firing rules, pattern 010 have nearest

distance to the 1-taught set to compare to 0-taught set, pattern 010 should not

fire.

Another example, this time we take pattern 011 to compare with the 1-taught sets

and 0-taught set, 2 elements different for 000, 1 element different for 001 (0-taught

set); 2 elements different for 101, 1 element different for 111 (1-taught set). From

this result, we can see that 011 have been same distant from both taught set,

pattern 011 will remain undefined.

After we have done the same comparison using pattern 100, 110, a new truth

Table 3.2 can be obtained that called generalization of a neuron. The firing rule

gives the neuron a sense of similarity and enables it to respond ’sensibly’ to patterns

not seen during training [?].

Page 31: Analysis and Classification of ECG Signal using Neural Network

3.5. ARCHITECTURE OF NEURAL NETWORKS 18

X1: 0 0 0 0 1 1 1 1X2: 0 0 1 1 0 0 1 1X3: 0 1 0 1 0 1 0 1

Output: 0 0 0/1 0/1 0/1 1 0/1 1

Table 3.1: Truth table of firing rules, two taught set is given. 0’s taught set is 000and 001, 1’s taught set is 101 and 111.

X1: 0 0 0 0 1 1 1 1X2: 0 0 1 1 0 0 1 1X3: 0 1 0 1 0 1 0 1

Output: 0 0 0 0/1 0/1 1 1 1

Table 3.2: Truth table after applying the firing rules, also called generalization ofneuron.

3.5 Architecture of Neural Networks

In this section, we will discuss some architecture of neural networks and that will

used in this project. So understanding the architecture of NN is important as this

project will have its own pattern of neural network based on those architectures.

3.5.1 Feed-forward Network

Feed-forward NN is defined from its transition direction of information or signal,

only one direction will be the information or signal travel from input to output.

There is not feedback from each output, so the output does not affect the same

layer of a neuron. Feed-forward NN is also used in pattern recognition see Fig-

ure 3.3.

3.5.2 Feedback Network

Feedback network is traveling in two directions by including the loops. Feedback

network is powerful but it can be very complicated network. The state of network

is changing continuously until it reached an equilibrium point. When the input

Page 32: Analysis and Classification of ECG Signal using Neural Network

3.5. ARCHITECTURE OF NEURAL NETWORKS 19

Figure 3.3: Left side is the feed-forward network, data or signal move forward untilit reached the output state.

Figure 3.4: Right side is the feedback network that signal can reverse back to theprevious state.

Page 33: Analysis and Classification of ECG Signal using Neural Network

3.5. ARCHITECTURE OF NEURAL NETWORKS 20

Figure 3.5: Simple perceptron networks that used for pattern recognition.

is changed, the state information or data will change until it reached another

equilibrium point.

Figure 3.4 shows that the input, hidden and output layers. The activity of input

units represents the raw information that fed into the network. The activity of

hidden units is determined by the activities of input units and the weight on the

connection between input and hidden units. The activity of output units depends

on the activity of hidden units and the weight between hidden and output units.

3.5.3 Perceptrons

In 1950s, Frank Rosenblatt and several researchers developed a class of NN called

perceptrons. The major different from other NN is the introduction of learning

rules for the training perceptron networks see Figure 3.5 to solve the pattern

recognition problem. He proved that the learning rule will always converge to

the correct network weights, if weight existed that solve the problem. There is a

limitation of perceptron network for incapable of implementing certain elementary

function. This is found by Minsky and Papert, to overcome this limitation were

improving the perceptron networks into multi layer and associated learning rules.

Learning rules mean a procedure for modifying the weight and biases of a network

Page 34: Analysis and Classification of ECG Signal using Neural Network

3.6. APPLICATIONS OF NEURAL NETWORK 21

also referred as the training algorithm. The purpose of the learning rule is to train

the network to perform some task [HDB02].

3.6 Applications of Neural Network

Neural network is widely applied in various fields and given great improvement

in each field. NN is best at identifying pattern or trends in data, so NN is well

suited for prediction or forecasting in sales forecasting, industrial process control,

and data validation and so on. There are few application examples that related

to this project.

Signature verification technique based on two-stage neural network classifier that

published by Baltzakis and Papamarkos, 2001. They had implemented a special

two-stage perceptron OCON (one class one network) classification structure. In

the first stage, the classifier combines the decision results of the neural networks

and the Euclidean distance obtained using the three feature sets. The results

of the first-stage classifier feed a second-stage radial base function (RBF) neural

network structure, which makes the final decision.

Feature-based decision aggregation in modular neural network classifier that pub-

lished by Wanas et al., 1999. In modular NN, the individual decisions at its level

have to be integrated together using a voting scheme. All voting schemes use the

output of individual modules to produce a global output without affect the infor-

mation from the problem feature space. This makes the choice of the collection

procedure very subjective. They focus on making decision fusion a more dynamic

process by integrated learning into voting scheme. Dynamic mean the collection

procedure has the flexibility to modify in the input.

Minimax classifier based on NN that published by Alaiz-Rodriguez et al., 2005.

The problem of designing a classifier when prior probabilities are not known or

are not representative of the underlying data distribution is discussed in this pa-

per. They address the problem of designing a neural-based minimax classifier

Page 35: Analysis and Classification of ECG Signal using Neural Network

3.7. SUMMARY 22

and propose two different algorithms: a learning rate scaling algorithm and a

gradient-based algorithm. Experimental results show that both succeed in finding

the minimax solution, and it is also pointed out the differences between common

approaches to cope with this uncertainty in priors and the minimax classifier.

A patient adaptable ECG beat classifier based on NN that published by Gaetano

et al., 2009. The basic idea behind this paper is to consider an ECG digital

recording of two consecutive R-wave segments (RRR interval) as a noisy sample

of an underlying function to be approximated by a fixed number of Radial Basis

Functions (RBF). The linear expansion coefficients of the RRR interval represent

the input signal of a feed-forward neural network which classifies a single beat as

normal or ischemic. The system has been evaluated using several patient records

taken from the European ST-T database. Experimental results show that the

proposed beat classifier is very reliable, and that it may be a useful practical tool

for the automatic detection of ischemic episodes.

3.7 Summary

From the discussion above, we can confirm that the NN classifier is widely and

successfully applied to the field of pattern recognition and ECG signal recognition.

The accuracy of pattern recognition also can be reliable on this project. Since we

have to design the structure of the classifier and the learning rule of the NN, this

will discuss at the future chapter. The next chapter will present the experimental

setup and feature extraction that mentioned in second part of this project.

Page 36: Analysis and Classification of ECG Signal using Neural Network

Chapter 4

Experimental Setup and

Methodology

After we have learned the working principle of neural network. In this chapter,

we will discuss about the experimental setup. The structure of laboratory and

the equipments will be introduced. The similar result will be produce in this

experiment if the procedure is according to our project procedure. The filtering

method and the feature extraction method also will introduce in this chapter.

We will move into detail to explain the methodology of biometrics system. The

algorithm of biometrics system will present in figures. We will classify two set of

ECG data from experiment A (11 test subjects) and B (4 test subjects).

4.1 Experimental Layout

The experiment was conducted at indoor room that has been air-conditioned, well

lit and quiet. As shown figure 4.1, the test subject is seated facing a monitor. There

are two dividers that limit the view of the test subject in order to concentrate on

the experiment. Two laboratory technicians are seated in front of the control

station that manages the computer to start or pause for the experiment. The

procedure of the experiment can be referring to appendix A.

23

Page 37: Analysis and Classification of ECG Signal using Neural Network

4.2. TEST SUBJECT 24

Figure 4.1: The layout of laboratory where experiment is conducted.

4.2 Test Subject

There are 11 test subjects were involved in this experiment as shown in table 4.1.

All subjects are male between the age of 21 to 25, which are students and stuffs

from Multimedia University. The test subject cannot have some drink, which

contained caffeine or analeptic. That will make their ECG signal not similar to

normal condition. 11 test subjects are required to record 10 set of ECG signal in

one day called experiment A. 4 test subjects are required to record 30 set of ECG

signal in three days called experiment B.

4.3 Filtering Process

The recorded ECG signal is contaminated with noise and unwanted signals. Fil-

tering process is necessary to reduce and eliminate noise in the ECG. The ECG

contains mainly three kinds of noises as shown in figure 4.2. In figure 4.2(a), 60 Hz

power-line interference that came from the power line of ECG signal measurement

systems despite proper grounding [ZC06]. In figure 4.2(b), electromyogram (EMG)

is produced by muscle electrical activity. EMG interference appears as rapid fluc-

Page 38: Analysis and Classification of ECG Signal using Neural Network

4.3. FILTERING PROCESS 25

Subject Name Day 1 Day 2 Day 3 Total SetFQ 19/01/2010 11/02/2010 24/02/2010 30YN 21/01/2010 11/02/2010 24/02/2010 30VR 20/01/2010 24/02/2010 12/03/2010 30YG 20/01/2010 24/01/2010 18/03/2010 30AR 22/01/2010 - - 10KSP 20/01/2010 - - 10LJX 21/01/2010 - - 10ML 21/01/2010 - - 10SH 21/01/2010 - - 10AA 22/01/2010 - - 10NA 26/01/2010 - - 10

Table 4.1: Data acquisition date and total set of data from test subjects.

Figure 4.2: Noise of ECG signal: (a) 60 Hz power-line interference; (b) Elec-tromyogram(EMG); (c) Motion artifacts [YW08].

Page 39: Analysis and Classification of ECG Signal using Neural Network

4.3. FILTERING PROCESS 26

tuations, which vary faster then ECG waves because the frequency ranges from dc

to 10 Hz [FJJ+90]. In figure 4.2(c), motion artifact results from the motion of the

electrode in relation to the test subject’s skin and it produce a large amplitude of

noise [FJJ+90].

There are many kinds of filters that can be used to remove the noise in ECG.

In this project, a digital infinite-duration impulse response (IIR) filter is used to

remove the ECG noise. The primary advantage of IIR filter is the filter has a

lower filter order compare to other finite-duration impulse responses (FIR) filters

for the same performance. An elliptic filter was selected to preprocess the ECG

signal because it has equalized ripple behavior in both bandpass and stop band

and gives the lowest order and narrower transition of any supported filter type.

In MatLab, the function ellip designs an n-order low-pass digital elliptic filter with

normalized passband edge frequency Wp, the desired ripple in the passband and

stopband as specified by the user in units of dB. The function returns the filter

coefficients in length n + 1 row vectors b and a, with coefficients in descending

powers of z as shown in equation 4.1:

H(z) =B(z)

A(z)=b(1) + b(2)z−1 + · · ·+ b(n+ 1)z−n

1 + a(2)z−1 + · · ·+ a(n+ 1)z−n(4.1)

The filter order, n and cutoff frequency, Wp is obtained directly from MATLAB

function ellipord. Wp, the passband corner frequency or cutoff frequency. Ws,

the stop band corner frequency also corresponding to the normalized Nyquist

frequency. Rp, the passband ripple that gives the maximum permissible passband

loss in decibels. Rs, the stopband attenuation also in dB with respect to the

passband response. Figure 4.3, IIR elliptic low-pass filter with an order of 15 and

41.6 Hz cutoff frequency. Rp and Rs set to 2dB and 90dB according to matwork,

2009. An example of filtered signal and how to find the cutoff frequency spectrum

is shown in appendix A.

Page 40: Analysis and Classification of ECG Signal using Neural Network

4.4. FEATURES EXTRACTION 27

Figure 4.3: The frequency response of IIR elliptic filter that used in this project.

4.4 Features Extraction

A feature is a distinctive or characteristic measurement, transform, structural

component extracted from a segment of a pattern. Features are used to represent

a pattern with the goal of minimizing the loss of important information [UCC07].

The feature extraction method could be based on either calculating statistical

characteristics or producing syntactic descriptions.

The wavelet transform (WT) provides general techniques, which can be applied

to many tasks in signal processing. Wavelet transforms is ideally suited for the

analysis of sudden short-duration signal changes. It can compute and manipulate

data in compressed parameters, which are often called features [Dau90]. Thus,

the ECG signal is time-varying and consists of many data points, the wavelet can

compress ECG signal into a few parameters. The parameters used to represent the

time-varying ECG signal as features can be used for recognition purposes [UCC07].

The wavelet transform is designed for non-stationary signals. Signals will represent

a time function in term of simple, fixed building blocks, termed wavelets. The

building blocks are derived from a single generating function called the mother

Page 41: Analysis and Classification of ECG Signal using Neural Network

4.4. FEATURES EXTRACTION 28

Figure 4.4: Subband decomposition of discrete wavelet transform implementation;g[n] is the high-pass filter, h[n] is the low-pass filter [UCC07].

wavelet by dilation operations. Dilation known as scaling, compresses or stretches

the mother wavelet and translation shifts signal along the time axis [Dau90, UG05,

Sol02, UA96].

The wavelet transform can be categorized into continuous and discrete. Contin-

uous wavelet transform (CWT) is defined by equation 4.2 . From equation 4.2,

where x(t) represents the ECG signal, a and b represent the scaling factor and

translation along the time axis respectively and the superscript asterisk denotes

the complex conjugation:

CWT(a, b) =

+∞∫−∞

x(t)ψ∗a,b(t)dt (4.2)

The term ψa,b(·) is obtained by scaling the wavelet at time b and scale a :

ψa,b(t) =1√|a|ψ(t− ba

) (4.3)

, where ψ(t) represent the mother wavelet [Dau90].

All wavelet transforms can be specified in terms of a low-pass filter h[n] in equa-

Page 42: Analysis and Classification of ECG Signal using Neural Network

4.4. FEATURES EXTRACTION 29

tion 4.4, which satisfies the standard quadrature mirror filter condition :

H(z)H(z−1) +H(−z)H(−z−1) = 1 (4.4)

, where H(z) is the z-transform of the filter h. Its complementary high-pass filter

can be defined as show in figure 4.4

G(z) = zH(−z−1). (4.5)

A sequence of filter with increasing length (indexed by i) can be obtained :

Hi+1(z) = H(z2i

)Hi(z), Gi+1(z) = G(z2i

)Hi(z), i = 0, . . . , I − 1 (4.6)

with the initial condition H0(z) = 1. It is expressed as a two-scale relation in time

domain:

hi+1(k) = [k]↑2i ∗ hi(k), gi+1(k) = [g]↑2i ∗ hi(k), (4.7)

where the subscript [·] ↑ m indicates the up-sampling by a factor of m and k is

the equally sampled discrete time .

The normalized wavelet and scale basis function ϕi,l(k), ψi,l(k) can be defined as:

ϕi,l(k) = 2i/2hi(k − 2il), ψi,l(k) = 2i/2gi(k − 2il), (4.8)

where the factor 2i/2 is an inner product normalization, i and l are the scale

parameter and the translation parameter, The discrete wavelet transform (DWT)

decomposition can be described as:

ai(l) = x(k) ∗ ϕi,l(k), di(l) = x(k) ∗ ψi,l(k), (4.9)

Where ai(l) and di(l) are the approximation coefficient and the detail coefficient

at resolution i [Dau90].

Page 43: Analysis and Classification of ECG Signal using Neural Network

4.5. METHODOLOGY 30

In this project, a Daubechies wavelet of order 2 will be used the smoothing feature

as made DWT more suitable to detect the changes of the ECG signal [UCC07].

The computed discrete wavelet coefficient provided a compact representation that

shows the energy distribution of the signal in time and frequency. The statistical

features used to represent the time-frequency distribution of the ECG signal is

shown in figure 4.5 and figure 4.6, where the first row is the maximum, the second

row is the minimum, the third row is the mean and the fourth row is the standard

deviation of the wavelet coefficient in each subband.

4.5 Methodology

We discussed about the experimental setup and preprocessing steps in previous

chapter. In this chapter, we will move into detail to explain the methodology of

biometrics system. The algorithm of biometrics system will present in figures. We

will classify two set of ECG data from experiment A (11 test subjects) and B (4

test subjects). Result of classification and discussion will include in this chapter.

The algorithm of biometric system will be explained in figure 4.7. The system can

be simply divided into five parts. First, subject’s ECG data will extract from each

recording MAT files that we recorded from our subject earlier. There are several

ways to extract all the data in MAT files.

4.5.1 Data Structure

This is important to have a systematic and flexibility data structure. The data

structure has included all test subject’s data sets from each recording. The data

structure is a three dimension matrix shown in figure 4.9.

Before combined all subject’s data into a single matrix, we store all the file name

to a string refer to Appendix C. By calling the string, we can access to all MAT

files and extract the data sets. In figure 4.8, two dimension matrix (Length of

sample x Number of set) is created from test subject no.1. Other subject’s data

Page 44: Analysis and Classification of ECG Signal using Neural Network

4.5. METHODOLOGY 31

Fig

ure

4.5:

Extr

acte

d(a

)m

axim

um

,(b

)m

ean,

(c)

min

imum

,(d

)st

andar

ddev

iati

onst

atis

tica

lfe

ature

sof

MH

EC

Gsi

gnal

from

exp

erim

ent

inap

pen

dix

A.

Page 45: Analysis and Classification of ECG Signal using Neural Network

4.5. METHODOLOGY 32

Fig

ure

4.6:

Extr

acte

d(a

)m

axim

um

,(b

)m

ean,

(c)

min

imum

,(d

)st

andar

ddev

iati

onst

atis

tica

lfe

ature

sof

YN

EC

Gsi

gnal

from

exp

erim

ent

inA

pp

endix

A.

Page 46: Analysis and Classification of ECG Signal using Neural Network

4.5. METHODOLOGY 33

Figure 4.7: The algorithm of biometrics system.

Page 47: Analysis and Classification of ECG Signal using Neural Network

4.5. METHODOLOGY 34

Figure 4.8: The matrix [Length of sample x number of set] of data structure intwo dimensions which is containing one subject’s data.

Figure 4.9: The matrix [Length of sample x number of set x number of subject]of data structure in three dimensions which is containing all test subject’s data.

Page 48: Analysis and Classification of ECG Signal using Neural Network

4.5. METHODOLOGY 35

Figure 4.10: The process of wavelet decomposition converts 1 peak of ECG signalinto five coefficients.

will place behind of the subject no.1, which shown in figure 4.9. The program

validation result can refer to Appendix B.

The three dimension data structure shown in figure 4.9 will be removed the noise

and segmented into 15 peaks [AA09] by preprocessing refer to Appendix C. Feature

extraction will use wavelet decomposition that already explained in the previous

chapter.Figure 4.10 is the process of wavelet decomposition that converts 1 peak

of ECG into five coefficients. In figure 4.11, five coefficients (cA4, cD4, cD3, cD2

and cD1) were generated from wavelet decomposition. The program validation

result can refer to Appendix B.

Previously, we had discussed about the data structure. Here, we will reconstruct

the data structure for train data set and input data set. The third dimension which

Page 49: Analysis and Classification of ECG Signal using Neural Network

4.5. METHODOLOGY 36

Figure 4.11: The data structure [number of peak*5 features x number of set xnumber of subject*4 characteristic] after the process of wavelet decomposition ex-tracted features. cA4 to cD1 are the features of ECG signal. Maximum, minimum,mean and stand derivation is the characteristic of each features.

Page 50: Analysis and Classification of ECG Signal using Neural Network

4.5. METHODOLOGY 37

Figure 4.12: The final face of data structure is two dimensions matrix [number ofpeak*4 characteristic x number of ser*number of subject].

is containing four characteristic and number of subject. The four characteristic

will move down under last peak of the previous subject and the next subject will

rearrange next to the last data set of the previous subject that shown in figure 4.12.

4.5.2 Classifier

When the data structure is ready for classifier, we have to create the train data

set and input data set. Finally, target data set will be created to train the neural

network.

In figure 4.12, data structure future divide into two parts, which will randomly

pick one set of data from all subjects for input data set and the rest will be the

train data set. Normalization for input data set and train data set is important to

get a better classification result. In figure 4.13, the target data matrix [number of

subject x number of train data set*number of subject] is created by a simple code

Page 51: Analysis and Classification of ECG Signal using Neural Network

4.5. METHODOLOGY 38

Figure 4.13: The target data matrix showed that first four column representedsubject 1, from fifth to eighth column represented subject 2 and so on.

refer to Appendix C.

The neural network classifier is used feed-forward back-propagation network. The

network training function is Levenberg-Marquardt back-propagation (trainlm) which

is highly recommended as a first choice supervised algorithm. The learning func-

tion is Gradient descent with momentum weight and bias learning function (learngdm).

In figure 4.14, two layers and 50 neurons in each layer neural network is created.

The differentiable transfer function is log-sigmoid (logsig) which is commonly used

in back-propagation networks. The data division function is randomly divide train

data set (dividerand) into three set which 60% for training, 20% for validation and

20% for testing.

Page 52: Analysis and Classification of ECG Signal using Neural Network

4.6. SUMMARY 39

Figure 4.14: The feed-forward back-propagation neural network designed in thisproject.

4.6 Summary

In this chapter, we have discussed about the experimental setup for data acquisi-

tion process. The result of the experiment is shown in Appendix A. A IIR elliptic

low-pass filter with an order of 15 and 41. 6 Hz cut-off frequency was designed

to filter the noise signal. The one dimension discrete wavelet transform method

to compute energy distribution of the signal in time and frequency was used for

feature extraction. The maximum, minimum, mean and standard deviation of

each frequency range were then computed.

Page 53: Analysis and Classification of ECG Signal using Neural Network

Chapter 5

Result and Discussion

In previous chapter, we knew that the classification was divided into two sections.

First section was experiment A (11 test subjects) and follow by experiment B (4

test subjects). In this part, we will show the recognition rate and the discussion.

We will discuss the recognition rate of experiment A and B. We can summaries

the project and our objectives in this chapter. Recommendation will provides for

future research to achieve better outcomes.

5.1 Result of Experiment A

The confusion matrix of experiment A shown in figure 5.1. The first column rep-

resented the subject FQ and second column represented subject YN accordingly.

The correct recognition of subject FQ has shown in the green box of first column.

The wrong recognition of subject AR has shown in any red box of fifth column.

In table 5.2, the result of classification on experiment A with random picked set

as input data. The average accuracy of forty trials is 80.89% and the random pick

number is from 1 to 10. When the input data set is from set 9, the recognition

rate is 94% within three trials. The Rpick 5 have two critical recognition rate,

which is 63.6% and 100% but most of the trials are 81.8%. The Rpick 1 and 6

40

Page 54: Analysis and Classification of ECG Signal using Neural Network

5.1. RESULT OF EXPERIMENT A 41

Subject No. Subject Name1 FQ2 YN3 VR4 AA5 AR6 KSP7 LJX8 ML9 NA10 SH11 YG

Table 5.1: 11 test subjects name represent by number shown in the result below.

Figure 5.1: The confusion matrix plot from Matlab showed 11 subjects recognitionresult and accuracy.

Page 55: Analysis and Classification of ECG Signal using Neural Network

5.1. RESULT OF EXPERIMENT A 42

Rpick Train Duration(S) Accuracy(%) Error subject no.1 6 72.7 5, 8, 91 9 90.9 51 10 90.9 51 11 81.8 5, 91 7 81.8 5, 71 9 72.7 5, 6, 92 6 81.8 6, 82 5 81.8 6, 92 8 72.7 3, 5, 62 10 72.7 3, 6, 93 6 90.9 33 30 81.8 3, 63 8 72.7 3, 5, 73 5 72.7 2, 3, 73 9 81.8 3, 64 7 90.9 95 6 63.6 1, 5, 7, 95 6 81.8 7, 115 8 81.8 7, 95 5 1005 6 81.8 7, 95 40 81.8 6, 115 4 81.8 6, 76 3 63.6 3, 5, 6, 96 14 81.8 5, 76 9 81.8 5, 77 6 81.8 3, 67 9 81.8 3, 97 7 72.7 3, 5, 67 6 90.9 38 8 81.8 3, 68 6 72.7 3, 6, 79 7 81.8 7, 89 12 1009 29 10010 5 72.7 1, 3, 810 6 72.7 3, 8, 910 19 81.8 3, 910 5 72.7 3, 7, 910 5 81.8 5, 7

Average Accuracy 80.89

Table 5.2: The accuracy of recognition on experiment A with forty trials. Errorsubject name refer to table 5.1

Page 56: Analysis and Classification of ECG Signal using Neural Network

5.2. RESULT OF EXPERIMENT B 43

Figure 5.2: The error rate of experiment A within forty trials.

Subject No. Subject Name1 FQ2 YN3 VR4 YG

Table 5.3: 4 test subjects name represent by number shown in the result below.

cannot recognize the subject AR. The Rpick 2 cannot recognize subject KSP. The

Rpick 3, 7 and 10 cannot recognize subject VR.

From figure 5.2, we can observe that the most frequent errors are subject VR and

AR with 17 and 14 times within forty trials. Subject KSP, LJX and NA also have

a high error rate, which compared with subject FQ, YN, ML and YG. The subject

AA and SH have no error recognition within forty trials.

Page 57: Analysis and Classification of ECG Signal using Neural Network

5.2. RESULT OF EXPERIMENT B 44

Figure 5.3: The error rate of experiment B within forty trials.

5.2 Result of Experiment B

We assumed that experiment B should have a better recognition rate compare to

experiment A. More train data sets are provided to the neural network for training.

This assumption can be true if ECG does not change significantly within three

months.

As shown in table 5.4, the recognition rate of experiment B is 93.75%, which is

a better recognition rate compare to experiment A. Increasing the train data set

can also increase the recognition rate. The subject no.1 has not error within forty

trials, which means subject no.1 has a better ECG recording compare to others.

Figure 5.3 shown that subject YN have the highest error rate compare to others.

When input data set is picked from set 13, subject YN cannot be recognized by

the classifier. Subject YG cannot be recognized by classifier when Rpick is 29.

Page 58: Analysis and Classification of ECG Signal using Neural Network

5.2. RESULT OF EXPERIMENT B 45

Rpick Train Duration(S) Accuracy(%) Error subject no.1 1 1001 2 1002 2 1003 2 1004 5 1005 1 1005 1 1006 3 1007 2 1007 3 1007 4 1008 6 75 39 2 10010 3 10011 3 75 212 4 10012 3 10013 2 75 213 7 75 213 3 75 214 2 100 7, 915 4 75 216 1 75 417 5 10017 3 10017 3 10018 6 10019 3 10019 2 10020 4 10021 3 10022 5 10022 2 10022 8 10023 1 10026 2 10027 2 10029 1 75 429 1 75 430 1 75 2

Average Accuracy 93.75

Table 5.4: The accuracy of recognition on experiment B with 40 times of trials.Test subjects number can refer to table 5.3

Page 59: Analysis and Classification of ECG Signal using Neural Network

5.3. DISCUSSION 46

5.3 Discussion

The result has shown that some ECG signals were not recorded well due to our

subjects. The subject had to rest without any movement during experiment pe-

riod. This are obviously the input data set is affected the recognition rate of

ECG signal. Following certain condition and rules to obtain a better ECG signal

from subjects to overcome this problem. This will not apply to the subject who

infected heart disease after they created their ECG database in the biometrics’s

system. Some of the heart diseases are changing the ECG signal significantly. The

number of train data set or features is also important for recognition rate. By

increasing number of train data set and features can improve the recognition rate.

we have discussed the recognition rate of experiment A and B. We can summaries

the project and our objectives in this chapter. Recommendation will provides for

future research to achieve better outcomes.

5.4 Conclusion

We have made some conclusions from our projects. From first part of project,

we study about the process of human heart generates ECG signal. We managed

to record ECG signal from our subjects. The characteristics of ECG signal are

difference from each others. So we make use from those characteristics to classify

our subjects. The ECG has a frequency range of 0 Hz to 45 Hz which contains

the characteristic of PQRST.

We are able to extract the features from ECG signal by wavelet transform [UCC07].

Recognition rate is more accurate when the ECG signal is represented by important

features. Segmentation generated more features from one period of ECG wave-

form. We selected some important features such as maximum, minimum, mean

and standard deviation. Instead of taking all features from wavelet transform, the

features vector is reduced by just including the important features.

We found that to construct data structure contains all ECG signal are important

Page 60: Analysis and Classification of ECG Signal using Neural Network

5.4. CONCLUSION 47

Figure 5.4: Features of subject AR. (a) Set 5 features from maximum. (b) Set 10features from maximum. (c) Set 6 features from maximum.

for an efficient biometrics’s system. From our research, we construct a 3D matrix

which is contain all subjects data. We also can easily access any subject or any set

of data by a simple code. This will makes our research more efficiency and simple.

In experiment A, we found that subject AR cannot be recognized when Rpick 6 as

input signal. So, we investigated the features of set 6 and others set from subject

AR in figure 5.4. We can observed that figure 5.4(c) has a significant dissimilarity

compare to (a) and (b). More features comparison for subject AR can refer to

Appendix B.

Experiment B has better recognition rate of 93.75%. Recognition rate is improved

by the extra train data provided from three days of recording. It is important to

collect enough ECG data from our subjects. For feature comparison plot can refer

to Appendix B.

Page 61: Analysis and Classification of ECG Signal using Neural Network

5.5. RECOMMENDATION 48

We concluded that wavelet transform provided efficient feature to represent a

ECG signal. Feed-forward back-propagation neural network can classify large size

of data set and performed high recognition rate. Electrocardiogram is a long term

stability biometrics signal that suitable for biometrics recognition.

5.5 Recommendation

Neural network and wavelet decomposition is strongly recommended for its su-

perior accuracy, powerful customization features. The concept of neural network

is easy to understand and customize for many others application. The wavelet

decomposition is also the simplest way to extract the features from signal. Since,

other methods are easy on concept but complex on algorithm. The project require

as many as possible of data to achieve high recognition rate. Same experiment

procedure is important to apply for all subjects involved.

For future study, We would like to collect the ECG data from different conditions

such as after drink caffeine, after short distance of walking or strenuous exercise.

This will change the heart rate or higher R peak which might happen in normal

life.

Page 62: Analysis and Classification of ECG Signal using Neural Network

Appendix A

Experiment Setup

This appendix discussed about pre-process ECG signal and procedure of ECG

signal acquisition. A simple filter will remove the ECG noise. So, the ECG

can represent the features of PQRST. Several ECG signals will be shown in this

appendix and discuss about the filter coefficient and cutoff frequency.

A.1 Procedure of ECG Acquisition

Model of Equipment: g.Mobilab+ (gTech)

Number of probe: 3 to 5 probes

1) Test subject lay down on a comfortable chair. The subject is silent and relax.

Sample Name: YN MH FQGender: Male Male Male

Age: 22 23 23Number of Electrode: 5 (ch5+/-, GND) 3 (ch5+/-, GND) 3 (ch5+/-, GND)Number of Channel: 2 (ECG, EMG) 1 (ECG) 1 (ECG)Condition of sample: Resting Resting RestingPosition of sample: Lie down Lie down Lie down

Sampling frequency: 256 Hz 256 Hz 256 Hz

Table A.1: Summary of test subject details.

i

Page 63: Analysis and Classification of ECG Signal using Neural Network

A.1. PROCEDURE OF ECG ACQUISITION ii

Figure A.1: (a) The default electrode configuration from the equipment manualfor subject MH. (b) This configuration is refer the Einthoven’s triangle Lead Ifor subject FQ. (c) Einthoven’s triangle Lead II for subject FQ. (d) Einthoven’striangle Lead III for subject FQ too. (e) Default configuration from manual andch6 for the EMG signal for subject YN.

Page 64: Analysis and Classification of ECG Signal using Neural Network

A.2. EXPERIMENT RESULT iii

ECG Peak P Q R S TMH 0.01007 0.009817 0.01251 0.009725 0.01034YN 0.01003 0.009797 0.01217 0.009394 0.01054

Amplitude Different 0.00004 0.00002 0.00034 0.000331 -0.0002

Table A.2: The dissimilarity of ECG peak from two subjects.

The detail of subjects showed in table A.1.

2) Place the electrodes on the subject. This equipment has one channel ECG

signal from three electrodes and one channel EMG signal from two electrodes.

3) According to figure A.1, which is the position of electrode configurations. We

check about the negative, positive and ground electrode is different in color ac-

cording to the equipment manual.

4) For MatLab setting, the sampling frequency is set to 256 Hz for ECG signals,

the duration of the signal is 10 seconds per recording.

5) Each sample had recorded three sets of ECG signal. The equipment can record

two channels of bio-signal, one is ECG signal from ch5 and one is EMG from ch6.

From this experiment, we measure the ECG signal for primary data of pre-process

filter. The filter will be tested in several coefficients to get a better and noiseless

signal.

A.2 Experiment Result

The experiment result will show in the figures. In order to generate our own

ECG database, a standard and easier electrode placement will be required. Pre-

processing like the filtering and segmentation is required. The filtering result will

be used to design FIR or IIR filter.

Page 65: Analysis and Classification of ECG Signal using Neural Network

A.2. EXPERIMENT RESULT iv

Fig

ure

A.2

:M

Hor

igin

alE

CG

sign

al,

each

reco

rdin

gca

nea

sily

see

the

noi

seis

not

icea

ble

.

Page 66: Analysis and Classification of ECG Signal using Neural Network

A.2. EXPERIMENT RESULT v

Fig

ure

A.3

:F

QE

CG

sign

al.

This

sign

alis

use

dth

eE

inth

oven

’str

iangl

ele

adco

nfigu

rati

onto

reco

rdth

esi

gnal

.L

ead

1,2

and

3is

reco

rded

separ

atel

ydue

toth

enum

ber

ofel

ectr

odes

.

Page 67: Analysis and Classification of ECG Signal using Neural Network

A.2. EXPERIMENT RESULT vi

Fig

ure

A.4

:Y

Nor

igin

alE

CG

sign

aluse

ddef

ault

elec

trode

sett

ing

from

the

man

ual

and

added

EM

Gsi

gnal

indiff

eren

tch

annel

show

edin

thir

dplo

t.

Page 68: Analysis and Classification of ECG Signal using Neural Network

A.2. EXPERIMENT RESULT vii

Fig

ure

A.5

:T

he

filt

ered

EC

Gsi

gnal

from

thre

esa

mple

s,to

pis

MH

EC

Gsi

gnal

,m

iddle

isF

QE

CG

sign

alan

db

otto

nis

YN

EC

Gsi

gnal

.

Page 69: Analysis and Classification of ECG Signal using Neural Network

A.2. EXPERIMENT RESULT viii

Fig

ure

A.6

:F

ast

fouri

ortr

ansf

orm

ofor

igin

alE

CG

sign

alan

dfilt

ered

sign

al.

Page 70: Analysis and Classification of ECG Signal using Neural Network

A.3. ANALYSIS ix

Figure A.7: The ECG features comparison from two samples. Both samples havethe same experiment setting so the comparison is reliable.

A.3 Analysis

First, the uniqueness of ECG signal is shown in figure A.7 and table A.2. We

can see that the PQRST have an amplitude difference from each subject. The

amplitude different is about 0.00002V to 0.0003V which is too small to become

a significant feature for the classifier to recognize the ECG from our database.

Another process to make this features significant. This uniqueness of ECG char-

acteristics is important in our project for classification.

Fast Fourier Transforms (FFT) plot can be an useful tools for analyse the frequency

spectrum. The frequency range of noise and useful features can observe from the

frequency spectrum plot that after and before filtering process. From figure A.6,

frequency spectrum is cut off from 50 Hz and above, 0 Hz to 50 Hz is the useful

features shown in the figure A.5.

A.4 Summary

We can concluded that the uniqueness of ECG signal is dependable on our project.

For the creation of ECG database, we also can set up an efficient and reliable

ECG signal acquisition experiment for many subjects. The moving average filter

is removed the noise that contained in the signal. However, we have to create

Page 71: Analysis and Classification of ECG Signal using Neural Network

A.4. SUMMARY x

IIR filter to clean the signal. The FFT shown the frequency spectrum that we

can predict the cut-off frequency range is 40 Hz to 50 Hz. The ECG is a low

frequency signal which requires a low pass filter to remove the noise.

Page 72: Analysis and Classification of ECG Signal using Neural Network

Appendix B

Program Validation

In this appendix, we will check the whole system function and sub-function is

working and give an expected result. The system function contains four main part

of sub-function. First, Construction of all data set from the recorded file(.mat) to

a single matrix. IIR filter has cleaned the noise in ECG signal. ECG signal will

cut into 15 peaks. The feature will extract from each peak of ECG signal. The

classifier will use feed-forward back-propagation neural network for classification.

B.1 Data Construction

From this function, the program extracted the ECG data from recorded files (.mat)

from each subject. There are two kinds of data sets can be constructed by the

user define, experiment A is 11 subjects with 1 day 10 sets of ECG recording and

experiment B is 4 subjects with 3 days 30 sets of ECG recording. Figure B.1

shown that each subject has 10 sets of data and sample length is 7000. Figure B.2

shown that 4 subjects have 30 sets of data and sample length is 7000.

The list of files store in each string for each subject:

1) FQ file = {FQ 1 11022010.mat, FQ 2 11022010.mat,

FQ 1 19012010.mat, FQ 2 19012010.mat, FQ 1 24022010.mat, FQ 2 24022010.mat}

xi

Page 73: Analysis and Classification of ECG Signal using Neural Network

B.1. DATA CONSTRUCTION xii

Figure B.1: This figure shown the MATLAB workspace that all subjects data arecombined into a single 3D matrix.

Figure B.2: This figure shown the MATLAB workspace that 4 subjects data arecombined into a single 3D matrix.

Page 74: Analysis and Classification of ECG Signal using Neural Network

B.2. FILTERING PROCESS xiii

2) YN file = {YN 1 11022010.mat, YN 2 11022010.mat,

YN 1 21012010.mat, YN 2 21012010.mat, YN 1 24022010.mat, YN 2 24022010.mat}

3) VR file = {VR 1 20012010.mat, VR 2 20012010.mat,

VR 1 24022010.mat, VR 2 24022010.mat, VR 19032010 day3.mat}

4) AR file = {AR 1 22012010.mat, AR 2 22012010.mat}

5) KSP file = {KSP 1 20012010.mat, KSP 2 20012010.mat}

6) YG file = {YG 1 20012010.mat, YG 2 20012010.mat,

YG 1 18032010.mat, YG 2 18032010.mat, YG 1 24022010.mat, YG 2 24022010.mat}

7) LJX file = {LJX 1 21012010.mat, LJX 2 21012010.mat}

8) ML file = {ML 1 21012010.mat, ML 2 21012010.mat}

9) SH file = {SH 1 21012010.mat, SH 2 21012010.mat}

10) AA file = {AA 1 22012010.mat, AA 2 22012010.mat}

11) NA file = {NA 1 26012010.mat, NA 2 26012010.mat}

B.2 Filtering Process

In this section will just show the random pick up ECG signal from 11 subjects,

to check the filtering result is noiseless. From figure B.3 and figure B.4 can prove

that all the data sets in the 3D matrix is filtered by the designed IIR filter.

B.3 Segmentation

For segmentation of ECG signal is the very first step to extract ECG features for

classification. This section will show the result of segmentation. We can see the

same R peak from the full ECG and ECG segments in figure B.5 and figure B.6.

Page 75: Analysis and Classification of ECG Signal using Neural Network

B.3. SEGMENTATION xiv

Fig

ure

B.3

:(a

)O

rigi

nal

EC

Gsi

gnal

from

FQ

11/0

2/20

10re

cord

ing

dat

a.(b

)filt

ered

EC

Gsi

gnal

.

Page 76: Analysis and Classification of ECG Signal using Neural Network

B.3. SEGMENTATION xv

Fig

ure

B.4

:(a

)O

rigi

nal

EC

Gsi

gnal

from

AR

24/0

1/20

10re

cord

ing

dat

a.(b

)filt

ered

EC

Gsi

gnal

.

Page 77: Analysis and Classification of ECG Signal using Neural Network

B.3. SEGMENTATION xvi

Fig

ure

B.5

:F

ull

range

ofE

CG

sign

alth

atsh

ould

be

segm

ent

by

the

funct

ion.

Pea

k1

toP

eak

15sh

ould

hav

esa

me

valu

eaf

ter

the

segm

enta

tion

inea

chse

gmen

tsh

own

isfigu

reB

.6.

Page 78: Analysis and Classification of ECG Signal using Neural Network

B.3. SEGMENTATION xvii

Fig

ure

B.6

:A

ll15

pea

ks

from

the

full

range

ofE

CG

sign

alsh

own

isfigu

reB

.5.

Page 79: Analysis and Classification of ECG Signal using Neural Network

B.4. FEATURES EXTRACTION xviii

Then, it can prove that the function has cut the correct ECG peak for all data set

from each subject.

B.4 Features Extraction

This section figure B.7 will show the features that extracted from one random

set of data from each subject. After we processed the wavelet decomposition, the

signal will down-sampling to several levels in different frequency range.

The figure B.8 is shown that the 15 peaks of the wavelet decomposition results and

figure B.9 is only taking 1 peak to show the coefficient. From each peak, we will

take the maximum, minimum, mean and standard derivation as our final features

that shown in figure B.10.

B.5 Classification

In this section, we will test on classification part that is most important in the

whole project. We will use the experiment B (4 test subjects data set) to test our

neural network classifier.

In figure B.11(d), the all confusion matrix shown a high accuracy of recognition

rate 97.4% and 2.6% of error. Inside the confusion matrix, the red box number is

not zero means that the recognition for that person is wrong during that trial.

In figure B.12, before we train the neural network, we have replaced 10 sets of

data for FQ and YN by YG and VR. So, we can see that from figure B.12(d) all

confusion matrix get about accuracy of 83.6%. In all confusion matrix, the first

column has total 8 trials fall into red boxes and also the second column has 8 trials

fall into red boxes.

Page 80: Analysis and Classification of ECG Signal using Neural Network

B.5. CLASSIFICATION xix

Fig

ure

B.7

:T

he

coeffi

cien

tof

EC

Gsi

gnal

that

conta

inof

15p

eaks.

Eac

hsu

bje

cthav

ele

ngt

hof

211

sam

ple

s.

Page 81: Analysis and Classification of ECG Signal using Neural Network

B.5. CLASSIFICATION xx

Fig

ure

B.8

:15

pea

ks

issh

own

inth

efigu

rew

ith

lengt

hof

211

sam

ple

per

pea

k.

Page 82: Analysis and Classification of ECG Signal using Neural Network

B.5. CLASSIFICATION xxi

Fig

ure

B.9

:1

pea

kis

show

nin

the

figu

rean

dcA

4an

dcD

4is

conta

in15

sam

ple

s,cD

3is

conta

in27

sam

ple

s,cD

2is

conta

in52

sam

ple

san

dcD

1is

conta

in10

2sa

mple

s.

Page 83: Analysis and Classification of ECG Signal using Neural Network

B.5. CLASSIFICATION xxii

Fig

ure

B.1

0:11

sub

ject

sfe

ature

sis

show

nin

the

figu

re,

we

can

see

the

diff

eren

tfr

omea

chsu

bje

ct.

Page 84: Analysis and Classification of ECG Signal using Neural Network

B.5. CLASSIFICATION xxiii

Figure B.11: The confusion plot for the trained neural network with correct dataset. (a) Training confusion matrix. (b) Validation confusion matrix. (c) Testconfusion matrix. (d) All confusion matrix.

Page 85: Analysis and Classification of ECG Signal using Neural Network

B.5. CLASSIFICATION xxiv

Figure B.12: The confusion plot for the trained neural network with mixed withsubject FQ and YN data sets. (a) Training confusion matrix. (b) Validationconfusion matrix. (c) Test confusion matrix. (d) All confusion matrix.

Page 86: Analysis and Classification of ECG Signal using Neural Network

B.5. CLASSIFICATION xxv

Fig

ure

B.1

3:T

he

feat

ure

sar

ediff

eren

tco

mpar

eto

other

dat

ase

t-

sub

ject

AR

.

Page 87: Analysis and Classification of ECG Signal using Neural Network

B.5. CLASSIFICATION xxvi

Fig

ure

B.1

4:T

he

feat

ure

sar

esi

milar

com

par

eto

set

10-

sub

ject

AR

.

Page 88: Analysis and Classification of ECG Signal using Neural Network

B.5. CLASSIFICATION xxvii

Fig

ure

B.1

5:T

he

feat

ure

sar

esi

milar

com

par

eto

set

5-

sub

ject

AR

.

Page 89: Analysis and Classification of ECG Signal using Neural Network

B.5. CLASSIFICATION xxviii

Fig

ure

B.1

6:T

he

feat

ure

sar

esi

milar

com

par

eto

other

dat

ase

t-

sub

ject

AA

.

Page 90: Analysis and Classification of ECG Signal using Neural Network

B.5. CLASSIFICATION xxix

Fig

ure

B.1

7:T

he

feat

ure

sar

esi

milar

com

par

eto

set

10-

sub

ject

AA

.

Page 91: Analysis and Classification of ECG Signal using Neural Network

B.5. CLASSIFICATION xxx

Fig

ure

B.1

8:T

he

feat

ure

sar

esi

milar

com

par

eto

set

5-

sub

ject

AA

.

Page 92: Analysis and Classification of ECG Signal using Neural Network

Appendix C

Source Code

This appendix will show the source code of biometrics’s system. Figure C.1 showneach functions and subfunctions in our biometrics system.

Here is the main program:

1 % BIOMETRICS SYSTEM USING ECG2

3 % This is the main program of whole system.4 % 1. Run this file.5 % 2. User input type of data set.6 % 3. Output will popup confusion matrix for all subjects.7 % 4. Workspace will show DATA, Input_data, train_data8 % num_sub, num_set, num_peak.9 % 5. Command Window will show Rpick.

10 % 6. User input y/n to repick input and classify again.11

12 % Author: LAM ZHENG YAN13 % Last Update: 12/4/201014 % Input: a - 11 subjects in one day recording15 % b - 4 subjects in three days recording16 % y - yes, to repick input and classify17 % n - no, stop program18 % Output variable: DATA - All subjects ECG signal matrix19 % Input_data - Input matrix for neural...20 % train_data - Training data set for...21 % neural network.22 % num_sub - Number of subject.23 % num_set - Number of data set.24 % num_peak - Number of peak segment.25 % Parent: -26 % Child : pre_processing, random_pick, classifier

xxxi

Page 93: Analysis and Classification of ECG Signal using Neural Network

xxxii

Figure C.1: The program tree of biometrics system.

Page 94: Analysis and Classification of ECG Signal using Neural Network

xxxiii

27 %END28

29 %The ECG signal classifier Program path30 clear all;31

32 %Pre-processing ECG signal33 [DATA,num_sub,num_set,num_peak] = pre_processing;34

35 %Random Pick one set of data from each subject...36 for input_data37 [Input_data,train_data] = random_pick(DATA,num_sub,...38 num_set,num_peak);39

40 %Classification ECG signal41 [Result_float,Result_round] = classifier(Input_data,...42 train_data, num_sub,num_set);43

44 %Random Pick one set of data from each subject for...45 % input_data46 sta = 0;47 while 1-sta == 148 yesno = input(’Repick the data set and classify...49 again?(y/n): ’,’s’);50 switch yesno51 case ’y’52 [Input_data,train_data] = random_pick(DATA,num_sub,...53 num_set,num_peak);54 %Classification ECG signal55 [Result_float,Result_round] = classifier(Input_data,...56 train_data,num_sub,num_set);57 sta = 0;58 case ’n’59 sta = 1;60 end61 end

Page 95: Analysis and Classification of ECG Signal using Neural Network

xxxiv

Here is the child function:

1 % This function contain all the pre-processing step2

3 % Before classification, all the ECG data must pass4 % thruogh this pre-processing steps.5 % 1. Extract all the ECG from .mat file.6 % 2. Filter the noise for all ECG signal.7 % 3. Segmentation process.8 % 4. Feature extraction.9

10 % Author: LAM ZHENG YAN11 % Last Update: 12/4/201012 % Input: -13 % Output variable: DATA - All subjects ECG signal matrix.14 % num_sub - Number of subject.15 % num_set - Number of data set.16 % num_peak - Number of peak segment.17 % Parent: ECG_Biometric_system18 % Child : Data_structure, IIRfilter, ecg_segment,...19 % wavelet_extract20

21 function [DATA,num_sub,num_set,num_peak] = pre_processing22

23 [Data,num_sub,num_set,num_peak] = Data_structure;24

25 fil_ecg = IIRfilter(Data,num_sub,num_set);26

27 seg = ecg_segment(fil_ecg,num_sub,num_set,num_peak);28

29 DATA = wavelet_extract(seg,num_sub,num_set,num_peak);

Page 96: Analysis and Classification of ECG Signal using Neural Network

xxxv

Here is the child function:

1 % This function randomly pick one set of data as input2

3 % Randomly pick one set of data from all subjects4 % for input data set, rest for train data set.5 % 1. Random pick by function "randperm".6 % 2. Create input data set.7 % 3. Create train data set.8 % 4. Reconstruct 3D matrix to 2D matrix, as neural network9 % require a 2D matrix as input.

10

11 % Author: LAM ZHENG YAN12 % Last Update: 12/4/201013 % Input: features - all subject features matrix(3D)14 % num_sub - Number of subject.15 % num_set - Number of data set.16 % num_peak - Number of peak segment.17 % Output: Input_data - Input matrix for neural...18 % network.19 % train_data - Training data set for...20 % neural network.21 % Parent: ECG_Biometric_system22 % Child : -23

24 % Random pick one set of data as classifier input data set.25 function [Input_data,train_data] = random_pick(features,...26 num_sub,num_set,num_peak)27 Rpick = randperm(num_set);28 Rpick = Rpick(:,1)29 % Rpick = 1030

31 % Create Input data set32 for n = 0:1:num_sub-133 for m = 0:1:334 p1 = 1+(m*(5*num_peak));35 b1 = (5*num_peak)*(m+1);36 Input_data(p1:b1,n+1) = features(1:(5*num_peak),...37 Rpick,(m+1)+(4*n));38 end39 end40

41 if Rpick ˜= num_set42 features1(:,1:Rpick-1,:) = features(:,1:Rpick-1,:);43 features1(:,Rpick:num_set-1,:) = features(:,...44 Rpick+1:num_set,:);45

46 % Create Training data set

Page 97: Analysis and Classification of ECG Signal using Neural Network

xxxvi

47 for n = 0:1:num_sub-148 for m = 0:1:349 train_data(1+(m*(5*num_peak)):(5*num_peak)*(m+1),...50 1+(n*(num_set-1)):(num_set-1)*(n+1)) = ...51 features1(1:(5*num_peak),1:num_set-1,(m+1)+(4*n));52 end53 end54

55 else56 features1(:,1:Rpick-1,:) = features(:,1:Rpick-1,:);57

58 for n = 0:1:num_sub-159 for m = 0:1:360 train_data(1+(m*(5*num_peak)):(5*num_peak)*(m+1),...61 1+(n*(num_set-1)):(num_set-1)*(n+1)) = ...62 features1(1:(5*num_peak),1:num_set-1,(m+1)+(4*n));63 end64 end65 end

Page 98: Analysis and Classification of ECG Signal using Neural Network

xxxvii

Here is the child function:

1 % Classification function2

3 % Neural network will be created, classificatiom result4 % will shown in confusion plot.5 % 1. Normalize the train data set.6 % 2. Normalize the input data set.7 % 3. Define train_parameter.8 % 4. Create network.9 % 5. Train network unitl it reach performance.

10 % 6. Classification.11

12 % Author: LAM ZHENG YAN13 % Last Update: 12/4/201014 % Input: Input_data - Input matrix for neural...15 % network.16 % train_data - Training data set for...17 % neural network.18 % Output: Confusion plot, Resutl_round19 % Parent: ECG_Biometric_system20 % Child : -21

22 %The ECG signal classifier Program path23 function [Result_float,Result_round] = ...24 classifier(Input_data,train_data,num_sub,num_set)25

26 % ********************************************************27 % Normalized the training set and the input_data set28 % MapStd is used to normalize the data.29

30 [train_data,PS] = mapstd(train_data);31 Input_data = mapstd(’apply’,Input_data,PS);32

33

34 target_data1 = zeros(num_sub,num_sub);35 target_data = zeros(num_sub,num_sub);36 for m = 0:1:num_sub-137 target_data(m+1,m+1) = 1;38 target_data1(m+1,1+(m*(num_set-1)):(m+1)*(num_set-1))= 1;39 end40

41 % ************************************************************42 % Pattern Recognition Network Properties43 % ************************************************************44 % val =45 %46 % Neural Network object:

Page 99: Analysis and Classification of ECG Signal using Neural Network

xxxviii

47 %48 % architecture:49 %50 % numInputs: 151 % numLayers: 252 % biasConnect: [1; 1]53 % inputConnect: [1; 0]54 % layerConnect: [0 0; 1 0]55 % outputConnect: [0 1]56 %57 % numOutputs: 1 (read-only)58 % numInputDelays: 0 (read-only)59 % numLayerDelays: 0 (read-only)60 %61 % subobject structures:62 %63 % inputs: {1x1 cell} of inputs64 % layers: {2x1 cell} of layers65 % outputs: {1x2 cell} containing 1 output66 % biases: {2x1 cell} containing 2 biases67 % inputWeights: {2x1 cell} containing 1 input weight68 % layerWeights: {2x2 cell} containing 1 layer weight69 %70 % functions:71 %72 % adaptFcn: ’trains’73 % divideFcn: ’dividerand’74 % gradientFcn: ’calcgrad’75 % initFcn: ’initlay’76 % performFcn: ’mse’77 % plotFcns: {’plotperform’,’plottrainstate’...78 % ,’plotconfusion’,’plotroc’}79 % trainFcn: ’trainscg’80 %81 % parameters:82 %83 % adaptParam: .passes84 % divideParam: .trainRatio, .valRatio, .testRatio85 % gradientParam: (none)86 % initParam: (none)87 % performParam: (none)88 % trainParam: .show, .showWindow, .showCommandLine,...89 % .epochs,90 % .time, .goal, .max_fail, .min_grad,91 % .sigma, .lambda, .lr, .lr_inc92 %93 % weight and bias values:

Page 100: Analysis and Classification of ECG Signal using Neural Network

xxxix

94 %95 % IW: {2x1 cell} containing 1 input weight matrix96 % LW: {2x2 cell} containing 1 layer weight matrix97 % b: {2x1 cell} containing 2 bias vectors98 %99 % other:

100 %101 % name: ’’102 % userdata: (user information)103 % ****************************************************************104 num_neu = 50105 net = newpr(train_data, target_data1, num_neu);106 net.trainParam.epochs = 150;107 net.trainParam.lr = 0.05;108 net.trainParam.lr_inc = 3.05;109 net.trainParam.goal = 2e-3;110 net.trainParam.max_fail = 50;111 % net.divideFcn = ’’;112 [net,tr,Y,E,Pf,Af] = train(net, train_data, target_data1);113 minPerf = min(tr.perf);114 goal = tr.goal;115

116 % Auto retrain network, when performance not reached.117 while minPerf > goal118 net = initnw(net,2);119 [net,tr,Y,E,Pf,Af] = train(net, train_data, target_data1);120 minPerf = min(tr.perf);121 goal = tr.goal;122 end123

124 Result_float = sim(net,Input_data);125 Result_round = round(Result_float);126

127 plotconfusion(target_data,Result_float)

Page 101: Analysis and Classification of ECG Signal using Neural Network

xl

Here is the child subfunction:

1 % This subfunction is extract all the .mat file2

3 % All file is defined in a string seperately for each4 % subject. Data structure is a 3D matrix:5 % [num_sample x num_set x num_subject]6

7 % Author: LAM ZHENG YAN8 % Last Update: 12/4/20109 % Input: .mat files

10 % Output variable: DATA - All subjects ECG signal matrix.11 % num_sub - Number of subject.12 % num_set - Number of data set.13 % num_peak - Number of peak segment.14 % Parent: pre_processing15 % Child : -16

17 function [Data,num_sub,num_set,num_peak] =...18 Data_structure19

20 % Add Data structure21 m = 7000;22 n = 10;23 num_sub = 11;24 % ***********************************************************25

26 % Faliq ECG signal x 20 set27 faliq_file = {’faliq_1_11022010.mat’,...28 ’faliq_2_11022010.mat’,’faliq_1_19012010.mat’,...29 ’faliq_2_19012010.mat’,’faliq_1_24022010.mat’,...30 ’faliq_2_24022010.mat’};31 for b = 1:1:632 faliq1 = load(faliq_file{:,b});33 v = 0:5:25;34 faliq_dat(:,1+v(:,b)) = faliq1.trial1(1:m,5);35 faliq_dat(:,2+v(:,b)) = faliq1.trial2(1:m,5);36 faliq_dat(:,3+v(:,b)) = faliq1.trial3(1:m,5);37 faliq_dat(:,4+v(:,b)) = faliq1.trial4(1:m,5);38 faliq_dat(:,5+v(:,b)) = faliq1.trial5(1:m,5);39 end40 % ***********************************************************41

42 % Yan ECG signal x 20 set43 yan_file = {’yan_1_11022010.mat’,...44 ’yan_2_11022010.mat’,’yan_1_21012010.mat’,...45 ’yan_2_21012010.mat’,’yan_1_24022010.mat’,...46 ’yan_2_24022010.mat’};

Page 102: Analysis and Classification of ECG Signal using Neural Network

xli

47 for b = 1:1:648 yan1 = load(yan_file{:,b});49 v = 0:5:25;50 yan_dat(:,1+v(:,b)) = yan1.trial1(1:m,5);51 yan_dat(:,2+v(:,b)) = yan1.trial2(1:m,5);52 yan_dat(:,3+v(:,b)) = yan1.trial3(1:m,5);53 yan_dat(:,4+v(:,b)) = yan1.trial4(1:m,5);54 yan_dat(:,5+v(:,b)) = yan1.trial5(1:m,5);55 end56 % ***********************************************************57

58 % Veren ECG singal x 10 set59 veren_file = {’veren_1_20012010.mat’,...60 ’veren_2_20012010.mat’,’veren_1_24022010.mat’,...61 ’veren_2_24022010.mat’,’veren_19032010_day3.mat’};62 for b = 1:1:463 veren1 = load(veren_file{:,b});64 v = 0:5:15;65 veren_dat(:,1+v(:,b)) = veren1.trial1(1:m,5);66 veren_dat(:,2+v(:,b)) = veren1.trial2(1:m,5);67 veren_dat(:,3+v(:,b)) = veren1.trial3(1:m,5);68 veren_dat(:,4+v(:,b)) = veren1.trial4(1:m,5);69 veren_dat(:,5+v(:,b)) = veren1.trial5(1:m,5);70 end71

72 veren1 = load(veren_file{:,5});73 veren_dat(:,21) = veren1.trial1(1:m,6);74 veren_dat(:,22) = veren1.trial2(1:m,6);75 veren_dat(:,23) = veren1.trial3(1:m,6);76 veren_dat(:,24) = veren1.trial4(1:m,6);77 veren_dat(:,25) = veren1.trial5(1:m,6);78 veren_dat(:,26) = veren1.trial6(1:m,6);79 veren_dat(:,27) = veren1.trial7(1:m,6);80 veren_dat(:,28) = veren1.trial8(1:m,6);81 veren_dat(:,29) = veren1.trial9(1:m,6);82 veren_dat(:,30) = veren1.trial10(1:m,6);83 % **********************************************************84

85 % Asyrani ECG signal x 10 set86 asyrani_file = {’asyrani_1_22012010.mat’,...87 ’asyrani_2_22012010.mat’};88 for b = 1:1:289 asyrani1 = load(asyrani_file{:,b});90 v = 0:5:5;91 asyrani_dat(:,1+v(:,b)) = asyrani1.trial1(1:m,5);92 asyrani_dat(:,2+v(:,b)) = asyrani1.trial2(1:m,5);93 asyrani_dat(:,3+v(:,b)) = asyrani1.trial3(1:m,5);

Page 103: Analysis and Classification of ECG Signal using Neural Network

xlii

94 asyrani_dat(:,4+v(:,b)) = asyrani1.trial4(1:m,5);95 asyrani_dat(:,5+v(:,b)) = asyrani1.trial5(1:m,5);96 end97 % **********************************************************98

99 % koshaopeng ECG signal x 10 set100 koshaopeng_file = {’koshaopeng_1_20012010.mat’,...101 ’koshaopeng_2_20012010.mat’};102 for b = 1:1:2103 koshaopeng1 = load(koshaopeng_file{:,b});104 v = 0:5:5;105 koshaopeng_dat(:,1+v(:,b)) = koshaopeng1.trial1(1:m,5);106 koshaopeng_dat(:,2+v(:,b)) = koshaopeng1.trial2(1:m,5);107 koshaopeng_dat(:,3+v(:,b)) = koshaopeng1.trial3(1:m,5);108 koshaopeng_dat(:,4+v(:,b)) = koshaopeng1.trial4(1:m,5);109 koshaopeng_dat(:,5+v(:,b)) = koshaopeng1.trial5(1:m,5);110 end111 % **********************************************************112

113 % yeong ECG signal x 10 set114 yeong_file = {’yeong_1_20012010.mat’,...115 ’yeong_2_20012010.mat’,’yeong_1_18032010.mat’,...116 ’yeong_2_18032010.mat’,’yeong_1_24022010.mat’,...117 ’yeong_2_24022010.mat’};118 for b = 1:1:6119 yeong1 = load(yeong_file{:,b});120 v = 0:5:25;121 yeong_dat(:,1+v(:,b)) = yeong1.trial1(1:m,5);122 yeong_dat(:,2+v(:,b)) = yeong1.trial2(1:m,5);123 yeong_dat(:,3+v(:,b)) = yeong1.trial3(1:m,5);124 yeong_dat(:,4+v(:,b)) = yeong1.trial4(1:m,5);125 yeong_dat(:,5+v(:,b)) = yeong1.trial5(1:m,5);126 end127 % **********************************************************128

129 % lowjinxiang ECG signal x 10 set130 lowjinxiang_file = {’lowjinxiang_1_21012010.mat’,...131 ’lowjinxiang_2_21012010.mat’};132 for b = 1:1:2133 lowjinxiang1 = load(lowjinxiang_file{:,b});134 v = 0:5:5;135 lowjinxiang_dat(:,1+v(:,b)) = lowjinxiang1.trial1(1:m,5);136 lowjinxiang_dat(:,2+v(:,b)) = lowjinxiang1.trial2(1:m,5);137 lowjinxiang_dat(:,3+v(:,b)) = lowjinxiang1.trial3(1:m,5);138 lowjinxiang_dat(:,4+v(:,b)) = lowjinxiang1.trial4(1:m,5);139 lowjinxiang_dat(:,5+v(:,b)) = lowjinxiang1.trial5(1:m,5);140 end

Page 104: Analysis and Classification of ECG Signal using Neural Network

xliii

141 % **********************************************************142

143 % mukhlish ECG signal x 10 set144 mukhlish_file = {’mukhlish_1_21012010.mat’,...145 ’mukhlish_2_21012010.mat’};146 for b = 1:1:2147 mukhlish1 = load(mukhlish_file{:,b});148 v = 0:5:5;149 mukhlish_dat(:,1+v(:,b)) = mukhlish1.trial1(1:m,5);150 mukhlish_dat(:,2+v(:,b)) = mukhlish1.trial2(1:m,5);151 mukhlish_dat(:,3+v(:,b)) = mukhlish1.trial3(1:m,5);152 mukhlish_dat(:,4+v(:,b)) = mukhlish1.trial4(1:m,5);153 mukhlish_dat(:,5+v(:,b)) = mukhlish1.trial5(1:m,5);154 end155 % **********************************************************156

157 % solehin ECG signal x 10 set158 solehin_file = {’solehin_1_21012010.mat’,...159 ’solehin_2_21012010.mat’};160 for b = 1:1:2161 solehin1 = load(solehin_file{:,b});162 v = 0:5:5;163 solehin_dat(:,1+v(:,b)) = solehin1.trial1(1:m,5);164 solehin_dat(:,2+v(:,b)) = solehin1.trial2(1:m,5);165 solehin_dat(:,3+v(:,b)) = solehin1.trial3(1:m,5);166 solehin_dat(:,4+v(:,b)) = solehin1.trial4(1:m,5);167 solehin_dat(:,5+v(:,b)) = solehin1.trial5(1:m,5);168 end169 % **********************************************************170

171 % alamin ECG signal x 10 set172 alamin_file = {’alamin_1_22012010.mat’,...173 ’alamin_2_22012010.mat’};174 for b = 1:1:2175 alamin1 = load(alamin_file{:,b});176 v = 0:5:5;177 alamin_dat(:,1+v(:,b)) = alamin1.trial1(1:m,5);178 alamin_dat(:,2+v(:,b)) = alamin1.trial2(1:m,5);179 alamin_dat(:,3+v(:,b)) = alamin1.trial3(1:m,5);180 alamin_dat(:,4+v(:,b)) = alamin1.trial4(1:m,5);181 alamin_dat(:,5+v(:,b)) = alamin1.trial5(1:m,5);182 end183 % **********************************************************184

185 % nikadam ECG signal x 10 set186 nikadam_file = {’nikadam_1_26012010.mat’,...187 ’nikadam_2_26012010.mat’};

Page 105: Analysis and Classification of ECG Signal using Neural Network

xliv

188 for b = 1:1:2189 nikadam1 = load(nikadam_file{:,b});190 v = 0:5:5;191 nikadam_dat(:,1+v(:,b)) = nikadam1.trial1(1:m,5);192 nikadam_dat(:,2+v(:,b)) = nikadam1.trial2(1:m,5);193 nikadam_dat(:,3+v(:,b)) = nikadam1.trial3(1:m,5);194 nikadam_dat(:,4+v(:,b)) = nikadam1.trial4(1:m,5);195 nikadam_dat(:,5+v(:,b)) = nikadam1.trial5(1:m,5);196 end197 % **********************************************************198

199 % Choose 2 type of data set200 % 1st type: 11 subjects in 1 day of recording201 % 2nd type: 4 subjects in 3 days of recording202

203 msg0 = {’The type of data set:’;...204 ’a. 11 subjects in 1 day of recording’;...205 ’b. 4 subjects in 3 days of recording’}206 type_data = input(’Choose the type of data set(a/b): ’,’s’);207

208 switch type_data209 case ’a’210 % data structure211 Data(:,:,1) = faliq_dat(:,1:10);212 Data(:,:,2) = yan_dat(:,1:10);213 Data(:,:,3) = veren_dat(:,1:10);214 Data(:,:,4) = alamin_dat;215 Data(:,:,5) = asyrani_dat;216 Data(:,:,6) = koshaopeng_dat;217 Data(:,:,7) = lowjinxiang_dat;218 Data(:,:,8) = mukhlish_dat;219 Data(:,:,9) = nikadam_dat;220 Data(:,:,10) = solehin_dat;221 Data(:,:,11) = yeong_dat(:,1:10);222 num_sub = 11;223 num_set = 10;224 num_peak = 15;225

226 case ’b’227 Data(:,:,1) = faliq_dat;228 Data(:,:,2) = yan_dat;229 Data(:,:,3) = veren_dat;230 Data(:,:,4) = yeong_dat;231 num_sub = 4;232 num_set = 30;233 num_peak = 15;234 end

Page 106: Analysis and Classification of ECG Signal using Neural Network

xlv

Here is the child subfunction:

1 % This subfunction is filtering the noise in ECG.2

3 % IIR filter is creadted for filtering process.4

5 % Author: LAM ZHENG YAN6 % Last Update: 12/4/20107 % Input: ecg - data structure(3D)8 % num_sub - Number of subject.9 % num_set - Number of data set.

10 % num_peak - Number of peak segment.11 % Output variable: fil_ecg - ECG without noise12 % Parent: pre_processing13 % Child : -14

15 function fil_ecg = IIRfilter(ecg,num_sub,num_set)16 % Lowpass Elliptic IIR filter design17 ftype = ’low’;18 Rp=2;19 Rs=90;20 Wp = 0.325;21 Ws = 0.33;22 [n, Wn] =ellipord(Wp,Ws,Rp,Rs);23

24 % Transfer Function design25 [b,a] = ellip(n,Rp,Rs,Wn,ftype);26

27 for n = 1:1:num_sub28 for m = 1:1:num_set29 fil_ecg(:,m,n) = filtfilt(b,a,ecg(:,m,n));30 end31 end

Page 107: Analysis and Classification of ECG Signal using Neural Network

xlvi

Here is the child subfunction:

1 % This subfunction is segmentation2

3 % The ECG is segmented into 15 pieces.4 % 1. Detect the first peak.5 % 2. Find 15 peak after the first peak.6 % 3. Define the range of each segment.7

8 % Author: LAM ZHENG YAN9 % Last Update: 12/4/2010

10 % Input: w1 - data structure(3D)11 % num_sub - Number of subject.12 % num_set - Number of data set.13 % num_peak - Number of peak segment.14 % Output variable: segments(3D)- contain 15 pieces of ECG15 % Parent: pre_processing16 % Child : -17

18 function segments = ecg_segment(w1,num_sub,...19 num_set,num_peak)20 RRmax = 250;21 RRmin = 150;22 RR2max = 500;23 RR2min = 300;24 %first double interval, all peak detected25 for v = 1:1:num_sub26 for c = 1:1:num_set27

28 for j = 1:1:RR2max29 if w1(j,c,v) == max(w1(1:RR2max,c,v))30 position = j;31 int_peak = [position,w1(j,c,v)];32 end33 end34

35 for m = 1:1:num_peak36 for k = position:1:position+37337 if w1(k,c,v) == ...38 max(w1(position+17:position+390,c,v))39 position = k;40 peak_pos(:,m) = position;41 peak_val(:,m) = w1(k,c,v);42 end43 end44 end45

46 %from peak, break each ECG wave in single vector

Page 108: Analysis and Classification of ECG Signal using Neural Network

xlvii

47 % Each peak is 201 samples48 for n = 0:1:num_peak-149 p = 1+(n*201);50 b = (n+1)*201;51 segments(p:b,c,v) = ...52 w1(peak_pos(:,n+1)-50:peak_pos(:,n+1)+150,c,v);53 end54

55 end56 end

Page 109: Analysis and Classification of ECG Signal using Neural Network

xlviii

Here is the child subfunction:

1 % This subfunction is feature extraction2

3 % Feature extraction is done by wavelet decomposition4 % 1. Find the maximum from each subband.5 % 2. Find the minimum from each subband.6 % 3. Find the mean from each subband.7 % 4. Find the standard deviation from each subband.8

9 % Author: LAM ZHENG YAN10 % Last Update: 12/4/201011 % Input: ecg_seg - data that already segmented(3D)12 % num_sub - Number of subject.13 % num_set - Number of data set.14 % num_peak - Number of peak segment.15 % Output variable: all data features (3D)16 % Parent: pre_processing17 % Child : -18

19 function features = ...20 wavelet_extract(ecg_seg,num_sub,num_set,num_peak)21 %Discreate Wavelet Transform22 for v = 0:1:num_sub-123 for c = 1:1:num_set24 for n = 0:1:num_peak-125 %Daubenchies wavelet order 2, lvl 426 p = 1+(n*201);27 b = (n+1)*201;28 p1 = 1+(n*211);29 b1 = (n+1)*211;30 [C(p1:b1,c,v+1),L]=...31 wavedec(ecg_seg(p:b,c,v+1),4,’db2’);32 end33 end34 end35

36 for q = 1:1:537 %convert L38 Lsum(:,1) = 1;39 Lsum(:,q+1) = sum(L(1:q,:));40 end41

42 %Create the 3D features cube43 %Define 3rd dimension axis44 maxi = 1;45 mini = 2;46 meanval = 3;

Page 110: Analysis and Classification of ECG Signal using Neural Network

xlix

47 stdval = 4;48 for v = 0:1:num_sub-149 for c = 1:1:num_set50 for m = 0:1:num_peak-151 p1 = 1+(m*211);52 b1 = (m+1)*211;53 C1(:,c,v+1) = C(p1:b1,c,v+1);54 for mn = 1:1:555 features(mn+(m*5),c,maxi+(v*4)) =...56 max(C1(Lsum(:,mn):Lsum(:,mn+1),c,v+1));57 features(mn+(m*5),c,mini+(v*4)) =...58 min(C1(Lsum(:,mn):Lsum(:,mn+1),c,v+1));59 features(mn+(m*5),c,meanval+(v*4)) =...60 mean(C1(Lsum(:,mn):Lsum(:,mn+1),c,v+1));61 features(mn+(m*5),c,stdval+(v*4)) =...62 std(C1(Lsum(:,mn):Lsum(:,mn+1),c,v+1));63 end64 end65

66 end67 end

Page 111: Analysis and Classification of ECG Signal using Neural Network

Bibliography

[AA09] M.Sheikh M. Algunaidi and M. A. Mohd Ali. Threshold-free detection of

maternal heart rate from abdominal electrocardiogram. In IEEE Inter-

national Conference on Signal and Image Processing Application, Kuala

Lumpur, Malaysia, 2009.

[AM01] A.Mitiche and M.Lebidoff. Pattern classification by a condensed neural

network. Pergamon Neural Networks, 14:575–580, 2001.

[Dau90] I. Daubechies. The wavelet transform, time-frequency localization and

signal analysis. IEEE Transactions on Information, 36:961–1005, 1990.

[FC08] Shih-Chin Fang and Hsiao-Lung Chan. Human identification by quanti-

fying similarity and dissimilarity in electrocardiogram phase space. El-

sevier Pattern recognition, 42:1824–1831, 2008.

[FJJ+90] G.M. Friesen, T.C. Jannett, M.A. Jadallah, S.L. Yates, S.R. Quint, and

H.T. Nagle. A comparison of the noise sensitivity of nine qrs detection

algorithm. IEEE Transactions on Biomedical Engineering, 37:85–98,

1990.

[HDB02] Martin T. Hagan, Howard B. Demuth, and Mark H. Beale. Neural

Network Design. Nelson Canada, Canada, 2002.

[Ran02] Rangaraj M. Rangayyan. Biomedical Signal Analysis: A Case-Study

Approach (IEEE Press Series on Biomedical Engineering). John Wiley

& Sons. Inc, New York, New York, NY, 2002.

l

Page 112: Analysis and Classification of ECG Signal using Neural Network

BIBLIOGRAPHY li

[Rus76] R.F. Rushmer. Cardiovascular Dynamics (4th edition). W.B Saunders,

Philadelphia, PA, 1976.

[Sol02] S. Soltani. On the use of the wavelet decomposition for time series

prediction. Neuracomputing, 48:267–277, 2002.

[SSB96] Christos Stergiou, Dimitrios Siganos, and Dr. Krysia Broda. Neural

networks and their uses. Technical report, Department of Computing,

Imperial College of Science Technology and Medicine., http://www.

doc.ic.ac.uk/˜nd/surprise_96/#Zhome, 1996.

[UA96] M. Unser and A Aldroubi. A review of wavelet in biomedical applica-

tions. In Proceeding of the IEEE, volume 84, pages 626–638, Bethesda,

USA, 1996.

[UCC07] Elif Derya Ubeyli, Irena Cosic, and Dean Cvetkovic. Wavelet transform

feature extraction from human PPG, ECG and EEG signal responses to

ELF PEMF exposures: A pilot study. Elsevier Digital signal processing,

18:861–874, 2007.

[UG05] E.D. Ubeyli and I Guler. Feature extraction from doppler ultrasound

signals for automated diagnostic systems. Computers in Biology and

Medicine, 35:735–764, 2005.

[YW08] Yun-Chi Yeh and Wen-June Wang. Qrs complexes detection for ecg

signal: The difference operation method. Elsevier Computer Method

and Program in Biomedicine, 91:245–254, 2008.

[ZC06] Z.D. Zhao and Y.Q. Chen. A new method for removel of baseline wander

and power line interference in ecg signals. In Proceedings of the Fifth

International Conference on Machine Learning and Cybernetics, Dalian,

pages 4342–4347, 2006.