User login

You are here

Dynamic Time Warping (DTW) and Correlation Optimized Warping (COW)


Giorgio Tomasi, Thomas Skov and Frans van den Berg


Many analytical signals based on time-trajectories show artifacts appear as shifts. Of the many algorithms developed to correct for these artifacts DTW (named Dynamic Multi-way Warping - DMW - to distinguish it form other implementations) and COW are implemented as Matlab code.


Main reference for alignment:
Correlation Optimized Warping and Dynamic Time Warping as Preprocessing Methods for Chromatographic Data
Tomasi, G., van den Berg, F., Andersson, C., Journal of Chemometrics 18(2004)231-241

Automatic selection of COW parameters by "optim_cow.m":
Automated Alignment of Chromatographic Data

Skov T, van den Berg F, Tomasi G, Bro R (2006) Automated alignment of chromatographic data, Journal of Chemometrics, 20 (11-12): 484-497



        Download DTW and COW (small fixes 070821, all cosmetic)



You can learn more about the two correction methods on this page.

• Small fix in "optim_cow" to make it backwards compatible with Matlab version 6.5.

• A much faster implementation (also closer to the original paper); new function "cow_apply" to apply an (old) computed warping path to new data; scripts changed to new functionality (061219).

• A new function for automatic selection of segment length and slack size (the two parameters in COW) called "optim_cow.m" has been added (060802); an example script (number six) illustrates it's use. Details on the optimization can be found in the second reference and in the figures below and/or from this report (PDF).

Contour plot of the Warping effect with initial search grid and six further optimizations.


Simplex/EVOP local optimzation principle applied to global grid optima.


Illustration of three combinations of segment and slack on one peak. This illustrates how improper selection of segment length and slack size can change the area/shape of a peak. Raw and aligned chromatograms using best combination found: "Warping effect" = "Simplicity" + "Peak factor"



• Rather silly mistake in "coshift" for correction in 2D landscapes fixed (060206); should work now.

• Based on some clever tricks by GT (051001), COW had become a lot faster! Also, a function for finding a good reference from a series of objects has been added ("ref_select.m"; work on this is still in progress). 051003 - small bug-fixes (only active when manual segment indexing is used), added fourth example script to illustrate the potential of manual segment indexing.

• In the new release (050509) some minor adjustments have been made plus a third sample script is added to show how the diagnostics output can be used to corrected a signal (so, correction based on previous alignment operation, e.g. in the case of a multi-channel measurement).

• In the new release (050106) some diagnostic-plotting adjustments have been made, a second sample script is added and - most important - the English spelling has been corrected!

• In the new release (041207) some (minor) errors have been corrected, a simple "linear" shift routine for vectors and matrices is added (and improved a little in December), and we have included a small sample script to illustrate use of the code.

Could not access file: