How to use the elephant.current_source_density_src.KCSD.KCSD function in elephant

To help you get started, we’ve selected a few elephant examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NeuralEnsemble / elephant / elephant / current_source_density_src / KCSD.py View on Github external
basis_func : method
            Fuction of the basis source
        Returns
        -------
        pot : float
        """
        L = ((x-xp)**2 + yp**2)**(0.5)
        if L < 0.00001:
            L = 0.00001
        correction = np.arcsinh((h-(2*h*self.iters))/L) + np.arcsinh((h+(2*h*self.iters))/L)
        pot = np.arcsinh(h/L) + np.sum(self.iter_factor*correction)
        dist = np.sqrt(xp**2 + yp**2)
        pot *= basis_func(dist, R) #Eq 20, Ness et.al.
        return pot

class KCSD3D(KCSD):
    """KCSD3D - The 3D variant for the Kernel Current Source Density method.
    This estimates the Current Source Density, for a given configuration of
    electrod positions and recorded potentials, in the case of 2D recording
    electrodes. The method implented here is based on the original paper
    by Jan Potworowski et.al. 2012.
    """
    def __init__(self, ele_pos, pots, **kwargs):
        """Initialize KCSD3D Class.
        Parameters
        ----------
        ele_pos : numpy array
            positions of electrodes
        pots : numpy array
            potentials measured by electrodes
        **kwargs
            configuration parameters, that may contain the following keys:
github NeuralEnsemble / elephant / elephant / current_source_density_src / KCSD.py View on Github external
R : float
            The size of the basis function
        h : float
            thickness of slice
        basis_func : method
            Fuction of the basis source

        Returns
        -------
        pot : float
        """
        m = np.sqrt((x-xp)**2 + h**2) - abs(x-xp)
        m *= basis_func(abs(xp), R)  #xp is the distance
        return m

class KCSD2D(KCSD):
    """KCSD2D - The 2D variant for the Kernel Current Source Density method.
    This estimates the Current Source Density, for a given configuration of
    electrod positions and recorded potentials, in the case of 2D recording
    electrodes. The method implented here is based on the original paper
    by Jan Potworowski et.al. 2012.
    """
    def __init__(self, ele_pos, pots, **kwargs):
        """Initialize KCSD2D Class.
        Parameters
        ----------
        ele_pos : numpy array
            positions of electrodes
        pots : numpy array
            potentials measured by electrodes
        **kwargs
            configuration parameters, that may contain the following keys:
github NeuralEnsemble / elephant / elephant / current_source_density_src / KCSD.py View on Github external
def __init__(self, ele_pos, pots, **kwargs):
        super(KCSD, self).__init__(ele_pos, pots)
        self.parameters(**kwargs)
        self.estimate_at()
        self.place_basis()
        self.create_src_dist_tables()
        self.method()
github NeuralEnsemble / elephant / elephant / current_source_density_src / KCSD.py View on Github external
V_test = self.pots[idx_test]
            I_matrix = np.identity(len(idx_train))
            B_new = np.matrix(B_train) + (lambd*I_matrix)
            try:
                beta_new = np.dot(np.matrix(B_new).I, np.matrix(V_train))
                B_test = self.k_pot[np.ix_(idx_test, idx_train)]
                V_est = np.zeros((len(idx_test), self.pots.shape[1]))
                for ii in range(len(idx_train)):
                    for tt in range(self.pots.shape[1]):
                        V_est[:, tt] += beta_new[ii, tt] * B_test[:, ii]
                err += np.linalg.norm(V_est-V_test)
            except LinAlgError:
                raise LinAlgError('Encoutered Singular Matrix Error: try changing ele_pos slightly')
        return err

class KCSD1D(KCSD):
    """KCSD1D - The 1D variant for the Kernel Current Source Density method.
    This estimates the Current Source Density, for a given configuration of
    electrod positions and recorded potentials, in the case of 1D recording
    electrodes (laminar probes). The method implented here is based on the
    original paper by Jan Potworowski et.al. 2012.
    """
    def __init__(self, ele_pos, pots, **kwargs):
        """Initialize KCSD1D Class.
        Parameters
        ----------
        ele_pos : numpy array
            positions of electrodes
        pots : numpy array
            potentials measured by electrodes
        **kwargs
            configuration parameters, that may contain the following keys: