EDR/DTW Only stretch one signal
Show older comments
I am working with ultrasound signals that are affected by a temperature change, I would like to use EDR/DTW (or whatever is most appropriate) to re-align the temperature shifted signal with a baseline signal, so that I can use subtraction methods to compared changes in amplitude between the two signals.
The problem with EDR/DTW is that both signals are stretched, I would like to only stretch the second signal (120°C), so that when I apply this transform to other signals the baseline signal (20°C) is always unaffected.
You can see the stretching of both signals in the following example code (data attached):
M1 = readmatrix("example_data.csv");
A1 = M1(8:end,:);
Time = A1(:,1);
S0_20C = A1(:,2);
S0_120C = A1(:,3);
[dist,ix,iy] =edr(S0_20C,S0_120C,0.001);
hold on
grid on
plot(S0_20C)
plot(1:numel(ix),S0_20C(ix),'.-', ...
1:numel(iy),S0_120C(iy),'.-');
legend('Original 20C', 'EDR 20C','EDR 120C')
Any suggestions are appreciated.
Answers (1)
Prathamesh
on 1 Aug 2025
I understand that the you are working with ultrasonic sounds and would like to use ‘EDR/DTW’ to re-align the temperature shifted signal with a baseline signal. But the problem with ‘EDR/DTW’ is that both signals are stretched, but you want to only stretch the second signal (120°C), so that when you apply this transform to other signals the baseline signal (20°C) is always unaffected.
To align your 120°C signal to the 20°C baseline without altering the 20°C data, follow these steps:
- Calculate the warping path between the two signals using the ‘dtw’ function.
[~, path_20C, path_120C] = dtw(S0_20C, S0_120C);
- Create the warped 120°C signal by interpolating the original 120°C data onto the 20°C timeline.
warped_S0_120C = interp1(Time(path_20C), S0_120C(path_120C), Time, 'linear');
- You can now use ‘S0_20C’ (your fixed baseline) and ‘warped_S0_120C’ for plotting and subtraction.
Refer below documentation link :
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!