0% found this document useful (0 votes)
70 views20 pages

Ecg Analysis

This document describes a project that aims to develop an artificial neural network (ANN) approach for analyzing and classifying electrocardiogram (ECG) signals to assist in automated cardiac condition diagnosis. The proposed approach involves preprocessing ECG signals, extracting features, designing an ANN architecture, and training the ANN model on a dataset of annotated ECG signals from various cardiac conditions to classify new ECG signals. The goal is to detect abnormalities and diagnose cardiac conditions from ECG signals using machine learning techniques.

Uploaded by

Deepesh Rajpoot
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views20 pages

Ecg Analysis

This document describes a project that aims to develop an artificial neural network (ANN) approach for analyzing and classifying electrocardiogram (ECG) signals to assist in automated cardiac condition diagnosis. The proposed approach involves preprocessing ECG signals, extracting features, designing an ANN architecture, and training the ANN model on a dataset of annotated ECG signals from various cardiac conditions to classify new ECG signals. The goal is to detect abnormalities and diagnose cardiac conditions from ECG signals using machine learning techniques.

Uploaded by

Deepesh Rajpoot
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

ECG Signal analysis and classification using ANN

This report is submitted to


Bundelkhand Institute of Engineering and Technology
For the partial fulfillment for the award of degree of
Bachelor of Technology
in
Electronics and Communication Engineering

By
Deepesh Rajpoot (2100430310023)
Ishant Vaidh(2100430310031)
Satyendra Singh Chauhan(2100430310048)
Under the supervision of
Dr. Atul Kumar Dwivedi

Department of Electronics and Communication


Engineering
Bundelkhand Institute of Engineering & Technology
Jhansi
(An Autonomous Institute)
Certificate

This is to certify that the work contained in the thesis


entitled “ECG Signal analysis and classification using ANN”
submitted by Deepesh Rajpoot, Ishant Vaidh, Satyendra
Singh Chauhan for the award of the degree of Bachelor of
Technology in Electronics and Communication Engineering
to the Bundelkhand Institute of Engineering and
Technology, Jhansi is a record of bonafide research works
carried out by him under my direct supervision and guidance.

I considered that the thesis has reached the standards and


fulfilling the requirements of the rules and regulations relating
to the nature of the degree. The contents embodied in the thesis
have not been submitted for the award of any other degree or
diploma in this or any other university.

Dr. Atul Kumar Dwivedi


Assistant Professor
ECE Department
BIET Jhansi
Declaration

We hereby declare that the project work “ECG Signal analysis


and classification using ANN” entitled is an authenticated
work carried out by us under the guidance of Dr. Atul Kumar
Dwivedi of Electronics and Communication Engineering
Department at Bundelkhand Institute of Engineering and
Technology, Jhansi. Information derived from the other source
has been quoted in the text and a list of refrences has been
given.

Deepesh Rajpoot (2100430310023)


Ishant Viadh(2100430310031)
Satyendra Singh Chauhan(2100430310048)
Acknowledgement

We would like to express our gratitude towards Dr. Atul


Kumar Dwivedi for his guidance and constant supervision as
well as for providing us necessary information regarding the
project and this report. We feel thankful and express our kind
gratitude towards our Director, Head of Department and all
faculty members. We would also like to express our special
gratitude and thanks to our parents for giving us constant
support that improved our performance significantly.
ABSTRACT

Electrocardiogram (ECG) signal analysis and classification play a crucial


role in diagnosing various cardiac conditions. With the advancements in
machine learning techniques, artificial neural networks (ANNs) have
emerged as powerful tools for ECG signal processing and classification.
This project aims to develop an ANN-based approach for ECG signal
analysis and classification to assist in automated cardiac condition
diagnosis.

The proposed project involves several stages, starting with preprocessing


and feature extraction from the ECG signals. Various signal processing
techniques are employed to remove noise, baseline wander, and artifacts,
ensuring clean and reliable ECG data. Key features, such as QRS
complexes, intervals, and waveform morphology, are then extracted to
capture the relevant information from the ECG signals.

