Skip to main content

Code for time warping multi-dimensional time series.

Project description

Piecewise Linear Time Warping

This repo contains research code for time warping multi-dimensional time series. This was developed as part of the following manuscript, which focuses on analysis of large-scale neural recordings (though this code can be also be applied to many other data types):

Discovering precise temporal patterns in large-scale neural recordings through robust and interpretable time warping.
Williams AH, Poole B, Maheswaranathan N, Dhawale AK, Fisher T, Wilson CD, Brann DH, Trautmann E, Ryu S, Shusterman R, Rinberg D, Ölveczky BP, Shenoy KV, Ganguli S (2020). Neuron. 105(2):246-259.e8

The code fits time warping models with either linear or piecewise linear warping functions. These models are more constrained than the classic Dynamic Time Warping (DTW) algorithm, and are thus less prone to overfit to data with high levels of noise. This is demonstrated below on synthethic data. Briefly, a 1-dimensional time series is measured over many repetitions (trials), and exhibits a similar temporal profile but with random jitter on each trial. Simply averaging across trials produces a poor description of the typical time series (red trace at bottom). A linear time warping model identifies a much better prototypical trace (labeled "template"), while accounting for the temporal translations on each trial with warping functions (blue to red linear functions at bottom). On the right, a nonlinear warping model based on DTW (called DBA) is shown for comparison. While DBA can work well on datasets with low noise, linear warping models can be easier to interpret and less likely to overfit.

screen shot 2018-11-05 at 2 03 55 pm

Getting started

After installing (see below), check out the demos in the examples/ folder.

Either download or clone the repo:

git clone https://github.com/ahwillia/affinewarp/

Then navigate to the downloaded folder:

cd /path/to/affinewarp

Install the package and requirements:

pip install .
pip install -r requirements.txt

You will need to repeat these steps if we update the code.

Other references / resources

  • tslearn - A Python package supporting a variety of time series models, including DTW-based methods.

Contact

alex.h.williams@nyu.edu (or open an issue here).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

affinewarp-0.2.0.tar.gz (37.2 kB view details)

Uploaded Source

Built Distribution

affinewarp-0.2.0-py3-none-any.whl (37.7 kB view details)

Uploaded Python 3

File details

Details for the file affinewarp-0.2.0.tar.gz.

File metadata

  • Download URL: affinewarp-0.2.0.tar.gz
  • Upload date:
  • Size: 37.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.13

File hashes

Hashes for affinewarp-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8211a3e8f65a2375b81e350528164dd8f883b56d03d730b2421a58d5d37d7880
MD5 6e0c119cd8ff0e79423ee98d6cdbfccb
BLAKE2b-256 23d3ba9afa3bf53da7c1f8f42691b7d1baee6bc6311304f016d7b7714412eb37

See more details on using hashes here.

File details

Details for the file affinewarp-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: affinewarp-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 37.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.13

File hashes

Hashes for affinewarp-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d03cfcd16822064f43e1810995d26dfef906802f3c3ac2450bef8df7f71413fd
MD5 d9770125156169927da9bd90de422ec4
BLAKE2b-256 9eb06215126b6a7385052f2d6ab72dccf89332dee9d938375d81e7e346dfd790

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page