7

I have an output signal $y$ which is an input signal $x$ convolved $\star$ with an impulse response function $h$ with some added noise $n$ :

$$y(t) = h(t) \star x(t) + n(t)$$

I know the input signal $x$ and output signal $y$ and would like to calculate $h$ the impulse response function. I found that deconvolution is not as straightforward as convolution because the input signal contains zeros and then division in the frequency domain would not be defined. Looking around the internet for ways to "deconvolve" if found two methods: Wiener deconvolution and regularized deconvolution. The Wiener deconvolution seemed easier to understand so I wanted to try and implement it in Matlab (the Matlab function deconv gives me errors about the input signal having a zero at the first entry and if I read the help file it only seems to work correctly for polynomials?).

So per the Wikipedia - Wiener Deconvolution explanation you want to find $g$ so that:

$$\hat{x}(t) = g(t) \star y(t)$$

But then in the definition of how to calculate $G$ they use all variables in the original equation. Also they only show how to find $x$ but probably $x$ and $h$ can be exchanged because convolution is commutative, but I'm unsure about the correct length of both vectors. Currently they are the same length.

$$G(f) = \frac{H^*(f) S(f)}{|H(f)|^2 S(f) + N(f)}$$

where:

  • $H = {\tt fft}(h)$
  • $G = {\tt fft}(g)$
  • $S =$ power spectral density of $x$ ? is this ${\tt fft}(x)$?
  • $N = $mean power spectral density of $n$, don't really understand what this is

My question is how do I get the impulse response function $h$ without already knowing it (as it is both in the definition of $G$ and in the original equation)? Since I know both input and output it should not be very different from finding the input with a known impulse response function. I want to do this in Matlab.

lennon310
  • 3,590
  • 19
  • 24
  • 27
Leo
  • 432
  • 7
  • 15
  • 3
    Wiener deconvolution assumes that the input signal is unknown and that the impulse response is known. In your case the opposite is true, so you just need to exchange the roles of $h(t)$ and $x(t)$, as you've already suggested. Basically, you just need a standard Wiener filter with an input signal $x(t)$ and a reference signal $y(t)$. The filter will minimize the MSE between its output and the reference signal. – Matt L. Nov 05 '14 at 10:11
  • 2
    Related question - http://dsp.stackexchange.com/questions/26433/use-matlab-to-restore-the-signal-from-a-given-degraded-signal-using-tikhonov-reg. – Royi Oct 22 '15 at 05:46
  • 1
    To use the most basic form of Weiner Deconvolution use this MATLAB function. deconvwnr does not require any sort of toolbox and computes 1D, 2D and 3D deconvolutions. – SDG Feb 14 '16 at 13:25
  • 1
    This seems more like a system identification problem (finding $h$ given $x$ and $y$) than a deconvolution problem (finding $x$ given $y$ and $h$). – Peter K. Apr 12 '16 at 11:59
  • @PeterK. Should I use a different approach for that case? It looks very similar to me. Maybe I should add that I usually work with images and my point spread function would be the 'impulse response'. – Leo Apr 12 '16 at 16:14
  • Are those 1D Signals? Do you have access to $ x \left( t \right) $? @PeterK. if $ x \left( t \right) $ is unknown, since Convolution is Commutative there is no difference between looking for the filter or the image (Given the proper statistics information, namely the filter is also stochastic or things like that). – Royi Apr 13 '16 at 06:20
  • @Drazick : Understood! I just think it opens up a whole other class of algorithms other than Wiener filtering that the OP might gainfully use. – Peter K. Apr 13 '16 at 11:13
  • I'm trying to understand if he has access to $ x \left( t \right) $ (LMS). Otherwise it is indeed Blind System Identification. Which given the Filter "Probabilistic" assumption the Wiener Filter can be used. – Royi Apr 13 '16 at 16:32
  • Yes I know the input signal 'x(t)' and output signal 'y(t)' – Leo Apr 14 '16 at 11:34
  • 1
    I am having exactly the same question you had here. I have inout and output but want impulse response. What did you end up doing? Thanks – Atra Es Nov 03 '16 at 04:40
  • This was a long time ago, I`m not exactly sure any more. I remember I was interested in this both for work (medical images) and hobby (astrophotography). For photography I both ended up using photoshop (which has a built-in tool for deconvolution) and trying some specific software I found online. For work I dont remember I pursued it, perhaps because my data was already pretty good without deconvolution. Still should be possible as people above have stated. – Leo Nov 03 '16 at 09:00
  • I believe I have answered it in other related question http://dsp.stackexchange.com/a/38325/27237 – Ozcan Mar 13 '17 at 13:25

1 Answers1

5

This is a nice question.
I will try solving it using 2 approaches (Which are basically the same).

The solution is the Least Squares Solution:

$$ \hat{h} = \arg \min_{h} \frac{1}{2} \left\| h \ast x - y \right\|_{2}^{2} $$

We assume data is given in finite discrete form (As it is in practice).
The convolution is done in valid mode (Like in MATLAB valid property).

Direct Solution

One could write the above as:

$$ \hat{h} = \arg \min_{h} \frac{1}{2} \left\| X h - y \right\|_{2}^{2} $$

Basically using the commutative property of the convolution one could the above as $ x $ was the filter and hence build a Convolution Matrix from $ x $.

Now, the solution is the usual Least Squares:

$$ \hat{h} = \arg \min_{h} \frac{1}{2} \left\| X h - y \right\|_{2}^{2} = \left( {X}^{T} X \right)^{-1} {X}^{T} y $$

Pay attention that for long signals the matrix is huge.
Hence this method is practical only for small signals.

Iterative Solution

Well, one could use the Gradient Descent Method to minimize the cost function:

$$ f \left( h \right) = \frac{1}{2} \left\| h \ast x - y \right\|_{2}^{2} $$

The Gradient is given by (Correlation is the Adjoint Operator of Convolution):

$$ \frac{d}{d h} f \left( h \right) = \left( h \ast x - y \right) \star h $$

Where $ \star $ stands for Cross Correlation.

In MATLAB Code it is given by:

hObjFun = @(vH) 0.5 * mean( (conv2(vX, vH, 'valid') - vY) .^ 2 );
vG      = conv2(flip(vX, 1), (conv2(vX, vHEst, 'valid') - vY), 'valid');

Where all data is in Column Vector (The conv2() is used as it is faster since conv() is just a wrapper around it).

This method is fast and not limited by the size (Or less, to be accurate).

enter image description here

The full MATLAB Code is in my StackExchange Signal Processing Q18993 GitHub Repository (Look at the SignalProcessing\Q18993 folder).

Royi
  • 19,608
  • 4
  • 197
  • 238