0% found this document useful (0 votes)
11 views17 pages

Lec 20

The document discusses the Pan-Tompkin algorithm for real-time QRS complex detection in ECG signals, detailing its sophisticated wave detection methodology. It outlines the steps involved in the algorithm, including the use of bandpass filters, differentiators, squaring operations, and adaptive thresholding to enhance signal detection. Key features include the implementation of integer filters for efficiency and the introduction of adaptive thresholds based on running estimates of signal and noise peaks.

Uploaded by

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

Lec 20

The document discusses the Pan-Tompkin algorithm for real-time QRS complex detection in ECG signals, detailing its sophisticated wave detection methodology. It outlines the steps involved in the algorithm, including the use of bandpass filters, differentiators, squaring operations, and adaptive thresholding to enhance signal detection. Key features include the implementation of integer filters for efficiency and the introduction of adaptive thresholds based on running estimates of signal and noise peaks.

Uploaded by

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

Biomedical Signal Processing

Prof Sudipta Mukhopadhyay


Department of Electrical and Electronics Communication Engineering
Indian Institute of Technology, Kharagpur

Lecture – 20
Event Detection (Contd.)

So, this session will take one more wave detection algorithm, which is much more
sophisticated than the previous algorithm that is called the Pan-Tompkin algorithm.

(Refer Slide Time: 00:31)

This Pan-Tompkin algorithm, it is that proposed by Pan and Tompkin this two scientist. And
it is proposed for the real-time operation, and again it is proposed based on the slope,
amplitude, and width of the QRS complex. So, these are the things keeping in mind that this
technique was proposed. And the first part of it is that there is a bandpass filter. To clean the
signal we know that when we are using that differentiator or the derivative so that it will
accentuate the high-frequency noise. So, we need to get rid of them.

So first, it is a first-way bandpass filter, next to that differentiator, after the differentiator,
there is a squaring operation. And, we know that if we take the square and if the amplitude is
more than 1, actually it gives a non-linear enhancement to the signal magnitude and the high
amplitude one it will be magnified and the difference between the low amplitude and the high
amplitude the signals they will get separated. That is followed by again a MA filter, because
we have seen in the previous two cases that many times output is jiggered, so to smooth it
out. And then the last part is the QRS peaks. And for finding out the peaks that the
Pan-Tompkin has suggested and elaborate procedure for that. And if you look at this part that
is that bandpass filter to MA integrator it would look like that it is just an extension of the
previous techniques, but the real impact comes that in terms of knowledge as well as that the
sophistication that comes in the QRS peak search.

So, let us go through that algorithm step by step.

(Refer Slide Time: 03:00)

So first, the signal is passed through that we have to pass through a bandpass filter for that in
low pass filter is taken, that low pass filter the transfer function is given here and the
corresponding that the difference equation is also given. And we have told that one thing that
we have a real-time, actually that algorithm we are looking for that the Pan-Tompkin has
proposed. And for that purpose what they have taken? They have taken an actual IIR filter,
they are using that both the poles and zeroes.

And for the IIR filter if you look at the weights, all these weights are the power of 2, either
that power of 2 this k is positive or it is negative. So, when it says 1 by 32; that means that in
that case, it is that 2 to the power minus say that 2 to the power 3 is 8, so 2 to the power 4 is
16, 2 to the power 5 is 32. So, that is 2 to the power -5 will give us 1 by 32. And that would
be implemented by actually 5 right shift operation of the register.

So, keeping that in mind that while we are multiplying which power of 2 that for example,
here we are multiplying with that, that would be left shift operation one left shift operation
will give us multiplication with two, here also will do the same thing. And when we are
taking that division by 32 that would be affected by that 5 right shift operations.

So, that is a way that they have implemented so that the operations can be done in a very fast
and frugal manner.

(Refer Slide Time: 05:36)

That is what they have taken that they have taken the signal that is a sample that 200 Hertz
sampling frequency. And for that, this filter has a cut-off frequency of 11 Hertz

