classification and detection of ecg-signals using artificial neural networks

56
i Abstract Electrocardiogram (ECG), a noninvasive technique is used as a primary diagnostic tool for cardiovascular diseases. A cleaned ECG signal provides necessary information about the electrophysiology of the heart diseases and ischemic changes that may occur. It provides valuable information about the functional aspects of the heart and cardiovascular system. The objective of the thesis is to automatic detection of cardiac arrhythmias in ECG signal. Recently developed digital signal processing and pattern reorganization technique is used in this thesis for detection of cardiac arrhythmias. The detection of cardiac arrhythmias in the ECG signal consists of following stages: detection of QRS complex in ECG signal; feature extraction from detected QRS complexes; classification of beats using extracted feature set from QRS complexes. In turn automatic classification of heartbeats represents the automatic detection of cardiac arrhythmias in ECG signal. Hence, in this thesis, we developed the automatic algorithms for classification of heartbeats to detect cardiac arrhythmias in ECG signal.QRS complex detection is the first step towards automatic detection of cardiac arrhythmias in ECG signal. A novel algorithm for accurate detection of QRS complex in ECG signal peak classification approach is used in ECG signal for determining various diseases . As known the amplitudes and duration values of P-Q-R-S-T peaks determine the functioning of heart of human. Therefore duration and amplitude of all peaks are found. R-R and P-R intervals are calculated. Finally, we have obtained the necessary information for disease detection .For detection of cardiac arrhythmias; the extracted features in the ECG signal will be input to the classifier. The extracted features contain morphological l features of each heartbeat in the ECG signal. This project is implemented by using MATLAB software. An interface was created to easily select and process the signal. “.dat” format is used the for ECG signal data. We have detected bradycardia and tachycardia. Massachusetts Institute of Technology Beth Israel Hospital (MIT-BIH) arrhythmias database has been used for performance analysis.

Upload: gaurav-upadhyay

Post on 21-Apr-2017

42 views

Category:

Engineering


2 download

TRANSCRIPT

Page 1: Classification and Detection of ECG-signals using Artificial Neural Networks

i

Abstract

Electrocardiogram (ECG), a noninvasive technique is used as a primary diagnostic tool for

cardiovascular diseases. A cleaned ECG signal provides necessary information about the

electrophysiology of the heart diseases and ischemic changes that may occur. It provides

valuable information about the functional aspects of the heart and cardiovascular system. The

objective of the thesis is to automatic detection of cardiac arrhythmias in ECG signal.

Recently developed digital signal processing and pattern reorganization technique is used in

this thesis for detection of cardiac arrhythmias. The detection of cardiac arrhythmias in the

ECG signal consists of following stages: detection of QRS complex in ECG signal; feature

extraction from detected QRS complexes; classification of beats using extracted feature set

from QRS complexes. In turn automatic classification of heartbeats represents the automatic

detection of cardiac arrhythmias in ECG signal. Hence, in this thesis, we developed the

automatic algorithms for classification of heartbeats to detect cardiac arrhythmias in ECG

signal.QRS complex detection is the first step towards automatic detection of cardiac

arrhythmias in ECG signal. A novel algorithm for accurate detection of QRS complex in ECG

signal peak classification approach is used in ECG signal for determining various diseases . As

known the amplitudes and duration values of P-Q-R-S-T peaks determine the functioning of

heart of human. Therefore duration and amplitude of all peaks are found. R-R and P-R

intervals are calculated. Finally, we have obtained the necessary information for disease

detection .For detection of cardiac arrhythmias; the extracted features in the ECG signal will

be input to the classifier. The extracted features contain morphological l features of each

heartbeat in the ECG signal. This project is implemented by using MATLAB software. An

interface was created to easily select and process the signal. “.dat” format is used the for ECG

signal data. We have detected bradycardia and tachycardia. Massachusetts Institute of

Technology Beth Israel Hospital (MIT-BIH) arrhythmias database has been used for

performance analysis.

Page 2: Classification and Detection of ECG-signals using Artificial Neural Networks

ii

Table of Contents

ABSTRACT …………………………………………………………………………………i

LIST OF FIGURES................................................................................................................iv

LIST OF ACRONYMS..........................................................................................................v

CHAPTER 1

INTRODUCTION..................................................................................................................1

1.1 GENERAL OVERVIEW...............................................................................................1

1.2 THE ELECTROCARDIOGRAM…..............................................................................1

1.3 ECG WAVEFORM DESCRIPITION………………………………………………..4

1.4 OBJECTIVE………………………...…………………………………………………6

1.5 PROBLEM STATEMENT…………………………………………………………….6

1.6 MOTIVATION………………………………………………………………………...7

1.7 ARRHYTHMIA DATASETS…………………………………………………………7

1.7.1. NORMAL SINUS RHYTHM…………………………………………………...8

1.7.2. SINUS TACHYCARDIA………………………….…………………………… 8

1.7.3. SINUS BRADYCARDIA ………………………………………………………9

1.7.4. HEART BLOCK………………………………………………………………...9

CHAPTER 2

LITERATURE SURVEY....................................................................................................10

CHAPTER 3

METHODOLOGY………………………...………………………………………………14

3.1 MATLAB………….…….…………………………………………………………...14

3.2 MIT-BIH ARRHYTHMIAS DATABASE….............................................................16

3.3 PRE-PROCESSING OF ECG SIGNALS …………………......................................16

3.4 INTRODUCTION TO WAVELET………………………. …………..……………19

3.5 QRS DETECTION…………………………………………………………………..24

Page 3: Classification and Detection of ECG-signals using Artificial Neural Networks

iii

CHAPTER 4

CLASSIFICATION AND DETECTION...................................................................…....29

4.1 CONCEPT OF PATTERN RECOGNITION……………….......................................29

4.2 NEURAL NETWORK BASED CLASSIFIER...........................................................31

4.3 ARCHITECTURE OF NEURAL NETWORK………………. ..................................31

4.4 APPLICATION OF NEURAL NETWORK…………………………………….…...33

CHAPTER 5

RESULTS AND CONCLUSIONS……..…………………………………….…………..36

5.1 RESULTS……………………………………………..……………………………..36

5.2 CONCLUSION…………………………….………………………………………..38

5.3 FUTURE SCOPE ………………………….………………………………………..38

REFERENCES ………………………….……………………………………...….……….39

ANNEXURE - A

ANNEXURE - B

Page 4: Classification and Detection of ECG-signals using Artificial Neural Networks

iv

LIST OF FIGURES

Figure1.1 Represents a typical ECG waves ............................................................................2

Figure 1.2 Shape of the electrocardiogram ……………………….………….….…...………3

Figure 1.3 The heart’s anatomy with waveforms …………………….……………..……….3

Figure 1.4 Location of chest electrodes ……………………………...………………………5

Figure 1.5 Normal Sinus Rhythms ..........................................................................................8

Figure 1.6 Sinus Tachycardia ……………………………………………….…….…………8

Figure 1.7 Sinus Bradycardia …………………………………………….………………….9

Figure 1.8 Heart Block ............................................................................................................9

Figure 3.1 Flow-chart of ECG Classification ................................................................…....15

Figure 3.2 Implementation results of preprocessing ..............................................................17

Figure 3.3 Normal ECG waveform .......................................................................................24

Figure 3.4 Implementation result of PQRST detection method ……………………………28

Figure 4.1 Three input of and one output neuron unit ………………...……………………29

Figure 4.2 Simple neural network structure ………………………………………………..30

Figure 4.3 Left side is the feed forward network …..……...……...………………...…..…..32

Figure 4.4 Right side is the feedback network …………………......………………………32

Figure 5.1: GUI Editor……………………………………...……………………………….35

Figure 5.2: Sample GUI ……...………………………………………………….……..…...35

Figure 5.3: GUI showing normal ECG ………………..……………………………………36

Figure 5.4: GUI showing Bradycardia ECG …...……………...……………………………36

Figure 5.7: GUI showing Tachycardia ECG ………………...……………..………………37

Page 5: Classification and Detection of ECG-signals using Artificial Neural Networks

v

LIST OF ACRONYMS

ECG Electrocardiogram

MIT-BIH Massachusetts Institute of Technology Beth Israel Hospital database

N Normal beat

LBBB Left Bundle Branch Block Beat

RBBB Right Bundle Branch Block Beat

APB Atrial Premature Beat

J Nodal (Junctional) Premature Beat

