I was playing around with the DTW implementation in Python by Pierre Rouanet to match two signals. While the reference signal is fix, a given measurement should be changed to nicely match the reference. BUT measurement features should be kept.
For everybody not familiar with DTW, the explanation in the paper “Derivative dynamic time warping” by Keogh and Pazzani was very helpfull to me: https://doi.org/10.1137/1.9781611972719.1.
My first try using DTW resulted in a fairly close matching, with huge plateaus, not resembling the original matching sequence at all 🙁
I visualized the matching between “raw” (the given measurement) and “ref” (the reference). When multiple points of the measurement are matched to one point in the reference, the resulting curve (“match type 0”) at this point is the mean value of all matched values. If one point of the measurement is matched to multiple points in the reference, the value is repeated forming plateaus.
This is uncool!
So what can I do about DTW completely changing the shape of the measurement curve? Two nice possibilities I found are
- Slope weighting: Leaving the diagonal with the matching path is punished with a constant factor.
- Windowing: The difference between indices that are allowed to be matched is restricted.
Both options seemed to be interesting, so I implemented both in the dtw package https://pypi.org/project/dtw/ and indeed! I got better results.
While the plateaus are effectively avoided/down scaled using these additions, it currently seems like I get best results using structure analysis instead of DTW. Anyway, playing around was nice 🙂