DoGKernel

DoGKernel#

class braintools.conn.DoGKernel(sigma_center, sigma_surround, amplitude_center=1.0, amplitude_surround=0.8, max_distance=None, allow_self_connections=False, weight=None, delay=None, **kwargs)#

Difference of Gaussians (DoG) kernel for center-surround receptive fields.

Implements DoG filters commonly found in retinal ganglion cells and LGN neurons, with excitatory center and inhibitory surround (or vice versa).

Only the first two position dimensions (x, y) are used; any extra columns (e.g. z) are ignored.

Parameters:
  • sigma_center (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – Standard deviation of center Gaussian.

  • sigma_surround (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – Standard deviation of surround Gaussian.

  • amplitude_center (float) – Amplitude of center Gaussian (default: 1.0).

  • amplitude_surround (float) – Amplitude of surround Gaussian (default: 0.8).

  • max_distance (Array | ndarray | bool | number | bool | int | float | complex | Quantity | None) – Maximum distance for connections (default: 3*sigma_surround).

  • allow_self_connections (bool) – Whether a neuron may connect to itself when pre and post are the same population (default: False).

  • weight (Initialization | float | int | ndarray | Array | Quantity | None) – Weight initialization (DoG values are multiplied by this).

  • delay (Initialization | float | int | ndarray | Array | Quantity | None) – Delay initialization.

Raises:

ValueError – At generation time, if either sigma is not positive.

Notes

The weight at distance d is amplitude_center * G_c(d) - amplitude_surround * G_s(d), where G_c and G_s are unit-peak braintools.init.GaussianProfile instances. Unlike braintools.init.DoGProfile, negative values are kept, so the surround is inhibitory. Weights whose magnitude is not above 1e-4 are 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 by jax.jit, jax.vmap or jax.grad.

Examples

>>> import brainunit as u
>>> import numpy as np
>>> from braintools.conn import DoGKernel
>>> positions = np.random.RandomState(0).uniform(0, 1000, (500, 2)) * u.um
>>> dog = DoGKernel(
...     sigma_center=30 * u.um,
...     sigma_surround=60 * u.um,
...     amplitude_center=1.0,
...     amplitude_surround=0.8,
...     weight=1.0 * u.nS
... )
>>> result = dog(
...     pre_size=500, post_size=500,
...     pre_positions=positions, post_positions=positions
... )
>>> result.n_connections
21182
generate(pre_size, post_size, pre_positions=None, post_positions=None, **kwargs)[source]#

Generate DoG kernel connections.

Return type:

ConnectionResult