Find a portion of a signal using dtw ?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Umar
am 23 Jul. 2024
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.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!