Find a portion of a signal using dtw ?

9 ビュー (過去 30 日間)
David Santos
David Santos 2024 年 7 月 19 日
コメント済み: Umar 2024 年 7 月 23 日
I have the two attached signals and I want to know if "ref" is included somehow (time warping could happen) inside "det" signal.
Figure 1 show ref and det signals:
As you can see ref "can fit" inside det (ref is similar to det(1:100) aprox ) so I try to adjust them normalizing signals and using dtw:
refn=ref/max(ref);
detn=det/max(det);
[~, ix ,iy]= dtw(detn,refn);
figure;plot(refn(iy));hold on;plot(detn(ix));
max(normxcorr2(refn(iy),detn(ix)))
Obtaining:
with a normalized correlation of 0.86
I would love to be able to dtw adjust ref signal over det with the nedd of both signal be the same size so the adjust could be better. For example in this case I could have the signals between x=57:204 and get a better correlation (0.99) of both signals:
x=detn(ix);
y=refn(iy);
max(normxcorr2(x(57:204),y(57:204)))
But I'm missing the first part of ref signal (which could fit quita well) and also some samples at the end because dtw always thinks that both signals have to be the same size but I'm looking also for the possibility of being just a fragment of the other.
Any clue on how to get this adjustment of signals when one can be a portion of the other?
All the best
  7 件のコメント
David Santos
David Santos 2024 年 7 月 23 日
Thanks a ot for your answer Umar!
So if I want that signal1 stay unmodified (no warping at all) should I put that constraint to 0?
% Fill the warpPath matrix with constraints
for i = 1:n+m
warpPath(i, 1) = max(1, i-0);
warpPath(i, 2) = min(n, i+constraint);
end
And for the indexes (ix, iy in the matlab dtw function) i Guess It must be obtained from the D matrix but do you know how?
All the best
Umar
Umar 2024 年 7 月 23 日
Hi David,
To keep signal1 unmodified (no warping), you should set the constraint to 0 in the warpPath matrix. By setting warpPath(i, 1) = max(1, i-0) and warpPath(i, 2) = min(n, i+constraint), it will make sure no warping for signal1.
Now, to obtain indexes (ix, iy) from the D matrix in DTW function, you can find the optimal warping path by backtracking through the accumulated cost matrix D. The indexes can be extracted by following the path with the lowest accumulated cost. It sounds like you are making progress.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by