1
$\begingroup$

Lets assume I want to apply a matched filter h which is non-symmetric to my signal x and the output is y in matlab:

y=filter(h,1,x);

Now I am interested in comparing the information between my filtered signal yand my input x. For this I want to compensate for the delay of the filter h.

When googling this topic I found the following tutorial which handles linear-phase fir filters. Obviously in such a case the group delay is $\frac{N-1}{2}$ given that the filter has the length $N$.

%this is the example from matlab
delay = mean(grpdelay(h,1,128)); 
x = x(1:end-delay);
y(1:delay) = [];

However, I am aware that the group delay of a non symmetric filter is frequency depending and I am not sure how to proceed to align my signals in time to compare them. As I am interested in real time application the function filtfilter is not applicable.

So my question is, how do I estimate in the best way the time delay to align (sync?) my signals in time given the coefficients of a non-symmetric filter h?

delay = .... h ....? 
x = x(1:end-delay);
y(1:delay) = [];

The desired output should look like the red curve in the following figure

AlignedSignals

Here the signal in blue is the input signal x and in green the filtered signal y. However, I would like to to compensate for the delay of the green signal so that the input and output align in time as in the case of the red curve.

$\endgroup$
  • $\begingroup$ I think the solution lies in your definition of "time delay" of a filter with a delay that depends on frequency. There is no single way to align the input and output signals of such a filter. The question is what you really mean by "align". $\endgroup$ – Matt L. Sep 5 at 7:02
  • $\begingroup$ I edited my question and added a plot. $\endgroup$ – Irreducible Sep 5 at 7:12
  • 1
    $\begingroup$ It looks like cross-correlation should work here. $\endgroup$ – Matt L. Sep 5 at 7:16
  • $\begingroup$ I see, but this would be an approach which works well for offline analysis, however, is there a way, knowing the shape of the non-symmetric filter, to estimate the delay in advance and apply it online? Or is your idea to apply cross-correlation in advance and estimate this delay for later online processing? Would this delay not be dependent on the shape of the input signal? In other words can I generalize the delay from a cross-correlation of one input signal to all kind of input signals? $\endgroup$ – Irreducible Sep 5 at 7:22
1
$\begingroup$

If your filters have a low pass characteristic (which at least the one in your example appears to have), then a possibly useful measure for the delay is the center of gravity of the impulse response:

$$\hat{\tau}=\frac{\displaystyle\sum_nnh[n]}{\displaystyle\sum_nh[n]}\tag{1}$$

For more general impulse responses, other than low pass, you can modify $(1)$ by either taking magnitudes or squares of $h[n]$. Note that $(1)$ is the filter's group delay evaluated at DC.

$\endgroup$
  • $\begingroup$ First of all thank you, first tests indicate that this is a good estimation. Have you any source for this approach where the idea is elaborated? $\endgroup$ – Irreducible Sep 5 at 8:28
  • $\begingroup$ @Irreducible: Great that it seems to work! Well, the center of gravity (center of mass) is of course a very general concept, which can be applied to any function. So I don't have a specific reference right now, but just for your intuition, imagine that $h[n]$ were a probability mass function of some random variable, then $(1)$ would be the expected value. $\endgroup$ – Matt L. Sep 5 at 8:42
  • $\begingroup$ Thanks for the additional interpretation. $\endgroup$ – Irreducible Sep 5 at 9:30

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.