why scipy.signal.filtfilt normalize the result?

280 views Asked by At

I try to filter my time-series data using filtfilt. My original sample ranged from 80 to about 130. The filtered sample ranged from -20 to 30. It seems like the filtfilt function filter the data and normalize it. How could I filter the data but not normalize it?

Orignal sample Filtered sample

The upper image is the original sample, and the lower image is the filtered sample.

I tried this code for filtering.

    def butter_bandpass(lowcut, highcut, fs, order=5):
        nyq = 0.5 * fs
        low = lowcut / nyq
        high = highcut / nyq
        b, a = butter(order, [low, high], btype='band')
        return b, a
    def butter_bandpass_filter(data, lowcut, highcut, fs, order=5):
        b, a = butter_bandpass(lowcut, highcut, fs, order=order)
        y = filtfilt(b, a, data)
        return y

I set band pass from 0.5 to 32.

    trial = butter_bandpass_filter(trial, 0.5, 32, 256, 5)

I am new to signal processing. Thanks in advance for your help!

1

There are 1 answers

0
sizzzzlerz On

You've designed a bandpass filter. As a result, frequencies less than 0.5 are filtered out. This includes the DC component of the input signal. Hence, the output signal, having the bulk of the DC removed, will be centered around 0.