neurotools.spatial.kernels module
Utilities related to spatial kernels
- neurotools.spatial.kernels.laplace_kernel()[source]
Returns a 3x3 laplacian kernel that is as radially symmetric as possible.
- Return type:
3x3 np.array containing the discrete 2D Laplacian kernel
- neurotools.spatial.kernels.laplacian(x)[source]
Graph laplacian of a 2D mesh with absorbing boundary
In the middle
[0 1 0] [1 -4 1] [0 1 0]
At edges
[ 1 0] [ -3 1] [ 1 0]
At corners
[ -2 1] [ 1 0]
Example
>>> test = np.zeros((5,11),'float32') >>> test[2,5] = 1 >>> showim(test) >>> showim(laplacian(test))
- Parameters:
x (2D np.array)
- Return type:
np.array 2D graph laplacian applied to data x
- neurotools.spatial.kernels.gaussian_2D_kernel(sigma)[source]
Generate 2D Gaussian kernel as product of 2 1D kernels >>> showim(gaussian_2D_kernel(1))
- Parameters:
sigma (positive float) – Standard deviation of Gaussian kernel
- Return type:
2D gaussian kernel
- neurotools.spatial.kernels.absorbing_gaussian(x, sigma)[source]
Applies a gaussian convolution to 2d array x with absorbing boundary conditions.
- neurotools.spatial.kernels.absorbing_laplacian(x)[source]
Applies absorbing 2d Laplacian kernel to 2d array data x
- Parameters:
x (2D np.array)
- Returns:
np.array – bounary conditions.
- Return type:
result of applying graph laplacian to x with reflected
- neurotools.spatial.kernels.continuum_kernel(x)[source]
limit of continuum magic kernel as a piecewise function. See http://johncostella.webs.com/magic/
Discrete magic kernel is [.25,.75,.75,.25]
- neurotools.spatial.kernels.log_spline_basis(N=range(1, 6), t=array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]), base=2, offset=1)[source]
- neurotools.spatial.kernels.cosine_kernel(x)[source]
raised cosine basis kernel, normalized such that it integrates to 1 centered at zero. Time is rescaled so that the kernel spans from -2 to 2
- neurotools.spatial.kernels.log_cosine_basis(N=range(1, 6), t=array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]), base=2, offset=1)[source]
Generate overlapping log-cosine basis elements
- Parameters:
N (array of wave quarter-phases)
t (time base)
base (exponent base)
offset (leave this set to 1 (default))
- Returns:
B
- Return type:
array, Basis with n_elements x n_times shape
- neurotools.spatial.kernels.make_cosine_basis(N, L, min_interval)[source]
Build N logarightmically spaced cosine basis functions spanning L samples, with a peak resolution of min_interval
# Solve for a time basis with these constraints # t[0] = 0 # t[min_interval] = 1 # log(L)/log(b) = n_basis+1 # log(b) = log(L)/(n_basis+1) # b = exp(log(L)/(n_basis+1))
- Returns:
B
- Return type:
array, Basis with n_elements x n_times shape
- neurotools.spatial.kernels.exponential_basis(N=range(1, 6), t=array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]), base=2, offset=1)[source]
- neurotools.spatial.kernels.diffusion_basis(N=range(1, 6), t=array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]))[source]
Note: conceptually similar to other basis functions in this file with base=2 and offset=1 repeatly convolves exponential with itself to generate basis