An ANN architecture is designed and trained using the extracted features


to classify the ECG signals into different cardiac conditions, including
normal sinus rhythm, arrhythmia, myocardial infarction, and others. The
ANN model is trained on a comprehensive dataset of annotated ECG
signals, encompassing a wide range of cardiac conditions and
abnormalities. The training process involves optimizing the network's
weights and biases using backpropagation and gradient descent algorithms
to minimize the classification error.
ECG Signal analysis and classification using ANN

Introduction:
Electrocardiogram (ECG) represents electrical activity of human heart.
ECG is composed from 5 waves - P, Q, R, S and T. This signal could be
measured by electrodes in human body with typical engagement. Signals
from these electrodes are brought into simple electrical circuits with
amplifiers and analogue digital converters. The main problem of
digitalized signal is interference with other noisy signals like power supply
network 50 Hz frequency and breathing muscle artefacts[1-3]. These noisy
elements have to be removed before the signal is used for next data
processing like heart rate frequency detection. Digital filters and signal
processing should be designed very effective for next real-time
applications in embedded devices. Heart rate frequency is very important
health status information. The frequency measurement is used in many
medical or sport applications like stress tests or life treating situation
prediction. One of possible ways how to get heart rate frequency is
compute it from the ECG signal. Heart rate frequency can be detected
from ECG signal by many methods and algorithms. Many algorithms for
heart rate detection are based on QRS complex detection and hear rate is
computed like distance between QRS complexes. QRS complex can be
detected using for example algorithms from the field of artificial neural
networks, genetic algorithms, wavelet transforms or filterbanks. Moreover
the next way how to detect QRS complex is to use adaptive threshold. The
direct methods
for heart rate detection are ECG signal spectral analyze and Short- Term
Autocorrelation method[4,5]. Disadvantage of all these methods is their
complicated implementation to microprocessor unit for real time heart rate
frequency detection. Real time QRS detector and heart rate computing
algorithm from resting 24 hours ECG signal for 8-bit microcontroller is
described in. This algorithm is not designed for physical stress testwith
artefacts. The designed digital filters and heart rate frequency detection
algorithms are very simple but robust. They can be used for ECG signal
processing during physical stress test with muscle artefacts. They are
suitable for easy implementation in C language to microprocessor unit in
embedded device. Design of these methods has been very easy with
Matlab tools and functions[7,8,9,10].

PROPOSEDSYSTEM

ECG signal get from patient by electrodes and give to the controller. Then
it process by image processing. Butterworth Notch filter is also used to
remove power-line interference of 50 and 100 Hz .Take FFT (Fast Fourier
Transform) for frequency domain conversion from time domain to
calculate the spectrum of our signal. Developed coding for threshold, peak
detection, heart rate and get result shown in fig 1.

Figure 1. Block diagram of proposed system

This example shows (Fig 2) how to detect the QRS complex of


electrocardiogram (ECG) signal in real-time. Model based design is used
to assist in the development, testing and deployment of the algorithm.The
electrocardiogram (ECG) is a recording of body surface potentials
generated by the electrical activity of the heart. Clinicians can evaluate an
individual's cardiac condition and overall health from the ECG recording
and perform further diagnosis.A normal ECG waveform is illustrated in
the following figure [3]. Because of the physiological variability of the
QRS complex and various types of noise present in the real ECG signal, it
is challenging to accurately detect the QRS complex.

Fig 2. Block diagram for real time QRS detection ECG

SignalSource

The ECG signals used in the development and testing of the biomedical
signal processing algorithms are mainly from three sources: 1) Biomedical
databases (e.g., MIT-BIH Arrhythmia Database) or other pre-recorded
ECG data; 2) ECG simulator; 3) Real-time ECG data acquisition.In this
example, the following pre-recorded and simulated ECG signals are used.
The signals all have sampling frequencies of 360Hz.one set of recorded
real ECG data sampled from a healthy volunteer with amean heart rate of
82 beats per minute (bpm). This ECG data was pre-filtered and amplified
by the analog front end before feeding it to the 12 bitADC.four sets of
synthesized ECG signals with different mean heart rates ranging from 45
bpm to 220 bpm. ECGSYN is used to generate synthetic ECG signals in

