Coder Social home page Coder Social logo

Comments (4)

vvasco avatar vvasco commented on July 19, 2024 1

The classical DTW requires that the template and the test timeseries are fully known (the starting and the ending point must be known, but not necessarily equal).
This is an example of how DTW works when having a full template and noisy test time series. The cost matrix is also shown, with the blue part indicating the optimal path used to align the two time series.
working-dtw

The alignment works very well and we might use classical DTW to provide a real-time feedback after the exercise is finished (and marked as finished).

However, during the exercise, we do not have the full test sequence a-priori (instead, we might have the full template). Therefore, if we want to provide real-time feedback during the exercise, a variant of DTW has to be used:

from assistive-rehab.

vvasco avatar vvasco commented on July 19, 2024 1

Given we know the duration of the exercise (D) and the number of repetitions (nrep) of a movement, we can evaluate the signals every n*(D/nrep) seconds, in order to have a template containing n repetitions of the movement, with defined starting and ending points.
The DTW distance (normalized by the length of the vector) between segmented template and test is an indicator of how well the movement is being performed, in terms of speed. If the normalized DTW distance is below a threshold, we can assume template and test are mostly synchronized (i.e. they move at the same speed). Otherwise, a difference in speed can be detected.

The expected situations are described below. The examples show the 1D case for simplicity, considering the x position of the hand during an abduction exercise. However, this analysis has to be extended to the whole skeleton, using the multivariate DTW.
In the following examples, the full signals are shown and segmented signals (template is segmented in order to have n = 4 repetitions of the movement) with the corresponding DTW distance.
DTW distance is typically lower when template and test move at same speed.

  • Template and test moving at same speed:

same_speed_full

DTW dist = 0.078 DTW dist = 0.081
same_speed1 same_speed2
  • Test moving slower than the template:

twarp 0 5_full

DTW dist = 0.10 DTW dist = 0.11
twarp 0 5_1 twarp 0 5_2
  • Test moving faster than the template:

twarp 2 0_full

DTW dist = 0.10 DTW dist = 0.12
twarp 2 0_1 twarp 2 0_2
  • Test moving randomly / not moving:

dtw-not-moving-full

DTW dist = 0.36 DTW dist = 0.51
dtw-not-moving_1 dtw-not-moving_2

from assistive-rehab.

pattacini avatar pattacini commented on July 19, 2024 1

That's super cool @vvasco!
Thus, DTW seems to be the tool we were seeking for!

from assistive-rehab.

vvasco avatar vvasco commented on July 19, 2024

The same analysis was repeated by considering all the joints (the z component was not used, since, at the moment, it is not reliable (#76, #77)). The multivariate DTW was used, by computing the cost matrix for each x and y component of each joint, and the sum of each DTW distance was considered as final distance.
The table below summarizes the results. Each row reports the DTW distance for different parts of the template and test signals.
As desired, DTW distance is typically lower when template and test move at same speed.

Same speed Slower test Faster test Not moving / randomly moving test
DTW dist = 0.40 0.62 0.61 3.44
DTW dist = 0.48 0.65 0.70 4.31
DTW dist = 0.46 0.63 0.68 4.17
DTW dist = 0.45 0.68 0.69 4.01

from assistive-rehab.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.