示例#1
0
def place_holder(fl):
    import calblitz as cb
    import ca_source_extraction as cse
    import numpy as np
    m=cb.load(fl)
    Cn = m.local_correlations()
    cnmf=cse.CNMF(1, k=4,gSig=[8,8],merge_thresh=0.8,p=2,dview=None,Ain=None)
    cnmf=cnmf.fit(m)
    A,C,b,f,YrA=cnmf.A,cnmf.C,cnmf.b,cnmf.f,cnmf.YrA    
    np.savez(fl[:-5]+'_result.npz',A=A,C=C,b=b,f=f,YrA=YrA,Cn=Cn)
    return fl[:-5]+'_result.npz'
示例#2
0
#fname_new='Yr_d1_501_d2_398_d3_1_order_F_frames_369_.mmap'
Yr, dims, T = cse.utilities.load_memmap(fname_new)
d1, d2 = dims
images = np.reshape(Yr.T, [T] + list(dims), order='F')
Y = np.reshape(Yr, dims + (T, ), order='F')
#%%
Cn = cse.utilities.local_correlations(Y[:, :, :1800])
pl.imshow(Cn)
#%%
if not is_patches:
    #%%
    K = 100  # number of neurons expected per patch
    gSig = [5, 5]  # expected half size of neurons
    merge_thresh = 0.8  # merging threshold, max correlation allowed
    p = 2  #order of the autoregressive system
    cnmf=cse.CNMF(n_processes, method_init=init_method, k=K,gSig=gSig,merge_thresh=merge_thresh,\
                        p=p,dview=dview,Ain=None)
    cnmf = cnmf.fit(images)

#%%
else:
    #%%
    rf = 30  # half-size of the patches in pixels. rf=25, patches are 50x50
    stride = 4  #amounpl.it of overlap between the patches in pixels
    K = 2  # number of neurons expected per patch
    gSig = [12, 12]  # expected half size of neurons
    merge_thresh = 0.8  # merging threshold, max correlation allowed
    p = 2  #order of the autoregressive system
    memory_fact = 1
    #unitless number accounting how much memory should be used. You will need to try different values to see which one would work the default is OK for a 16 GB system
    save_results = False
    #%% RUN ALGORITHM ON PATCHES
示例#3
0
Y=np.reshape(Yr,dims+(T,),order='F')
#%%
Cn = cse.utilities.local_correlations(Y[:,:,:3000])
pl.imshow(Cn,cmap='gray')  
#%%
rf=10 # half-size of the patches in pixels. rf=25, patches are 50x50
stride = 4 #amounpl.it of overlap between the patches in pixels    
K=4 # number of neurons expected per patch
gSig=[5,5] # expected half size of neurons
merge_thresh=0.8 # merging threshold, max correlation allowed
p=2 #order of the autoregressive system
memory_fact=1; #unitless number accounting how much memory should be used. You will need to try different values to see which one would work the default is OK for a 16 GB system
save_results=False
#%% RUN ALGORITHM ON PATCHES
cnmf=cse.CNMF(n_processes, k=K,gSig=gSig,merge_thresh=0.8,p=0,dview=c[:],Ain=None, \
        rf=rf,stride=stride, memory_fact=memory_fact,\
        method_init='greedy_roi',alpha_snmf=10e2)
cnmf=cnmf.fit(images)

A_tot=cnmf.A
C_tot=cnmf.C
YrA_tot=cnmf.YrA
b_tot=cnmf.b
f_tot=cnmf.f
sn_tot=cnmf.sn

print 'Number of components:' + str(A_tot.shape[-1])
#%%

idx_components, fitness, erfc ,r_values, num_significant_samples = cse.utilities.evaluate_components(Y,C_tot+YrA_tot,A_tot,robust_std=False,thresh_finess=-15)
sure_in_idx= idx_components[np.logical_and(np.array(num_significant_samples)>0 ,np.array(r_values)>=.3)]