MATLAB.
Fig 3. ECG signal source
A real-time QRS detection algorithm, which references developed in
Simulink with the assumption that the sampling frequency of the input
ECG signal is always 200 Hz (or 200 samples/s). However the recorded
real ECG data may have different sampling frequencies ranging from 200
Hz to 1000 Hz, e.g., 360 Hz . To bridge the different sampling frequencies,
a sample rate converter block is used to convert the sample rate to 200 Hz.
A buffer block is inserted to ensure the length of the input ECG signal is a
multiple of the calculated decimation factor of the sample-rate converter
block.

Real-Time QRS Detection of ECGSignal


The QRS detection block detects peaks of the filtered ECG signal in real-
time. The detection threshold is automatically adjusted based on the mean
estimate of the average QRS peak and the average noise peak. The
detected peak is classified as a QRS complex or as noise, depending on
whether it is above the threshold.
The following QRS detection rules reference the PIC-based QRS detector
implemented in.
Rule 1: Ignore all peaks that precede or follow larger peaks by less than
196 ms (306bpm).
Rule 2: If a peak occurs, check to see whether the raw signal contains both
positive and negative slopes. If true, report a peak being found. Otherwise,
the peak represents a baseline shift.
Rule 3: If the peak is larger than the detection threshold, classify it as a
QRS complex. Otherwise classify it as noise.
Rule 4: If no QRS has been detected within 1.5 R-to-R intervals, but there
is a peak that was larger than half the detection threshold, and that peak
followed the preceding detection by at least 360ms, classify that peak as a
QRScomplex.
Simulate and Deploy

1. Open the examplemodel.

2. Change your current folder in MATLAB® to a writablefolder.

3. On the model tool strip, click Run to start the simulation. Observe the Heart Rate
display and the raw and filtered ECG signal in the scope, which also illustrates the
updating of peaks, threshold and estimated mean heartrate.

4. Open the dialog of ECG Signal Selector block. Select the ECG signal mean heart
rate in the drop down menu. Click Apply and observe the real-time detection results
in the scopes and Heart Ratedisplay.
5. Click Stop to endsimulation.

6. After selecting target hardware, you can generate code from the ECGSignal
Processing subsystem and deploy it to thetarget.

Time-DomainAnalysis
So far, research in time-domain analysis has been aiming at obtaining
roughly estimated ranges of each statistical measure, which might lead to
better indicative results for various cardiovascular diseases. In general,
time domain measures used for signal analysis include standard deviation
of all NN intervals (SDNN) in seconds, standard deviation of the averages
of NN intervals in all 5- min segments of the entire recording (SDANN) in
milliseconds, the square root of the mean of the sum of the squares of
differences between adjacent NN intervals (RMSSD) in milliseconds,
mean of the standard deviations of all NN
intervals for all 5-min segments of the entire recording (SDNN index) in
milliseconds, standard deviation of differences between adjacent NN
intervals (SDSD), and number of pairs of adjacent NN intervals differing
by more than 50 ms in the entirerecording.In this regard, three variants are
possible, namely, counting all such NN interval pairs, only pairs in which
the first or the second interval is longer (NN50 count), or NN50 count
divided by the total number of all NN intervals (pNN50) in percentage.
The resulting numbers that fall out of the normal case may be due to either
lower or higher number of heart beats. Previous studies showed apparent
implications of SDNN and pNN50 in patients with chronic heart failure
(CHF) and acute myocardial infarction (AMI). Although RMSSD has been
preferred over pNN50 due to its robustness, pNN50 indicates
cardiovascular risk levels more clearly. Having a value of SDNN that is
less than 50 ms or a pNN50 value lower than 3% is regarded as an
implication of high risk. In contrast, if SDNN falls between 50 ms and 100
ms, implies moderate risk and having SDNN greater than 100 ms or
pNN50 over 3% is considered normal. Most of the time-domain measures
are related to the evaluation of cardiovascular high-risklevels.Still,
however, their beneficial reference data could also be supportive in
simplifying the judgment of cardiovascular health state via analyzing HRV
at rest. Time-domain measures are characterized by simplicity of
calculation, but are not sufficiently informative when utilized in a stand-
alone manner. However, frequency-domain and geometry-based analysis
techniques do not have reference data such as those of time- domain.
Therefore, to maintain a reliable HRV-related study, data interpretation
should be performed by combining more than one analysis technique. The
validity of normal values of HRV at rest in a young (18 to 25 years old),
healthy and active Mexican population was investigated. The argument
involved time-domain, frequency- domain analysis methods, and a
Poincare plot. A thirty-minute time window of HR recordings is acquired
for 200 individuals. Significant variations were found between athletes and
active subjects. These major differences, however, were not based on
gender. Percentile ranges and distributions were obtained for all predefined
population categories that can be used as a reference for future researches.

