Conv2dKernel#
- class braintools.conn.Conv2dKernel(kernel, kernel_size, threshold=0.0, weight=None, delay=None, **kwargs)#
Convolutional kernel connectivity for spatially arranged point neurons.
Applies a 2D convolution kernel to neuron positions, creating connections where the kernel weight exceeds a threshold. This allows implementing receptive field structures in spiking neural networks.
- Parameters:
kernel (
ndarray) – 2D convolution kernel array.kernel_size (
Array|ndarray|bool|number|bool|int|float|complex|Quantity) – Physical size of the kernel in position units.threshold (
float) – Connection threshold - only kernel values above this create connections.weight (
Initialization|float|int|ndarray|Array|Quantity|None) – Weight initialization (kernel values are multiplied by this).delay (
Initialization|float|int|ndarray|Array|Quantity|None) – Delay initialization.
Examples
>>> # Create 5x5 Gaussian-like kernel >>> kernel = np.array([ ... [0.04, 0.12, 0.18, 0.12, 0.04], ... [0.12, 0.37, 0.56, 0.37, 0.12], ... [0.18, 0.56, 1.00, 0.56, 0.18], ... [0.12, 0.37, 0.56, 0.37, 0.12], ... [0.04, 0.12, 0.18, 0.12, 0.04] ... ]) >>> positions = np.random.uniform(0, 1000, (500, 2)) * u.um >>> conn = Conv2dKernel( ... kernel=kernel, ... kernel_size=100 * u.um, ... threshold=0.1, ... weight=1.0 * u.nS ... ) >>> result = conn( ... pre_size=500, post_size=500, ... pre_positions=positions, post_positions=positions ... )