I am trying to implement a deconvolution-based event detection algorithm in python, but scipy.signal.deconvolve doesn't seem to work in my case. Here is a basic example:
#!/usr/bin/python import numpy as np from scipy.signal import convolve, deconvolve, unit_impulse def event(x, start, a, t1, t2): """Event model based on two-exponent differential. Positional arguments: x - time array start - event start time a - event amplitude t1 - rise tau t2 - decay tau """ y = -np.exp(-(x - start) / t1) + np.exp(-(x - start) / t2) n = a / y.max() res = n * np.array([0 if t < start else i for t, i in zip(x, y)]) return(res) signal = unit_impulse(1000, idx=100) ev = event(np.arange(300), 0, -10, 1, 5) conv = convolve(signal, ev) signal_recovered = deconvolve(conv, ev)
Here, signal_recovered always ends up containing all NaNs, except for the first value, which is Inf. Why does it happen?