SPB Supraventricular Premature Beat

PVC Premature Ventricular Contraction

AEB Atrial Escape Beat

NEB Nodal (junctional) escape beat

VEB Ventricular Escape Beat

PB Paced Beat

UB Unclassifiable Beat

MLP-BP Multilayer Perceptron Back Propagation

RBF Radial Basis Function

ANN Artifical Neural Network

WT Wavelet Transform

DWT Discrete Wavelet Transform

CAT Computer-Aided Tomography

Page 6: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

1

CHAPTER 1

INTRODUCTION

1.1 General Overview

The population increases day by day. Therefore people don't get enough benefit from

health services. It is impossible for patients to be kept under the supervision of a physician

at all times. Speed and time are very important for physicians. This project is intended to

help doctors to analyze the ECG signal. Doctors will save time thanks to program. This

program can also be used for education.

1.2 The Electrocardiogram

Open and see methods were used for diseases of internal organs by physician. It meant that

people were always suffering. This was also a very difficult situation for both physicians

and patients. Technology has improved. Now doctors use non-invasive methods. For

example urine and blood tests.

Various signals are taken from the organs in the human body. The information generated

by these signals is in this group. For examples EEG (electrical activity of the brain,

electroencephalogram), EMG (electrical activity of the muscles, electromyogram). and

ECG. ECG signal analysis was performed in this project. Detailed information about this

signal is given below.

The electrical current is spread through the body when the heart undergoes depolarization

(The electrical activation of the tissues is positive) repolarization (The discharge of

electrical charge of the tissues). This electrical activity generated by heart. It can be

measured by an array of electrodes placed on the body surface. These records are called

electrocardiograms (ECG or EKG).

Over the past few years, there has been an increased trend toward processing of the

electrocardiogram (ECG) using microcomputers. A survey of literature in this reach area

indicates that system based on microcomputers can perform needed medical services in

extremely efficient manner.

Page 7: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

2

Figure 1.1: Represents a typical ECG waves.

The heart beat period of time curve (typical ECG waveforms) is examined in figure 1.

There is sharpness in the figure. Periodic sharpness can be seen in figure 1. This sharpness

associated with the contraction of the ventricular. These are called “depolarization”.

Muscle fibers lost resting potential during depolarization. Signal prepared to go slightly

negative deviation as a rule, it continues with a big positive taper. Followed by a second

negative deviation income. The cons traction of the ventricles is called “QRS complex”. A

oscillation is seen after QRS complex. This oscillation also is called ST range or ST wave.

Now the potential difference is immeasurable. A zero line is drawn at this time is called the

isoelectric line. This is followed by T-wave (representing the depolarization). The P wave

indicates that they are in the excited state to the atrium. Finally a U wave is not always

seen. It is typically small. U waves are thought to represent repolarization of the papillary

muscles. An ECG signal can be examine in figure 2 (This is a theoretical signal. The actual

ECG signal is not as smooth as this signal).

Page 8: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

3

Figure 1.2: Shape of the electrocardiogram

An electrocardiogram is a measurement of the electrical activity of the heart muscle which can be

obtained from the surface of the skin and from different angles like Figure 3. When the heart

muscle contracted and pumping the blood for all parts of body, action potentials will be released

through the mechanical process within the heart muscle which leads to electrical activity.

Figure 1.3: The heart’s anatomy with waveforms from different specific part of the heart.

Page 9: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

4

1.3 ECG waveform description

As we mentioned earlier ECG, wave is formed as a projection of summarized potential

vectors of the heart. ECG wave has several peaks and "formations", which is useful for its

diagnosis. These are:

• P-wave - indicates the depolarized wave that distributes from the SA node to the

atria, and its duration is between 80 to 100 milliseconds.

• P-R interval - indicates the amount of time that the electrical impulse passing from

the sinus node to the AV node and entering the ventricles and is between 120 to 200

milliseconds.

• P-R segment - Corresponds to the time between the ends of atrial depolarization to

the onset of ventricular depolarization. Last about 100ms.

• QRS complex - Represents ventricular depolarization. The duration of the QRS

complex is normally 0.06 to 0.1 seconds.

• Q-wave - Represents the normal left-to-right depolarization of the inter ventricular

septum.

• R-wave - Represents early depolarization of the ventricles.

• S-wave - Represents late depolarization of the ventricles.

• S-T segment – it appears after QRS and indicates that the entire ventricle is

depolarized.

• Q-T interval - indicates the total time that need for both repolarization and

ventricular depolarization to happen, so it is estimation for the average ventricular

action duration. This time can vary from 0.2 to 0.4 seconds corresponding to heart

rate.

• T-wave - indicates ventricular repolarization and its time is larger than

depolarization.

Page 10: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

5

Figure 1.4: Location of chest electrodes

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.

Leads I, II and III are commonly referred to bipolar leads as they use only two electrodes to

derive a view. One electrode acts as the positive electrode while the other as the negative

electrode (hence bipolar) .Chest (precordial) leads are

V1: 4th intercostal space, right sternal edge.

V2: 4th intercostal space, left sternal edge.

V3: between the 2nd and 4th electrodes

.

Page 11: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

6

V4: 5th intercostal space in the midclavicular line.

V5: on 5th rib, anterior axillary line.

V6: in the midaxillary line.

To make recordings with the chest leads (different electrode), the three limb leads are

connected to form an indifferent electrode with high resistances. The chest leads mainly

detect potential vectors directed towards the back. These vectors are hardly detectable in

the frontal plane . Since the mean QRS vector is usually directed downwards and towards

the left back region, the QRS vectors recorded by leads V1–V3 are usually negative, while

those detected by V5 and V6 are positive. In leads V1 and V2, QRS = -ve because, the

chest electrode in these leads is nearer to the base of the heart, which is the direction of

electronegativity during most of the ventricular depolarization process. In leads V4, V5,

V6, QRS = +ve because the chest electrode in these leads is nearer the heart apex, which is

the direction of electropositivity during most of depolarization.

1.4 Objective

Objective of the project is to classify the ECG signal into cases of various arrhythmias.

Digital Wavelet Transform approach is used to derive key parameters of the sampled ECG

signal. A MATLAB based GUI is also designed to present the relevant results in graphical

form.

1.5 Problem Statement

Recently biomedical signal processing has been a hot topic among researchers. Their most

effort is focused on improving the data analysis of automatic systems. Cardiologists by

using various values which occurred during the ECG recording can decide whether the

heart beat is normal or not. Since observation of these values are not always clear,

existence of automatic ECG detection system is required.

Page 12: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

7

1.6 Motivation

Cardiovascular diseases are one of the most common causes of death. A patient normally

suspected of cardiac disorder undergoes the test of the electrical activity of the heart.ECG

beat recognition can be done by Artificial Neural Network (ANN). If the ECG signals are

clean and high fidelity then the health information can be understood properly.

1.7 Arrhythmia Datasets

ECG signals are collected from Physionet MIT-BIH arrhythmia database. ECG signals are

described by a text header file (.hea), a binary file (.dat) and a binary annotation file (.atr).

Header file consists of detailed information such as number of samples, sampling

frequency, format of ECG signal, type of ECG leads and number of ECG leads, patient’s

history and the detailed clinical information. In binary data signal file, raw ECG recordings

were sampled at 360 Hz with an 12-bit resolution over the 10 mV range. Binary data file

store raw data signals (12 bits used for each sample). Binary data files are created with

reference to header files. The signal is stored in 212 format. Other files are .atr files

(annotation file). “.atr” files contain some comments for the record files. So which storages

some experts note about the analysis of signal quality results.

ARRHYTHMIA

For a normal healthy person the ECG comes off as a nearly periodic signal with

depolarization followed by repolarization at equal intervals (as figure 2). However,

sometimes this rhythm becomes irregular.

Cardiac arrhythmia is a term for any of a large and heterogeneous group of conditions in

which there is abnormal electrical activity in the heart. The heart beat may be too fast or

too slow, and may be regular or irregular. Arrthymia comes in varieties. It may be

described as a flutter in chest or sometimes “racing heart”. The diagnosis of Arrthymia

requires Electrocardiogram. By studying ECG, Doctors can diagnose the disease and

prescribe the required medications. Most of time arrythmia’s are harmless and happen in

healthy people free of heart disease. However, some abnormal heart rhythms can be serious

or even deadly. Having other types of heart disease an also increase the risk of arrhytmia’s.

