ArticleslgStudy

computer science

Pan–Tompkins algorithm

Pan–Tompkins algorithm is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Pan–Tompkins algorithm rather than just read about it. In short: The Pan–Tompkins algorithm is commonly used to detect QRS complexes in electrocardiographic signals (ECG). The QRS complex represents the ventricular depolarization and the main spike visible in an ECG signal (see figure).

Pan–Tompkins algorithm — main illustration
Pan–Tompkins algorithm — illustration

Key takeaways

  • Pan–Tompkins algorithm belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Pan–Tompkins algorithm to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Pan–Tompkins algorithm from memory before moving on to harder problems.

Reference excerpt

The Pan–Tompkins algorithm is commonly used to detect QRS complexes in electrocardiographic signals (ECG). The QRS complex represents the ventricular depolarization and the main spike visible in an ECG signal (see figure). This feature makes it particularly suitable for measuring heart rate, the first way to assess the heart health state. In the first derivation of Einthoven of a physiological heart, the QRS complex is composed by a downward deflection (Q wave), a high upward deflection (R wave) and a final downward deflection (S wave). The Pan–Tompkins algorithm applies a series of filters to highlight the frequency content of this rapid heart depolarization and removes the background noise. Then, it squares the signal to amplify the QRS contribution, which makes identifying the QRS complex more straightforward. Finally, it applies adaptive thresholds to detect the peaks of the filtered signal. The algorithm was proposed by Jiapu Pan and Willis J. Tompkins in 1985, in the journal IEEE Transactions on Biomedical Engineering. The performance of the method was tested on an annotated arrhythmia database (MIT/BIH) and evaluated also in presence of noise. Pan and Tompkins reported that the 99.3 percent of QRS complexes was correctly detected.

Pre-processing

Noise cancellation As a first step, a band-pass filter is applied to increase the signal-to-noise ratio. A filter bandwidth of 5-15 Hz is suggested to maximize the QRS contribute and reduce muscle noise, baseline wander, powerline interference and the P wave/T wave frequency content. In the original algorithm proposed in 1985, the band-pass filter was obtained with a low-pass filter and a high-pass filter in cascade to reduce the computational cost and allow a real-time detection, while ensuring a 3 dB passband in the 5–12 Hz frequency range, reasonably close to the design goal. For a signal sampled at a frequency of 200 Hz, Pan and Tompkins suggested the filters with the following transfer functions H ( z ) {\displaystyle H(z)} in an updated version of their article:

H ( z ) = ( 1 − z − 6 ) 2 ( 1 − z − 1 ) 2 {\displaystyle H(z)={(1-z^{-6})^{2} \over (1-z^{-1})^{2}}} for a second-order low-pass filter with a gain of 36 and a processing delay of 5 samples;

H ( z ) = ( − 1 / 32 + z − 16 − z − 17 + z − 32 / 32 ) ( 1 − z − 1 ) {\displaystyle H(z)={(-1/32+z^{-16}-z^{-17}+z^{-32}/32) \over (1-z^{-1})}} for a high-pass filter with a unity gain and a processing delay of 16 samples.

Derivative step As a third step, a derivative filter is applied to provide information about the slope of the QRS. For a signal sampled at 200 Hz, Pan and Tompkins suggested the following transfer function:

H ( z ) = 0.1 ( − z − 2 − 2 z − 1 + 2 z 1 + z 2 ) {\displaystyle H(z)=0.1(-z^{-2}-2z^{-1}+2z^{1}+z^{2})} for a 5-point derivative filter with gain of 0.1 and a processing delay of 2 samples.

Squaring and integration The filtered signal is squared to enhance the dominant peaks (QRSs) and reduce the possibility of erroneously recognizing a T wave as an R peak. Then, a moving average filter is applied to provide information about the duration of the QRS complex. The number of samples to average is chosen in order to average on windows of 150 ms. The signal so obtained is called integrated signal.

Decision rules

Fiducial mark In order to detect a QRS complex, the local peaks of the integrated signal are found. A peak is defined as the point in which the signal changes direction (from an increasing direction to a decreasing direction). After each peak, no peak can be detected in the next 200 ms (i.e. the lockout time). This is a physiological constraint due to the refractory period during which ventricular depolarization cannot occur even in the presence of a stimulus.

Thresholds Each fiducial mark is considered as a potential QRS. To reduce the possibility of wrongly selecting a noise peak as a QRS, each peak amplitude is compared to a threshold (ThresholdI) that takes into account the available information about already detected QRS and the noise level:

… excerpt ends here. Continue reading the full article.

Illustrations

Pan–Tompkins algorithm: ECG beat
ECG beat
Pan–Tompkins algorithm: Block diagram of the pre-processing phase of the Pan–Tompkins algorithm.
Block diagram of the pre-processing phase of the Pan–Tompkins algorithm.
Pan–Tompkins algorithm: Example of Pan–Tompkins processing.[5]
Example of Pan–Tompkins processing.[5]

Worked examples

Example 1 — a first encounter with Pan–Tompkins algorithm

Start with the simplest possible case. Write down what Pan–Tompkins algorithm claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Pan–Tompkins algorithm before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Pan–Tompkins algorithm ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Pan–Tompkins algorithm

In research
Pan–Tompkins algorithm appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Pan–Tompkins algorithm in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Pan–Tompkins algorithm is common in secondary-school and first-year university syllabi. It links to neighbouring topics Algorithms, Cardiac electrophysiology, so understanding it makes those chapters shorter.
In everyday life
Look for Pan–Tompkins algorithm outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Pan–Tompkins algorithm” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Pan–Tompkins algorithm in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Pan–Tompkins algorithm means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Pan–Tompkins algorithm out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Pan–Tompkins algorithm in simple terms?

The Pan–Tompkins algorithm is commonly used to detect QRS complexes in electrocardiographic signals (ECG). The QRS complex represents the ventricular depolarization and the main spike visible in an ECG signal (see figure).

Why does Pan–Tompkins algorithm matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Pan–Tompkins algorithm?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Pan–Tompkins algorithm.

Tags

  • Algorithms
  • Cardiac electrophysiology

Keep exploring