So, what we get is that it is a very I would say that low cut-off; that means the maximum part
of the signal and the noise; of course, the high-frequency anything above 11 Hertz that will
get eliminated. And that also takes care of the power frequency that in North America that
would be 60 Hertz, in our country or some part of the Europe that would be 50 Hertz that is
well above this cut off frequency. So, that will be eliminated by this filter itself.
And they have used this integer filter for the real-time operation. Attenuation at 60 Hertz
would be more than 35 dB, and that is why that this operation is good enough and we do not
need any more notch filters in this case.

(Refer Slide Time: 07:01)

Now that, as we told that we take actually that a bandpass filter, so we have to have a high
pass filter also along with the low pass filter to do the job. And for that first will start with a
low pass filter. So, this is the low pass filter, the corresponding that the difference equation is
given. Again note that all the coefficients are 1, so no multiplication is required only addition
is required for that. And, from that low pass filter that the corresponding high pass filter is
derived from this low pass filter. And this is the corresponding high pass filter, the
corresponding difference equation also is given. And here that the only term other than that
one that is 1 by 32, we know that this means that it is power of 2 to the power -5 and we can
incorporate that for 5 right shifts operation.

So, again this high pass filter is also a real-time integer filter and with that, we can apply it
after the low pass filter this high pass filter along with the low pass filter gives rise to a
bandpass filter.
(Refer Slide Time: 09:02)

And that for these if we look at that cut-off frequency, the cut-off frequency is low that is 5
Hertz. So now, the signal is restricted in between 5 Hertz to 11 Hertz; only that part of the
signal is preserved. So, below the 5 Hertz means that all the low-frequency signals are also
eliminated; and that means, Pan-Tompkin has found that most of the energy of the QRS
complex is concentrated within this band: 5 to 11 Hertz. And if we just keep that and throw
away the other part that is good enough for the QRS complex detection.

And this real-time algorithm helps us to; do the fast operation and for that, the integer filter is
used again.
(Refer Slide Time: 10:07)

Now, let us look at the corresponding difference operator. That, for the Pan-Tompkins
algorithm they have a little more elaborate than difference operator. That, the difference
operator is weighted difference operator is taken; some of the weights are 2 some of them
they are 1, and that for averaging that 1/8 is taken. And again you note that this is an integer
filter because the coefficients are integer and the divisions are also the power of 2. So, again
that multiplication can be replaced by the shift operations here. And after that differentiator
will do the squaring.

Now, for in this case these difference operators the way it is chosen it acts as an ideal
derivative filter up to 30 Hertz. That means, within that band that 5 Hertz to 11 Hertz where
the signal is present or preserved at that part it has a linear operation. And, for that when you
pass it through that will get the high-frequency terms would be emphasized and followed by
squaring operation which will help us to make it positive and emphasize the large derivatives.
And following this squaring operation, there would be an integration block that will help in
smoothing, and multiple peaks will merge into a single peak. And for that purpose, the MA
filter is used and they found that N is equal to 32 which gives a good result for fs equal to 20
Hertz.

Now, if you ask that why they have chosen N equal to 30 is difficult to answer. The only way
we can think of is that they empirically come across these numbers. If we think in terms of
that integer filter we should have chosen 32 instead of 30, but I think what they may have
done that MA filter that when you are supposed to compute the average they may have taken
as a sum because following this there will be a threshold operation. So, that division by 30 if
it is omitted instead of average will get the sum that will simply give a scaling. And so long
that our computer registers bandwidth that can handle that number there is no problem with
that scaling. That may be that the reason that they have settled it to 30 not gone for 32.

(Refer Slide Time: 13:52)

So now here, let us look at that how the signal changes by these operations. First, we show at
the top that this is the ECG signal, and after the bandpass filter, we see that the signal is
distorted that we get the QRS complex that is the most prominent one. Also, the T signal is
there, this is not completely eliminated. And another thing we note is that if you look at that
the position of the R, because of this filtering it has added some delay. So, the position of the
QRS complex or that R wave varies it has actually that it has been delayed and the delay is
corresponding to the delay introduced by this bandpass filter.