Page 13: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

8

1.7.1 Normal Sinus Rhythm

Figure 1.5: Normal Sinus Rhythm

The first measurement is known as the "P-R interval" and is measured from the beginning

of the upslope of the P wave to the beginning of the QRS wave. This measurement should

be between 0.12 and 0.20 seconds (120-200 ms). Duration of PR is represented “res” in

MATLAB code. When measuring the PR interval, the lead with the longest PR interval

should be chosen. (In some leads, the initial part of the PR interval may be isoelectric. This

may be misinterpreted as a short PR interval) . The R-R intervals are constant; the rhythm

is regular for normal sinus rhythm. Duration of RR interval should be between 480 and 600

ms

1.7.2 Sinus Tachycardia

Figure 1.6: Sinus Tachycardia

Generally, occurs normally in exercises and stress. Other causes may be under lying

medical problems (Anemia, Fever, Blood loss…) Electrical signal is faster than usual. The

heart rate is fast. But heart beats is properly. Therefore RR interval is constant and regular.

Due to the above reasons, duration of RR peak should be shorter than normal sinus (it is

between 0.45 and 0.48 second). PR interval is between 0.12–0.20 seconds.

Page 14: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

9

1.7.3 Sinus Bradycardia

Figure 1.7: Sinus Bradycardia

Electrical signal is slower than usual. The heart rate is slower. But heart beats is properly.

Therefore RR interval is constant and regular. PR interval is between 0.12–0.20 seconds.

Causes of bradycardia are Sleep, hypothermia; some drugs etc. Duration of RR peak should

be bigger than tachycardia and sinus rhythm.

1.7.4 Heart Block

Figure 1.8: Heart Block

Heart block is an abnormal heart rhythm where the heart beats too slowly. It's slower than

bradycardia. PR interval is bigger than 0.20 second.

Page 15: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

10

CHAPTER 2

LITERATURE SURVEY

Dr. Sudhir G. Akojwar,Pravin Kshirsagar and Vijetalaxmi Pai “Feature Extraction of EEG

Signals using Wavelet and Principal Component analysis”. In this paper it gives a

comparative analysis along with results of feature extraction of different types of EEG

signals using two best methods of feature extraction they are Wavelet transform method &

Principal component analysis. Electroencephalogram is the record of electrical activity of

the brain. And to classify these disorders we need to extract the features. So this paper

gives successive results with wavelet and PCA for the EEG signals with the disorders with

the epileptic Seizers, slow wave activity, brain death & brain tumors. [1]

Sudhir G. Akojwar, Pravin R. Kshirsagar “A Novel Probabilistic-PSO Based Learning

Algorithm for Optimization of Neural Networks for Benchmark Problems” This paper

approbates a modern and stentorian version of standard particle swarm optimization(PSO)

for optimization of initial weights and biases for multi layer feed forward neural networks

(MLFFNN) with back propagation (BP). The combination of probabilistic-PSO and

MLFFNN sevenfold help in fast convergence of MLFFNN in assortment and sortilege to

various benchmark problems by alienating the imperfection of back-propagation of being

stuck at local minima or local maxima. The propane probabilistic- PSO differs from the

standard PSO in velocity and position parameters. In velocity parameters only particle best

value is make use of for cicerone the particle to gait towards the pursuit in the search space,

while in standard PSO both particle best and global best values are considered for

adjudging the new velocity of the particle. A new parameter introduced which called as the

probability parameter (P0), which adjudges if the standard PSO is that instead of using

same random number, different particles use different random numbers to soar in search

space. The proposed method used to detect the initial weights and biases for MLFFNN with

BP, once the optimum value for initial weights and biases estimated the MLFFNN then

used for classification and sortilege of various neural network benchmark problems. The

benchmarking databases for neural network contain various datasets from various different

domains. All datasets represent sensible issue, which can call diagnosis tasks, and all the

Page 16: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

11

datasets consist of real world data. The results for accuracy of the proposed probabilistic-

PSO method compared with existing methods. [2]

Nazmy et al described adaptive neuro-fuzzy inference system (ANFIS) algorithm for

classification of ECG wave .The feature extraction is done with the help of Independent

Component Analysis (ICA) and Power spectrum and input is obtained by the RR-interval

of ECG. This paper proposed the classified ECG signals are normal sinus rhythm,

premature ventricular contraction, atrial premature contraction, Ventricular Tachycardia,

Ventricular Fibrillation and Supraventricular Tachycardia .using ANFIS approach the

classification accuracy is also obtained. [3]

Alan and Nikola in presented that use chaos theory for classification of ECG signal and

feature extraction. In this paper consist of phase space and attractors, correlation

dimension, spatial filling index and approximate entropy. The new program is developed

for ECG classification which is based on the chaos method and has developed semi-

automatic program for the feature extraction. The program is helpful to classify the ECG

Signal and extract the feature of the signal. [4]

Castro et al. in paper describe the feature extraction with the help of wavelet transform

technique and gives an algorithm which will utilize the wavelet transform for extracting the

features of ECG signal. This proposed method first denoise by use of soft or hard threshold

then the feature of ECG wave divided in to coefficient vector by optimal wavelet

transformation. In this proposed method choose the mother wavelet transform set of

orthogonal and biorthogonal wavelet filter bank by means of the best correlation with the

ECG signal was developed. After the analysis of ECG signal coefficient are divided as

QRS complex, T wave, P wave then sum to obtain feature extraction. [5]

Wisnu Jatmiko, et al. employed Back-Propagation Neural Network and Fuzzy Neuro

Learning Vector Quantization (FLVQ) as classifier in ECG classification [3]. In their work

they used only the MLII lead as source data. The classes that are considered are Left

Bundle Branch Block beat, Normal beat, Right Bundle Branch Block beat, Premature

Page 17: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

12

Ventricular Contraction. They used training classification methods namely Back

propagation and FLVQ for their experiment. It provides an average accuracy 99.20% using

Back- Propagation and 95.50% for FLVQ. The result shows that back-propagation leading

than FLVQ and back-propagation has disadvantages to classified unknown category beat

but not for FLVQ. FLVQ has stable accuracy although contain unknown category beat.[6]

Maedeh Kiani Sarkaleh, , proposed a Neural Network based algorithm for classification of

Paced Beat, Atrial Premature Beat arrhythmias as well as the normal beat signal. They

applied Discrete Wavelet Transform for feature extraction and used it along with timing

interval features to train the Neural Network. About 10 recording of the MIT/BIH

arrhythmia database have been used for training and testing the neural network based

classifiers. The model result shows that the classification accuracy is 96.54%. [7]

Karpagachelvi.S, this paper describes an ECG beat classification system using RVM is

proposed and applied to MIT-BIH arrhythmia database to classify five kinds of abnormal

waveforms and normal beats. In feature exacting, the sensitivity of the RVM classifier is

tested and that is compared with ELM. The obtained result confirms the superiority of the

RVM approach when compared to traditional classifiers.[8]

Ruchita Gautam and Anil Kumar Sharma proposed a method based on the Dyadic wavelet

transform technique this method is applied for finding the QRS complex. In this method

focused on the interval of the two consecutive R wave and calculate the heartbeat. This

method is on the ECG waveforms for detect the dieses Ventricular Late Potentials, and

separate the wave P R & T which is associated with features of ECG waveforms. In this

method the main consideration is to find out the R waves and threshold is set to 75% of the

maximum peak. [9]

Manpreet Kaur, A.S.Arora, shows with the help of K-clustering techniques the output

signal is analyzed, the parameter is wave shape, duration and amplitude. With the help of

K-clustering technique minimize the sum of point to centroid distance, this clustered K

summed. In this technique first phase give information about the point are resigned to the

Page 18: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

13

closest cluster around the centroid. The second phase gives information on line value where

values are self-resigned. The data is taken from MIT-BIH for analysis. The success rate of

classification for set 2, set 3, set 4, set 5 and set 7 is 99.98%, for set 1 it is 87.5% and for set

6 it is 75%. [10]

Maedeh Kiani Sarkaleh and Asadollah Shahbahrami. This paper discuss the Recognition

of cardiac arrhythmias is important for diagnosis of cardiac abnormalies. Several

algorithms have been proposed to classify ECG arrhythmias; however, they cannot perform

very well. Therefore, in this paper, an expert system for Electrocardiogram (ECG)

