Login Login



Recent changes
Wanted articles
Who is online?
Article tools


From Orthoload Wiki

Jump to: navigation, search

Software averDTW

averDTW calculates an average signal from several varying, time dependent signals, using a dynamic time warping procedure.

Simplified description: k signals are first time normalized and then time distorted (warped) so that the summed squared distance between all of them become a minimum. All distorted signals are treated statistically, obtaining different output signals: mean, median, minimum, maximum, 25 percentiles, 75 percentiles.

There are two versions of the algorithm:

  • Visual Basic (2015) software and
  • MatLab (2016b) script.

Data Structure

The time can be measured using any time base (e.g. milliseconds, hours ...). It has to start with zero. The time intervals don’t have to be equidistant. The number m of synchronously measured signals is not limited but has to be the same for each measurement. The number n of data sets can be different for each measurement.

The signal Ak(i, j) consists of time points and m synchronously measured signals. It is measured p times. Each of the p measurements is about n data sets long. Each measurement k = 1 ... p is stored in a 2-dimensional, null-terminated array Ak(i,j).

Signal used for warping

Warping is done with one of the synchronously measured signals (DTWcomp). All other signals are then distorted identically before the average/ median etc. signals are calculated. That signal DTWcomp, which is most representative for all other signals, has to be applied for warping. In case of a spatial force, for example, the most representative signal would be the resultant force F.

m = 4 synchronously measured and calculated signals: The resultant force F and its components Fx, Fy, Fz in directions x, y, z;
p = 5 measurements (each is about 1 second long);
Each measurement k = 1 … p (p = 5) consists of n = 1001 data sets.
Each measurement k = 1 ... p (p = 5) is stored in a 2-dimensional, null-terminated array Ak(i,j) with the indizes:
i = 0 ... 4     - time (i = 0) and m = 4 synchronously measured signals Fx (i = 1), Fy (i = 2), Fz (i = 3) and Fres (i = 4)
j = 0 ... n-1 - n=1001 data sets in each measurement.

Input for the algorithm:

Arrays Ak(i,j) from p different measurements.

The following parameters can be chosen:

  • DTWComp - number of that signal in the array Ak(i,j) which is used for calculation of dynamic time warping path (interger). Standard value DTWComp = 1
  • NumOfIntervals - number j of data sets in the average signal (integer). Standard value = 600
  • WinConstraint - windows constraint for dynamic time warping matrix in percent (integer). Standard value = 20 (details see Bender and Bergmann 2012).
  • Filter: all signals in output (average, median, maximum, minimum, 25 percentiles, 75 percentiles) can be smoothed by a single pole low-pass filter with smoothing factors between 0 and 100 (unsmoothed):
    • SmoothAver - smoothing factor applied to average signal
    • SmoothMedian - smoothing factor applied to median signal
    • Smooth25Perc - smoothing factor applied to 25 percentile signal
    • Smooth75Perc - smoothing factor applied to 75 percentile signal
    • SmoothMax - smoothing factor applied to maximum signal
    • SmoothMin - smoothing factor applied to minimum signal

Output for the algorithm:

Arrays Aout(i,j) with average (median/min etc) signals, having the same data structure as Ak(i,j).

It has to be mentioned that our load data consist of three force and three moment components. In our applications, time warping is always performed on the resultant force. The obtained warping paths of the resultant forces are then applied to the corresponding three force components.

The same strategy can be applied on synchronous gait data, for example. It then has to be decided and justified which of the variables will be used as the ‘master’ for calculating the warping paths.

For details see

Bender A., Bergmann G., Determination of Typical Patterns from Strongly Varying Signals,Comput Methods Biomech Biomed Engin. 2012;15(7):761-9.


Example 1

There are 10 curves of resultant force Fres=f(time). Every curve consists of 400 … 450 measurement points:

  • CurveA: Fres(j) = f(time(j)), j = 1…400
  • CurveB: Fres(j) = f(time (j)), j = 1…410
  • CurveC: Fres(j) = f(time (j)), j = 1…403
  • CurveD: Fres(j) = f(time (j)), j = 1…421
  • CurveE: Fres(j) = f(time (j)), j = 1…400
  • CurveF: Fres(j) = f(time (j)), j = 1…411
  • CurveG: Fres(j) = f(time (j)), j = 1…429
  • CurveH: Fres(j) = f(time (j)), j = 1…439
  • CurveI: Fres(j) = f(time (j)), j = 1…450
  • CurveJ: Fres(j) = f(time (j)), j = 1…410
Example 1: 10 curves Fres

Calculated ‘typical’ or average curve without smoothing:

Example 1: 10 curves with average (DTW)

Calculated ‘typical’ or average curve with and without smoothing:

10curves avg smooth.png

Example 2:

There are 20 curves CurveA…CurveT = f(time). Every curve consists of 1001 measurement points for eight synchronously measured and calculated signals Fx, Fy, Fz, Fres, Mx, My, Mz, Mres:


Example 2: CurveA


Example 2: CurveB


Example 2: CurveT

Calculated ‘typical’ or average curves for Fx, Fy, Fz, Fres, Mx, My, Mz, Mres (for algorithmus: DTWcomp = 4 - Fres):

Example 2: Average of 20 curves (with 8 components)

Example 3

There are 12 curves CurveA…CurveL = f(time). Every curve consists of 1001 measurement points for three synchronously measured signals Fres, Fipsi, Fcontra. Fipsilat – ipsilateral force (crutches), Fcontralat – contralateral force (crutches).

Calculated median, 25-percentil and 75-percentil curves for Fres, Fipsilat and Fcontralat:

Example 3