Next, we look at that squaring operation after the squaring we get that the output of this T
wave is giving rise to a small waveform, whereas the QRS complex it is giving a much larger
wave from. So, using that be actually, we get that separation of the other waves and
amplification of the QRS complex.
(Refer Slide Time: 15:33)

So once it is squared, now we can get that effect that the R wave that gives multiple peaks
and that is much higher than the peaks created by the T wave. And you see that P wave
hardly that is visible nothing is there almost. And, once it is passed through that integrator
that is a MA filter of order 30 then we get that it becomes a solid stamp that all the peaks they
get merged and give raise to a post kind of structure here which can be the threshold to find
out that there is a QRS complex is present at this position, and it is very difficult to miss. So,
up to this, we get actually from the knowledge of that previous algorithm.
(Refer Slide Time: 16:43)

Now, comes the special contribution of Pan-Tompkin; that the first change they have made
the thresholding should be adaptive. That is the beauty of the Pan-Tompkins algorithm. So for
that what they have done that, they have introduced a couple of terms that first, one is SPK1,
second is NPK1, and two thresholds: threshold 1 and threshold 2 they are introduced. Out of
that if we look at that here the inputs are the peak, peak means that the overall the peak
whenever after we take a threshold that the peak what we get that we get anything above the
threshold that is a peak. So, using that we are updating that SPK1; that is the signal peak
running estimate and NPK1 is a running estimate of the noise peak.

So, if we take a threshold whatever we get above the threshold could be a signal peak or a
noise peak. If it is a signal peak that is used to update the estimated running estimate of the
signal peak. If it is a noise peak then that peak is used to update the estimate of the noise
peak. And in both cases what we get is that we are taking 0.125; 0.125 this fraction this
comes out of 1 by 8. Again, it is a power of 2, 2 to the power of -3 has been taken. And these
part what we are taking, this is actually if it one 8 the other part is 7, 8. So, the previous value
whatever was there it is multiplied by 7 and then 3 right shifts will give. So, one-eight part of
that previous estimate that is taken and it is used to modify both the signal peak and the noise
peak.
And after that, we go for the selection of the threshold. And the philosophy is very simple:
that threshold should be above the noise peak so that no noise peak should be detected. And it
should be much lower than the signal peak so that we can catch all the signal peaks; there
should not be any miss of signal peak. So, they have proposed that threshold 1 should be
above the noise peak so that is the baseline. And then the difference between the signal peak
and the noise peak; that running estimates the difference of that one-fourth of that difference
is added with the noise peak. So, that would be the threshold.

That is the threshold 1. And 50% of that threshold 1 is taken as the threshold 2. So, there is
that number of actually that terms we get, and this is how we define the threshold 1 and
threshold 2.

(Refer Slide Time: 21:06)

Now, let us go through the definitions once more so that we can give remember that, but then
that we have peak 1 that is the overall peak whenever we get one post that is above the
threshold. The peak of it is taken as peak 1. That will have some more steps to find out
whether it is a signal peak or a noise peak. If it is a signal peak then that peak is used to again
update the signal peak estimate; running estimate. If it is a noise peak then that is used to
update the running estimate of the noise peak. And we have used that using that these two
running estimates of the signal and the noise peak that the threshold 1 that is a first estimate
of the threshold first threshold that is calculated and half of the value of the first threshold
that gives a lower threshold that is we call the second threshold or threshold 2.

So, with that, we proceed. And here one more thing that if a signal or a peak we miss by this
that threshold 1. That means, a time has passed we could not get any peak above threshold 1,
then we would fall back on the threshold 2 and try to find out whether we can get any peak.
And if we get a peak by threshold 2 and if that peak is a signal peak then our speed of update
of the signal peak becomes more. Instead of one eighth, we take one-fourth part of this new
peak and three-fourths part of the previous estimate of the signal peak and we update the
running estimate. That means, that we realize that due to some reason maybe contact
resistance or so that signal amplitude has reduced. And because of that, we could not get any
peak above threshold 1. Under that situation, we need to update the thresholds so that we do
not miss any peaks. And for that, we have used that second threshold to get that peak.