Frequency-DomainAnalysis
Time domain measures are easy to compute, but they lack the capability of
distinguishing between sympathetic and parasympathetic contributions to
HRV. In comparison, frequency domain methods evaluate HRVs by
examining the frequency content of each acquired ECG signal. The two
main frequencies that resemble ANS activity are the low frequency
component (LF) ranging from 0.04 to 0.15 Hz, and the high frequency
component (HF) falling between 0.15 and 0.4 Hz. It is established that LF
indicates physiologically the sympathetic modulation of heart rate while
HF exploits the vagal or parasympathetic activity of ANS and matches the
respiratory activities. The index ratio LF/HF describes the sympathovagal
balance and shows which part of the ANS is dominating. Each parameter
(LH or HF) is computed by integrating with respect to frequency and
expressed in units of (ms)2. The result is also expressed in terms of Power
Spectral Density (PSD). To obtain LF and HF components, avariety of
approaches can be implemented one of which is FFT that transforms the
signal to computation of the PSD from the measured parameters. However,
FFT is not an adequate approach for analyzing non-stationary signals as
previously expressed. As indicated earlier in the text, HHT has the
capabilities to handle the FFT shortcomings related to the nonlinear and
non-stationary nature of the signal. Initially, EMD
is applied to the signal, which resolves the signal into smaller IMFs or
components. Each obtained IMF is then transformed into its own
frequency domains by applying Hilbert transform. However, previous
investigations demonstrated that there exists an approximate correlation
between time domain and frequency domain measures such that both are
related to each other and also contribute to HRVassessment.
Butterworthfilter
The Butterworth filter is a type of signal processing filter designed to have
as flat a frequency response as possible in the passband. Butterworth had a
reputation for solving "impossible" mathematical problems. At the time,
filterdesign required a considerable amount of designer experience due to
limitations of the theory then in use. The filter was not in common use for
over 30 years after its publication. Butterworth stated that:"An ideal
electrical filter should not only completely reject the unwanted frequencies
but should also have uniform sensitivity for the wanted frequencies".Such
an ideal filter cannot be achieved but Butterworth showed that
successively closer approximations were obtained with increasing numbers
of filter elements of the right values.
EXPERIMENTAL RESULTS
The simulation results are in the heart rate calculator in matlab algorithm.
In this workmatlab 2013a is used. In this we get the result are using
Butterworth filter for removing the noise shown in fig 4.

Fig 4. ECG waveform


Fig 5. ECG FFT waveform

Basically ECG signals are received within the sort of time domain. so as to
convert it into frequency domain we tend to square measure opting FFT
here. The on top of image explains the conversion of signals from time
domain to frequency domainshown in fig 5.

Figure 6 Total Filtered Signal

By exploiting FFT, noise signal plays a significant role in it. So as to get


rid of noise signals we have a tendency to are exploitation Butterworth
second order filter here. By exploitation
it, we've got determined clear wave form of our signal shown in fig 6.

