# Large spike at beginning of signal after applying Bandpass filter

Foreword: I am a PhD student and fairly unexperienced with many signal processing and engineering concepts, please be gentle.

I am attempting to filter out a frequency range of 1Hz to 2Hz from a 2.4GHz CSI amplitude signal, however after applying a butterworth bandpass filter I observe a large spike at the beginning of my signal. If I remove the first 100 or so samples from my signal, this has no effect on the spike. I have attempted this using both Python (with scipy's lfilter), and MATLAB (with butter and filter), and have observed the same behaviour in both. I am aware there are variations of these filter methods, however perhaps I do not understand which one I should be using. I am attempting to replicate this work.

The signal is comprised of roughly 60 OFDM subcarriers, which are all plotted in my example.

Where:

• buttOrd = 2
• fcutlow = 1
• fcuthigh = 2
• Fs = 9.7

MATLAB:

[b, a] = butter(buttOrd, [fcutlow fcuthigh]/(Fs/2), "bandpass");
filterSig = filter(b, a, signal);


Python:

b, a = signal.butter(buttOrd, [fcutlow/(Fs/2), fcuthigh/(Fs/2)], "bandpass")
filterSig = signal.lfilter(b, a, signal)


Above: Unfiltered signal.

Above: Filtered signal.

By reducing the range given to the bandpass filter to something much smaller, like 1Hz-1.01Hz, a smaller, consistent signal can be observed. I understand why a smaller range would produce a different response, but I don't understand the specific behaviour I'm observing.

• At the beginning you are seeing the output of the filter before it has converged to your signal and is erroneous data that you can exclude. All filters have delay (and memory). So that initial output is not your signal yet and can be excluded. The tighter your filter the more memory is required and hence the longer the delay- you can use the group delay function in matlab mathworks.com/help/signal/ref/grpdelay.html to easily see what your filter delay is. Nov 25 '19 at 12:13
• Also unless you chose an IIR butterworth filter for specific reasons an FIR filter with least squares (firls) is often a better choice (if post-processing subtract the mean to eliminate the DC and use a least-squares low pass filter design using Matlab firls function). Nov 25 '19 at 12:15