Functions

src/warping.c File Reference

#include "warping.h"
#include "optarg.h"
#include "array.h"
#include "linalg.h"
#include "eeg.h"
#include <math.h>

Go to the source code of this file.

Functions

Arraydtw_add_signals (const Array *s1, const Array *s2, const Array *path, OptArgList *opts)
 Add signals according to a warppath.
WarpPathdtw_backtrack (const double **d, int M, int N, WarpPath *P)
void dtw_cumulate_matrix (double **d, int M, int N, OptArgList *optargs)
EEGeeg_gibbons (EEG *eeg, int stimulus_marker, int response_marker, double k)
void free_warppath (WarpPath *p)
WarpPathinit_warppath (WarpPath *path, int n1, int n2)
Arraymatrix_dtw_backtrack (const Array *d)
 calculate the warping path.
Arraymatrix_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)

Function Documentation

WarpPath* dtw_backtrack ( const double **  d,
int  M,
int  N,
WarpPath P 
)

Definition at line 526 of file warping.c.

void dtw_cumulate_matrix ( double **  d,
int  M,
int  N,
OptArgList optargs 
)

cumulate a distance matrix d to give

\[ D_{jk} = d_{jk}+\min{\{D_{j,k-1}, D_{j-1,k}, D_{j-1, k-1}\}} \]

Parameters:
d input/output matrix
M,N dimensions of d
optargs may contain:

  • "slope_constraint=int" slope constraint, one of SLOPE_CONSTRAINT_*; default=SLOPE_CONSTRAINT_NONE

Definition at line 488 of file warping.c.

EEG* eeg_gibbons ( EEG eeg,
int  stimulus_marker,
int  response_marker,
double  k 
)

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

\[ \phi_t^{-1}(t) = t + \frac{t^k}{R^k_t}(E(R) - R_t) \]

where$ R_t $ 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$ k \in \{1,2,3,4\} $.

Individual trials are warped according to$ \phi $ and also the averages obtained from different individuals. Warping takes place between stimulus-onset-marker and response-marker

Parameters:
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
Returns:
pointer to newly allocated memory

Definition at line 318 of file warping.c.

void free_warppath ( WarpPath p  ) 

Definition at line 450 of file warping.c.

WarpPath* init_warppath ( WarpPath path,
int  n1,
int  n2 
)

Definition at line 419 of file warping.c.

void print_warppath ( FILE *  out,
WarpPath P 
)

Definition at line 456 of file warping.c.

void reset_warppath ( WarpPath P,
int  n1,
int  n2 
)

Definition at line 441 of file warping.c.