arrhythmia classification is proposed. Discrete wavelet transform is used for processing

ECG recordings, and extracting some features, and neural network performs the

classification task. Two types of arrhythmias can be detected by the proposed system.

Some recordings of the MIT-BIH arrhythmias database have been used for training and

testing our neural network based classifier. The simulation results show that the

classification accuracy of our algorithm is 96.5% using 10 files including normal. [11]

Pratiksha Sarma, S. R. Nirmala, Kandarpa Kumar Sarma. Heart diseases are frequent

reasons of death. Hence, there is always a need to develop systems that can provide prior

indication about the state of the heart. This is also required because medical facilities may

not be uniform everywhere. In such situation certain innovative approaches using certain

signal processing techniques can provide considerable support. Several algorithms have

been proposed to classify cardiac arrhythmias in the literature; however, many of them fail

to perform optimally. Here, we have proposed a method for ECG arrhythmia classification

using Artificial Neural Network (ANN). Fast Fourier Transform is used for pre-processing

the ECG recordings. Linear Prediction Coefficients (LPC) and Principal Component

Analysis (PCA) are used for extracting some features and then Multi-Layer Perceptron

ANN performs the classification. [12]

Page 19: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

14

CHAPTER 3

METHODOLOGY

3.1 What is MATLAB?

MATLAB is a numerical computation and simulation tool that was developed into a

commercial tool with a user friendly interface from the numerical function libraries

LINPACK and EISPACK, which were originally written in the FORTRAN programming

language. As opposed to the well-known computer algebra programs, such as MAPLE or

MATHEMATICA, which are capable of performing symbolic operations and, therefore,

calculating with mathematical equations as a person would normally do with paper and

pencil, in principle MATLAB does purely numerical calculations. Nevertheless, computer

algebra functionality can be achieved within the MATLAB environment using the so-called

“symbolic” toolbox. This capability is a permanent component of MATLAB 13 and is also

provided in the student version of MATLAB 13. It involves an adaptation of MAPLE to

the MATLAB language.

3.1.1 Introduction to MATLAB

Computer algebra programs require complex data structures that involve

complicated syntax for the ordinary user and complex programs for the programmer.

MATLAB, on the other hand, essentially only involves a single data structure, upon which

all its operations are based. This is the numerical field, or, in other words, the matrix. This

is reflected in the name: MATLAB is an abbreviation for Matrix Laboratory. As MATLAB

developed, this principle gradually led to a universal programming language. MATLAB is

not just a numerical tool for evaluation of formulas, but is also an independent

programming language capable of treating complex problems and is equipped with all the

essential constructs of a higher programming language. Since the MATLAB command

interface involves a so-called interpreter and MATLAB is an interpreter language, all

commands can be carried out directly. This makes the testing of particular programs much

easier. The elementary MATLAB operations can be divided roughly into five classes:

Arithmetic operations

Logical operations

Page 20: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

15

Mathematical functions

Graphical functions

I/O operations (data transfer)

Figure 3.1: Flow-chart of ECG classification

Page 21: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

16

3.2 MIT-BIH Arrhythmias database

The MIT-BIH arrhythmia database is used in the study for performance evaluation.

The database contains 48 records, each containing two-channel ECG signals for 30 min

duration selected from 24-hr recordings of 47 individuals. There are 116,137 numbers of

QRS complexes in the database .The subjects were taken from, 25 men aged 32 to 89 years,

and 22 women aged 23 to 89 years and the records 201 and 202 came from the same male

subject. Each recording includes two leads; the modified limb lead II and one of the

modified leads V1, V2, V4 or V5. Continuous ECG signals are band pass-filtered at 0.1–

100 Hz and then digitized at 360 Hz. Twenty-three of the recordings (numbered in the

range of 100–124) are intended to serve as a representative sample of routine clinical

recordings and 25 recordings (numbered in the range of 200–234) contain complex

ventricular, junctional, and supraventricular arrhythmias. The database contains annotation

for both timing information and beat class information verified by independent experts

3.3 Preprocessing of ECG signals

ECG signal inherently contains of various type of unwanted noise and artifact effects like

baseline drift, noise of electrode contact, polarization noise, the internal amplifier noise, noise

due to muscle movement, and motor artifacts. The movements of electrodes induced artifacts

noise. Therefore in order to make the ECG signal ready for feature extraction step, we must

remove baseline wander and eliminate above noise. We propose to use wavelet filtering to filter

the ECG signal since this technique is suitable for computing the R-peak locations without

change of the shape or position of the original signal. According to the previous experimental

knowledge, in order to optimize the signal filtering, we must consider these two criteria: the

signal sampling frequency and the knowledge that most of the noises are located outside of the

frequency interval between 1.5 Hz to 50 Hz . For this purpose, we use a band pass filter which

is constructed by a high pass filter with cutoff frequency 1.5 Hz. This filter eliminates baseline

variations. The output of this filter is cascade with a low pass filter with cutoff frequency 50

Hz. This filter removes high frequency noise. The scale and type of the mother function

parameters are specific to each filter. Thus, the automatic compute of optimal scale for high

Page 22: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

17

pass filtering when the sampling frequency is 256 is equal to order 6. The optimal scale Order

for the low pass filtering is equal to order 2. The results of above steps are shown in the Figure.

Figure 3.2: Implementation results of preprocessing on record [100] from MIT-BIH

database (a) Original signal, (b) eliminated baseline, (c) noise removal

(a)

Page 23: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

18

(b)

(c)

Page 24: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

19

3.4 Wavelet

A wavelet is a wave-like oscillation with a amplitude that starts out at zero, increases, and

then decreases back to zero. It can typically be visualized as a "brief oscillation" like one

might see recorded by a seismograph or heart monitor. Generally, wavelets are

purposefully crafted to have specific properties that make them useful for signal

processing. Wavelets can be combined, using a "reverse, shift, multiply and sum"

technique called convolution, with portions of an unknown signal to extract information

from the unknown signal. For example, a wavelet could be created to have a frequency of

Middle C and a short duration of roughly a 32nd note. If this wavelet were to be convolved

at periodic intervals with a signal created from the recording of a song, then the results of

these convolutions would be useful for determining when the Middle C note was being

played in the song. Mathematically, the wavelet will resonate if the unknown signal

contains information of similar frequency– just as a tuning fork physically resonates with

sound waves of its specific tuning frequency. This concept of resonance is at the core of

many practical applications of wavelet theory.

As a mathematical tool, wavelets can be used to extract information from many different

kinds of data, including – but certainly not limited to – audio signals and images. Sets of

wavelets are generally needed to analyze data fully. A set of "complementary" wavelets

will deconstruct data without gaps or overlap so that the deconstruction process is

mathematically reversible. Thus, sets of complementary wavelets are useful in wavelet

based compression/decompression algorithms where it is desirable to recover the original

information with minimal loss.In formal terms, this representation is a wavelet series

representation of a square-integrable function with respect to either a complete,

orthonormal set of basis functions, or an overcomplete set or frame of a vector space, for

the Hilbert space of square integrable functions.

The word wavelet has been used for decades in digital signal processing and exploration

geophysics. The equivalent French word ondelette meaning "small wave" was used by

Morlet and Grossmann in the early 1980s.

Page 25: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

20

3.4.1 Wavelet Theory

Wavelet theory is applicable to several subjects. All wavelet transforms may be considered

forms of time-frequency representation for continuous-time (analog) signals and so are

related to harmonic analysis. Almost all practically useful discrete wavelet transforms use

discrete-time filter banks. These filter banks are called the wavelet and scaling coefficients

in wavelets nomenclature. These filter banks may contain either finite impulse response

(FIR) or infinite impulse response (IIR) filters. The wavelets forming a continuous wavelet

transform (CWT) are subject to the uncertainty principle of Fourier analysis respective

sampling theory: Given a signal with some event in it, one cannot assign simultaneously an

exact time and frequency response scale to that event. The product of the uncertainties of

time and frequency response scale has a lower bound. Thus, in the scaleogram of a

continuous wavelet transform of this signal, such an event marks an entire region in the

time-scale plane, instead of just one point. Also, discrete wavelet bases may be considered

in the context of other forms of the uncertainty principle. Wavelet transforms are broadly

divided into three classes: continuous, discrete and multiresolution-based.

3.4.2 Discrete wavelet transforms (discrete shift and scale parameters)

It is computationally impossible to analyze a signal using all wavelet coefficients, so one

