Objective: Extract the PQRST wave of the heart's ECG from a complex noisy time-based signal obtained from a 3-lead differential input.
Answer: The Fast Fourier Transform and Digital Signal Processing
Hardware: Microcontroller with boot-loadable flash memory, a nifty algorithm written in C++ or other compatible language.
A simple example using MATLAB. Construct a noisy waveform and superimpose upon it three sinusoidal waveforms at 50, 120, and 300 hertz. The equation for this composite of sinusoidal waveforms is x = sin(2*pi*50*t) + sin(2*pi*120*t) + sin(2*pi*300*t).
The code entered into MATLAB to determine the hidden sinusoidal components buried in the noise floor would be:
t = 0:.001:.25;
x = sin(2*pi*50*t) + sin(2*pi*120*t) + sin(2*pi*300*t);
y = x + 2*randn(size(t));
plot(y(1:50))
title('Noisy time domain signal')
Y = fft(y,256);
Pyy = Y.*conj(Y)/256;
f = 1000/256*(0:127);
plot(f,Pyy(1:128))
title('Power spectral density')
xlabel('Frequency (Hz)')

Figure 1. Frequency spectra produced by MATLAB FFT algorithm.
Digital signal processors use FFT for a wide variety of applications. Perhaps one of the most interesting applications is to take the noisy complex waveform obtained from a 3-lead electrocardiogram of the heart and then applying an FFT algorithm to yield the PQRST wave of the heart's rhythm.
In its simplest form, the FFT is nothing more than a Fourier Transform conversion done from the time domain to the frequency domain. However, it is a computation done at a much higher speed than what a Continuous-Time Fourier Transform would require in computing time. This makes the FFT idea for microprocessor based instruments used to extract periodic waveforms, such as cardiac rhythms from a very noisy source. The noise source in the case of the ECG instrument is inherent broadband noise that exists on the ECG leads as picked up on the patient's body and the ambient electromagnetic energy field in the environment of the instrument.
If one was to construct a simple 3-lead ECG detector using 3 wire leads with adhesive and conductive electrodes and an oscilloscope, one would only see a huge mess of random noise on the scope's display. But the cardiac rhythm is there. It just a matter of extracting the periodic waveforms that comprise the true PQRST wave shape and discarding the noise. It is not simple enough to filter out the noise with solid state filters. The cardiac signal is a complex waveform of many Fourier frequency components in the same spectra band as the noise. Filtering the noise means the wanted signal is also filtered. Enter the Fast Fourier Transform. In the end, below is what is sought.
Figure 2. ECG printout, leads V1, II, and V5.
Figure 3. PQRST waves as seen in an electrocardiogram of a patient post-MI.
The Fourier transform X(f) of a continuous time function x(t) can be expressed as
The inverse transform is
The Discrete
Fourier Transform is given by
![]()
where
![]()
where,
x(nT) is the
discrete time signal in the
time domain, and
X(mF)
is the discrete frequency
domain function that
represents the time domain
signal
A short discussion of about electrocardiograms: the action potential and heart contractions
Under Construction - more to come