Figure 7. ECG conditioned result

Threshold for QRS detection. Threshold could be a technique distributed


for police work the R wave peak. This method is performed by employing
a try of threshold limits knownas higher restricted threshold (hth) and
lower restricted threshold (lth) shown in fig 7.
Fig 8. Peak Detector

Once the information has been processed the peaks it ought to be known.
Peaks square measure detected as native maxima. The trace curve is that
the total of all peak signals. Little peaks will even hide in additional
outstanding peaks. With the assistance of peak detector solely able to
notice whether or not the patient is Tachycardia or Bradycardia or normal
shown in fig 8.

Fig 9. Hardware module

The higher than kit in the main consists of PIC Microcontroller, TTL logic
device, Opto coupler, electrical device and GSM module. The data’s that is
received from the electrodes goes to the PIC microcontroller then to the
TTL logic device then to the Opto coupler and eventually the output are
received to the mobile through GSM module shown in fig 9.
Fig 10. Hardware output display

The electrocardiogram data's area unit collected from the patient supply
passes through all the electrical devices and eventually the output gets
received through GSM to the the registered mobile number. Hence the
higher than image clearly shown the results of the patients shown in fig 10.

MATLAB code:

load('ECGData.mat');
data = ECGData.Data;
labels = ECGData.Labels;

ARR = data(1:30,:);
CHF = data(97:126,:);
NSR = data(127:156,:);
signallength = 500;

