3

Given a known signal $ x \left( t \right) $ and its delayed version $ y \left(t, \tau \right) = x \left( t - \tau \right) $.
Both are sampled by Sampling Frequency $ {F}_{s} $ to generate the signals $ x \left[ n \right] $ and $ y \left[ n \right] $.

Assume they are sampled on a time support much larger than their non zero time (Namely, the whole part of the signal where it is not vanished is sampled).

Given those 2 sampled signals, using Cross Correlation (Matched Filter) the Delay Parameter $ \tau $ can be estimated.

Yet, its estimation is limited to the grid defined by the sampling Frequency which means if $ \tau < {T}_{s} = \frac{1}{{F}_{s}} $ the estimation isn't accurate (Actually, the part which is the modulo of the time interval can't be estimated).

Is there an effective method to estimate the delay in Sub Sampling resolution?

Thank You.

Royi
  • 19,608
  • 4
  • 197
  • 238
Haider
  • 97
  • 1
  • 9
  • This is either too broad or too simple. What don't you understand about finding the maximum value? – Peter K. Sep 14 '15 at 12:18
  • Please edit your question to add the details. It's too hard to read here in the comments, and may be missed by other DSP.SE readers. – Peter K. Sep 14 '15 at 13:09
  • Dear Peter,I have edited the question.Please see it. – Haider Sep 14 '15 at 13:12
  • How is this different from all your other questions? – Peter K. Sep 14 '15 at 13:15
  • Actually I just want to know is there any built in function to find the exact value of lag or i have to use interpolation or approximation.Please comment. – Haider Sep 14 '15 at 13:17
  • I think it would have been better for you to have edited one of your existing questions instead of posting what is now something like your fifth or sixth copy of the same question (counting deleted/merged ones.) – JRE Sep 14 '15 at 14:33
  • Jamil: Please STOP asking the same question again and again. Please edit this question to try to get the information you (and we) are looking for. – Peter K. Sep 21 '15 at 14:32
  • @JamilHayder, Are you trying to estimate the delay using a correlation between two signals? Are you using the Matched Filter or just arbitrary filtering? I think you really should edit your question to be more clear. Thank You. – Royi Sep 22 '15 at 08:18
  • @Drazick Yes.I am trying to find delay between two signals using cross correlation.I did not use any filter .My first signal is x1 and other is p (obtained by giving sub sampling shift of 90.1344 in x1).Now I want to find delay between x1 and p using cross correlation. – Haider Sep 22 '15 at 08:29
  • :Facepalm: I give up. What is wrong with the answers the other folks posted? What is wrong with the method you YOURSELF posted as an answer? Was fehlt damit Sie endlich mit einem Antwort zufrieden sind? – JRE Sep 22 '15 at 08:56
  • @JRE I am sorry I think I am unable to explain my question.I do not understand how to make it more clear :( :( – Haider Sep 22 '15 at 10:14
  • @Drazick: He already has answered this question in one of the numerous duplicates. He has received answers that give him the same info, and yet he keeps asking the same question. It seems someone has cleaned up (deleted) the duplicates. – JRE Sep 22 '15 at 12:07

4 Answers4

4

Since the Matched Filter is used the Cross Correlation becomes "Auto Correlation" which is assured to be "Symmetric" relative to its maximum.

Hence a good approximation would be to approximate the area around the sampled peak by a Symmetric Function as a parametric model of the function.

The most trivial and easiest model for such function would be the Parabolic Function which is illustrated in the following.

Here's some scilab code that does the cross-correlation and then finds the inter-sample peak by doing a simple (ish) parabolic interpolation.

The plot shows the absolute relative error between the truth and the estimate.

Absolute relative error

// 25684
vals= [];
taus = [-0.5:.005:0.5] + 10^-9; // Add a small amount to not have a zero.

for tau = taus

    N = 1000;
    t = 0:N-1;
    omega=0.1902834909;
    phi = 2*%pi*0.3823483924;

    x = sin(omega*t + phi);
    x_tau = sin(omega*(t-tau) + phi);

    xc = xcorr(x_tau,x);

    [mx,ix] = max(xc);

    x_vals = [-1 0 +1];
    y_vals = xc(ix + x_vals);

    //https://stackoverflow.com/a/717791/12570
    den = (x_vals(1) - x_vals(2))*(x_vals(1) - x_vals(3))*(x_vals(2) - x_vals(3));
    A = x_vals(3)*(y_vals(2) - y_vals(1)) + x_vals(2)*(y_vals(1) - y_vals(3)) + x_vals(1)*(y_vals(3) - y_vals(2))
    A = A/den;

    B = x_vals(3)^2*(y_vals(1) - y_vals(2)) + x_vals(2)^2*(y_vals(3) - y_vals(1)) + x_vals(1)^2*(y_vals(2) - y_vals(3));
    B = B/den;

    C = x_vals(2) * x_vals(3) * (x_vals(2) - x_vals(3))* y_vals(1) + x_vals(3) * x_vals(1) * (x_vals(3) - x_vals(1))* y_vals(2) + x_vals(1) * x_vals(2) * (x_vals(1) - x_vals(2))* y_vals(3);
    C = C/den;

    x_v = -B / (2*A);
    y_v = C - B*B / (4*A);

    vals= [vals; tau x_v y_v];

end 

clf
plot(taus,abs((vals(:,2)' - taus)./taus));
xlabel('True value of delay');
title('Error in using parabola peak as subsample delay estimate');
Peter K.
  • 25,714
  • 9
  • 46
  • 91
  • You "stole" my answer :-). Anyhow, great link at - http://stackoverflow.com/a/717791/12570. – Royi Sep 22 '15 at 12:38
  • :-) Mea culpa, mea culpa, mea maxima culpa. :-) @Drazick – Peter K. Sep 22 '15 at 12:40
  • Added suggested edit to the answer, now it is just what I wanted (Minus the MATLAB instead of Scilab). – Royi Sep 22 '15 at 12:45
  • Feel free to improve! I've made it community wiki, so that I won't hog any rep. – Peter K. Sep 22 '15 at 12:47
  • @Drazick Thanks a lot i will go through this and then respond .Thank you for posting this explanation. – Haider Sep 22 '15 at 12:54
  • @Drazick Thanks for the information.One question please.In above code how you decide the values in x_vals. In the code you took x_vals = [-1 0 +1]; If we have different signals what should be values in x_vals.Is the same method can be used if the fractional delay is greater than 1 samples i.e lets say 89.1344.Thank in advance! – Haider Sep 23 '15 at 08:20
  • @Haider, Chose the peak of the Cross Correlation. Now, take one sample to the left, one sample to the right. You can chose 2 samples to the left or to the right if the sampling frequency is high. You take more samples and use Least Squares. The guiding rule is being symmetric around the peak of the Cross Correlation. – Royi Sep 23 '15 at 08:47
  • @Drazick Thanks for the response.I will do that. – Haider Sep 23 '15 at 08:49
  • @Drazick ,Please do not mind if i say some thing silly.I have two signals x and y2 .Plz. see below.Using your code (given above) how I can find the delay between x and y2. I dont mean that you should write code but just a little hint.Actual delay is 76.968 samples I am sorry if said some thing stupid.Thanks in advance. t=010^-9:410^-9:15010^-9; fc=510^6; xi=sin(2pifct); yi=15410^-9:410^-9:200010^-9; y=yi*0; x=[xi y]; delay=76.968094834192172; y2=fshift(x,delay); – Haider Sep 23 '15 at 12:27
  • Find the peak: [mx,ix] = max(xcorr(x,y2)); If there is zero delay between the two, ix will be 500. For the example you give, I get ix=423 so the delay is 77 samples. Center on ix=423 and use indices 422, 423, and 424. Bingo, you have the fractional part of the delay using the code. – Peter K. Sep 23 '15 at 13:21
  • @PeterK. Thanks for your response I will do this in my code and see.Thanks a lot! – Haider Sep 23 '15 at 13:59
  • @PeterK.Thanks for your reply.I have run the code and the value of x_v is 423.164... .So the fractional delay would be 76.8353..? And actual delay was 76.9680948..Is the difference between actual and calculated delay ( 0.1327...) is because of interpolation or am I making some mistake? Just need confirmation please.Please forgive me if I mentioned some thing wrong.Thanks! – Haider Sep 23 '15 at 14:21
  • @PeterK. Do I have to use indices 422 ,423 and 424 in the vector x_vals = [-1 0 +1];(in the code). I mean should I use 422 ,423 and 424 in place of -1 , 0 and +1? Please help.Thanks – Haider Sep 23 '15 at 14:29
  • If you're not worried about how the estimate is achieved, just do: possible_delays = floor(delay)+[-1:.001:1];for estimate = possible_delays err = [err sum(abs(y2-fshift(x,estimate)))]; end; [mn,ix] = min(err); possible_delays(ix) – Peter K. Sep 23 '15 at 14:32
  • I'd just use [-1 0 +1]. All you're really interested in is either side of the peak. The actual x values should not matter. – Peter K. Sep 23 '15 at 14:33
  • @PeterK.I am so sorry to interrupt you.Kindly can you respond to my message in chat please.It would be really nice of you.Please forgive me if said some thing stupid in my message.Thanks in advance. – Haider Sep 24 '15 at 12:42
  • @Haider: Done!! – Peter K. Sep 24 '15 at 13:09
  • @PeterK.I am so sorry to disturb you.Please do not mind.Can you have a look onto my last comment in chat please.Thanks in advance. – Haider Oct 01 '15 at 09:04
  • @PeterK.Hi Peter,I am sorry to disturb you,Kindly can you read my last comment in chat please.I would much appreciate it.Thanks in advance. – Haider Oct 14 '15 at 12:19
  • @PeterK.Kindly can you read my last comment in chat please.I am really thankful to you.Would be really nice if you respond please.Thanks in advance – Haider Oct 19 '15 at 10:46
  • @PeterK. I am sorry again.Kindly it would be really nice if you have a look onto my last comment please.Thanks in advance! – Haider Oct 19 '15 at 14:20
3

Because a shift in time manifests itself as a phase angle shift in the frequency domain, perhaps comparing the spectral phase of the DFT of x(n) and the spectral phase of the DFT of y(n) would be useful. Just a thought.

Richard Lyons
  • 5,777
  • 13
  • 25
1

As the question as been focused, I edit the answer in a three-fold way:

One first approach consists in (somehow) compensating the unknow delay, by applying the initial algorithm for several delays, and in comparing results. This can be done brute force or with optimization loops. One frequent filter design for such a task is known as the Thiran Allpass Interpolators. A Matlab implementation is given at: Thiran Allpass Interpolation in Matlab. A reference paper is J.-P. Thiran, Recursive digital filters with maximally flat group delay, 1971, IEEE Transactions on Circuits Theory.

A second approach may consist in finding a more invariant transformation. The phase suggested by @Richard Lyons is a very good option, since several Fourier transforms possess nice shift/time invariant properties. The two above methods can be extented with GCC or Generalized Cross Correlation, a link with nice background references (like Optimum Estimation of Time Delay by a Generalized Correlator, IEEE Trans. Acoustics, Speech and Signal Processing, 1979). They can also be merged, for instance with GCC-PHAT Cross-Correlation, including phase information.

Invariance is indeed a neat concept, and may be used as well using other signal properties (or non-properties). If the process under consideration is quite stationary, you can get good results with the methods above, up to an integer number of periods if the signal is periodic.

In the case the data is unstationary, has amplitude variations, gets noisy, other methods, or combinations, can be useful. Wavelets can deal with unstationarity. Some are quite shift-invariant. Some others are complex and provide local phase information.

I would suggest a combination of continuous complex wavelets and correlation, such as the one proposed in Time Delay Estimation Using Wavelet Transform for Pulsed-Wave Ultrasound, Annals of Biomedical Engineering, 1995. Other reference? On Wavelet Denoising and its Applications to Time Delay Estimation, IEEE Transactions on Signal Processing, 1999.

A careful reference analysis or the above mentioned concepts may provide you with other useful insights.

My personal experience is not global. It is mostly based on image processing experience, and a work on local delay adaptation for adaptive pattern subtraction in seismic data, using complex wavelets and very short one-tap (unary) complex phase filters, which proved to work quite well.

Laurent Duval
  • 31,850
  • 3
  • 33
  • 101
1

You can interpolate samples at fractional positions by using a high quality interpolation function or kernel, such as a wide enough windowed Sinc kernel.

hotpaw2
  • 35,346
  • 9
  • 47
  • 90