SobelKernel#
- class braintools.conn.SobelKernel(direction='horizontal', kernel_size=1.0, allow_self_connections=False, weight=None, delay=None, **kwargs)#
Sobel edge detection kernel for orientation-selective connectivity.
Implements Sobel operators for detecting edges at specific orientations, useful for implementing orientation-selective connectivity patterns.
The Sobel kernel contains essential negative coefficients; connections are selected on coefficient magnitude so those negative weights are retained.
- Parameters:
direction (
str) – Direction of edge detection (‘horizontal’, ‘vertical’, ‘both’).kernel_size (
Array|ndarray|bool|number|bool|int|float|complex|Quantity) – Physical size of the 3x3 kernel in position units.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 (Sobel values are multiplied by this).delay (
Initialization|float|int|ndarray|Array|Quantity|None) – Delay initialization.
Notes
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 SobelKernel >>> positions = np.random.RandomState(0).uniform(0, 1000, (500, 2)) * u.um >>> sobel = SobelKernel( ... direction='horizontal', ... kernel_size=60 * u.um, ... weight=1.0 * u.nS ... ) >>> result = sobel( ... pre_size=500, post_size=500, ... pre_positions=positions, post_positions=positions ... ) >>> result.n_connections 418