neuroprob/rate_models.py
def gaussian_to_w(mu, prec, rate_0, theta_p):
    """
    Get GLM parameters from Gaussian and orthogonal theta parameterization
    
    :param np.array mu: mean of the Gaussian field of shape (neurons, 2)
    :param np.array prec: precision matrix elements xx, yy, and xy of shape (neurons, 3)
    :param np.array rate_0: rate amplitude of shape (neurons)
    :param np.array theta_p: theta modulation parameters beta and theta_0 of shape (neurons, 2)
    """
    neurons = mu.shape[0]
    prec_mat = []
    for n in range(neurons):
        prec_mat.append([[prec[n, 0], prec[n, 2]], [prec[n, 2], prec[n, 1]]])
    prec_mat = np.array(prec_mat)
    w = np.empty((neurons, 8))
    w[:, 0] = np.log(rate_0) - 0.5*(mu * np.einsum('nij,nj->ni', prec_mat, mu)).sum(1)
    w[:, 1] = mu[:, 0]*prec[:, 0] + mu[:, 1]*prec[:, 2]
    w[:, 2] = mu[:, 1]*prec[:, 1] + mu[:, 0]*prec[:, 2]
    w[:, 3] = -0.5*prec[:, 0]
    w[:, 4] = -0.5*prec[:, 1]
    w[:, 5] = -prec[:, 2]
    w[:, 6] = theta_p[:, 0]*np.cos(theta_p[:, 1])
    w[:, 7] = theta_p[:, 0]*np.sin(theta_p[:, 1])
    return w

    Get GLM parameters from Gaussian and orthogonal theta parameterization
    
    :param np.array mu: mean of the Gaussian field of shape (neurons, 2)
    :param np.array prec: precision matrix elements xx, yy, and xy of shape (neurons, 3)
    :param np.array rate_0: rate amplitude of shape (neurons)
    :param np.array theta_p: theta modulation parameters beta and theta_0 of shape (neurons, 2)
    
Get GLM parameters from Gaussian and orthogonal theta parameterization
Get GLM parameters from Gaussian and orthogonal theta parameterization
def gaussian_to_w(mu, prec, rate_0, theta_p):
    neurons = mu.shape[0]
    prec_mat = []
    for n in range(neurons):
        prec_mat.append([[prec[n, 0], prec[n, 2]], [prec[n, 2], prec[n, 1]]])
    prec_mat = np.array(prec_mat)
    w = np.empty((neurons, 8))
    w[:, 0] = np.log(rate_0) - 0.5*(mu * np.einsum('nij,nj->ni', prec_mat, mu)).sum(1)
    w[:, 1] = mu[:, 0]*prec[:, 0] + mu[:, 1]*prec[:, 2]
    w[:, 2] = mu[:, 1]*prec[:, 1] + mu[:, 0]*prec[:, 2]
    w[:, 3] = -0.5*prec[:, 0]
    w[:, 4] = -0.5*prec[:, 1]
    w[:, 5] = -prec[:, 2]
    w[:, 6] = theta_p[:, 0]*np.cos(theta_p[:, 1])
    w[:, 7] = theta_p[:, 0]*np.sin(theta_p[:, 1])
    return w
def gaussian_to_w ( mu , prec , rate_0 , theta_p ) : neurons = mu . shape [ 0 ] prec_mat = [ ] for n in range ( neurons ) : prec_mat . append ( [ [ prec [ n , 0 ] , prec [ n , 2 ] ] , [ prec [ n , 2 ] , prec [ n , 1 ] ] ] ) prec_mat = np . array ( prec_mat ) w = np . empty ( ( neurons , 8 ) ) w [ : , 0 ] = np . log ( rate_0 ) - 0.5 * ( mu * np . einsum ( 'nij,nj->ni' , prec_mat , mu ) ) . sum ( 1 ) w [ : , 1 ] = mu [ : , 0 ] * prec [ : , 0 ] + mu [ : , 1 ] * prec [ : , 2 ] w [ : , 2 ] = mu [ : , 1 ] * prec [ : , 1 ] + mu [ : , 0 ] * prec [ : , 2 ] w [ : , 3 ] = - 0.5 * prec [ : , 0 ] w [ : , 4 ] = - 0.5 * prec [ : , 1 ] w [ : , 5 ] = - prec [ : , 2 ] w [ : , 6 ] = theta_p [ : , 0 ] * np . cos ( theta_p [ : , 1 ] ) w [ : , 7 ] = theta_p [ : , 0 ] * np . sin ( theta_p [ : , 1 ] ) return w
Get GLM parameters from Gaussian and orthogonal theta parameterization
Get GLM parameters from Gaussian and orthogonal theta parameterization
"""
    Get GLM parameters from Gaussian and orthogonal theta parameterization
    
    :param np.array mu: mean of the Gaussian field of shape (neurons, 2)
    :param np.array prec: precision matrix elements xx, yy, and xy of shape (neurons, 3)
    :param np.array rate_0: rate amplitude of shape (neurons)
    :param np.array theta_p: theta modulation parameters beta and theta_0 of shape (neurons, 2)
    """
mu
mean of the Gaussian field of shape (neurons, 2)
mean of the Gaussian field of shape ( neurons 2 )
prec
precision matrix elements xx, yy, and xy of shape (neurons, 3)
precision matrix elements xx yy and xy of shape ( neurons 3 )
rate_0
rate amplitude of shape (neurons)
rate amplitude of shape ( neurons )
theta_p
theta modulation parameters beta and theta_0 of shape (neurons, 2)
theta modulation parameters beta and theta_0 of shape ( neurons 2 )