flatironinstitute / NoRMCorre

Matlab routines for online non-rigid motion correction of calcium imaging data
GNU General Public License v2.0
142 stars 88 forks source link

Prevent normcorre from failing if shifts are too large relative to patch size #34

Open ehennestad opened 2 years ago

ehennestad commented 2 years ago

We have occasional failures when running NoRMCorre on very sparse data or data with occasional very large movements. The error happens in the remove_boundaries function, and this is a proposed workaround to prevent normcorre from aborting.

Sometimes the big movements are only present in a subset of frames and its better to have the corrected result with some frames being suboptimal than spending time debugging and trying to find a better grid size.

I added a warning whenever the shifts are to large relative to the grid_size, but this might mess up the command line, so maybe it should only be displayed once (i.e use a persistent variable to skip showing warning multiple times) or be connected to the verbosity levels.