0
$\begingroup$

i am trying to remove the base wander noise from ecg signal, base wander noise is low-frequency artefact of around 0.5Hz , for that i tried a digital butterworth highpass filter: code of filter

frequency response

the ecg signal used is the record 100 from mit bih arrhythmia data base ( record sampled at 360 samples per second), first i read the record using wfdb package and then i applied the filter on it, but the result looks something like this:

code

result

the result looks kinda off. i want to know where is the problem?

$\endgroup$
5
  • $\begingroup$ Hard to tell without having access to the actual signal but it doesn't look unreasonable. What exactly do you think is off? Can you post the signal in some standard format (text, binary or wave)? Why do you design the filter in analog and then use the bilinear transform instead designing directly in the Z-domain ? You are designing a high pass with a cutoff of about 28 Hz. Is that what you wanted ? $\endgroup$
    – Hilmar
    Mar 24 at 11:30
  • $\begingroup$ @Hilmar if believe the cutoff is at 0.5 Hz, since he selected "analog" so the units of frequency are in Hz, right? $\endgroup$ Mar 24 at 13:17
  • $\begingroup$ But he uses 1Hz as the sample rate for the bilinear transform. That makes it the cutoff roughly $f_s/(4\pi)$ $\endgroup$
    – Hilmar
    Mar 24 at 13:44
  • $\begingroup$ @Hilmar what's wrong is that the amplitude got changed, , and i was designing a highpass with frequency of 0.5hz to eliminate the low frequency noise $\endgroup$
    – imene
    Mar 24 at 22:42
  • $\begingroup$ @imene: your code designs a high pass filter at 28Hz, not at 0.5Hz. You don't take into account that your sample rate is 360 Hz $\endgroup$
    – Hilmar
    Mar 25 at 15:07

1 Answer 1

0
$\begingroup$

The OP's result looks reasonable in that the DC offset was removed (average of the waveform which includes the peaks which serve to shift the average upward) as well as all frequency content up to the highpass cutoff of the filter. If there is no concern with losing information in this frequency range (note that the peak to floor is slightly reduced), then the highpass as given would be a reasonable approach. If a much longer dataset is observed, it should be clear that the base wander noise has been significantly reduced, especially if there was an actual drift (as all drift will be eliminated and we will be past the initial transient of the filter-see last paragraph).

Also, instead of selecting 'analog' and then mapping the filter from s to z, we can get the coefficients directly by using the default parameters and entering the sampling rate:

b,a = sig.butter(4, 0.5,'high', fs=360)

Which gives the following result matching the expected 4th order Butterworth response (both approaches are shown with identical results, the difference is this is a log log plot while the OP's has the magnitude not shown in dB as typically viewed):

Result

If the goal was to remove a noise signal at 0.5 Hz and not shift the entire signal (meaning there is no concern with actual drift and the DC value is desired to pass through), note that the current filter only has -3 dB attenuation at 0.5 Hz. Increasing the cutoff frequency would start removing desired signal content, so an alternative approach is a tight notch filter directly at 0.5 Hz to null that frequency with a bandwidth constrained to the actual bandwidth of the noise being removed. I have a link to one such implementation here- for this $a$ is adjusted to the desired bandwidth of the notch as described. The tighter the notch, the tighter the initial transient will be for the filter to reach the desired settled condition. A longer time duration capture will be required; consider the duration required to be on the order of the inverse of the notch width-- so if applying a notch at 0.5 Hz with 0.2 Hz of BW this would require greater than 10 seconds of data which may be prohibitive depending on sampling rate and tolerable delay to see results- this is applicable to the notch and highpass and is the inevitable result of wanting to pass a very low frequency. This would be fine if post processing and sufficient data can be captured. If this is an issue, the upper corner for the high pass could be increased at the expense of removing desired signal if signal content of interest extends lower in frequency. The notch could also be combined with the highpass in cascade for increased nulling at 0.5 Hz in addition to long term drift removal.

Alternatively for the case of post processing, circular convolution techniques can be used (often done with FFT but not naively by just nulling bins) which would be equivalent to setting the initial state of the filter based on the existing values so that no transient occurs. This is analogous to removing DC by taking the average of a complete block of data and subtracting it.

$\endgroup$
2
  • $\begingroup$ It looks like actual signal is 10 seconds long. That makes the high pass filter problematic. It takes over 5 seconds for the attenuation to get down to 60 dB. $\endgroup$
    – Hilmar
    Mar 24 at 12:32
  • $\begingroup$ Right- that is the issue with such a tight rejection (must always trade between time and frequency). This would be the case with any highpass or notch. More bandwidth, faster result but removes more signal. $\endgroup$ Mar 24 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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