plt.plot(np.asarray(shifts).reshape((j+1)*shift.shape[0],shift.shape[1])) #%% apply shifts to another channel, you need to reload the original movie other channel (mov_other_channel) if False: # here reload the original imaging channel from movie totalShifts=np.sum(np.asarray(shifts),axis=0)[:,0:2].tolist() mov_other_channel.applyShifstToMovie(totalShifts) #%% if you want to apply the shifts only ones to reduce the smoothing if False: totalShifts=np.sum(np.asarray(shifts),axis=0)[:,0:2].tolist() m=XMovie(filename, frameRate=frameRate); m.applyShifstToMovie(totalShifts) #%% plot movie median minBrightness=0; maxBrightness=20; medMov=np.median(m.mov,axis=0) plt.imshow(medMov,cmap=plt.cm.Greys_r,vmin=minBrightness,vmax=maxBrightness) #%% save motion corrected movie inpython format along with the results. This takes some time now but will save a lot later... np.savez(filename_mc,mov=m.mov,frameRate=frameRate,templates=templates,shifts=shifts,max_shift=max_shift) #%% RELOAD MOTION CORRECTED MOVIE m=XMovie(mat=np.load(filename_mc)['mov'], frameRate=frameRate); max_shift=np.load(filename_mc)['max_shift']