Initial and end artifacts after applying digital filter (filtfilt)

조회 수: 10 (최근 30일)
I need to filter highly noisy signals (at a sample rate of 2000 Hz).
When applying the code:
[b,a]=butter(order,Fcutoff/(2*Fs),'low');
f_signal=filtfilt(b,a,x);
Where:
order = 2; Fcutoff = 4Hz; Fs = 2000 Hz; x = Non filtered signal as a double vector;
The output filtered signals appear to have (only for some cases) and initial and end artifact, where they tend to deviate upwards or downwards (only at the edges of the filtered signal).
What is the data that is being processed by the filter at the edges?
How can I know how many data points are being used in this process?
Is there a clean way to tackle this problem?
  댓글 수: 1
Mathieu NOE
Mathieu NOE 2020년 10월 23일
hi
these artifacts are sometimes caused by the filtfilt function that do filtering in both direct and reverse time axis (so no phase lag)
try filter instead (this runs the signal only in the causal time direction, but you will get phase alg according to the low pass filter)
i see also that you are focusing on the very low frequency range , while your signal is sampled at 2000 Hz
I woud recommend to decimate your signal (this also apply a low pass filter) so if you have very long data, this will help you speed up your post processing
help decimate
DECIMATE Resample data at a lower rate after lowpass filtering.
Y = DECIMATE(X,R) resamples the sequence in vector X at 1/R times the
original sample rate. The resulting resampled vector Y is R times shorter,
LENGTH(Y) = LENGTH(X)/R.
DECIMATE filters the data with an eighth order Chebyshev Type I lowpass
filter with cutoff frequency .8*(Fs/2)/R, before resampling.

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2020년 10월 23일
In many situations that is caused by the signal having a significant d-c (constant) offset. There are two general ways to deal with it:
(1.) concatenate a constant value vector equal to the mean of the signal of about 10% of the signal length to each end
(2.) subtract the mean of the signal from the signal, and then filter it, then add the mean value of the original signal to the filtered output
Those have both worked for me in the past when I had similar problems.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by