Now, after getting that peak if it is a signal peak we should update that estimate more quickly
so that next time such a thing does not occur. So, we increase the speed of adaptation in this
case.

(Refer Slide Time: 24:32)

Now, we get the search back part of it. Here, we have two quantities of the RR average. If we
have an ECG signal we know that we get the PQRST then a gap again we get PQRST. So, in
between the two beats, this difference between the two Rs is called the RR interval. And for
this RR interval, they are having that two averages estimates of the RR interval. The first one:
it is taking the row one that whatever the peaks are we get that we take those that
corresponding the RR intervals and that gives rise to their RR average 1. And from these RR
intervals raw RR intervals, we can say that we refine them and then the refined estimate that
is taken as RR dashed that is used to calculate the second average.

Now, how that is refined? There is a limit lower limit and upper limit that is set that if the RR
average 2 is taken as actually a more stable or robust estimate of the RR interval. If the lower
limit is set as 92 % of it and the upper limit is taken as 116 % of it.

So, please note that they have not taken a symmetric window, if this is 100 % that lower side
if this is 100 % lower side they are taking it 92; that means, in allowance of 8 and upper side
8 % upper side they are taking it 116 % means an allowance of 16 %. If it is within that, then
that RR interval we call RR dashed; that means, that is an acceptable one. If it goes outside
that then what could happen, RR interval if it is bigger, means bigger than the that within
these limits if it is above 116 %. That means that is an unusual kind of situation: for a healthy
person the person that heart is beating so that the QRS complex would be there all the time.
So, if it is absent, what is concluded here is that our algorithm has missed to peak actually
that QRS that beat or the R actually peak. That means, we have missed one and that is why
RR has become more.

The other option could be if it is very small; that is less than 92 % of the RR average that
such a sudden change in the beat does not happen even if there is a change in the rhythm that
is a gradual one. If the RR interval is smaller than that signifies there must be a noisy peak
that has reduced the RR interval. So now, we need to take care of that noisy peak. So, if it is
below that then we get that new peak as a noisy peak and that helps us to change that running
estimate of the noise peak. And if it is within these intervals then it is a signal peak then that
helps us to find out that from the signal peak that we can get that RR average 2 as well as we
can estimate or update the estimate of the signal peak.

And if it is above, that means you have missed something. So, we need to look back and find
out that missed peak and that is a part we call a search back operation.
(Refer Slide Time: 29:39)

So, as a part of it what is done? Whenever the QRS waveform is not detected within that is a
started interval that is called that RR missed limit. Then the QRS peak between threshold 1
and threshold 2 is taken. The first part is imperative we call it missed because there is no peak
above threshold 1. And in that situation, we can get a peak only if it is above threshold 2. And
that essentially means it has to be between these two threshold: threshold 1 and threshold 2.
So, that becomes the new peak that we take here.

And that RR missed limit is set pretty high it is taken 116 % of the RR average 2. So, that RR
average 2 is the stable average of the robust average of the RR interval if it is 166 % of that;
that means, 166 % more is considered as the limit if still we do not get that the R peak. That
means, we assure that we have missed that R peak because the signal cannot heart can stop
beating that long or the frequency cannot go down that low. So, we should go for threshold 2
and take that peak above that threshold.

So, when the heart rate is normal that we do not have any problem then we get that RR
average 1 and RR average 2 should be similar. There is no reason that they would be
different. However, if there is fluctuation in that heartbeat then this two can vary. And using
this algorithm which is a real-time algorithm the Pan-Tompkin found that they could achieve
a very low error rate; that is 0.68 %. And, that means only 33 beats per hour for a huge
database of 116000 beats of 24 hours recording of 48 patients. So, with a very exhaustive
state of a database of 48 patients and by collecting that 24 hours recording; that means,
throughout the day whatever the changes have occurred they could get a very good actual
estimate of only 0.68 % that the R beats are missed in this case. That means, less than 1 %
actually loss.

