PT - JOURNAL ARTICLE AU - Eftychios A. Pnevmatikakis AU - Andrea Giovannucci TI - NoRMCorre: An online algorithm for piecewise rigid motion correction of calcium imaging data AID - 10.1101/108514 DP - 2017 Jan 01 TA - bioRxiv PG - 108514 4099 - http://biorxiv.org/content/early/2017/02/14/108514.short 4100 - http://biorxiv.org/content/early/2017/02/14/108514.full AB - Motion correction is a challenging pre-processing problem that arises early in the analysis pipeline of calcium imaging data sequences. Here we introduce an algorithm for fast Non-Rigid Motion Correction (NoRMCorre) based on template matching. NoRMCorre operates by splitting the field of view into overlapping spatial patches that are registered for rigid translation against a continuously updated template. The estimated alignments are subsequently up-sampled to create a smooth motion field for each frame that can efficiently approximate non-rigid motion in a piecewise-rigid manner. NoRMCorre allows for subpixel registration and can be run in an online mode resulting in comparable to or even faster than real time motion registration on streaming data. We evaluate the performance of the proposed method with simple yet intuitive metrics and compare against other non-rigid registration methods on two-photon calcium imaging datasets. Open source Matlab and Python code is also made available.