Detection of ECG signal using Pan Tompkins Algorithm


An ECG is a simply a representation of the electrical activity of the heart muscle as it changes with time. It is used to measure the rate and regularity of the heart beats as well as the size and position of the chambers. Primary function of the ECG is to detect possible cardiac arrhythmias like irregular heart beat or heart murmurs. P wave shows us   the activation of atriums.  QRS complex shows us the ventricles action. T wave is a diagram of depolarization of ventricle muscle cells coming back into stable stage for another contraction. There are 2 methods for ECG detection.
  • Derivation method
  • Pan Tompkins method
In this project we are going to discuss about Pan Tompkins method. The works of Pan Tompkins greatly influence the QRS detection as compared to others. The “Pan and Tompkins” QRS detection algorithm identifies the QRS complexes based upon digital analysis of slope, amplitude, and width of the ECG data. The algorithm implements a special digital band pass filter. It can reduce false detection caused by the various types of interference present in the ECG signal. The algorithm automatically adjusts the thresholds and parameters periodically to adapt the changes in QRS morphology and heart rate.

The aim of the ECG simulator is to produce the typical ECG waveforms of different leads and as many arrhythmias as possible. My ECG simulator is a mat lab based simulator and is able to produce normal lead II ECG waveform.  The use of a simulator has many advantages in the simulation of ECG waveforms. First one is saving of time and another one is removing the difficulties of taking real ECG signals with invasive and non-invasive methods. The ECG simulator enables us to analyse and study normal and abnormal ECG waveforms without actually using the ECG machine. One can simulate any given ECG waveform using the ECG simulator.
Electrocardiogram (ECG) signals are composed of five important waves: P, Q, R, S, and T. Sometimes, a sixth wave (U) may follow T. Q, R, and S are grouped together to form the QRS-complex. Detection of these waves is a vital step in ECG signal analysis to extract hidden patterns. Many prior studies have focused only on detection of the QRS-complex, because P and T waves are sparse and harder to isolate from the signal. In this paper, we develop an algorithm to detect all five waves - P, Q, R, S, and T in ECG signals using wavelet transformation.

 Main features of this simulator:
 1. Any value of heart beat can be set.
 2. Any value of intervals between the peaks (ex-PR interval) can be set.
 3. Any value of amplitude can be set for each of the peaks.
 4. Fibrillation can be simulated.
 5. Noise due to the elect.


The most important information about ECG signal is almost concentrated on the P wave, QRS complex and T wave. These data include the positions and/or magnitudes of PR interval, QRS interval, QT interval, ST interval, PR segment, and ST segment. Electrocardiogram is a signal containing information about the condition and operation of heart. Nowadays, many heart diseases can be efficiently diagnosed using these signals. However, a proper recognition and classification of the heart signals are essential requirement for the diagnosis of heart diseases.

The P Wave:

The P wave represents the spread of electrical activity over the atrium. The normal depolarization begins at the Sino atrial (SA) node near the top of the atrium. Because of the top-to-bottom, right-to-left path of the P wave, it’s normally largest in lead II. The normal P wave is upright in all leads except R. The P wave normally lasts less than 0.11 seconds. An abnormally long P wave occurs whenever it takes extra time for the electrical wave to reach the entire atrium. This occurs in left atrial enlargement. The height of the P wave is normally less than 2.5 small boxes (less than 0.25 millivolts). An abnormally tall P wave is seen when larger amounts of electricity are moving over the atrium. This usually indicates hypertrophy of the right atrium. The P wave may be decreased in height by hyperkalaemia. 

The PR Interval:

Following the P wave is the PR segment (NOTE: the PR segment and the PR interval are NOT the same thing). The PR segment is not routinely measured, but may be commented on if it is depressed or elevated. During the PR segment, the electrical wave moves slowly through the atrial ventricular (AV) node. This activity is not seen on the ECG.
The PR interval is the time from the beginning of the P wave until the beginning of the QRS complex. It is normally between 0.12 and 0.2 seconds .The PR interval may be prolonged when conduction of the electrical wave through the AV node is slow. This may be seen with degenerative disease of the node, or with digoxin, hyperkalaemia, hyperkalaemia, or hypothermia. The PR interval may be unusually short when conduction is rapid. A mildly short PR interval may be seen with hypokalaemia or hypocalcaemia. The PR interval is measured from the beginning of the P wave to the beginning of the QRS complex. It reflects the time taken by the impulse to travel the entire distance from the SA Node to the ventricular muscle fibres. The normal duration for this is 0.12-0.20 seconds. Normally this interval varies with heart rate and is shorter at faster rates. Under certain circumstances, for instance if the conduction system is diseased or affected by Digitalis, the P-R interval may lengthen as the rate increases. Also if the atria are paced, the interval lengthens as the paced rate increases. A prolonged interval, beyond normal limits (0.12-0.20 sec.), is considered evidence of AV block. An abnormally short P-R interval is cause for alarm as it is often seen in association with hypertension and paroxysms of tachycardia. The P-R interval is shortened when the impulse originates in the AV node rather than the SA node or when the passage of the impulse to the ventricle is accelerated as in Wolff-Parkinson-White syndrome (WPW).

The QRS Complex:

The QRS complex represents activation of the ventricle. Special conducting bundles spread the wave of depolarization rapidly over the ventricle. The QRS complex is normally less than 0.10 seconds. Lengthening of the QRS indicates some blockage of the electrical action in the conducting system. This may be due to ischemia, necrosis of the conducting tissue, electrolyte abnormality, or hypothermia. If the first deflection of the QRS is downward, it’s called a Q wave. The Q wave represents activation of the ventricular septum. The electricity spreads from right to left through the septum. Q waves may be normal. For example in lead I, a Q less than 1/4 of the R height, and less than one box wide, is considered normal. This is the early activation of the septum.
Q waves are “significant” if they are greater than 1 box in width (longer than 0.04 m sec) OR are larger than 1/4 of the R wave. Significant Q waves indicate either myocardial infarction or obstructive septal hypertrophy (IHSS). The first upward deflection of the QRS is called the R wave. Most of the ventricle is activated during the R wave. The R wave may be prolonged if the ventricle is enlarged, and may be abnormally high (indicating strong voltage) if the ventricular muscle tissue is hypertrophied. The S wave is any downward deflection following the R wave. Like the R wave, an abnormally large S wave may indicate hypertrophy of the ventricle. If a second upward deflection is seen, it’s called an R-prime wave. R-prime waves are never normal, but indicate a problem in the ventricular conduction system. QRS complexes may be described by naming the waves that form them. For example, a complex with an R, an S, and an R’ is called an RSR’ complex. 
Pan Tompkins method:

Pan Tompkins is one of the method for the detection of ECG waves. The QRS detection algorithm introduced by Pan and Tompkins  is the most widely used and often cited algorithm for the extraction of QRS complexes from electrocardiograms. The methodology followed is that the ECG is passed through a low-pass and a high-pass filter in order to remove noise from the signal. Then the filtered signal is passed through derivative, squaring and window integration phases. Finally, a thresholding technique is applied and the R-peaks are detected.

Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Web Developer, Student and Mechanical Engineer. He Enjoys writing articles, Blogging, Solving Errors and Social Networking. Feel Free to let me know any of your concerns about hacking or let me know if you need any more methods on hacking anything. Enjoy Learning

No comments:

Post a Comment