# Correlation between a signal segment and its stretched replica

In my application the measurements are affected by temperature and the signal is stretched over time, though preserving relatively similar structure.

I want to find incremental stretching between pairs of consecutive signals. Having a pair of signals, I divide the first into N segments (windows) and for each window I want to find it's shift and new length in the next signal.

I tried to estimate these incremental shifts with peak detection, but got low accuracy estimates, probably due to the stretching effects on the waveform structure.

In addition, I was advised to try Dynamic Time Warping algorithm, but it manipulates both signals to find the minimal Euclidean distance. In my case I would want only the first segment to be warped until it correlates perfectly with some waveform in the 2nd signal. Couldn't find the way to do so with DTW.

• Can you please explain a bit more about the source of these signals (if possible) and what does this "warping" mean in your specific application? – A_A Aug 14 at 10:06
• look at (google) cross ambiguity function if the stretch is affine – Stanley Pawlukiewicz Aug 14 at 12:07
• @A_A the source is from ultrasonic transducer. What you see in the graphics is the temperature influence on the backscattering echoes – Alex Z Aug 15 at 14:38
• @AlexZ Can you post these two signals on Pastebin? Have you tried DTW already? – A_A Aug 15 at 14:55
• @A_A yeah, I've posted them on pastebin, please see the link below pastebin.com/u/LexZ . Regarding the DTW, as I wrote it manipulates both signals. I have tried it, but it stretched both signals to match between them and the euclidean distance it provided didn't make any sense... – Alex Z Aug 16 at 18:21

If I understand your problem correctly, let us say $$S_1$$ and $$S_2$$ is the pair of signals, where, $$W_1$$ is the window segment from original signal and $$S_2$$ is the stretched version of the original signal. Since you do not know the stretching factor, you can only vary it over a reasonable range and check the auto correlation values. For each stretching factor $$\Delta$$ ($$\Delta \gt 1$$), you need to get the correlation of $$W_1 S_2^*$$. You can vary $$\Delta$$ over a reasonable range in steps to record peak of each auto-correlation. The value which gives you maximum should be the stretching factor you are looking for.