#%% PREPROCESS DATA t1 = time() Yr,sn,g=cse.preprocess_data(Yr,**preprocess_params) Ain, Cin, b_in, f_in, center=cse.initialize_components(Y, **init_params) print time() - t1 plt2 = plt.imshow(Cn,interpolation='None') plt.colorbar() plt.scatter(x=center[:,1], y=center[:,0], c='m', s=40) crd = cse.plot_contours(coo_matrix(Ain[:,::-1]),Cn,thr=0.9) plt.axis((-0.5,d2-0.5,-0.5,d1-0.5)) plt.gca().invert_yaxis() pl.show() #%% t1 = time() A,b,Cin = cse.update_spatial_components_parallel(Yr, Cin, f_in, Ain, sn=sn, **spatial_params) t_elSPATIAL = time() - t1 print t_elSPATIAL crd = cse.plot_contours(A,Cn,thr=0.9) #%% update_temporal_components t1 = time() C,f,Y_res,S,bl,c1,neurons_sn,g = cse.update_temporal_components_parallel(Yr,A,b,Cin,f_in,bl=None,c1=None,sn=None,g=None,**temporal_params) t_elTEMPORAL2 = time() - t1 print t_elTEMPORAL2 # took 98 sec #%% merge components corresponding to the same neuron t1 = time() A_m,C_m,nr_m,merged_ROIs,S_m,bl_m,c1_m,sn_m,g_m=cse.mergeROIS_parallel(Y_res,A,b,C,f,S,sn,temporal_params, spatial_params, bl=bl, c1=c1, sn=neurons_sn, g=g, thr=0.8, mx=50) t_elMERGE = time() - t1 print t_elMERGE #%% view results. Notice that in order to scroll components you need to click on the plot A_or, C_or, srt = cse.order_components(A_m,C_m)
'noise_method': 'logmexp', 'lags': 5, 'fudge_factor': 1., 'verbosity': False } #%% PREPROCESS DATA t1 = time() Yr, sn, g = cse.preprocess_data(Yr, **preprocess_params) Ain, Cin, b_in, f_in, center = cse.initialize_components(Y, **init_params) print time() - t1 #%% t1 = time() A, b, Cin = cse.update_spatial_components_parallel(Yr, Cin, f_in, Ain, sn=sn, **spatial_params) t_elSPATIAL = time() - t1 print t_elSPATIAL #%% update_temporal_components t1 = time() C, f, Y_res, S, bl, c1, neurons_sn, g = cse.update_temporal_components_parallel( Yr, A, b, Cin, f_in, bl=None, c1=None, sn=None,
'memory_efficient':False, 'bas_nonneg':True, 'noise_range':[.25,.5], 'noise_method':'logmexp', 'lags':5, 'fudge_factor':1., 'verbosity':False } #%% PREPROCESS DATA t1 = time() Yr,sn,g=cse.preprocess_data(Yr,**preprocess_params) Ain, Cin, b_in, f_in, center=cse.initialize_components(Y, **init_params) print time() - t1 #%% t1 = time() A,b,Cin = cse.update_spatial_components_parallel(Yr, Cin, f_in, Ain, sn=sn, **spatial_params) t_elSPATIAL = time() - t1 print t_elSPATIAL #%% update_temporal_components t1 = time() C,f,Y_res,S,bl,c1,neurons_sn,g = cse.update_temporal_components_parallel(Yr,A,b,Cin,f_in,bl=None,c1=None,sn=None,g=None,**temporal_params) t_elTEMPORAL2 = time() - t1 print t_elTEMPORAL2 # took 98 sec #%% merge components corresponding to the same neuron t1 = time() A_m,C_m,nr_m,merged_ROIs,S_m,bl_m,c1_m,sn_m,g_m=cse.mergeROIS_parallel(Y_res,A,b,C,f,S,sn,temporal_params, spatial_params, bl=bl, c1=c1, sn=neurons_sn, g=g, thr=0.8, mx=50) t_elMERGE = time() - t1 print t_elMERGE except: print 'test failed' raise