Example #1
0
#%% crop movie after motion correction. 
m.crop(max_shift,max_shift,max_shift,max_shift)    

#%% if you want to make a copy of the movie
if False:
    m_copy=m.copy()


#%% resize to increase SNR and have better convergence of segmentation algorithms
resizeMovie=True
if resizeMovie:
    fx=.5; # downsample a factor of four along x axis
    fy=.5;
    fz=.1; # downsample  a factor of 5 across time dimension
    m.resize(fx=fx,fy=fy,fz=fx)
else:
    fx,fy,fz=1,1,1

#%% compute delta f over f (DF/F)
initTime=time.time()
m.computeDFF(secsWindow=15,quantilMin=20,subtract_minimum=False)
print 'elapsed time:' + str(time.time()-initTime) 

#%% compute subregions where to apply more efficiently facrtorization algorithms
fovs, mcoef, distanceMatrix=m.partition_FOV_KMeans(tradeoff_weight=.7,fx=.25,fy=.25,n_clusters=4,max_iter=500);
plt.imshow(fovs)

#%% create a denoised version of the movie, nice to visualize
if True:
    m2=m.copy()