1
$\begingroup$

If I have a set of regularly spaced sample data (spacing $\delta x$) and some of my data is missing (zero) but not at regular intervals, i.e.

$[a_0, (missing), (missing), (missing), a_4, a_5, (missing), a_7, a_8, a_9, a_{10}, ...]$

Can digital signal processing techniques be used to interpolate the missing data?

I've only read of interpolating by a FIR or IIR when the missing data is every nth element.

There is a lot more data present than missing.

The interpolation can be done offline.

The first or last data point(s) might be missing.

$\endgroup$
1
$\begingroup$

If you want to have just a working example, you can consider the functionality of scipy.interpolate:

N = 128
n = np.arange(N)
x = np.sin(2*np.pi*n/32)
plt.plot(n, x)

pos = np.random.randint(N, size=(50,))

x_received = np.delete(x, pos)
n_received = np.delete(n, pos)
plt.stem(n_received, x_received)

import scipy.interpolate

interpolated = scipy.interpolate.interp1d(n_received, x_received, bounds_error=False, kind='cubic')
plt.plot(n, interpolated(n), 's')

enter image description here

This code generates a signal x for n=0,...,127. Then, it deletes some values out of it and interpolates the missing values by spline cubic interpolation. See that the blue vertical lines denote the received samples, the green squares denote the interpolated values. The approximation is quite good.

$\endgroup$
  • $\begingroup$ That looks good enough for my purposes, does it cope with data at the start or end being missing? $\endgroup$ – keith Mar 14 '17 at 12:25
  • $\begingroup$ According to the scipy documentation for interp1d (where the server currently appears to be down for me), there is the parameter fill_value='extrapolate' to yield values outside of the sampling points. It's available after version 0.17 (which I don't have here, so I cannot try this out) $\endgroup$ – Maximilian Matthé Mar 14 '17 at 12:31
  • $\begingroup$ Nice demo @MaximilianMatthé, I didn't realize the scipy interpolate handled this case so well! $\endgroup$ – Dan Boschen Mar 14 '17 at 16:49
2
$\begingroup$

I found a method similar to the zero-padding FFT interpolation but in which the missing samples can be nonuniformly spaced. I think it exactly solves the problem you have. The method is described here:

J. Selva, "FFT interpolation from nonuniform samples lying in a regular grid", IEEE Trans. on Signal Processing, vol. 63, n. 11, June 2015.

The code is available here.

$\endgroup$
1
$\begingroup$

Use inpainting method. Check this question. Inpainting methods also work for 1D signals.

$\endgroup$
  • $\begingroup$ I didn't know about inpainting so that's good to learn, although the technique is a bit computationally heavy for my needs - thanks though. $\endgroup$ – keith Mar 15 '17 at 9:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.