How is the high-pass filter with a cutoff frequency of 0.05 Hz(or 0.2 Hz or 0.5 Hz) implemented in Real time for ECG devices?
What kind of filter or algorithm is used?
The order of FIR filter is high. Is an IIR filter used? Does the IIR filter cause distortion?
Thanks for your help

  • $\begingroup$ General remark: the complexity and delay a filter needs to have is not given by the cutoff frequency, but by the inverse of how narrow the transition between pass band and stop band is, and by how strong the stop band attenuation is. You need to consider these two key specifications of the filter, not the cutoff. $\endgroup$ Commented Jan 7, 2023 at 10:08
  • $\begingroup$ And if your filter is digital, the sampling rate is paramount to defining the complexity. $\endgroup$ Commented Jan 7, 2023 at 10:10
  • 1
    $\begingroup$ @Hamidof. Perhaps the material at the following web site could be useful to you: dsprelated.com/showarticle/1383.php $\endgroup$ Commented Jan 7, 2023 at 13:28

1 Answer 1


First Order IIR DC Nulling Filter

A high pass filter with a very low cut-off frequency is commonly referred to as a "DC Nulling Filter" where the interest is in removing the average offset or long term drift in the signal. This can be implemented easily as a first order IIR filter with the following structure where a zero is placed at $z=1$ and a pole at $z=\alpha$ where $\alpha$ is a gain constant with $\alpha<1$. The closer $\alpha$ is to $1$, the lower the cutoff frequency.

$$H(z)= \frac{1+\alpha}{2}\frac{z-1}{z-\alpha}$$

DC Nulling filter

The multiplier constant $\frac{1+\alpha}{2}$ is just to normalize the gain to 1 and can be excluded if the slight gain offset is of no concern (as $\alpha$ approaches $1$, so does $(1+\alpha)/2$). As $\alpha$ gets closer to 1, the more digital precision is needed to keep that pole inside the unit circle (stability) and minimize error in cut-off frequency selection.

As derived in this post, the bandwidth for the first DC nulling filter is as follows (that post uses $\omega_c/2$ since it is describing there the bandwidth of a 2nd order notch filter):

$$\omega_c = \cos^{-1}\frac{2\alpha}{\alpha^2+1}$$

And to get $\alpha$ from a target bandwidth:

$$\alpha = \sec(\omega_c) - \tan(\omega_c)$$

For very high $\alpha$ values close to $1$, the above simplifies conveniently to $\alpha \approx (1-\omega_c)$.

Where $\omega_c$ is the 3 dB cutoff frequency in units of radians/sample (normalized by the sampling rate). As the sampling rate increases, $\omega_c$ gets proportionally smaller and thus increases $\alpha$ for a given target cutoff frequency in units of Hz, and with that, the precision needed in implementation. It is to our advantage to use the lowest acceptable sampling rate.

As an IIR filter, this structure will introduce phase distortion (called group delay distortion) but that will be insignificant at frequencies well above the cutoff frequency as demonstrated in the example below. The tighter the cutoff, the greater the delay distortion will be in vicinity of frequency cutoff and below.

Linear Phase DC Nulling Filter

If this distortion is of actual concern, Rick Lyons has detailed some nice solutions here for linear phase DC Nulling Filters which can be implemented at the expense of longer delay lines (and longer delay overall).

Example of the First Order IIR DC Nulling Filter

According to this link, a 500 Hz sampling rate would be more than adequate for ECG. A 0.05 Hz cutoff with a sampling rate of 500 Hz would result in a cutoff frequency of:

$$\omega_c = 0.05/500 = 0.0001 \text { rad/sample}$$

Using the equation above for $\alpha$ we get

$$\alpha = \sec(0.0001) - \tan(0.0001) \approx 0.9999$$

(Confirming the $(1-\omega_c)$ approximation is more than adequate.)

The resulting frequency response is plotted below:

Frequency Response

And from a plot of the Group Delay (in samples) we see that the distortion is minimal for all frequencies above 1 Hz:

Group Delay

  • 1
    $\begingroup$ One of the things you might have to worry about, Dan, is the coefficient quantization and word length and limit cycles (getting stuck on a non-zero DC value due to roundoff), especially if this is fixed-point. $\endgroup$ Commented Jan 8, 2023 at 3:40
  • 1
    $\begingroup$ Even with single precision floating point, there is a limit to how close $\alpha$ can get to 1. $\endgroup$ Commented Jan 8, 2023 at 3:42
  • $\begingroup$ @robertbristow-johnson Indeed! all good points and nice link on error shaping that you wrote! I was just reading Jon Dattoro's paper on such error shaping for 2nd order biquads. (ccrma.stanford.edu/~dattorro/HiFi.pdf) $\endgroup$ Commented Jan 8, 2023 at 4:08
  • 1
    $\begingroup$ That very same issue of JAES (Nov 1988) was my very first published paper. $\endgroup$ Commented Jan 8, 2023 at 4:16
  • $\begingroup$ @robertbristow-johnson nice mug of you at the end of that paper. $\endgroup$ Commented Jan 8, 2023 at 4:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.