Ecg Analysis
Ecg Analysis
By
Deepesh Rajpoot (2100430310023)
Ishant Vaidh(2100430310031)
Satyendra Singh Chauhan(2100430310048)
Under the supervision of
Dr. Atul Kumar Dwivedi
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.
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.
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.
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.
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.
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
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)
[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.