fb=cwtfilterbank('SignalLength',signallength,'Wavelet','amor','VoicesPerO
ctave',12);

mkdir('ecgdataset');
mkdir('ecgdataset\arr');
mkdir('ecgdataset\chf');
mkdir('ecgdataset\nsr');

ecgtype={'ARR','CHF','NSR'};

ecg2cwtscg(ARR,fb,ecgtype{1});
ecg2cwtscg(CHF,fb,ecgtype{2});
ecg2cwtscg(NSR,fb,ecgtype{3});

function ecg2cwtscg(ecgdata,cwtfb,ecgtype)
nos=10;
nol=500;
colormap=jet(128);
if ecgtype=='ARR'
folderpath=strcat('D:\project based learning\ecgsignal\ecgdataset\arr\');
findx=0;
for i=1:30
indx=0;
for k=1:nos
ecgsignal=ecgdata(i,indx+1:indx+nol);
cfs=abs(cwtfb.wt(ecgsignal));
im=ind2rgb(im2uint8(rescale(cfs)),colormap);
filenameindex=findx+k;
filename=strcat(folderpath,sprintf('!%d.jpg',filenameindex));
imwrite(imresize(im,[227 227]),filename);
indx=indx+nol;
end
findx=findx+nos;
end
elseif ecgtype=='CHF'
folderpath=strcat('D:\project based learning\ecgsignal\ecgdataset\chf\');
findx=0;
for i=1:30
indx=0;
for k=1:nos
ecgsignal=ecgdata(i,indx+1:indx+nol);
cfs=abs(cwtfb.wt(ecgsignal));
im=ind2rgb(im2uint8(rescale(cfs)),colormap);
filenameindex=findx+k;
filename=strcat(folderpath,sprintf('!%d.jpg',filenameindex));
imwrite(imresize(im,[227 227]),filename);
indx=indx+nol;
end
findx=findx+nos;
end
elseif ecgtype=='NSR'
folderpath=strcat('D:\project based learning\ecgsignal\ecgdataset\nsr\');
findx=0;
for i=1:30
indx=0;
for k=1:nos
ecgsignal=ecgdata(i,indx+1:indx+nol);
cfs=abs(cwtfb.wt(ecgsignal));
im=ind2rgb(im2uint8(rescale(cfs)),colormap);
filenameindex=findx+k;
filename=strcat(folderpath,sprintf('!%d.jpg',filenameindex));
imwrite(imresize(im,[227 227]),filename);
indx=indx+nol;
end
findx=findx+nos;
end
end

DatasetPath='D:\project based learning\ecgsignal\ecgdataset';


images =
imageDatastore(DatasetPath,'IncludeSubfolders',true,'LabelSource','foldern
ames');
numTrainFiles=250;
[TrainImages,TestImages] =
splitEachLablel(images,numTrainFiles,'randomize');

net=alexnet;
layersTransfer = net.Layers(1:end-3);
numClasses=3;
layers=[layersTransfer
fullyConnectedLayer(numClasses,'WeightLearnRateFactor',20,'BaisLea
rnRateFactor',20)
softmaxLayer
classificationLayer];
options=trainingOptions('sgdm', ...
'MiniBatchSize',20,'MaxEpochs',8, ...
'InitialLearnRate',le-4, 'Shuffle','every-epoch', ...
'ValidationData',TestImages, 'ValidationFrequency',10, ...
'Verbose',false,'Plots','training-progress');

netTransfer = trainNetwork(TrainImages,layers,options);
YPred=classify(netTransfer,TestImages);
YValidation = TestImages.Labels;
accuracy=sum(YPred==YValidation)/numel(YValidation);
plotconfusion(YValidation,YPred);
MATLAB output:
CONCLUSION
Combined use of MATLAB and Simulink is very useful in ECG signal
analysis. Different digital filters are used in simulink to remove noise from
raw ECG signal. The noise free ECG signal obtained from filter circuit is
used as input for ECG analysis to find various intervals and peaks in
MATLAB environment. Many works are done in the field of ECG analysis
and they involve complicated calculations and hence difficult to
design.The algorithm used in this work is very efficient and simple, so it
can be easily implemented on ECG signal. In this case the waveform is
divided into positive and negative parts and each section is analyzed
separately. Various peaks are detected by finding local maxima and
minima of the signal and then setting minimum threshold limit for them
according to the standard values. The results obtained can be used for
clinical diagnosis by the physician and will be very helpful in finding
various abnormalities in theheart. This work is done using the Butterworth
filter. This Butterworth filter used to remove the noise like interferences
and while using electrode that paste also a one type of nose ,so avoid this
type of noise this project using the Butterworth filter. In future using the
electrodes we will get real time ECG signal after that calculate the heart
rate.We have to implement in tiny wearable device with low value for all
because it is compact device it leads as a transportable device for patients.
The foremost aim is power consumption with charge in device. It'll be
associate degree easy device. We have a tendency to square measure
operating it on to store info in cloud.

REFERENCES
[1] Aulia A. Iskandar; Reiner Kolla; Klaus Schilling;A wearable 1-lead
necklace ECG for continuous heart rate monitoring Wolfram Voelker 2016
IEEE 18th International Conference on e-Health Networking, Applications
and Services (Healthcommission)

[2]E. Aguilar-Pelaez and E. Rodriguez-Villegas, “LED power reduction


trade-offs for ambulatory pulse oximetry,” in IEEE EMBC, Lyon, August
2007.

[3]Gavin P. Shorten; Martin J. Burke “A precision ECG signal generator


providing full Lead II QRS amplitude variability and an accurate timing
profile” 2009 Annual International Conference of the IEEE Engineering in
Medicine and Biology Society.

[4]N. Kohli, N. K. Verma, and A. Roy, “Svm based methods for


arrhythmia classification in ecg,” in Computer and Communication
Technology (ICCCT), 2010 International Conference on. IEEE, 2010, pp.
486–490.

[5]S.Z.Mahmoodabadi,A.Ahmadian,M.D.Abolhasani,M.Eslami,andJ.H.
Bidgoli. "ECG feature extraction based on multiresolution wavelet
transform", Proceedings of IEEE 27th Annual International Conference of
the Engineering in Medicine and Biology Society, pp. 3902-3905, Jan
2006.

[6] Dr.AntoBennet, M , Sankaranarayanan S, Ashokram S ,Dinesh Kumar T


R,“Testing of Error Containment Capability in can Network”, International Journal
of Applied Engineering Research, Volume 9, Number 19 (2014) pp. 6045-6054.

You might also like