// engineering › Applications of Fourier

ECG Noise Filtering

Watch a noisy heartbeat trace get cleaned by transforming to the frequency domain, low-pass filtering, and transforming back.

y = mathcal{F}^{-1}big[,mathcal{F}(x)cdot H(f),big]

Formula

\[ y = \mathcal{F}^{-1}\big[\,\mathcal{F}(x)\cdot H(f)\,\big] \]

ECG Noise Filtering

When a hospital ECG machine cleans the heartbeat trace before showing it to a cardiologist, it does this: take the noisy signal into the frequency domain, delete the bins that don't belong to a heart, take it back. Same maths drives every biosignal monitor on the planet.

The pipeline

\[ x(t) \xrightarrow{\mathcal{F}} X(f) \;\;\xrightarrow{\text{mask } |f|>f_c \to 0}\;\; \tilde X(f) \;\xrightarrow{\mathcal{F}^{-1}}\; \tilde x(t) \]

Reference: Wikipedia — Low-pass filter; MIT 6.003 Signals & Systems, Lecture 20. Oppenheim, A. V., & Schafer, R. W. (2010). Discrete-Time Signal Processing, 3rd ed., Ch. 7.

🧪 Try these experiments in order

  1. Set noise = 0 and mains hum = 0. You see a clean heartbeat pattern. Note the regular spikes — those are the QRS complexes.
  2. Push mains hum to maximum. The 50 Hz interference swamps the trace — this is exactly what happens when an ECG cable runs too close to a power outlet.
  3. Now drag cutoff from 80 Hz down to 30 Hz. Watch the 50 Hz spike in the spectrum vanish, and the heart trace return cleanly underneath.
  4. Push noise to max too. Drag cutoff lower — at what frequency does the heartbeat start to lose its sharp R-spike?

Noisy input signal (what the electrode actually sees)

Magnitude spectrum (yellow = kept, red = filtered out)

Filtered output (what the cardiologist sees)

⚠ Watch out for

  • Cutoff too low (below ~15 Hz) starts deleting the QRS spike itself — the R-wave goes round and smooth. In a real ICU this would hide arrhythmias.
  • The brick-wall mask used here is what textbooks call an "ideal" filter — in real hardware it would introduce ringing (Gibbs again). Real ECG machines use gentler Butterworth or Chebyshev filters.
✅ Do

Pick the cutoff just above the highest frequency that carries information you care about (≈40 Hz for ECG diagnostics).

❌ Don't

Reuse the same cutoff for every signal. A 40 Hz lowpass is right for ECG, lethal for music (you'd lose every cymbal), wrong for EEG (cutoff ≈ 70 Hz).

Where this matters in industry

ICU and bedside ECG monitors, Holter recorders, fitness-tracker heart-rate algorithms, EEG/EMG biomedical work, seismometers, audio noise gates, power-line interference removal on every sensor that touches a mains-powered system.

🎯 Learning checkpoint

If you set the cutoff higher than 50 Hz, does the mains hum disappear? Why or why not? (Try it.)

Frequently asked questions

How does a hospital ECG machine actually clean the signal?

Exactly the way this tool shows: it transforms the noisy heartbeat into the frequency domain, keeps the low frequencies that carry the heart's rhythm, discards the high-frequency noise and the 50/60 Hz mains hum, then transforms back. What the cardiologist sees is the filtered output.

What is the 50 Hz spike in the spectrum?

That is interference picked up from the mains electricity supply (60 Hz in the Americas). It is everywhere in a hospital, and it shows up as a sharp spike in the ECG spectrum. A 'notch' filter removes exactly that frequency — try lowering the cutoff here and watch the hum vanish from the output.

Why not just average the signal to remove noise?

Crude averaging would also blur the sharp QRS spike that doctors rely on to measure heart timing. Fourier filtering is surgical: it removes specific unwanted frequencies while protecting the ones that carry diagnostic information. That selectivity is why frequency-domain filtering is the standard.

Could I trust this exact output for a real diagnosis?

No — this is a teaching toy with a simplified heartbeat model and a brick-wall filter. Real ECG processing uses carefully designed filters validated to clinical standards. The value here is intuition: seeing why filtering happens in the frequency domain at all.

Where else is this 'transform, mask, transform back' trick used?

Everywhere. Noise reduction in audio recordings, removing rumble from seismographs, cleaning up radio signals, and de-noising scientific images all use the same three-step recipe. Master it once here and you understand a huge swathe of signal processing.