elephant.current_source_density_src.KCSD module — Elephant 0.5.0 documentation

# elephant.current_source_density_src.KCSD module

This script is used to generate Current Source Density Estimates, using the kCSD method Jan et.al (2012). This was written by : [1]Chaitanya Chintaluri, [2]Michal Czerwinski, Laboratory of Neuroinformatics, Nencki Institute of Exprimental Biology, Warsaw. KCSD1D[1][2], KCSD2D[1], KCSD3D[1], MoIKCSD[1]

class `elephant.current_source_density_src.KCSD.` `CSD`(ele_pos, pots)

  Bases: `object`

  CSD - The base class for KCSD methods.

  Methods

  `sanity`(true_csd, pos_csd)

    Useful for comparing TrueCSD with reconstructed CSD. Computes, the RMS error between the true_csd and the reconstructed csd at pos_csd using the method defined. Parameters ———- true_csd : csd values used to generate potentials pos_csd : csd estimatation from the method Returns ——- RMSE : root mean squared difference

  `validate`(ele_pos, pots)

    Basic checks to see if inputs are okay

    Parameters: | ele_pos : numpy array positions of electrodes pots : numpy array potentials measured by electrodes

class `elephant.current_source_density_src.KCSD.` `KCSD`(ele_pos, pots, **kwargs)

  Bases: `elephant.current_source_density_src.KCSD.CSD`

  KCSD - The base class for all the KCSD variants. This estimates the Current Source Density, for a given configuration of electrod positions and recorded potentials, electrodes. The method implented here is based on the original paper by Jan Potworowski et.al. 2012.

  Methods

  `compute_cverror`(lambd, index_generator)

    Useful for Cross validation error calculations Parameters ———- lambd : float index_generator : list Returns ——- err : float

    > the sum of the error computed.

  `create_lookup`(dist_table_density=20)

    Creates a table for easy potential estimation from CSD. Updates and Returns the potentials due to a given basis source like a lookup table whose shape=(dist_table_density,) Parameters ———- dist_table_density : int

    > number of distance values at which potentials are computed. Default 100

  `cross_validate`(lambdas=None, Rs=None)

    Method defines the cross validation. By default only cross_validates over lambda, When no argument is passed, it takes lambdas = np.logspace(-2,-25,25,base=10.) and Rs = np.array(self.R).flatten() otherwise pass necessary numpy arrays Parameters ———- lambdas : numpy array Rs : numpy array Returns ——- R : post cross validation Lambda : post cross validation

  `method`()

    Actual sequence of methods called for KCSD Defines: self.k_pot and self.k_interp_cross matrices Parameters ———- None

  `parameters`(**kwargs)

    Defining the default values of the method passed as kwargs Parameters ———- **kwargs

    > Same as those passed to initialize the Class

  `process_estimate`(estimation)

    Function used to rearrange estimation according to dimension, to be used by the fuctions values Parameters ———- estimation : np.array Returns ——- estimation : np.array

    > estimated quantity of shape (ngx, ngy, ngz, nt)

  `update_R`(R)

    Update the width of the basis fuction - Used in Cross validation Parameters ———- R : float

  `update_b_interp_pot`()

    Compute the matrix of potentials generated by every source basis function at every position in the interpolated space. Updates b_interp_pot Updates k_interp_pot Parameters ———- None

  `update_b_pot`()

    Updates the b_pot - array is (#_basis_sources, #_electrodes) Updates the k_pot - array is (#_electrodes, #_electrodes) K(x,x’) Eq9,Jan2012 Calculates b_pot - matrix containing the values of all the potential basis functions in all the electrode positions (essential for calculating the cross_matrix). Parameters ———- None

  `update_b_src`()

    Updates the b_src in the shape of (#_est_pts, #_basis_sources) Updates the k_interp_cross - K_t(x,y) Eq17 Calculate b_src - matrix containing containing the values of all the source basis functions in all the points at which we want to calculate the solution (essential for calculating the cross_matrix) Parameters ———- None

  `update_lambda`(lambd)

    Update the lambda parameter of regularization, Used in Cross validation Parameters ———- lambd : float

  `values`(estimate='CSD')

    Computes the values of the quantity of interest Parameters ———- estimate : ‘CSD’ or ‘POT’

    > What quantity is to be estimated Defaults to ‘CSD’

    estimation : np.array
      estimated quantity of shape (ngx, ngy, ngz, nt)

class `elephant.current_source_density_src.KCSD.` `KCSD1D`(ele_pos, pots, **kwargs)

  Bases: `elephant.current_source_density_src.KCSD.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.

  Methods

  `create_src_dist_tables`()

    Creates distance tables between sources, electrode and estm points Parameters ———- None

  `estimate_at`()

    Defines locations where the estimation is wanted Defines: self.n_estm = self.estm_x.size self.ngx = self.estm_x.shape self.estm_x : Locations at which CSD is requested. Parameters ———- None

  `forward_model`(x, R, h, sigma, src_type)

    FWD model functions Evaluates potential at point (x,0) by a basis source located at (0,0) Eq 26 kCSD by Jan,2012 Parameters ———- x : float R : float h : float sigma : float src_type : basis_1D.key Returns ——- pot : float

    > value of potential at specified distance from the source

  `int_pot_1D`(xp, x, R, h, basis_func)

    FWD model function. Returns contribution of a point xp,yp, belonging to a basis source support centered at (0,0) to the potential measured at (x,0), integrated over xp,yp gives the potential generated by a basis source element centered at (0,0) at point (x,0) Eq 26 kCSD by Jan,2012

    Parameters: | xp : floats or np.arrays point or set of points where function should be calculated x : float position at which potential is being measured R : float The size of the basis function h : float thickness of slice basis_func : method Fuction of the basis source
    Returns: | pot : float

  `place_basis`()

    Places basis sources of the defined type. Checks if a given source_type is defined, if so then defines it self.basis, This function gives locations of the basis sources, Defines source_type : basis_fuctions.basis_1D.keys() self.R based on R_init self.dist_max as maximum distance between electrode and basis self.nsx = self.src_x.shape self.src_x : Locations at which basis sources are placed. Parameters ———- None

class `elephant.current_source_density_src.KCSD.` `KCSD2D`(ele_pos, pots, **kwargs)

  Bases: `elephant.current_source_density_src.KCSD.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.

  Methods

  `create_src_dist_tables`()

    Creates distance tables between sources, electrode and estm points Parameters ———- None

  `estimate_at`()

    Defines locations where the estimation is wanted Defines: self.n_estm = self.estm_x.size self.ngx, self.ngy = self.estm_x.shape self.estm_x, self.estm_y : Locations at which CSD is requested. Parameters ———- None

  `forward_model`(x, R, h, sigma, src_type)

    FWD model functions Evaluates potential at point (x,0) by a basis source located at (0,0) Eq 22 kCSD by Jan,2012 Parameters ———- x : float R : float h : float sigma : float src_type : basis_2D.key Returns ——- pot : float

    > value of potential at specified distance from the source

  `int_pot_2D`(xp, yp, x, R, h, basis_func)

    FWD model function. Returns contribution of a point xp,yp, belonging to a basis source support centered at (0,0) to the potential measured at (x,0), integrated over xp,yp gives the potential generated by a basis source element centered at (0,0) at point (x,0) Parameters ———- xp, yp : floats or np.arrays

    > point or set of points where function should be calculated

    x : float
      position at which potential is being measured
    R : float
      The size of the basis function
    h : float
      thickness of slice
    basis_func : method
      Fuction of the basis source

    pot : float

  `place_basis`()

    Places basis sources of the defined type. Checks if a given source_type is defined, if so then defines it self.basis, This function gives locations of the basis sources, Defines source_type : basis_fuctions.basis_2D.keys() self.R based on R_init self.dist_max as maximum distance between electrode and basis self.nsx, self.nsy = self.src_x.shape self.src_x, self.src_y : Locations at which basis sources are placed. Parameters ———- None

class `elephant.current_source_density_src.KCSD.` `KCSD3D`(ele_pos, pots, **kwargs)

  Bases: `elephant.current_source_density_src.KCSD.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.

  Methods

  `create_src_dist_tables`()

    Creates distance tables between sources, electrode and estm points Parameters ———- None

  `estimate_at`()

    Defines locations where the estimation is wanted Defines: self.n_estm = self.estm_x.size self.ngx, self.ngy, self.ngz = self.estm_x.shape self.estm_x, self.estm_y, self.estm_z : Pts. at which CSD is requested Parameters ———- None

  `forward_model`(x, R, h, sigma, src_type)

    FWD model functions Evaluates potential at point (x,0) by a basis source located at (0,0) Utlizies sk monaco monte carlo method if available, otherwise defaults to scipy integrate Parameters ———- x : float R : float h : float sigma : float src_type : basis_3D.key Returns ——- pot : float

    > value of potential at specified distance from the source

  `int_pot_3D`(xp, yp, zp, x, R, h, basis_func)

    FWD model function. Returns contribution of a point xp,yp, belonging to a basis source support centered at (0,0) to the potential measured at (x,0), integrated over xp,yp gives the potential generated by a basis source element centered at (0,0) at point (x,0) Parameters ———- xp, yp, zp : floats or np.arrays

    > point or set of points where function should be calculated

    x : float
      position at which potential is being measured
    R : float
      The size of the basis function
    h : float
      thickness of slice
    basis_func : method
      Fuction of the basis source

    pot : float

  `int_pot_3D_mc`(xyz, x, R, h, basis_func)

    The same as int_pot_3D, just different input: x,y,z <– xyz (tuple) FWD model function, using Monte Carlo Method of integration Returns contribution of a point xp,yp, belonging to a basis source support centered at (0,0) to the potential measured at (x,0), integrated over xp,yp gives the potential generated by a basis source element centered at (0,0) at point (x,0) Parameters ———- xp, yp, zp : floats or np.arrays

    > point or set of points where function should be calculated

    x : float
      position at which potential is being measured
    R : float
      The size of the basis function
    h : float
      thickness of slice
    basis_func : method
      Fuction of the basis source

    pot : float

  `place_basis`()

    Places basis sources of the defined type. Checks if a given source_type is defined, if so then defines it self.basis, This function gives locations of the basis sources, Defines source_type : basis_fuctions.basis_2D.keys() self.R based on R_init self.dist_max as maximum distance between electrode and basis self.nsx, self.nsy, self.nsz = self.src_x.shape self.src_x, self.src_y, self.src_z : Locations at which basis sources are placed. Parameters ———- None

class `elephant.current_source_density_src.KCSD.` `MoIKCSD`(ele_pos, pots, **kwargs)

  Bases: `elephant.current_source_density_src.KCSD.KCSD2D`

  MoIKCSD - CSD while including the forward modeling effects of saline.

  This estimates the Current Source Density, for a given configuration of electrod positions and recorded potentials, in the case of 2D recording electrodes from an MEA electrode plane using the Method of Images. The method implented here is based on kCSD method by Jan Potworowski et.al. 2012, which was extended in Ness, Chintaluri 2015 for MEA.

  Methods

  `forward_model`(x, R, h, sigma, src_type)

    FWD model functions Evaluates potential at point (x,0) by a basis source located at (0,0) Eq 22 kCSD by Jan,2012 Parameters ———- x : float R : float h : float sigma : float src_type : basis_2D.key Returns ——- pot : float

    > value of potential at specified distance from the source

  `int_pot_2D_moi`(xp, yp, x, R, h, basis_func)

    FWD model function. Incorporates the Method of Images. Returns contribution of a point xp,yp, belonging to a basis source support centered at (0,0) to the potential measured at (x,0), integrated over xp,yp gives the potential generated by a basis source element centered at (0,0) at point (x,0) #Eq 20, Ness(2015) Parameters ———- xp, yp : floats or np.arrays

    > point or set of points where function should be calculated

    x : float
      position at which potential is being measured
    R : float
      The size of the basis function
    h : float
      thickness of slice
    basis_func : method
      Fuction of the basis source

    pot : float