Baseline Wander Removing from ECG with Python

Moklesur Rahman
3 min readMar 22

Baseline wandering in an ECG refers to the fluctuation of the baseline or the “zero” point of the ECG trace. This causes the entire signal to shift from its normal base. The frequency content of the baseline wander is in the range of 0.5 Hz. However, increased movement of the body during exercise or stress tests increases the frequency of baseline wandering. Baseline wandering can make it difficult to interpret the ECG and can lead to misdiagnosis if not properly addressed. To correct baseline wandering, ECG technicians may use filters or other techniques to remove or minimize the effects of the artifact.

Causes of baseline wander:

  • Patient movement — especially respiration.
  • Inadequate contact between electrodes and body surface.
  • Improper skin preparation.
  • Patient sweating.

There are several ways to remove baseline wandering from an ECG trace. These are:

  1. Filtering: One of the most common methods of removing baseline wander is by using a low-pass filter. This can help remove high-frequency noise and smooth out the ECG signal.
  2. Baseline Correction: This method involves determining the baseline of the ECG signal and then removing any deviation from this baseline. This can be done using mathematical algorithms such as spline interpolation or polynomial fitting.
  3. Wavelet Transform: This technique uses a mathematical method called wavelet transform to decompose the ECG signal into different frequency components. The baseline wander can then be removed by removing the low-frequency components that are responsible for it.
  4. Principal Component Analysis (PCA): PCA is a technique that can be used to identify and remove the components of the ECG signal that are responsible for baseline wander. This can be done by analyzing the correlation between different features of the ECG signal and removing those that are not important.
  5. Adaptive Filtering: Adaptive filters can be used to remove baseline wander by constantly adjusting their parameters in response to changes in the ECG signal. This can help to effectively remove noise and baseline wander in real time.

In any of the above methods, it is important to carefully choose the parameters of the filter or transform to ensure that the baseline wander is effectively removed without damaging the important…

Moklesur Rahman

PhD student | Computer Science | University of Milan | Data science | AI in Cardiology | Writer | Researcher