#%% concatenate movies (it will add to the original movie) # you have to create another movie new_mov=XMovie(...) m.append(new_mov) #%% motion correct run 3 times # WHEN YOU RUN motion_correct YOUR ARE MODIFYING THE OBJECT!!!! templates=[]; shifts=[]; max_shift=5; num_iter=10; # numer of times motion correction is executed template=None # here you can use your own template (best representation of the FOV) for j in range(0,num_iter): template_used,shift=m.motion_correct(max_shift=max_shift,template=None,show_movie=False); templates.append(template_used) shift=np.asarray(shift) shifts.append(shift) 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
# you have to create another movie new_mov=XMovie(...) m.append(new_mov) #%% motion correct run 3 times # WHEN YOU RUN motion_correct YOUR ARE MODIFYING THE OBJECT!!!! templates=[]; shifts=[]; max_shift_w=5; max_shift_h=5; num_iter=3; # numer of times motion correction is executed template=None # here you can use your own template (best representation of the FOV) for j in range(0,num_iter): template_used,shift=m.motion_correct(max_shift_w=max_shift_w,max_shift_h=max_shift_h,template=None,show_movie=False); templates.append(template_used) shift=np.asarray(shift) shifts.append(shift) plt.plot(np.asarray(shifts).reshape((j+1)*shift.shape[0],shift.shape[1])) #%% motion correct Cristina initTime=time.time() m=XMovie(mat=np.load(filename_py)['mov'], frameRate=np.load(filename_py)['frameRate']); m.makeSubMov(range(2000)) m.crop(crop_top=0,crop_bottom=1,crop_left=0,crop_right=0,crop_begin=0,crop_end=0) m_tmp=m.copy() _,shift=m_tmp.motion_correct(max_shift_w=60,max_shift_h=20,template=None,show_movie=False); template=np.median(m_tmp.mov,axis=0)