Skip to content
Christopher Fleetwood edited this page Jul 1, 2021 · 2 revisions

RustDTW

Python extension backed by a multi-threaded Rust implementation of Dynamic Time Warping (DTW).


⚡️ Quick Install

To install rustDTW, simply:

pip install rust-dtw

❓ What is Dynamic Time Warping

In time series analysis, dynamic time warping (DTW) is one of the algorithms for measuring similarity between two temporal sequences, which may vary in speed 1. This has applications in speech recognition, time series classification and neuroscience.

API Documentation

dtw

Core dynamic time warping routine. Computes the distance between 2 float64 numpy arrays that represent time series data Example Usage:

result = rust_dtw.dtw(
    s=np.array([0., 1., 2.]),
    t=np.array([3., 4., 5.]),
    window=50,
    distance_mode="euclidean"
)
  • Window represents the warping window size.
  • Distance mode is the distance metric used between points (euclidean | manhattan)

dtw_connectome/dtw_matrix

Computes the distance between each timeseries, with the timeseries data represented as a 2d numpy matrix. For fMRI data, we would expect an (m x n) matrix where ( number of time points x number of ROIs).

Example Usage:

result = rust_dtw.dtw_connectome(
    connectome=timeseries, 
    window=100,
    distance_mode="euclidean"
)

dtw_connectomes

Computes the DTW connectomes for an entire cohort of subjects. Float64 numpy matrix provided, where (m x n x k) is ( n_subjects x n_samples x n_features).

Example Usage:

result = rust_dtw.dtw_connectomes(
    connectomes=timeseries, 
    window=100, 
    vectorize=False, 
    distance_mode="euclidean"
)