This website is currently being developed and is not ready yet!

Logo

ECG filter using Python

Published on Sep 1, 2025 • 5 min read

THIS PROJECT IS NOT FINISHED YET!

Project resources

  • Google Colab
  • Github repo
  • Physionet ECG signal database

Electrocardiogram (ECG) signals are often affected by noise such as baseline wander, muscle artifacts, and power line interference. To make these signals useful for medical interpretation, we apply digital filters…

Why Filtering Matters

Noise in ECG signals can obscure critical features such as the P wave, QRS complex, and T wave. By applying filters, we improve signal quality and diagnostic accuracy.

Types of Noise

It's important to mention that there are different kinds of ECG equipment, designed for different purposes. In general:

  1. Diagnostic equipment: requieres high precision to find and diagnose pathologies. Used in, for example, a cardilogy lab. This kind of equipment uses a wider bandwith (0.05 Hz to 100 Hz, depending on the manufacturer)
  2. Monitoring equipment: does not requiere that amount of precision, it is only meant for checking the patient vitals along with other diagnostic data (0.05 Hz to 40 Hz, also depeding on the equipment)

Different kinds of equipment, will require specific filters due to the different bandwiths they work with.

What kind of filters are used

In a basic design, the two kinds of filters that an ECG signal needs is:

Since the electrical activity of the heart only produces signals in the range of 0.05 to 100 Hz, but mostly up to 40/50 Hz, this is the band I'm going to be focusing on this design.

In the following scheme, we can see the basic frequency structure of the filter:

Frequency diagram of the filter
Fig. 1: Frequency diagram of the filter

It is important to mention that real equipment uses more complex filters, adding more layers of filtering to this basic desing.

The ECG signal

Using Physionet's PTB-XL dataset, we have access to a large dataset of real ECG signals.

Conclusion

Digital filters are essential tools in biomedical signal processing. They help clinicians focus on the meaningful features of ECGs and ignore irrelevant noise.