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() m2.IPCA_denoise(components = 100, batch = 1000) m2.playMovie(frate=.05,magnification=4,gain=10.0) #%% #%% compute spatial components via NMF initTime=time.time() space_spcomps,time_comps=m.NonnegativeMatrixFactorization(n_components=20,beta=1,tol=5e-7); print 'elapsed time:' + str(time.time()-initTime)