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

problem when mod(stackSize, binwidth) = 1 #5

Closed ehennestad closed 7 years ago

ehennestad commented 7 years ago

I was aligning a stack containing 701 frames using a bin width of 50 and got an error on alignment of the last bin:

Error using mat2cell (line 80) Number of input vector arguments, 3, does not match the input matrix's number of dimensions, 2.

Error in normcorre_batch (line 266) if nd == 2; Ytc = mat2cell(Ytm,d1,d2,ones(1,size(Ytm,ndims(Ytm)))); end

Error in imregSession (line 131) [M1, shifts, ~] = normcorre_batch(Y1, options_nonrigid);

Error in runPipelineTMP (line 152) imregSession(sessionID)

I ran it again using bin width of 40 and then it worked fine. Have not reproduced it with other combinations of stack sizes/bin widths.

epnev commented 7 years ago

Thanks @ehennestad that's a great catch. The error occurs because the mat2cell function assumes a number of dimensions for each mini batch and in the case when mod(T,bin_width) = 1 the last dimension of the mini batch matrix is suppressed.

I "fixed" it by increasing bin_width by 1 until mod(T,bin_width) = 1 is no longer satisfied.