TransWikia.com

Weird ringing at signal start and end for default Matlab lowpass filter

Signal Processing Asked by Anand Kulkarni on February 19, 2021

**FIND UPDATES BELOW THE ORIGINAL QUESTION TEXT:

I am trying to lowpass filter electrophysiological data and I see ringing near sharp transients at signal start and end.

Ringing at start:
enter image description here

Ringing at sharp transients:
enter image description here

I am simply using Matlab’s default lowpass filter:

fpass=1000;
f_sampling=20000;
fil_X=lowpass(X,fpass,f_sampling);

Two questions:

  1. Why do I see the weird ringing effect at signal start and end?
  2. What strategies can I use for reducing the ringing (both at start/end and at sharp transients) other than reducing the steepness of the filter in the frequency domain? Can some fancy windowing be of help? I tried forcing Matlab to use IIR filter with filtfilt and the ringing stays the same.

Thanks,
Anand

UPDATES:
Padding the signal at start and then removing the padded portion from the filtered trace gets rid of the ringing at start. Thanks!!

For the other problem, I tried an IIR filter without filtfilt. Ignore the unnecessary double filtering. I do it because lowpass automatically applies filtfilt.

[~,ft_obj]=lowpass(X,fpass,f_sampling,'impulseresponse','iir');
fil_X=filter(ft_obj,X); 

Here is what I get:
enter image description here

As you can see, it gets rid of the pre-transient ringing, while introducing post-transient ringing. The post-transient ringing should not be a big issue. But, there is also a signal delay/distortion that becomes clear at the same time point across different conditions (red line). That can shift the absolute and relative timing of events in the signal.

Is there a way to compensate for that?

One Answer

  1. You are using a linear phase filter. These are non causal and hence you get pre-ringing at your transients. Use a minimum phase or IIR filter. Do NOT use filtfilt, since that makes an IIR filter linear phase again and you end up with the same problem
  2. The artifact at the beginning is the step response of the filter. The filter needs access to "past" samples and since it doesn't know what these are, it assumes they are 0. In your case, you have a DC jump and it looks like they are more like -0.05. There multiple work-arounds. In your case it's probable the easiest to pre-pend the signal with a few hundred constant samples that are the average of the first few hundred sample of your signal, filter the whole thing and cut the pre-pended section off again.

Correct answer by Hilmar on February 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP