elephant.current_source_density_src.utility_functions module

These are some useful functions used in CSD methods, They include CSD source profiles to be used as ground truths, placement of electrodes in 1D, 2D and 3D., etc These scripts are based on Grzegorz Parka’s, Google Summer of Code 2014, INFC/pykCSD This was written by : Michal Czerwinski, Chaitanya Chintaluri Laboratory of Neuroinformatics, Nencki Institute of Experimental Biology, Warsaw.

elephant.current_source_density_src.utility_functions.check_for_duplicated_electrodes(elec_pos)[source]

Checks for duplicate electrodes Parameters ———- elec_pos : np.array Returns ——- has_duplicated_elec : Boolean

elephant.current_source_density_src.utility_functions.distribute_srcs_1D(X, n_src, ext_x, R_init)[source]

Distribute sources in 1D equally spaced Parameters ———- X : np.arrays

points at which CSD will be estimated
n_src : int
number of sources to be included in the model
ext_x : floats
how much should the sources extend the area X
R_init : float
Same as R in 1D case
X_src : np.arrays
positions of the sources
R : float
effective radius of the basis element
elephant.current_source_density_src.utility_functions.distribute_srcs_2D(X, Y, n_src, ext_x, ext_y, R_init)[source]

Distribute n_src’s in the given area evenly Parameters ———- X, Y : np.arrays

points at which CSD will be estimated
n_src : int
demanded number of sources to be included in the model
ext_x, ext_y : floats
how should the sources extend the area X, Y
R_init : float
demanded radius of the basis element
X_src, Y_src : np.arrays
positions of the sources
nx, ny : ints
number of sources in directions x,y new n_src = nx * ny may not be equal to the demanded number of sources
R : float
effective radius of the basis element
elephant.current_source_density_src.utility_functions.distribute_srcs_3D(X, Y, Z, n_src, ext_x, ext_y, ext_z, R_init)[source]

Distribute n_src sources evenly in a rectangle of size Lx * Ly * Lz Parameters ———- X, Y, Z : np.arrays

points at which CSD will be estimated
n_src : int
desired number of sources we want to include in the model
ext_x, ext_y, ext_z : floats
how should the sources extend over the area X,Y,Z
R_init : float
demanded radius of the basis element
Returns:

X_src, Y_src, Z_src : np.arrays

positions of the sources in 3D space

nx, ny, nz : ints

number of sources in directions x,y,z new n_src = nx * ny * nz may not be equal to the demanded number of sources

R : float

updated radius of the basis element

elephant.current_source_density_src.utility_functions.gauss_1d_dipole(x)[source]

1D Gaussian dipole source is placed between 0 and 1 to be used to test the CSD

Parameters:

x : np.array

Spatial pts. at which the true csd is evaluated

Returns:

f : np.array

The value of the csd at the requested points

elephant.current_source_density_src.utility_functions.gauss_3d_dipole(x, y, z)[source]

3D Gaussian dipole profile - to be used to test csd. Parameters ———- x : np.array

Spatial x pts. at which the true csd is evaluated
y : np.array
Spatial y pts. at which the true csd is evaluated
z : np.array
Spatial z pts. at which the true csd is evaluated
f : np.array
The value of the csd at the requested points
elephant.current_source_density_src.utility_functions.generate_electrodes(dim, xlims=[0.1, 0.9], ylims=[0.1, 0.9], zlims=[0.1, 0.9], res=5)[source]

Generates electrodes, helpful for FWD funtion. Parameters ———- dim : int

Dimensionality of the electrodes, 1,2 or 3
xlims : [start, end]
Spatial limits of the electrodes
ylims : [start, end]
Spatial limits of the electrodes
zlims : [start, end]
Spatial limits of the electrodes
res : int
How many electrodes in each dimension

ele_x, ele_y, ele_z : flattened np.array of the electrode pos

elephant.current_source_density_src.utility_functions.get_src_params_2D(Lx, Ly, n_src)[source]

Distribute n_src sources evenly in a rectangle of size Lx * Ly Parameters ———- Lx, Ly : floats

lengths in the directions x, y of the area, the sources should be placed
n_src : int
demanded number of sources
Returns:

nx, ny : ints

number of sources in directions x, y new n_src = nx * ny may not be equal to the demanded number of sources

Lx_n, Ly_n : floats

updated lengths in the directions x, y

ds : float

spacing between the sources

elephant.current_source_density_src.utility_functions.get_src_params_3D(Lx, Ly, Lz, n_src)[source]

Helps to evenly distribute n_src sources in a cuboid of size Lx * Ly * Lz Parameters ———- Lx, Ly, Lz : floats

lengths in the directions x, y, z of the area, the sources should be placed
n_src : int
demanded number of sources to be included in the model
nx, ny, nz : ints
number of sources in directions x, y, z new n_src = nx * ny * nz may not be equal to the demanded number of sources
Lx_n, Ly_n, Lz_n : floats
updated lengths in the directions x, y, z
ds : float
spacing between the sources (grid nodes)
elephant.current_source_density_src.utility_functions.large_source_2D(x, y)[source]

2D Gaussian large source profile - to use to test csd Parameters ———- x : np.array

Spatial x pts. at which the true csd is evaluated
y : np.array
Spatial y pts. at which the true csd is evaluated
f : np.array
The value of the csd at the requested points
elephant.current_source_density_src.utility_functions.patch_quantities()[source]

patch quantities with the SI unit Siemens if it does not exist

elephant.current_source_density_src.utility_functions.small_source_2D(x, y)[source]

2D Gaussian small source profile - to be used to test csd Parameters ———- x : np.array

Spatial x pts. at which the true csd is evaluated
y : np.array
Spatial y pts. at which the true csd is evaluated
f : np.array
The value of the csd at the requested points