Esempio n. 1
0
def synchrony_stats(V, dt, maxlags=3000):
    """
    Synchrony measures

    Parameters
    ----------
        V: numneuron x time
        maxlags: maximal lag for autocorrelation, default = 3000 ms
    
    Returns
    -------
        chi: synchrony measure
        autocorr: autocorrelation of population avg \bar{V}(t)
    """
    Vpop = np.mean( V, axis=0 ) # pop avg
    sigmaV = np.mean( np.square(Vpop) ) - np.square( np.mean(Vpop) )
    sigmaVi = np.mean( np.square(V), axis=1 ) - np.square( np.mean(V, axis=1) )
    sigmaViMean = np.mean( sigmaVi )
    chisq = sigmaV / sigmaViMean
    chi = np.sqrt( chisq )
    autocorr = acorr( Vpop - np.mean(Vpop), onesided=True, scale='coeff' )
    return chi, autocorr
Esempio n. 2
0
def synchrony_stats(V, dt, maxlags=3000):
    """
    Synchrony measures

    Parameters
    ----------
        V: numneuron x time
        maxlags: maximal lag for autocorrelation, default = 3000 ms
    
    Returns
    -------
        chi: synchrony measure
        autocorr: autocorrelation of population avg \bar{V}(t)
    """
    Vpop = np.mean(V, axis=0)  # pop avg
    sigmaV = np.mean(np.square(Vpop)) - np.square(np.mean(Vpop))
    sigmaVi = np.mean(np.square(V), axis=1) - np.square(np.mean(V, axis=1))
    sigmaViMean = np.mean(sigmaVi)
    chisq = sigmaV / sigmaViMean
    chi = np.sqrt(chisq)
    autocorr = acorr(Vpop - np.mean(Vpop), onesided=True, scale='coeff')
    return chi, autocorr
Esempio n. 3
0
def synchrony_stats(data, dt, maxlags=3000):
    '''
    Synchrony measures

    Parameters
    ==========
      data: numneuron x time
      maxlags: maximal lag for autocorrelation, default = 3000 ms
    
    Returns
    =======
      chi: synchrony measure
      autocorr: autocorrelation of population avg \bar{data}(t)
    '''
    data_pop = np.mean(data, axis=0) # pop avg
    sigma_pop = np.mean(np.square(data_pop)) - np.square(np.mean(data_pop))
    sigma = np.mean(np.square(data), axis=1) - np.square(np.mean(data, axis=1))
    sigma_mean = np.mean(sigma)
    chisq = sigma_pop / sigma_mean
    chi = np.sqrt(chisq)
    autocorr = acorr(data_pop - np.mean(data_pop), onesided=True, scale='coeff')
    return chi, autocorr
Esempio n. 4
0
def synchrony_stats(data, dt, maxlags=3000):
    '''
    Synchrony measures

    Parameters
    ==========
      data: numneuron x time
      maxlags: maximal lag for autocorrelation, default = 3000 ms
    
    Returns
    =======
      chi: synchrony measure
      autocorr: autocorrelation of population avg \bar{data}(t)
    '''
    data_pop = np.mean(data, axis=0)  # pop avg
    sigma_pop = np.mean(np.square(data_pop)) - np.square(np.mean(data_pop))
    sigma = np.mean(np.square(data), axis=1) - np.square(np.mean(data, axis=1))
    sigma_mean = np.mean(sigma)
    chisq = sigma_pop / sigma_mean
    chi = np.sqrt(chisq)
    autocorr = acorr(data_pop - np.mean(data_pop),
                     onesided=True,
                     scale='coeff')
    return chi, autocorr
Esempio n. 5
0
#         y[i] = lfilter(b[i], a[i], x[i])
#     return y
# 
# def f2(b, a, x):
#     return lfilter2(b, a, x)
# 
# nframes = 3600
# a = np.random.randn(nframes, 1)
# #a = np.array([[1], [-1]])
# b = np.random.randn(nframes, 24)
# #b = np.array([[1, 1], [1, 1]])
# x = np.random.randn(nframes, 256)
# #x = np.linspace(0, 19, 20).reshape((2, 10))
# 
# y = f1(b, a, x)
# yr = f2(b, a, x)
# np.testing.assert_array_almost_equal(y, yr)

x = np.random.randn(1, 5)

maxlag = 1
onesided = False
axis = 1
nx = x.shape[1]
y = cacorr(x, maxlag, onesided, axis)
r_y = acorr(x, axis, onesided)

#print y
#print r_y
np.testing.assert_array_almost_equal(y, r_y[:,nx-maxlag-1:nx+maxlag])