neuroprob/utils/neural.py
def geometric_tuning(ori_rate, smth_rate, prob):
    r"""
    Compute coherence and sparsity related to the geometric properties of tuning curves.
    """
    # Pearson r correlation
    units = ori_rate.shape[0]
    coherence = np.empty(units)
    for u in range(units):
        x_1 = ori_rate[u].flatten()
        x_2 = smth_rate[u].flatten()
        coherence[u] = np.dot(x_1 - x_1.mean(), x_2 - x_2.mean()) / len(x_1) / x_1.std() / x_2.std()

    # Computes the sparsity of the tuning
    sparsity = np.empty(units)
    for u in range(units):
        sparsity[u] = 1-(prob * ori_rate[u]).sum()**2 / (prob * ori_rate[u]**2).sum()
        
    return coherence, sparsity
r"""
    Compute coherence and sparsity related to the geometric properties of tuning curves.
    
r"""
Compute coherence and sparsity related to the geometric properties of tuning curves.
r " " " Compute coherence and sparsity related to the geometric properties of tuning curves .
def geometric_tuning(ori_rate, smth_rate, prob):
    units = ori_rate.shape[0]
    coherence = np.empty(units)
    for u in range(units):
        x_1 = ori_rate[u].flatten()
        x_2 = smth_rate[u].flatten()
        coherence[u] = np.dot(x_1 - x_1.mean(), x_2 - x_2.mean()) / len(x_1) / x_1.std() / x_2.std()
    sparsity = np.empty(units)
    for u in range(units):
        sparsity[u] = 1-(prob * ori_rate[u]).sum()**2 / (prob * ori_rate[u]**2).sum()
    return coherence, sparsity
def geometric_tuning ( ori_rate , smth_rate , prob ) : units = ori_rate . shape [ 0 ] coherence = np . empty ( units ) for u in range ( units ) : x_1 = ori_rate [ u ] . flatten ( ) x_2 = smth_rate [ u ] . flatten ( ) coherence [ u ] = np . dot ( x_1 - x_1 . mean ( ) , x_2 - x_2 . mean ( ) ) / len ( x_1 ) / x_1 . std ( ) / x_2 . std ( ) sparsity = np . empty ( units ) for u in range ( units ) : sparsity [ u ] = 1 - ( prob * ori_rate [ u ] ) . sum ( ) ** 2 / ( prob * ori_rate [ u ] ** 2 ) . sum ( ) return coherence , sparsity
r"""
Compute coherence and sparsity related to the geometric properties of tuning curves.
r " " " Compute coherence and sparsity related to the geometric properties of tuning curves .
r"""
    Compute coherence and sparsity related to the geometric properties of tuning curves.
    """ # Pearson r correlation # Computes the sparsity of the tuning
ori_rate
smth_rate
prob