The Removal of 50/60Hz powerline interference from delicate information rich ECG biomedical waveforms is a challenging task! The challenge is further complicated by adjusting for the effects of EMG, such as a patient limb/torso movement or even breathing. A traditional approach adopted by many is to use a 2nd order IIR notch filter:

\(\displaystyle H(z)=\frac{1-2cosw_oz^{-1}+z^{-2}}{1-2rcosw_oz^{-1}+r^2z^{-2}}\)

where, \(w_o=\frac{2\pi f_o}{fs}\) controls the centre frequency, \(f_o\) of the notch, and \(r=1-\frac{\pi BW}{fs}\) controls the bandwidth (-3dB point) of the notch.

What’s the challenge?

As seen above, \(H(z) \) is simple to implement, but the difficulty lies in finding an optimal value of \(r\), as a desirable sharp notch means that the poles are close to unit circle (see right).

In the presence of stationary interference, e.g. the patient is absolutely still and effects of breathing on the sensor data are minimal this may not be a problem.

However, when considering the effects of EMG on the captured waveform (a much more realistic situation), the IIR filter’s feedback (poles) causes ringing on the filtered waveform, as illustrated below:

Contaminated ECG with non-stationary 50Hz powerline interference (IIR filtering)

As seen above, although a majority of the 50Hz powerline interference has been removed, there is still significant ringing around the main peaks (filtered output shown in red). This ringing is undesirable for many biomedical applications, as vital cardiac information such as the ST segment cannot be clearly analysed.

The frequency reponse of the IIR used to filter the above ECG data is shown below.

IIR notch filter frequency response

Analysing the plot it can be seen that the filter’s group delay (or average delay) is non-linear but almost zero in the passbands, which means no distortion. The group delay at 50Hz rises to 15 samples, which is the source of the ringing – where the closer to poles are to unit circle the greater the group delay.

ASN FilterScript offers designers the notch() function, which is a direct implemention of H(z), as shown below:

ClearH1;  // clear primary filter from cascade
ShowH2DM;   // show DM on chart

interface BW={0.1,10,.1,1};


Num = getnum(Hd); // define numerator coefficients
Den = getden(Hd); // define denominator coefficients
Gain = getgain(Hd); // define gain

Savitzky-Golay FIR filters

A solution to the aforementioned mentioned ringing as well as noise reduction can be achieved by virtue of a Savitzky-Golay lowpass smoothing filter. These filters are FIR filters, and thus have no feedback coefficients and no ringing!

Savitzky-Golay (polynomial) smoothing filters or least-squares smoothing filters are generalizations of the FIR average filter that can better preserve the high-frequency content of the desired signal, at the expense of not removing as much noise as an FIR average. The particular formulation of Savitzky-Golay filters preserves various moment orders better than other smoothing methods, which tend to preserve peak widths and heights better than Savitzky-Golay. As such, Savitzky-Golay filters are very suitable for biomedical data, such as ECG datasets.

Eliminating the 50Hz powerline component

Designing an 18th order Savitzky-Golay filter with a 4th order polynomial fit (see the example code below), we obtain an FIR filter with a zero distribution as shown on the right. However, as we wish to eliminate the 50Hz component completely, the tool’s P-Z editor can be used to nudge a zero pair (shown in green) to exactly 50Hz.

The resulting frequency response is shown below, where it can be seen that there is notch at exactly 50Hz, and the group delay of 9 samples (shown in purple) is constant across the frequency band.

FIR  Savitzky-Golay filter frequency response

Passing the tainted ECG dataset through our tweaked Savitzky-Golay filter, and adjusting for the group delay we obtain:

Contaminated ECG with non-stationary 50Hz powerline interference (FIR filtering)

As seen, there are no signs of ringing and the ST segments are now clearly visible for analysis. Notice also how the filter (shown in red) has reduced the measurement noise, emphasising the practicality of Savitzky-Golay filter’s for biomedical signal processing.

A Savitzky-Golay may be designed and optimised in ASN FilterScript via the savgolay() function, as follows:

ClearH1;  // clear primary filter from cascade

interface L = {2, 50,2,24};
interface P = {2, 10,1,4};


Hd=savgolay(L,P,"numeric");  // Design Savitzky-Golay lowpass


This filter may now be deployed to variety of domains via the tool’s automatic code generator, enabling rapid deployment in Matlab, Python and embedded Arm Cortex-M devices.



Download demo now


Licencing information


Generations have been entertained by the gadgets and future technology portrayed in Sci-fi series, such as Star Trek, but is it all science fiction?

The Tricorder

One device that intrigued me for years was the so called ‘Tricorder’ and the ability for the doctor to read a person’s vital life signs or VLS (e.g. heart beat and respiration) with a handheld device from about a metre away.

Back to the 21st century!

With advances in radar technology over the last few years, a few chip manufacturers are now producing affordable radar devices suitable for biomedical VLS measurement. Radar technology that used to cost thousands of Euros, and was primarily aimed a military technology, is now available for a few hundred Euros, making it viable for home medical products.

Sounds great, but what can UWB (ultrawide band) pulse doppler radar do?

  • millimetre accuracy: allowing for detection of the smallest changes, such as respiration and heart rate from several metres away.
  • Penetrates duvets, blankets and clothes: The virtue of the small wavelength ensures accurate detection of humans in a bed or sitting in chair watching TV or reading a book.
  • Penetrates Walls and doors: Tracking of VLS and movement when radar is mounted within a ceiling or behind a wall – no ugly module on the wall!
  • High sensitivity: able to see the VLS from tiny premature babies.
  • Ultra-safe technology: RF emission is 0.01% the energy typically found in a household WiFi router – meaning that prolonged exposure will have no detrimental effects on human health.

After receiving a request from a client about monitoring the health of an eldery person living alone or in a nursing home, we decided to conduct a few tests of our own to see what was possible with this new technology.

VLS of a subject lying in bed

After building a demonstrator, and placing the radar sensor about 1 metre from a subject sleeping (similar to the doctor in Star Trek), we obtained the following waveform:

Captured VLS data captured from a UWB radar – containing both heart beat and respiration information

Wow! Was our initial reaction to the test data – this is millimetre movement through a duvet! Notice how slow the biomedical signal is, as an average adult’s respiration rate at rest is about 12bpm, requiring relatively long data acquisition times (tens of seconds) for meaningful data analysis.

What’s the respiration and heart beat?

Passing the signal through our algorithm, we could easily estimate the respiration (RR) and heartbeat (HB) from the plot (see the two red squares on the two peaks). However, in order to be objective, we attached a clip-on pulse oximeter to the subject finger, and as seen they matched very well.

What does this all mean for me?
Contactless VLS measurement for home use is closer than you think, and is certainly not science-fiction anymore. This technology opens up many possibilities for monitoring when normal sensors are infeasible, such as premature babies, patients with dementia and even sleep trend analysis. We’ll improve our algorithm in order to make it more robust and faster, but as seen our results are very promising indeed, and open up the possibility of contactless vital life signs (VLS) measurements for many practical applications!