Hi Guys,
I am doing beep detection on a signal. The signal has a beep every few seconds, and I am processing the signal in chunks.
To better detect beeps in noisy signals I have this smoothing function:
samples = signal.convolve(samples, [1]*189, 'same')/189
I think this is a moving average filter, and since I am outputting 'same' (I dont want the chunk size to change) I get these artifacts on the edges of my chunks:

So how can I fix this?
Are there any other ways around this issue?
I am doing beep detection on a signal. The signal has a beep every few seconds, and I am processing the signal in chunks.
To better detect beeps in noisy signals I have this smoothing function:
samples = signal.convolve(samples, [1]*189, 'same')/189
I think this is a moving average filter, and since I am outputting 'same' (I dont want the chunk size to change) I get these artifacts on the edges of my chunks:
So how can I fix this?
https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.savgol_filter.html#scipy.signal.savgol_filter seems to be one option?
Another might be to pad with the previous samples, something like this:
| >>> previous = np.random.sample(size=(200,)) |
| >>> samples = np.random.sample(size=(200,)) |
| >>> kernel = np.ones(189)/189. |
| >>> np.convolve(samples, kernel, mode='valid').shape |
| (12,) |
| >>> np.convolve(np.concatenate((previous[-188:], samples)), kernel, mode='valid').shape |
| (200,) |
IIRC I need to keep the output the same size else it screws up my calculations.
Thanks
AL
No comments:
Post a Comment