# Path: pyglm/utils/basis.py
# def create_basis(prms):
#     """ Create a basis for impulse response functions
#     """
#     type = prms['type'].lower()
#     if type == 'exp':
#         basis = create_exp_basis(prms)
#     elif type == 'cosine':
#         basis = create_cosine_basis(prms)
#     elif type == 'gaussian':
#         basis = create_gaussian_basis(prms)
#     elif type == 'identity' or type == 'eye':
#         basis = create_identity_basis(prms)
#     elif type == 'file':
#         if os.path.exists(prms["fname"]):
#             basis = load_basis_from_file(prms['fname'])
#     else:
#         raise Exception("Unrecognized basis type: %s", type)
#     return basis
# 
# Path: pyglm/components/priors.py
# def create_prior(model, **kwargs):
#     typ = model['type'].lower()
#     if typ == 'normal' or \
#        typ == 'gaussian':
#        return Gaussian(model, **kwargs)
#     elif typ == 'categorical':
#        return Categorical(model, **kwargs)
#     elif typ == 'jointcategorical' or \
#          typ == 'joint_categorical':
#        return JointCategorical(model, **kwargs)
#     elif typ == 'spherical_gaussian':
#         return SphericalGaussian(model, **kwargs)
#     elif typ == 'group_lasso' or \
#          typ == 'grouplasso':
#         return GroupLasso(model, **kwargs)
#     elif typ == 'dpp':
#         return DeterminenalPointProcess(model, **kwargs)
#     elif typ == 'dirichlet':
#         return Dirichlet(model)
#     else:
#         raise Exception("Unrecognized prior type: %s" % typ)


import numpy as np
import theano.tensor as T
from component import Component
from pyglm.utils.basis import create_basis
from pyglm.components.priors import create_prior
        from pyglm.components.priors import Categorical, JointCategorical
        Lt_int = self.type_model['dt_max']/dt
        t_int = np.linspace(0,1,Lt_int)
        t_bas = np.linspace(0,1,Lt)
        ibasis_t = np.zeros((len(t_int), Bt))
        for b in np.arange(Bt):
            ibasis_t[:,b] = np.interp(t_int, t_bas, self.temporal_basis[:,b])

        # Normalize so that the interpolated basis has unit L1 norm
        if self.type_model['temporal_basis']['norm']:
            ibasis_t = ibasis_t / np.tile(np.sum(ibasis_t,0),[Lt_int,1])

        # Save the interpolated bases
        self.interpolated_temporal_basis = ibasis_t
        self.interpolated_spatial_basis = self.spatial_basis


class LatentLocation(Component):
    """
    The latent location of a neuron in either real or abstract space
    """
    def __init__(self, model, loc_model):
        self.model = model
        self.N = model['N']

        self.prms = loc_model
        self.name = self.prms['name']
        self.N_dims = self.prms['N_dims']


        # Create a location prior

# Path: pyglm/utils/basis.py
# def create_basis(prms):
#     """ Create a basis for impulse response functions
#     """
#     type = prms['type'].lower()
#     if type == 'exp':
#         basis = create_exp_basis(prms)
#     elif type == 'cosine':
#         basis = create_cosine_basis(prms)
#     elif type == 'gaussian':
#         basis = create_gaussian_basis(prms)
#     elif type == 'identity' or type == 'eye':
#         basis = create_identity_basis(prms)
#     elif type == 'file':
#         if os.path.exists(prms["fname"]):
#             basis = load_basis_from_file(prms['fname'])
#     else:
#         raise Exception("Unrecognized basis type: %s", type)
#     return basis
# 
# Path: pyglm/components/priors.py
# def create_prior(model, **kwargs):
#     typ = model['type'].lower()
#     if typ == 'normal' or \
#        typ == 'gaussian':
#        return Gaussian(model, **kwargs)
#     elif typ == 'categorical':
#        return Categorical(model, **kwargs)
#     elif typ == 'jointcategorical' or \
#          typ == 'joint_categorical':
#        return JointCategorical(model, **kwargs)
#     elif typ == 'spherical_gaussian':
#         return SphericalGaussian(model, **kwargs)
#     elif typ == 'group_lasso' or \
#          typ == 'grouplasso':
#         return GroupLasso(model, **kwargs)
#     elif typ == 'dpp':
#         return DeterminenalPointProcess(model, **kwargs)
#     elif typ == 'dirichlet':
#         return Dirichlet(model)
#     else:
#         raise Exception("Unrecognized prior type: %s" % typ)


# Path: pyglm/components/latent.py
import numpy as np
import theano.tensor as T
from component import Component
from pyglm.utils.basis import create_basis
from pyglm.components.priors import create_prior
        from pyglm.components.priors import Categorical, JointCategorical

        Lt_int = self.type_model['dt_max']/dt
        t_int = np.linspace(0,1,Lt_int)
        t_bas = np.linspace(0,1,Lt)
        ibasis_t = np.zeros((len(t_int), Bt))
        for b in np.arange(Bt):
            ibasis_t[:,b] = np.interp(t_int, t_bas, self.temporal_basis[:,b])

        # Normalize so that the interpolated basis has unit L1 norm
        if self.type_model['temporal_basis']['norm']:
            ibasis_t = ibasis_t / np.tile(np.sum(ibasis_t,0),[Lt_int,1])

        # Save the interpolated bases
        self.interpolated_temporal_basis = ibasis_t
        self.interpolated_spatial_basis = self.spatial_basis


class LatentLocation(Component):
    """
    The latent location of a neuron in either real or abstract space
    """
    def __init__(self, model, loc_model):
        self.model = model
        self.N = model['N']

        self.prms = loc_model
        self.name = self.prms['name']
        self.N_dims = self.prms['N_dims']


        # Create a location prior

        self.location_prior = create_prior(self.prms['location_prior'])