GaussianKernel#
- class braintools.conn.GaussianKernel(sigma, max_distance=None, normalize=True, allow_self_connections=False, weight=None, delay=None, **kwargs)#
Gaussian kernel connectivity for center-surround receptive fields.
Creates connections weighted by a Gaussian function of distance, useful for implementing smooth spatial receptive fields.
Only the first two position dimensions (x, y) are used; any extra columns (e.g. z) are ignored.
- Parameters:
sigma (
Array|ndarray|bool|number|bool|int|float|complex|Quantity) – Standard deviation of Gaussian.max_distance (
Array|ndarray|bool|number|bool|int|float|complex|Quantity|None) – Maximum distance for connections (default: 3*sigma).normalize (
bool) – Whether to normalize the Gaussian (default: True). Normalization uses the 2-D constant1 / (2 * pi * sigma**2)(positions are treated as 2-D, see above).allow_self_connections (
bool) – Whether a neuron may connect to itself when pre and post are the same population (default: False). A coincident pre/post would otherwise connect at the Gaussian peak.weight (
Initialization|float|int|ndarray|Array|Quantity|None) – Weight initialization (Gaussian is multiplied by this).delay (
Initialization|float|int|ndarray|Array|Quantity|None) – Delay initialization.
- Raises:
ValueError – At generation time, if
sigmais not positive.
See also
braintools.init.GaussianProfileThe distance profile that computes the Gaussian values.
Notes
The unnormalized weight between neurons at distance
disexp(-d**2 / (2 * sigma**2)), evaluated bybraintools.init.GaussianProfile. Pairs farther apart thanmax_distanceand weights not above1e-6are dropped.Candidate pairs are found with a k-d tree over the positions and handled in chunks of bounded size, so memory grows with the number of edges rather than with
pre_size * post_size. The edges, their order and the weights are the same as in version 0.3 (up to rounding). Generation runs on the host with NumPy and cannot be traced byjax.jit,jax.vmaporjax.grad.Examples
>>> import brainunit as u >>> import numpy as np >>> from braintools.conn import GaussianKernel >>> positions = np.random.RandomState(0).uniform(0, 1000, (500, 2)) * u.um >>> gauss = GaussianKernel( ... sigma=50 * u.um, ... max_distance=150 * u.um, ... weight=2.0 * u.nS ... ) >>> result = gauss( ... pre_size=500, post_size=500, ... pre_positions=positions, post_positions=positions ... ) >>> result.n_connections 14104