AxonalBranching

AxonalBranching#

class braintools.conn.AxonalBranching(branches_per_axon=5, branch_spread=None, weight=None, delay=None, allow_self_connections=False, **kwargs)#

Axonal branching patterns.

Models realistic axonal branching where each presynaptic axon makes multiple synaptic contacts following branching structure.

Parameters:
  • branches_per_axon (int) – Average number of branches per axon (Poisson-distributed per axon).

  • branch_spread (float | Quantity | None) – Spatial spread of the branches. When given, positions are required and each axon picks its targets with probability proportional to exp(-d**2 / (2 * branch_spread**2)) of the distance d, so branches stay near the source neuron. A plain number is interpreted in the unit of pre_positions. None (default) picks targets uniformly.

  • weight (Initialization | float | int | ndarray | Array | Quantity | None) – Weight initialization.

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

  • allow_self_connections (bool) – Whether a neuron may connect to itself. Default False.

Notes

The number of branches of each axon is Poisson distributed and capped at the number of eligible targets; the targets of one axon are distinct. With branch_spread the targets are drawn by successive sampling without replacement, implemented with exponential keys [1] evaluated in chunks of presynaptic rows of bounded size.

Generation runs on the host with NumPy and cannot be traced by jax.jit, jax.vmap or jax.grad.

Changed in version 0.4.0: The branch counts and targets are drawn in bulk instead of in a Python loop over axons, and no pre_size x post_size distance matrix is built. The edges for a given seed differ from 0.3 (same distribution).

References

Examples

>>> import brainunit as u
>>> import numpy as np
>>> from braintools.conn import AxonalBranching
>>> positions = np.random.RandomState(0).uniform(0, 500, (60, 2)) * u.um
>>> branching = AxonalBranching(branches_per_axon=4, branch_spread=50 * u.um, seed=0)
>>> result = branching(pre_size=60, post_size=60,
...                    pre_positions=positions, post_positions=positions)
>>> result.n_connections
237
generate(pre_size, post_size, pre_positions=None, post_positions=None, **kwargs)[source]#

Generate axonal branching connections.

Return type:

ConnectionResult