may wonder if it is sufficient to pick a discrete subset of the upper half plane to be able to

reconstruct a signal from the corresponding wavelet coefficients. One such system is the

affine system for some real parameters a > 1, b > 0. The corresponding Discrete subset of

the halfplane consists of all the points (am, namb) with m, n in Z. The corresponding baby

wavelets are now given as

A sufficient condition for the reconstruction of any signal x of finite energy by the formula

is that the functions form a tight frame of L2

(R).

Page 26: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

21

Scaling filter

An orthogonal wavelet is entirely defined by the scaling filter – a low-pass finite impulse

response (FIR) filter of length 2N and sum 1. In biorthogonal wavelets, separate

decomposition and reconstruction filters are defined.

For analysis with orthogonal wavelets the high pass filter is calculated as the quadrature

mirror filter of the low pass, and reconstruction filters are the time reverse of the

decomposition filters.

Daubechies and Symlet wavelets can be defined by the scaling filter.

Scaling function

Wavelets are defined by the wavelet function ψ(t) (i.e. the mother wavelet) and scaling

function φ(t) (also called father wavelet) in the time domain.

The wavelet function is in effect a band-pass filter and scaling it for each level halves its

bandwidth. This creates the problem that in order to cover the entire spectrum, an infinite

number of levels would be required. The scaling function filters the lowest level of the

transform and ensures the entire spectrum is covered.

For a wavelet with compact support, φ (t) can be considered finite in length and is

equivalent to the scaling filter g.

Wavelet function

The wavelet only has a time domain representation as the wavelet function ψ (t). For

instance, Mexican hat wavelets can be defined by a wavelet function.

3.4.3 Applications of discrete wavelet transform

Generally, an approximation to DWT is used for data compression if signal is already

sampled, and the CWT for signal analysis. Thus, DWT approximation is commonly used in

engineering and computer science, and the CWT in scientific research.

Wavelet transforms are now being adopted for a vast number of applications, often

replacing the conventional Fourier Transform. Many areas of physics have seen this

paradigm shift, including molecular dynamics, ab initio calculations, astrophysics, density-

Page 27: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

22

matrix localisation, seismology, optics, turbulence and quantum mechanics. This change

has also occurred in image processing, blood-pressure, heart-rate and ECG analyses, brain

rhythms, DNA analysis, protein analysis, climatology, general signal processing, speech

recognition, computer graphics and multifractal analysis. In computer vision and image

processing, the notion of scale space representation and Gaussian derivative operators is

regarded as a canonical multi-scale representation.

One use of wavelet approximation is in data compression. Like some other transforms,

wavelet transforms can be used to transform data, then encode the transformed data,

resulting in effective compression. For example, JPEG 2000 is an image compression

standard that uses biorthogonal wavelets. This means that although the frame is

overcomplete, it is a tight frame (see types of Frame of a vector space), and the same frame

functions (except for conjugation in the case of complex wavelets) are used for both

analysis and synthesis, i.e., in both the forward and inverse transform. For details see

wavelet compression.

A related use is for smoothing/denoising data based on wavelet coefficient thresholding,

also called wavelet shrinkage. By adaptively thresholding the wavelet coefficients that

correspond to undesired frequency components smoothing and/or denoising operations can

be performed.

Wavelet transforms are also starting to be used for communication applications. Wavelet

OFDM is the basic modulation scheme used in HD-PLC (a power line communications

technology developed by Panasonic), and in one of the optional modes included in the

IEEE 1901 standard. Wavelet OFDM can achieve deeper notches than traditional FFT

OFDM, and wavelet OFDM does not require a guard interval (which usually represents

significant overhead in FFT OFDM systems).

3.4.4 Wavelet transforms

A wavelet is a mathematical function used to divide a given function or continuous-time

signal into different scale components. Usually one can assign a frequency range to each

scale component. Each scale component can then be studied with a resolution that matches

its scale. A wavelet transform is the representation of a function by wavelets. The wavelets

are scaled and translated copies (known as "daughter wavelets") of a finite-length or fast-

Page 28: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

23

decaying oscillating waveform (known as the "mother wavelet"). Wavelet transforms have

advantages over traditional Fourier transforms for representing functions that have

discontinuities and sharp peaks, and for accurately deconstructing and reconstructing finite,

non-periodic and/or non-stationary signals.

Wavelet transforms are classified into discrete wavelet transforms (DWTs) and continuous

wavelet transforms (CWTs). Note that both DWT and CWT are continuous-time (analog)

transforms. They can be used to represent continuous-time (analog) signals. CWTs operate

over every possible scale and translation whereas DWTs use a specific subset of scale and

translation values or representation grid.

There are a large number of wavelet transforms each suitable for different applications. For

a full list see list of wavelet-related transforms but the common ones are listed below:

• Continuous wavelet transform (CWT)

• Discrete wavelet transform (DWT)

• Fast wavelet transform (FWT)

• Lifting scheme & Generalized Lifting Scheme

• Wavelet packet decomposition (WPD)

• Stationary wavelet transform (SWT)

• Fractional Fourier transform (FRFT)

• Fractional wavelet transform (FRWT)

Discrete wavelets

• Beylkin (18)

• BNC wavelets

• Coiflet (6, 12, 18, 24, 30)

• Cohen-Daubechies-Feauveau wavelet

• Daubechies wavelet (2, 4, 6, 8, 10, 12, 14, 16, 18, 20)

• Binomial-QMF (Also referred to as Daubechies wavelet)

• Haar wavelet

Page 29: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

24

• Mathieu wavelet

• Legendre wavelet

• Villasenor wavelet

• Symlet[15]

3.5 QRS detection

Each ECG cycle is consists of a P-wave which is corresponding to the atrial

depolarization, a QRS complex which is corresponding to the ventricular depolarization

and a T wave which is point to the rapid repolarization of the ventricles. A normal ECG

signal and its time intervals are shown.

Figure 3.3: Normal ECG waveform

Most of the clinically features which are useful for diagnostic the disease can be found in

the time interval between components of ECG and the value of the signal amplitude. For

example, the Q-T feature is used to recognition one dangerous disease, the Long Q-T

Syndrome (LQTS), which is responsible of thousand deaths each year. The shape of T

wave is a critical factor and it is essential to identify it correctly since inverted T waves can

be caused as an effect of a serious disease named coronary ischemia.

Designing an algorithm in order to extract the ECG features automatically is very hard

since ECG signal has a time-variant behavior. As a result of these signal properties, we face

with multiple physiological constraints and the existence of noise.

Page 30: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

25

In recent years several algorithms have been proposed for detection those features. In they

introduced a method to extract wavelet features and used SVM for classification. In this

thesis, we proposed a method for recognition of time interval and amplitude of various

wave parts of ECG. In the First stage of our approach, the R-peak is detected accurately.

For this purpose we used wavelet. In the second stage, the other ECG components are

identified by using a local search around the detected R-peak. We can summarize this

approach: The location of the R-wave has been identified by using wavelet transform.

Each R-R interval from ECG signal is segmented as follow:

Within an interval, finding the maximum and minimum of the wave which are

corresponding to the Q and S waves. Since P-wave and T-wave is dependant to other

factors; we must provide some deterministic point in order to find their location. These

points are including the end point of S-wave or Soff, the start point of T-wave or Ton, and

the start point of Q-wave or Qon.

3.5.1 R-peaks detection

The detection of R-peak is the first step of feature extraction. For this purpose, we used

DWT due to its ability to recognize different locations of the waves accurately. Similarly to

the preprocessing, we apply the same steps in order to compute the scale and choose the

mother function. We have the QRS complex signal as an input which has the frequencies

between 5Hz and 15Hz, so we select scale of order 4 and choose the Db4 mother wavelet.

The Db4 wavelet is very popular for the detection and location of R peaks due to the strong

similarity of its shape to the ECG signal. Our method is organized in the following steps.

By performing wavelet decomposition, we down sampling the input. Therefore the amount

of unnecessary information is reduced but the component of QRS is not changed.

In order to find the location of R-peak, first we choose the locations which their amplitude

are greater than 60% of the max value of the whole input signal. Since we remove the noise

from the signal in the previous step, it is useful for R-peak detection.

Since we decompose the signal into 4th level, the R-peak location in the modified signal is

at least 0.25 of the R-peak location in the original signal. So in order to find the actual

