7
$\begingroup$

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.

$\endgroup$
12
  • 3
    $\begingroup$ 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. $\endgroup$
    – Matt L.
    Commented Nov 5, 2014 at 10:11
  • 2
    $\begingroup$ Related question - dsp.stackexchange.com/questions/26433/…. $\endgroup$
    – Royi
    Commented Oct 22, 2015 at 5:46
  • 1
    $\begingroup$ 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. $\endgroup$
    – SDG
    Commented Feb 14, 2016 at 13:25
  • 1
    $\begingroup$ This seems more like a system identification problem (finding $h$ given $x$ and $y$) than a deconvolution problem (finding $x$ given $y$ and $h$). $\endgroup$
    – Peter K.
    Commented Apr 12, 2016 at 11:59
  • 1
    $\begingroup$ 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 $\endgroup$
    – Atra Es
    Commented Nov 3, 2016 at 4:40

1 Answer 1

5
$\begingroup$

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).

$\endgroup$
4
  • 1
    $\begingroup$ Excellent answer, thanks. What is an Adjoint Operator? $\endgroup$
    – Leo
    Commented Sep 25, 2017 at 16:27
  • $\begingroup$ Thank You! You can read here encyclopediaofmath.org/index.php/Adjoint_operator and here en.wikipedia.org/wiki/Hermitian_adjoint. $\endgroup$
    – Royi
    Commented Sep 25, 2017 at 17:50
  • 1
    $\begingroup$ Royi, nice animations! Well done. :-) $\endgroup$
    – Peter K.
    Commented Sep 25, 2017 at 19:47
  • 1
    $\begingroup$ @PeterK., Thank You. For others to use, the animations are created using Animated PNG (APNG) which is much superior to GIF and supported in imgur. I just saved each figure as PNG in MATLAB and used Animated PNG Maker. $\endgroup$
    – Royi
    Commented Sep 26, 2017 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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