STATUS: stable Warping functions. More...
#include "mathadd.h"
#include "definitions.h"
#include "time_frequency.h"
#include "regularization.h"
#include "eeg.h"
Go to the source code of this file.
Data Structures | |
struct | WarpPath |
Defines | |
#define | warppath_CHECK(flag, w) |
is w a warppath? | |
Enumerations | |
enum | SlopeConstraint { SLOPE_CONSTRAINT_NONE = 0, SLOPE_CONSTRAINT_LAX, SLOPE_CONSTRAINT_MEDIUM, SLOPE_CONSTRAINT_SEVERE } |
Severity of the slope constraint in the Dynamic Time-Warping Alg. More... | |
Functions | |
Array * | dtw_add_signals (const Array *s1, const Array *s2, const Array *path, OptArgList *opts) |
Add signals according to a warppath. | |
WarpPath * | dtw_backtrack (const double **d, int M, int N, WarpPath *P) |
void | dtw_cumulate_matrix (double **d, int M, int N, OptArgList *opts) |
EEG * | eeg_dtw_hierarchical (EEG *eeg_in, const double **distmatrix, EEG *out, OptArgList *optargs) |
EEG * | eeg_gibbons (EEG *eeg, int stimulus_marker, int response_marker, double k) |
void | free_warppath (WarpPath *p) |
WarpPath * | init_warppath (WarpPath *path, int n1, int n2) |
Array * | matrix_dtw_backtrack (const Array *d) |
calculate the warping path. | |
Array * | matrix_dtw_cumulate (Array *mat, bool alloc, OptArgList *optargs) |
cumulate a distance matrix d for Dynamic Time-Warping. | |
void | print_warppath (FILE *out, WarpPath *P) |
void | reset_warppath (WarpPath *P, int n1, int n2) |
STATUS: stable Warping functions.
Example for warping 2D data:
Dynamic Time-Warping is a method to account for temporal distortion when comparing two signals. It is done by finding a function that minimizes the sum of entries through a distance matrix, such that
for a given pointwise distance between two signals. Such distances can be computed using the functions in distances.h.
The minimization is done by cumulating the matrix
and backtracking via the minimum of the three neighboring entries (down, down-right, right) from to. Here, the functions dtw_cumulate_matrix() and dtw_backtrack() do that.
Finally, the signals need to be mapped to one another to get time-amplitude averaging with
using weights. Here, you can use warp_add_signals_by_path().
Definition in file warping.h.
void dtw_cumulate_matrix | ( | double ** | d, | |
int | M, | |||
int | N, | |||
OptArgList * | optargs | |||
) |
EEG* eeg_dtw_hierarchical | ( | EEG * | eeg_in, | |
const double ** | distmatrix, | |||
EEG * | out, | |||
OptArgList * | optargs | |||
) |
Warp-average according to Gibbons+Stahl 2007. They proposed to stretch or compress the single signals in order to match the average reaction time, by simply moving the sampling points in time according to a linear, quadratic, cubic or to-the-power-of-four function. Formally, they adjusted the time-axis by letting
where denotes the reaction time of the current trial and E is the expected value (the mean reaction time across trials). In their work, Gibbons et al. studied this approach for.
Individual trials are warped according to and also the averages obtained from different individuals. Warping takes place between stimulus-onset-marker and response-marker
eeg_in | input | |
stmulus_marker | gives the index indicating which of the markers within eeg_in is the stimulus-onset | |
response_marker | gives the index indicating which of the markers within eeg_in is the response-onset | |
k | parameter for gibbon's method |