So, that is a way Pan-Tompkin has contributed in terms of a very sophisticated that QRS
detection algorithm.

(Refer Slide Time: 33:29)

Now, will go through another small part before concluding this session. We have seen that the
cardiovascular system. And a part of it we told that the left ventricle which is pumping out
the blood through the arteries and which reaches throughout the body; that the first the QRS
complex signifies the start of the compression then between S and T that the contraction
remains, and because of that the blood flows out of the ventricle because of that pressure.

And when the T wave comes which signifies the start of the relaxation of the ventricles. The
moment the pressure of the blood inside the left ventricle becomes lower than that of actually
that means the blood pressure within that aorta. So, then the valve that is helping for the
unidirectional flow of the blood in the aorta that will get closed; and that gives rise to a small
dip in the pressure and that will remain constant after that because the valve is closed even if
the ventricles relaxed it will not allow for backflow of the blood.
And that part we would like to capture.

(Refer Slide Time: 35:17)

And that can be done by the carotid pulse signal. That, we know that the carotid means it is
that is an artery that is going towards the head for supplying of the blood. So, when we have
the QRS complex, here is the QRS complex of the ECG that is associated with some noise
called the actual S1 signal. And the S1 signal we get in that PCG signal the phonocardiogram.

Phonocardiogram is that audible sound we get near the heart. And how that is generated is
generated by the sound of the valves. And again that the blood is oozing out from the
ventricles to the arteries or in the left ventricle to the aorta. Now it gives rise to turbulence
and we get that noise as the S1 signal.

So, the S1 signal can help us to find out that whether it is the normal sound or in the case of
some steroids in the artery or imperfection in the valve. Say at the time when the blood is
flowing from the left ventricle to the aorta if our valves in between that aorta and the
ventricles they should have closed before that. If they have not closed properly some blood
can backflow and that will give rise to some sound. So, all such scenes will be depicted in the
S1 sound or S1 vibration. And that the way we are getting here the PCG signal is a very clean
one or clean of it. It is superimposed with lots of noise including the power frequency noise
and high-frequency noise. So, we do not get such a clean signal. So, we need to have some
idea that where the S1 and S2 sounds are occurring.

So, the first trigger to get the position of S1 comes from the QRS complex. And already we
have seen that how we can capture the QRS complex the three algorithms we have learned.
Now for the S2 one that comes when the ventricles relax and the valves which were so far
allowing the flow of the blood from the ventricles to the arteries, they close down. If the
valves get calcified; so instead of a soft sound it will make a metallic sound and that will give
rise to an increase in the S2 sound.

However, to get that where that is occurring it becomes very difficult because a T signal is a
non-event it's a subdued signal we cannot get actually when it is finishing. So, instead of
looking at ECG from where you cannot get the boundary that of the end of the T signal we go
for the carotid pulse signal which peaks up after the QRS complex the pressure in increasing.
And when the valve is closed there is a sudden dip which gives rise to a deep in pressure.

Again as the valve is closed that pressure remains constant and slowly that is going down. So,
we can tell this part of the pressure is the systolic pressure and this part is the diastolic
pressure actually. So, in between this change this notch in this carotid pulse if we can catch
this position it can help us to get the location of the S2 signal in the PCG signal. So, that is
the importance of the carotid pulse signal and the notch. This two are very close to each
other.
(Refer Slide Time: 40:01)

So, Lehner and Rangayyan have used again a second derivative of the best technique. So,
they have suggested that let us take the second derivative of the carotid pulse signal followed
by a MA filter. And these will give rise to two peaks: one peak would be for the actually that
if we take the second derivative that it will give the peak somewhere here where there is an
increase in the signal amplitude. Again that will give a peak here. So, to get that is why they
are talking about that you look for the second peak out of the two peaks the second one is
taken that is corresponding to the dicrotic notch. And dicrotic notch may be located that
where the peak comes they look for local minima around that peak by taking an interval of
±20 milliseconds around that second peak.

That is how they could get the location of the dicrotic notch. And we know from that we can
get that time window where the S2 is located.

Thank you.

You might also like