location of R-peal we must convert the founded positions by multiplying them with 4.

Page 31: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

26

Another important point is that R-peak location in modified signal is not exactly on the

original signal at a scale of 4. Position of the signal will change during the down sampling,

so we must to do local search around the R-peaks which calculated in previous part. The

interval of this search can be limited to a window of ± 20 samples.

3.5.2 P, Q and S detection algorithms

The accuracy of detecting R-peak completely affected on P, Q and S detection parts since

their location is determined relatively to R-peak. In the other hand, detect the location of R-

peaks are corresponding to recognize the heart beat interval.

One of the most popular features in ECG signal processing is the R-R interval which can be

computed by the following formula:

R_R (i) = R (i+1) - R (i)

Where R (i) and R (i + 1) are the indexes of the current and next R wave peak respectively.

3.5.3 S wave detection

The S-wave is located on the end of the QRS complex so in order to find its location we

must start from R-peak location plus 6 units because range of the shortest length of it is

between 0.016 and 0.036 seconds. This range is corresponding to 6 and 13 samples. The

stop point of search interval is related to the value of R-R interval.

However the maximum length of the RS intervals is recorded is around 0.27 seconds where

its R-R interval was 1.41 seconds.

3.5.4 Q-wave detection

The Q-wave indicates the start point of the QRS complex section. It is reported that Q-

wave peak location can be found in the range between 0.02 to 0.06 seconds from R-peak.

In the other hand, this interval is equal to 8 and 22 samples. But this interval must be

relevant to the value heart beat length. Therefore Q-R interval varies from one patient to

another, for example a patient with a R-R equal to 235 can have a Q-R interval equal to 19

Page 32: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

27

and another one can have Q-R equal to 8 while has a R-R equal to 292. As a result, the

range for search will be larger for longer R-R interval.

3.5.5 P- wave detection

Since P-wave can be located far or near from Q-wave, it is necessary for its interval to be

relative to the R-R interval value.

It is reported that duration of the P-R interval is between 0.09 and 0.19 seconds and this

interval also depends on the R-R interval. This interval is equal to 19 and 38 samples. From

the point of view of proportional, the limits are 14% to 22% of the respective RR range.

One of the benefits of this approach is that we can detect P-waves with low amplitude, so

according to the search area interval.

3.5.6 T-wave detection

Finding T-wave in ECG signal is the most complicated task. Designing a procedure for

detecting T-wave is difficult since it has a time variant behaviors. By checking the ECG

waveform someone can see that the T- wave is located as the interval which has largest

amplitude between S and the middle of the R-R interval. Therefore, the search interval for

T started from S-wave and finished at the middle point of the R-R interval.

Page 33: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

28

Figure 3.4: Implementation result of PQRST detection method in (a) record [100], (b)

record [111] from ECG MIT-BIH arrhythmia database.

(a) PQRST detected in record [100].

(b) PQRST detected in record [111].

Page 34: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

29

CHAPTER 4

CLASSIFICATION AND DETECTION

4. 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.

4.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.

Figure 4.1: Three input of and one output neuron unit

Page 35: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

30

4.1.1 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 networks 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 Ho_ (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.

Figure 4.2: Simple neural network structure that output compare with the target

and feedback to the NN until the output matches the target.

Page 36: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

31

4.2 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.

4.3 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.

4.3.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.

Page 37: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

32

4.3.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.

Figure 4.3: Left side is the feed-forward network, data or signal move forward until

it reached the output state.

Figure 4.4: Right side is the feedback network that signal can reverse back to the

previous state.

Page 38: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

33

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

another equilibrium point. Figure 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.

4.4 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) classi_cation structure. In the _rst 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 _rst-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 published 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 information 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 exibility 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 paper. They address the problem of designing a neural-

based minimax classifier and propose two different algorithms: a learning rate scaling

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

Page 39: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

34

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.

Page 40: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

35

CHAPTER 5

RESULTS AND CONCLUSIONS

5.1 RESULTS

Figure 5.1: GUI Editor

Figure 5.2: Original GUI

Page 41: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

36

Figure 5.3: GUI showing normal ECG

Figure 5.4: GUI showing Bradycardia ECG

Page 42: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

37

Figure 5.5: GUI showing Tachycardia ECG

FILE Disease

100.dat PERSON IS HEALTY(Normal)

101.dat PERSON IS SUFFERING FROM TACHYCARDIA

104.dat PERSON IS HEALTY

105.dat PERSON IS SUFFERING FROM BRADYCARDIA

106.dat PERSON IS SUFFERING FROM BRADYCARDIA

108.dat PERSON IS HEALTY

111.dat PERSON IS SUFFERING FROM BRADYCARDIA

119.dat PERSON IS SUFFERING FROM BRADYCARDIA

123.dat PERSON IS SUFFERING FROM TACHYCARDIA

201.dat PERSON IS SUFFERING FROM BRADYCARDIA

205.dat PERSON IS SUFFERING FROM TACHYCARDIA

208.dat PERSON IS HEALTY

212.dat PERSON IS HEALTY

217.dat PERSON IS SUFFERING FROM BRADYCARDIA

Page 43: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

38

5.2 CONCLUSION

This study is on detection and classification of arrhythmia beats. The heart beats are

different for different person and all these beats are having different variations with

nonlinear nature. Thus the proposed computerized system will be helpful for early

detection of heart status and to decrease the death percentage of human which occurs due to

the heart disease.

Over the past few years, importance for human life has been known heart disease. ECG is

the main method is used in the diagnosis of heart disease. Purpose of project that the

analysis of heart disease with ECG signals. This project is implemented by using

MATLAB software and on the basis of the wave form obtain the peaks are classified and

are used for the detection of the disease.

The location of the other peaks was determined with location of R peaks. Lastly, we

calculated RR and PR intervals. These intervals are very important for detecting diseases.

These intervals are important for determining the type of illness. For example, electrical

signal is faster than usual for tachycardia. Therefore duration of RR peak should be shorter

than normal sinus. PR interval is also important for us. It was a fixed interval in the

detection of tachycardia and bradycardia.

5.3 FUTURE SCOPE

Automatic cardiac abnormality classification is necessary for real time application. The

classification accuracy can improve by extracting the better features of ECG signal. Future

developments can be made as follows

· To design better feature extraction methodology this can improve the classification result

of cardiac arrhythmias in ECG signal.

· To analyze the classification accuracy using different classifier such that it can classify

the beat arrhythmias in the approved manner.

· To modify the network structure according to cost function of multilayer neural network

so that it can achieve better classification accuracy as compared to existing ECG beat

Classifier.

· Real time operation for recognizing the cardiac arrhythmias can also be done since the

methodology uses the automatic detection of R-peaks and feature extraction techniques.

Page 44: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

39

REFERENCES

[1] Pravin Kshirsagar and Sudhir Akojwar, “Hybrid Heuristic Optimization for Benchmark

Datasets”, International Journal of Computer Application (0975-8887), Vol.146-No.7, July

2016.

[2] Advances in Cardiac Signal Processing Rajendra Acharya U, Jasjit S. Suri, Jos A.E.

Spaan an d S .M. Krishnan, pp.3-13

[3] P. Gustafsso and J. Hagblad, “Miniaturised multi-channel wireless ECG connected to

graphical computer interface using bluetooth,” M.S. thesis, Dept. of Comp. Sci. and

Electronics, Mälardalen University, Sweden, 2007.

[4] http://www.mathworks.com/matlabcentral/fileexchange/35328, 01/02/2017

[5] THE MIT-BIH Arrhythmia Database On CD_ROM AND Software For Use With It,

George B. Moody And Roger G. Mark

[6] https://www.physionet.org/physiobank/database/mitdb/, 01/02/2017

[7] Pravin Kshirsagar and Sudhir Akojwar,“Hybrid Heuristic Optimization for Benchmark Datasets”, International Journal of Computer Application (0975-8887), Vol.146-No.7, July

2016.

[8] H. Al-jobouri, “Designation of interface and software program as a base for ECG monitoring and signal analysis,” M.S. thesis, Dept. of Medical Eng., AlNahrain Univ., Baghdad, Iraq, 2004

[9] Pravin Kshirsagar and Sudhir Akojwar “Classification of Human Emotions using EEG

Signals” International Journal of Computer Applications (0975 – 8887) Volume 146 – No.7, July 2016

[10] Pravin Kshirsagar ,Vijetalaxmi Pai and Sudhir Akojwar “ Feature Extraction of EEG

