Пример #1
0
def print_stats(g,name='',prefix=''):
    '''
    computes, prints, and returns
    mode
    mean
    median
    '''
    mode = modefind.modefind(g,0)
    mn   = np.mean(g)
    md   = np.median(g)
    print(prefix,'mode    %s\t%0.4f'%(name,mode))
    print(prefix,'mean    %s\t%0.4f'%(name,mn))
    print(prefix,'median  %s\t%0.4f'%(name,md))
    return mode,mn,md
Пример #2
0
def get_isi_stats(spikes,epoch,FS=1000,BURST_CUTOFF_MS=10,MIN_NISI=100):
    '''
    Computes a statistical summary of an ISI distribution.
    Accepts a list of lists of spike times
    return burstiness, ISI_cv, mean_rate, KS, mode, burst_free_ISI_cv, burst_free_mean_rate, burst_free_mode
    '''
    event,start,stop = epoch
    duration = (stop-start)/float(FS)
    ISI_events = list(flatten(map(diff,spikes)))
    allisi = np.array(ISI_events)
    if len(ISI_events)<MIN_NISI: return None
    mode = FS/modefind(allisi)
    mean_rate = (sum(map(len,spikes))) / float(len(spikes)) / duration
    ISI_cv = np.std(allisi)/np.mean(allisi)
    KS = poisson_KS(allisi)
    burstiness = sum(allisi<BURST_CUTOFF_MS)/float(len(allisi))*100
    burst_free_spikes     = remove_bursts(spikes, duration=BURST_CUTOFF_MS)
    burst_free_ISI_events = list(flatten(map(diff,burst_free_spikes)))
    burst_free_allisi     = np.array(burst_free_ISI_events)
    burst_free_mode   = FS/modefind(burst_free_allisi)
    burst_free_mean_rate = (sum(map(len,burst_free_spikes))) / float(len(burst_free_spikes)) / duration
    burst_free_ISI_cv    = np.std(burst_free_allisi)/np.mean(burst_free_allisi)
    return burstiness, ISI_cv, mean_rate, KS, mode, burst_free_ISI_cv, burst_free_mean_rate, burst_free_mode