ahwillia / affinewarp

An implementation of piecewise linear time warping for multi-dimensional time series alignment
MIT License
162 stars 36 forks source link

About Nonlinear Warping #20

Open Wasabi111 opened 2 years ago

Wasabi111 commented 2 years ago

Hi Alex,

I have a question about nonlinear warping you mentioned in Discovering Precise Temporal Patterns in Large-Scale Neural Recordings through Robust and Interpretable Time Warping, 2020. 1644371464(1)

Fig.1C shows that for all trials the template time and clock time have little difference at the begining and ending. However when applying this technique to High-performance brain-to-text communication via handwriting, 2021, the warp function looks different. This paper use your time warp technique to warp all the single letter motor imaginary neuron activity data to an average template. image

Take 'L' for example. the warping function shows that the clock time and aligned time have little difference at the beginning and big difference in the end. I am confused by this phenomenon since after alignment, raw data would nonlinearly map to the template and the start time should change as the same level as end time. Could you please help me with this confusion? Thanks!

Best regards, Dongming

ahwillia commented 2 years ago

Fig.1C shows that for all trials the template time and clock time have little difference at the begining and ending.

I'm not exactly sure that the figure shows that. There is a big spread in the top two plots (shift-only and linear time warping) around t=0 and t=1. The DTW barycenter averaging (bottom plot) is a different method which constrains there to be no spread in the warping functions and t=0 and t=1.

when applying this technique to High-performance brain-to-text communication via handwriting, 2021, the warp function looks different

They used an older version of the time warping code -- available here: https://github.com/ganguli-lab/twpca -- the essential ideas behind the model are the same, but the nonlinear warping functions are fit via gradient descent. That version of the code also let you add constraints (e.g. all warping functions must go through the origin -- which it seems may be an added constraint in this plot).

Wasabi111 commented 2 years ago

Hi Alex,

Thank you very much for your detailed instructions.

That version of the code also let you add constraints (e.g. all warping functions must go through the origin -- which it seems may be an added constraint in this plot). 1644479531(1)

Since I could reproduce the plot, I checked the constraints and found the origin index set to None. From my perspection, I thought this mean no constraints of pinned start added. However, when I changed the origin index from None to 0, the plot remains the same. I wonder if a start point must set and if origin index is none, it would be default set to 0. Thanks!

Best regards, Dongming