Design and Simulation of Electrocardiogram Circuit
Design and Simulation of Electrocardiogram Circuit
net/publication/334455337
CITATIONS READS
5 9,513
2 authors, including:
Tosin Jemilehin
Google Inc.
1 PUBLICATION 5 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Tosin Jemilehin on 15 July 2019.
1. Introduction
Wave/Segment/Interval Duration(sec)
P wave 0.1 ±0.05
PR segment 0.1 ±0.05
PR interval 0.2 ±0.05
QRS complex 0.1 ±0.05
QT interval 0.4 ±0.05
T wave 0.12 ±0.05
156
An electrocardiogram machine act like a galvanometer whereby it’s positive
and negative probe are placed at two adjacent point on the heart, when the heart
cells undergo depolarization and repolarization, the galvanometer deflects in
response to the direction of the electrical vector produced by the heart per time.
The concept of galvanometer is realized efficiently using a difference amplifier
which also helps in amplifying the small ECG signal that can be read easily using a
scope.
The automatic ECG signal analysis comprises of using computational
method/approach in extracting important features and classification of ECG
waveform. It gets information about each component of an ECG signal and
arrange it in such a way that will be understood by the classifier which classifies
the beat.
Instrumentation amplifier
One of the most useful and versatile op amp circuits for precision measure-
ment and process control is the instrumentation amplifier (IA) [2]. An IC package
INA128 can be used is a low power, general purpose instrumentation amplifier of-
fering excellent accuracy. A single external resistor sets any gain from 1 to 10,000,
it has a high common-mode rejection of about 120dB at gain greater than 100 [3]
The gain equation for the amplifier is;
(1)
For INA128,
Analog filtering
In practice, ECG signal will not come out clean as shown in figure 1, it is al-
ways mixed with noise which distort the signal and makes it difficult to get useful
information. One of the major noise associated with raw electrocardiogram is the
baseline drift which is usually caused by respiration at frequencies between 0.15-
0.3Hz and electromyographic noise which between DC to 10000Hz [4]. Others
157
noises are power line interference, patient-electrode motion artifact, electrosurgical
noise and so on. Passive low-pass filter (fc = 100Hz) and high-pass filter (fc =
0.1Hz) can be cascaded to form a band-pass filter.
For low-pass filter, the equation is given as,
(3)
Given, C = 1uF and fc = 100Hz
R = 1591
For high-pass filter the equation is same as for low-pass filter,
Given, C=100uF and fc = 0.1Hz
R=15913
158
Figure 3. Right leg drive circuit
Signal pre-processing
During signal acquisition, some noises are also added to the ECG signal and
also, the analog filters designed for the signal acquisition are not 100% efficient
hence, it is expedient the acquired signal is pre-processed. Digital filters can be
designed to filter off unwanted frequency component from the signal. The baseline
wandering is suppressed by using the ‘detrend()’ function on MATLAB while low-
pass filtering is realized using the 1D-Median filter ,the filter performs averaging
over certain number of samples in order to smoothen successive spikes.
159
The pseudocode for the algorithm used in this work is written below
(4)
From the QRS complex detection, QRS area can also be calculated for each
heartbeat, the QRS complex can be likened to a triangle, and where the base is
the difference between the Q-wave and S-wave, the height can be approximated
to be the R-peak.
160
point, P-wave can be said to be located around R-peak (i) – 100ms to 150ms and
T-wave can be located around R-peak (i) + 150ms to 200ms, the idea of peak
finding is also employed in the section of interest. For easier detection, Q-peak can
be used as reference point for P-wave and S-peak as reference point for T-wave.
In doing so, QT interval, PR interval and even few samples form the P wave and T
wave can be extracted also to aid classification.
Feature Description
1 QRS duration
2 QRS Area
3 PR interval
4 P peak
5 RT interval
6 QT interval
7 T peak
8 Signal Energy(PSD)
161
In this paper, the pattern recognition neural network will be used in classification
of the electrocardiogram signal.
Figure 4. Neural network architecture showing the input neurons, hidden layer
and output neurons
The pattern recognition neural network should be able to classify an ECG beat
into one of these three.
• Normal beat(N)
• Left Bundle Branch Block (LBBB)
• Right Bundle Branch Block(RBBB)
The most common ECG waveforms that fall under the above listed categories
were selected from the MIT/BIH database. To achieve clustering similar waveforms
into the four different classes, the neuron output layer should be three (3).The
target vector was arranged as the desired output for each class using a set of
Boolean values for easy adjustability of the system. Accompanying each record in
the database is an annotation file in which each beat in the record have been
classified by expert cardiologist, the annotator was used in assembling the training
dataset into groups by grouping beats into different classes. The output vectors
are shown the table 3;
The neural network structure used is shown in figure 5 below, from the
diagram it can be seen that the neural has two neurons in the hidden layer with
162
the tan-sigmoid transfer function. The output neurons have the linear transfer
function and the final output gives a three values output whereby each value can
be a zero or one.
After network configuration, the network is trained with the available dataset
from each heart rhythm downloaded from the database. The training algorithm
used is the scaled conjugate gradient method (trains cg) which is the best training
algorithm for pattern recognition. The training window is shown in figure 6 and the
performance graph.
163
Figure 6. Neural network training and confusion matrix
164
Figure 7. Full ECG circuit and simulation result
• Signal filtering
The digitized ECG signal gotten from the Arrhythmia database is noisy hence,
it needs filtering. The digital filter used is the median filter implemented using the
midfilt1() function in MATLAB. Figure 9 shows the noisy signal and the filtered sig-
nal.
The median filter is used to implement a 4 sample moving average filter and it
is also passed through the filter multiple times to improve or enhance the spectral
of the filter. As shown in figure 9 above, high frequency component in the noisy
signal are smoothened out hence, the performance of the filter is satisfactory.
• Feature extraction
Filtering of the ECG signal makes it possible to perform further processing op-
eration on the signal. QRS detection, P and T wave detection and statistical feature
extraction of the signal are discussed in this section.
165
Figure 8. Simulated ECG waveform using MULTISIM
• QRS detection
Feeding-in the filtered ECG signal into the QRS detection algorithm. The
outcome of implementing this algorithm is shown in Figure 10. The green boxes
indicate Q-wave peaks, red boxes indicate R-wave peaks and the blue boxes
represent S-wave peaks. The algorithm is seen to be efficient as it detects all the R
peaks in the ECG record shown in Figure 10, though in noisy or bad heart rhythm,
there some misdetection but it is not significant as compared to the rightly
detected R peaks.
167
• Frequency domain feature
The next phase of the feature extraction is the extraction of the statistical fea-
ture of the ECG signal. Figure 12 shows the autocorrelation of the signal and the
Fast Fourier Transform (FFT) of the signal. The magnitude spectrum shows that
most of the signal energies fall in the region 0Hz - 50Hz.
The signal extraction process helps in describing the timing information of the
ECG signal. Shown in Figure 13 is the final report on the timing information of an
ECG signal on the MATLAB command window, it shows the R-R interval, heart rate
and the QRS duration. The R-R, Heart rate and QRS duration are calculated by
averaging theirs for lets says 10 beats to get a single for each parameter. In
addition, the timings are gotten using the sampling frequency- sample relationship.
(5)
168
• Signal classification
The performance plot of the neural network training shows that the neural
network performance satisfactory, the confusion matrix shows that the neural net-
work is around 87% accurate and below is the receiver operating characteristic
(ROC), which is the graph of True positive rate (sensitivity) versus false positive
rate (1-specificity).The ROC plot for the training, validation and testing gives High
TP rate value in the overall plot and a low value in the (1-specificity) plot. Using
the inbuilt statistical and probability package in MATLAB, the mean value for TP is
above 85% and the mean value for (1-specificity) below 0.9, that is the specificity
is estimated to be above 90%. This is a satisfactory performance and can be im-
proved upon by increasing the amount of training dataset and also using a more
suitable neural network model.
169
Figure 15. Signal classification result in MATLAB command window
MATLAB GUI
The whole signal analysis algorithm and process is packaged into a MATLAB
graphical user interface. It allows users to interact well with the program and
shield them from the abstractness of the underlying process involved. Figure 15
shows the MATLAB GUI without operation and when in operation.
Hardware implementation
The circuit for the signal acquisition is implemented on hardware and also
tested, the waveform is read via the sound card of a PC and displayed via an audio
recording software. The hardware implementation is shown below and the wave-
form displayed by the software. The waveform is observed to be noisy compared
to the simulated ECG circuit; the low quality ECG signal is due to the passive filter
used.
170
Figure 17. Hardware implementation of the ECG circuit
4. Conclusion
171
References
Addresses:
172