Signals using Wavelet and Principal Component analysis” National Conference On

Research Trends In Electronics, Computer Science & Information Technology And

Doctoral Research Meet, Feb 21st & 22nd

.

[11]Karpagachelvi.S, Dr.M.Arthanari and Sivakumar M,“Classification of Electrocardiogram Signals with Extreme Learning Machine and Relevance Vector

Machine”, International Journal of Computer Science Issues, Volume 8, Issue 1, January 2011 ISSN (Online): 1694-0814.

[12] Alan Jovic, and Nikola Bogunovic, “Feature Extraction for ECG Time-Series Mining

based on Chaos Theory”, Proceedings of 29th International Conference on Information Technology Interfaces.

Page 45: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

40

[13] Castro, D. Kogan, and A. B. Geva, 2000. “ECG feature extraction using optimal mother wavelet” The 21st IEEE Convention of the Electrical and Electronic Engineers in

Israel, pp. 346-350.

[14] Wisnu Jatmiko, Nulad W. P., Elly Matul I.,I Made Agus Setiawan, P. Mursanto,

“Heart Beat Classification Using Wavelet Feature Based on Neural Network ” Wseas Transactions on Systems, ISSN: 1109-2777 Issue 1, Volume 10, January 2011.

[15] Maedeh Kiani Sarkaleh and Asadollah Shahbahrami, “Classification of ECG Arrhythmias using Discrete Wavelet Transform and Neural Networks”, International Journal of Computer Science, Engineering and Applications (IJCSEA) Volume 2, Issue 1,

February 2012.

[16] V. Vijaya, K. Kishan Rao, V. Rama, “Arrhythmia Detection through ECG Feature Extraction using Wavelet Analysis”, European Journal of Scientific Research, Vol. 66, pp. 441-448, 2011.

[17] T. M. Nazmy, H. El-Messiry and B. Al-bokhity. 2009. “Adaptive Neuron-Fuzzy

Inference System for Classification of ECG Signals”, Journal of Theoretical and Applied Information Technology.

[18] H. Al-jobouri, “Designation of interface and software program as a base for ECG monitoring and signal analysis,” M.S. thesis, Dept. of Medical Eng., AlNahrain Univ., Baghdad, Iraq, 2004.

[19] P.de Chazal, M. O'Dwyer, and R. B. Reilly, "Automatic Classification of Heartbeats

Using ECG Morphology and Heartbeat Interval Features," IEEE Trans. on Biomedical

Engineering, Vol. 51, No. 7, pp.1196-1206, July 2004.

[20] H. G. Hosseini , K. J. Reynolds, D. Powers, “A Multi-Stage Neural Network Classifier

For ECG Events”, 23rd Annual International Conference of the IEEE Engineering in Medicine and Biology Society, October 25-28, 2001.

[21] Jaylaxmi C Mannurmath, Prof. Raveendra“MATLAB Based ECG Signal Classification” International Journal of Science, Engineering and Technology Research (IJSETR), Volume 3, Issue 7, July 2014

[22] Sayantan Mukhopadhyay1, Shouvik Biswas, “Wavelet Based QRS Complex Detection of ECG Signal”, International Journal of Engineering Research and Applications,

Vol.2, Issue3, pp.2361-2365, May-Jun 2012,

[23] Mujeeb Rahman, Mohamed Nasor,”An Algorithm for Detection of Arrhythmia”, International Journal of Biological Engineering, Volume 2Issue 5, pp.44-47, 2012.

[24] S. Z. Mahmoodabadi, A. Ahmadian,” ECG Feature Extraction Using Daubechies” fifth iasted international conference visualization, imaging and image processing,

September Issue , pp.7-9, 2005

Page 46: Classification and Detection of ECG-signals using Artificial Neural Networks

Classification and Detection of ECG-signal using ANN

41

[25] Introduction to graphical user interface (GUI),”The Mathworks”

[26] The wavelet tutorial, second edition part 1, Robi polikar

[27] Jaylaxmi C Mannurmath,Prof. Raveendra M, ”MATLAB Based ECG Signal

Classification”, International Journal of Science, Engineering and Technology Research ,Vol 3, Issue 7, July 2014

[28] M.Sabarimalai Manikandana, K.P. Soman,” A novel method for detecting R-peaks in

electrocardiogram(ECG) signal”, Elsevier, Biomedical Signal Processing and Control ,

Issue 7 , pp.118– 128 , 2012

[29] C. Saritha, V. Sukanya,” ECG Signal Analysis Using Wavelet Transform”, Bulg. J. Phys. Issue 35, pp.68 –77, 2008

[30] Gordan cornelia, reiz romulus,” ECG signals processing using wavelets”,

[31] Anuja sas, Shreetam behera, “Identification of Tachycardia and Bradycardia Heart Disorders using Wavelet Transform based QRS Detection” ,International Journal of Image Processing and Vision Sciences,Volume-2 Issue-1, pp.2278–1110 , 2013.

Page 47: Classification and Detection of ECG-signals using Artificial Neural Networks

I

Annexure A

Page 48: Classification and Detection of ECG-signals using Artificial Neural Networks

II

Page 49: Classification and Detection of ECG-signals using Artificial Neural Networks

III

Page 50: Classification and Detection of ECG-signals using Artificial Neural Networks

IV

Page 51: Classification and Detection of ECG-signals using Artificial Neural Networks

V

Annexure B

function varargout = gui(varargin) % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @gui_OpeningFcn, ... 'gui_OutputFcn', @gui_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT function gui_OpeningFcn(hObject, eventdata, handles, varargin) handles.output = hObject; guidata(hObject, handles); function varargout = gui_OutputFcn(hObject, eventdata, handles) varargout{1} = handles.output; function edit_time_min_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end %% Load ECG signal function load_ecg_file_Callback(hObject, eventdata, handles) [filename,pathname] = uigetfile({'*.mat'},'Load ECG signal'); path = [pathname filename]; if (filename == 0) disp('Cancel') else disp(['ECG loaded: ', fullfile(pathname,filename)]) Struct = load(filename); handles.filename = filename; end guidata(hObject,handles)

% Display ECG signal in time interval function ecg_time_display_Callback(hObject, eventdata, handles) view = 8; % on default the first 8 seconds are viewed filename=handles.filename;

Page 52: Classification and Detection of ECG-signals using Artificial Neural Networks

VI

Struct = load(filename); ecg = Struct.ecg; fs = 250; R_i = [];%save index of R wave R_amp = []; %save amp of R wave S_i = [];%save index of S wave S_amp = []; %save amp of S wave T_i = [];%save index of T wave T_amp = [];%save amp of T wave thres_p =[]; %for plotting adaptive threshold buffer_plot =[]; buffer_long=[]; % buffer for online processing state = 0 ; % determines the state of the machine in the algorithm c = 0; % counter to determine that the state-machine doesnt get stock in T wave detection wave T_on = 0; % counter showing for how many samples the signal stayed above T wave threshold T_on1=0; % counter to make sure its the real onset of T wave S_on = 0; % counter to make sure its the real onset of S wave sleep = 0; % counter that avoids the detection of several R waves in a short time S_amp1 = []; % buffer to set the adaptive T wave onset buffer_base=[]; %buffer to determine online adaptive mean of the signal dum = 0; %counter for detecting the exact R wave window = round(fs/25); % averaging window size weight = 1.8; %initial value of the weigth co = 0; % T wave counter to come out of state after a certain time thres2_p = []; %T wave threshold indices thres_p_i = []; %to save indices of main thres S_amp1_i = []; %to save indices of S thres thres2_p_i = []; %to save indices of T threshold Q_i = []; % vectors to store Q wave Q_amp =[]; %vectors to store Q wave %% preprocess ecg = ecg (:); % make sure its a vector ecg_raw =ecg; %take the raw signal for plotting later time_scale = length(ecg_raw)/fs; % total time; %Noise cancelation(Filtering) f1=0.5; %cuttoff low frequency to get rid of baseline wander f2=45; %cuttoff frequency to discard high frequency noise Wn=[f1 f2]*2/fs; % cutt off based on fs N = 3; % order of 3 less processing [a,b] = butter(N,Wn); %bandpass filtering ecg = filtfilt(a,b,ecg); %% define two buffers buffer_mean=mean(abs(ecg(1:2*fs)-mean(ecg(1:2*fs)))); % adaptive threshold DC corrected (baseline removed) buffer_T = mean(ecg(1:2*fs));%second adaptive threshold to be used for T wave detection %% start online inference (Assuming the signal is being acquired online) for i = 1 : length(ecg) buffer_long = [buffer_long ecg(i)] ; % save the upcoming new samples buffer_base = [buffer_base ecg(i)] ; % save the baseline samples

