Package gmisclib :: Module dtw4
[frames] | no frames]

Module dtw4

Classes
  NoRoute
  slice_c
  state_c
  state_jump_c
Functions
 
check_names(...)
numpy.ndarray, 2-dimensional array of integers with shape [n,2]. [i,0] is the index (time) in x, [i,1] is the index (time) in y.
dtw(...)
A standard Dynamic Time Warp match of two sequences of feature vectors.
numpy.ndarray - 2-dimensional array of floats.
dtw_ti(...)
Does a DTW on a pair of signals, but allows you to specifiy a region of each signal to match.
 
dtwjump(...)
A constrained Dynamic Time Warp match of two sequences of feature vectors.
 
map2dist(...)
 
map2index(...)
tuple(numpy.ndarray(float, 1-d), numpy.ndarray(float, 2-d), numpy.ndarray(float, 2-d))
map2shared(...)
This is used after dtw() to map the two sequences onto the same time axis.
 
namelist(...)
 
parse_args(...)
 
scale_tmap(...)
 
shift_idxmap(...)
 
test(...)
 
test_partial(...)
 
test_same(...)
 
test_scaled(...)
 
test_stretched(...)
 
time_it(...)
Variables
  S = '.'
  __package__ = 'gmisclib'
  __test__ = {}

Imports: die, edit_distance, gpkimgclass, math, numpy, sys


Function Details

dtw(...)

 

A standard Dynamic Time Warp match of two sequences of feature vectors. The allowed time increments are (0,1), (1,0), and (1,1).

Parameters:
  • x (numpy.ndarray, 2-dimensional. First index is the time axis, second index is the feature axis.) - one array of feature vectors
  • y (numpy.ndarray, 2-dimensional. First index is the time axis, second index is the feature axis.) - the other array of feature vectors
  • alpha (float) - exponent for differences in features. 2=Euclidean, 1=city block
  • beta (float) - exponent for summing along time axis. Normally 1.
Returns: numpy.ndarray, 2-dimensional array of integers with shape [n,2]. [i,0] is the index (time) in x, [i,1] is the index (time) in y.
An array that maps from indices in x to indices into y. x[r[i,0]] matches y[r[i,1]] for all i.

dtw_ti(...)

 

Does a DTW on a pair of signals, but allows you to specifiy a region of each signal to match. It returns the alignment in time units, rather than in integer indices.

Parameters:
  • y (gpkimgclass.gpk_img)
  • x (gpkimgclass.gpk_img)
Returns: numpy.ndarray - 2-dimensional array of floats.
An array of corresponding times. The time rv[i,0] in utterance x and rv[i,1] in utterance y correspond to similar acoustic events. Output has units of seconds.

dtwjump(...)

 

A constrained Dynamic Time Warp match of two sequences of feature vectors. It constrains the time mapping to be a piecewise linear function with a corner every mm samples.

Parameters:
  • x (numpy 2-dimensional array of floats. The first index is time, the second index is within each feature vector.) - A sequence of feature vectors.
  • y (numpy 2-dimensional array of floats. The first index is time, the second index is within each feature vector.) - A sequence of feature vectors.

map2shared(...)

 

This is used after dtw() to map the two sequences onto the same time axis.

Parameters:
  • x - a sequence of feature vectors, typically the same data you pass into dtw().
  • y - a sequence of feature vectors, typically the same data you pass into dtw().
  • tmap (numpy.ndarray[integer, 2-dimensional, shape is Nx2]) - a time mapping as returned from dtw() or dtwjump().
Returns: tuple(numpy.ndarray(float, 1-d), numpy.ndarray(float, 2-d), numpy.ndarray(float, 2-d))
a tuple with a time axis, the x-feature vectors mapped onto that time axis, and the y-feature vectors mapped onto the same axis. Analogous to x and y, the first index is the pseudotime index.

parse_args(...)

 
Parameters:
  • args (list(things) Things that are flags need to be strings. Things that are numbers can be either floats, ints, or strings. The last two things (corresponding to the "filenames") can be anything.) - an argument list, much like you might feed to a command line program.