Filtering low frequencies using a High Pass Filter does not seem to work

1k Views Asked by At

I am trying to implement an algorithm from a research paper where we use accelerometers for detecting activity patterns. The authors mention in the paper that use a High Pass Filter with a cutoff frequency of 1Hz to remove the effect of low frequency gravity components which I have applied on my dataset with x,y,z accelerometer values like this

sos = signal.butter(1, 1, 'highpass', output='sos', fs=12.5, analog=False)
filtered = signal.sosfilt(sos, segments)

where segments is a numpy array with slices of 50 values (4 second x,y,z values sampled at 12.5Hz). I then make new segments where the each of the values on separate axes are segmented together so e.g. 50 values for x, 50 values for y and so on. I then proceed on to apply a Fast Fourier Transform on these filtered values but no matter whichever segment I choose the highest amplitude is always at 0 Hz leading me to believe that the High Pass Filter is not implemented correctly.

Here's a sample:

freq_data = np.fft.fft(features_segments[0][0])
y = 2/N * np.abs(freq_data[0:np.int(N/2)])

The features_segments[0][0] implies the first segment and the x axis values only which gives a result of

time_signal = np.linspace(0,4,50)
plt.plot(time_signal, features_segments[0][0])

enter image description here

plt.plot(frequency, y)
plt.title('Frequency domain Signal')

enter image description here

This is just one example for every fft that I try to get the 0Hz amplitude is always the highest on the order of 50-100x than the other amplitudes.

0

There are 0 best solutions below