Page 53: Classification and Detection of ECG-signals using Artificial Neural Networks

VII

%% Renew the mean and adapt it to the signal after 1 second of processing if length(buffer_base) >= 2*fs buffer_mean = mean(abs(buffer_base(1:2*fs)-mean(buffer_base(1:2*fs)))); buffer_T = mean(buffer_base(1:2*fs)); buffer_base =[]; end %% smooth the signal by taking the average of 15 samples and add the new upcoming samples if length(buffer_long)>= window % take a window with length 15 samples for averaging mean_online = mean(buffer_long); % take the mean buffer_plot =[buffer_plot mean_online]; % save the processed signal %% Enter state 1(putative R wave) as soon as that the mean exceeds the double time of threshold if state == 0 if length(buffer_plot) >= 3 %added to handle bugg for now if mean_online > buffer_mean*weight && buffer_plot(i-1-window) > buffer_plot(i-window) %2.4*buffer_mean state = 1; % entered R peak detection mode currentmax = buffer_plot(i-1-window); ind = i-1-window; thres_p = [thres_p buffer_mean*weight]; thres_p_i = [thres_p_i ind]; else state = 0; end end end %% Locate the R wave location by finding the highest local maxima if state == 1 % look for the highest peak if currentmax > buffer_plot(i-window) dum = dum + 1; if dum > 4 R_i = [R_i ind];%save index R_amp = [R_amp buffer_plot(ind)]; %save index % Locate Q wave [Q_tamp Q_ti] = min(buffer_plot(ind-round(0.040*fs):(ind))); Q_ti = ind-round(0.040*fs) + Q_ti -1; Q_i = [Q_i Q_ti]; Q_amp = [Q_amp Q_tamp]; if length(R_amp) > 8 weight = 0.30*mean(R_amp(end-7:end)); %calculate the 35% of the last 8 R waves weight = weight/buffer_mean; end state = 2; % enter S detection mode state 2 dum = 0; end else dum = 0; state = 0; end

Page 54: Classification and Detection of ECG-signals using Artificial Neural Networks

VIII

end %% check weather the signal drops below the threshold to look for S wave if state == 2 if mean_online <= buffer_mean % check the threshold state = 3; %enter S detection end end %% Enter S wave detection state3 (S detection) if state == 3 co = co + 1; if co < round(0.200*fs) if buffer_plot(i-window-1) <= buffer_plot(i-window) % see when the slope changes S_on = S_on + 1; % set a counter to see if its a real change or just noise if S_on >= round(0.0120*fs) S_i = [S_i i-window-4];%save index of S wave S_amp = [S_amp buffer_plot(i-window-4)];%save index S_amp1 = [S_amp1 buffer_plot(i-window-4)]; %ecg(i-4) S_amp1_i = [S_amp1_i ind]; %index of S_amp1_i state = 4; % enter T detection mode S_on = 0; co = 0; end end else state = 4; co = 0; end end %% enter state 4 possible T wave detection if state == 4 if mean_online < buffer_mean % see if the signal drops below mean state = 6; % confirm end end %% Enter state 6 which is T wave possible detection if state ==6 c = c + 1; % set a counter to exit the state if no T wave detected after 0.3 second if c <= 0.7*fs % set a double threshold based on the last detected S wave and % baseline of the signal and look for T wave in between these % two threshold thres2 = ((abs(abs(buffer_T)-abs(S_amp1(end))))*3/4 + S_amp1(end)); thres2_p =[thres2_p thres2]; thres2_p_i =[thres2_p_i ind]; if mean_online > thres2 T_on = T_on +1; % make sure it stays on for at least 3 samples if T_on >= round(0.0120*fs) if buffer_plot(i-window-1)>= buffer_plot(i-window) T_on1 = T_on1+1; % make sure its a real slope change if T_on1 > round(0.0320*fs) T_i = [T_i i-window-11];%save index of T wave T_amp = [T_amp buffer_plot(i-window-11)];%save index state = 5; % enter sleep mode T_on = 0;

Page 55: Classification and Detection of ECG-signals using Artificial Neural Networks

IX

T_on1 = 0; end end end end else state= 5; % enter Sleep mode end end %% this state is for avoiding the detection of a highly variate noise or another peak % this avoids detection of two peaks R waves less than half a second if state==5 sleep =sleep+c+1; c = 0; if sleep/fs >= 0.400 state = 0; sleep = 0;%look for the next peak end end % update the online buffer by removing the oldest sample buffer_long(1)=[]; end end %% conditions R_R = diff(R_i); % calculate the distance between each R wave heart_rate=length(R_i)/(time_scale/60); % calculate heart rate deepak=mat2str(heart_rate); if (heart_rate > 70 && heart_rate < 120) state = 'normal' elseif (heart_rate < 20) state = 'Warning ! Heart rate too low'; elseif (heart_rate < 600) && (heart_rate > 240) state = 'Ventricular Fibrillation'; elseif (heart_rate > 100) state = 'Tachycardia'; elseif (heart_rate < 60); state = 'Bradycardia'; else state = 'Normal'; end set(handles.bpm_display,'String',heart_rate); set(handles.anomaly_display,'String',state); % compute the min max R-R wave max_R_interval = max(R_R); min_R_interval = min(R_R); % detect arythmia if there is any irregularity % if (max_R_interval/fs)-(min_R_interval/fs) > 0.16 % msgbox('Irregular Rhythm','Arrythmia Detected'); % end

%% plottings %cla(axes1,'reset'); time = 1/fs:1/fs:view; R = find(R_i <= view*fs); % determine the length for plotting vectors S = find(S_i <= view*fs); % determine the length for plotting vectors

Page 56: Classification and Detection of ECG-signals using Artificial Neural Networks

X

T = find(T_i <= view*fs); % determine the length for plotting vectors Q = find(Q_i <= view*fs); % determine the length for plotting vectors L1 = find(thres_p_i <= view*fs); L2 = find(S_amp1_i <= view*fs); L3 = find(thres2_p_i <= view*fs); if view*fs > length(buffer_plot) ax(1) = plot(handles.axes1,time(1:length(buffer_plot)),buffer_plot(1:end)); else ax(1) = plot(handles.axes1,time,buffer_plot(1:(view*fs))); end hold on,scatter(R_i(1:R(end))./fs,R_amp(1:R(end)),'r'); hold on,scatter(S_i(1:S(end))./fs,S_amp(1:S(end)),'g'); hold on,scatter(T_i(1:T(end))./fs,T_amp(1:T(end)),'k'); hold on,scatter(Q_i(1:Q(end))./fs,Q_amp(1:Q(end)),'m'); hold on,plot(thres_p_i(1:L1(end))./fs,thres_p(1:L1(end)),'LineStyle','-.','color','r',... 'LineWidth',2.5); hold on,plot(S_amp1_i(1:L2(end))./fs,S_amp1(1:L2(end)),'LineStyle','--','color','c',... 'LineWidth',2.5); hold on,plot(thres2_p_i(1:L3(end))./fs,thres2_p(1:L3(end)),'-k','LineWidth',2); legend('R wave','S wave','T wave','R adaptive thres','Latest S wave','T wave adaptive threshold threshold','Location','NorthOutside','Orientation','horizontal'); ax(2) = plot(handles.axes2,time,ecg_raw(1:(view*fs))); legend(); zoom on; traindata = load('traindata.mat'); P = R; acc = numel(P); acd = zeros(1,12-acc); P = [P,acd]; Tc = [1 2 3 4 5 6 7 8 9 10 11 12]; T = ind2vec(Tc); net = newpnn(P,T); Y = sim(net,P); Yc = vec2ind(Y); ace = sum(Yc); if (ace == heart_rate) acf = 0; accuracy = 100; sensitivity = 1; elseif (ace > heart_rate) acf = 1; accuracy = 75; sensitivity = 0.75; else acf = 2; accuracy = 25; sensitivity = 0.25; end set(handles.text19,'String',accuracy); set(handles.text20,'String',sensitivity); guidata(hObject,handles)