Ejemplo n.º 1
0
def logmode(points,K=5,burst=None):
    '''
    Accepts list of ISI times.
    Finds the mode using a log-KDE density estimate
    '''
    points = np.array(points)
    if not burst is None:
        points = points[points>burst] # remove burst
    x,y = kdepeak(np.log(K+points[points>0]))
    x   = np.exp(x)-K
    y   = y/(K+x)
    mode = x[np.argmax(y)]
    return mode
Ejemplo n.º 2
0
def modefind(points,burst=10):
    '''
    Removes intervals shorter than 10m
    Finds peak using log-KDE approximation
    '''
    points = np.array(points)
    points = points[points>burst] # remove burst
    K   = 5
    x,y = kdepeak(np.log(K+points[points>0]))
    x   = np.exp(x)-K
    y   = y/(K+x)
    mode = x[np.argmax(y)]
    return mode
Ejemplo n.º 3
0
def peakfinder5(st,K=5):
    '''
    Found this with the old unit classification code.
    Haven't had time to reach it and check out what it does
    '''
    points = np.diff(st)
    points = np.array(points)
    points = points[points>10] # remove burst
    n, bins, patches = hist(points,
        bins=np.linspace(0,500,251),
        facecolor='k',
        normed=1)
    centers = (bins[1:]+bins[:-1])/2
    x,y = kdepeak(points,
        x_grid=np.linspace(0,500,251))
    plot(x,y,color='r',lw=1)
    p1 = x[np.argmax(y)]
    x,y = kdepeak(np.log(K+points[points>0]))
    x = np.exp(x)-K
    y = y/(K+x)
    plt.plot(x,y,color='g',lw=1)
    p2 = x[np.argmax(y)]
    plt.xlim(0,500)
    return p1,p2
Ejemplo n.º 4
0
def logmodeplot(points,K=5,burst=None):
    '''
    Accepts list of ISI times.
    Finds the mode using a log-KDE density estimate
    Plots this along with histogram
    '''
    points = np.array(points)
    if not burst is None:
        points = points[points>burst] # remove burst
    x,y = kdepeak(np.log(K+points[points>0]))
    x   = np.exp(x)-K
    y   = y/(K+x)
    cla()
    plt.hist(points,60,normed=1,color='k')
    plt.plot(x,y,lw=2,color='r')
    ybar(x[np.argmax(y)],color='r',lw=2)
    plt.draw()
    plt.show()
    mi = np.argmax(y)
    mode = x[mi]
    return mode