Warning: Number of input vectors, 3, did not match the input matrix's number of dimensions, 2. 1 trailing
singleton input vectors were removed.
In mat2cell (line 73)
In apply_shifts (line 189)
In drift_revphase (line 98)
Error using mat2cell (line 97)
Input arguments, D1 through D4, must sum to each dimension of the input matrix size, [4 4 1 2].'
Error in apply_shifts (line 211)
Error in drift_revphase (line 98)
phasemap1 = apply_shifts(single(phasemap1),shifts1,options_nonrigid);
lummask1but not for the
phasemap1file. As a result different methods for applying the shifts were used in the two cases causing a conflict. The way to fix this, is to get the options struct as an output when you apply the normcorre function so that this relative shift is passed on in the
apply_shiftsfunction. Alternatively, if you don’t do bidirectional scanning, then you can set
options_nonrigid.correct_bidir = falseand this will not be used at all
I am using the matlab implementation of your code to motion correct 2-p calcium imaging data (512 x 512 px, edge length of FOV 750 um, 30 Hz, green (GCaMP6) and and red channel (red microspheres)). I usually do not have a lot of motion (around 1 - 2 pixels between frames, maybe up to 8 px across frames).
I manually generate a template (imagej) from a subset of red channel frames to feed it into 'normcorr_batch' and motion correct the red channel. Then, I apply the shifts to the green channel using 'apply_shifts'.
The motion correction itself works very well(!), unfortunately, it seems to generate two types of artifacts (see 'https://drive.google.com/file/d/1QVuISIUVAGXnoDzo7VUKEHZPwgQePm-o/view' for a PDF with example images):
Many bright spots in the motion corrected red channel (and also the brightest spots in the green channel) cause stripy artefacts in the x and y direction (see white arrows in PDF).
Mainly the green and less so the red channel show a raster of tiling artefacts (see white arrow in PDF).
I would be very happy about any suggestions, which could resolve these issues.
I thought the 'stripy artefacts' issue could be due to conversion problems, but after trying a lot of stuff this seems unlikely to me. This is how I handle the data:
Thanks so much for your help!
I have large datasets (1044X1344X2000) so I break them down to 20 to 50 frame where ever i see the movement, when i run the demo script with "T,'bin_width',10,'iter',3,'fr',4,'shifts_method','FFT','phase_flag',true,'grid_size',[128,128]*2" with these Normcorr options and gsig 10, gsiz 20, I get this "Error using mat2cell (line 89)
Input arguments, D1 through D4, must sum to each dimension of the input matrix size, [4 6 1 2].
Error in apply_shifts (line 199)
parfor ii = 1:lY"
remove_boundaries.mmight be due to some interplay between the parameters
max_devare you using? I think I’ve seen this error when the patches are small but the shifts are large causing the patch to move out of the window.
max_shiftparameter to a higher value than the default.
run_pipeline.mframework, or you can simply ignore them (if you think they are too small) and let the motion correction step deal with them.