AxonalProjection

AxonalProjection#

class braintools.conn.AxonalProjection(topographic_map=None, connection_prob=0.05, arborization_sigma=None, target_compartments=None, weight=None, delay=None, allow_self_connections=False, **kwargs)#

Axonal projection onto dendritic compartments.

Every presynaptic axon contacts every postsynaptic neuron independently with a pair-specific probability, and each resulting synapse is placed on one dendritic compartment drawn uniformly from target_compartments.

The pair probability is built from up to two spatial terms (positions are needed for either):

  • topographic_map(pre_xy, post_xy), if given, replaces the uniform connection_prob;

  • arborization_sigma, if given, multiplies the probability by a Gaussian fall-off exp(-d**2 / (2 * arborization_sigma**2)) of the distance d between the two neurons, confining the axon’s arbor to a local field.

Without positions every pair uses connection_prob.

Parameters:
  • topographic_map (Callable | None) – Function (pre_xy, post_xy) -> probability. It receives one row of each position array as plain numbers in the unit of pre_positions and must return a value in [0, 1].

  • connection_prob (float) – Probability for every pair when no topographic_map is given.

  • arborization_sigma (float | Quantity | None) – Width of the Gaussian arborization field. A plain number is interpreted in the unit of pre_positions. None (default) applies no fall-off.

  • target_compartments (List[int] | None) – Postsynaptic dendritic compartments to target. Each connection is randomly assigned one of these. Default [BASAL_DENDRITE, APICAL_DENDRITE].

  • 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

With a spatial term (topographic_map or arborization_sigma) the pair probabilities are evaluated in chunks of presynaptic rows of bounded size, and the random draws are the same as in version 0.3. topographic_map stays a scalar function of one pre and one post position; within each chunk it is called once per pair of distinct positions and the values are shared by neurons at equal positions, so repeated positions cost no extra calls. It is still a Python call per distinct pair, so its cost grows with pre_size * post_size when all positions differ.

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: Without topographic_map and arborization_sigma the pairs are sampled with a binomial edge count and distinct pairs, so the edges for a given seed differ from 0.3 (same distribution). topographic_map is called once per pair of distinct positions instead of once per neuron pair.

Examples

>>> import brainunit as u
>>> import numpy as np
>>> from braintools.conn import AxonalProjection
>>> def retinotopic_map(source_pos, target_pos):
...     return 0.5 * np.exp(-np.sum((source_pos - target_pos) ** 2) / (2 * 50.0 ** 2))
>>>
>>> positions = np.random.RandomState(0).uniform(0, 300, (40, 2)) * u.um
>>> topographic = AxonalProjection(topographic_map=retinotopic_map, seed=0)
>>> result = topographic(pre_size=40, post_size=40,
...                      pre_positions=positions, post_positions=positions)
>>> result.n_connections
88
>>> local_arbor = AxonalProjection(connection_prob=0.3, arborization_sigma=80 * u.um, seed=0)
>>> result = local_arbor(pre_size=40, post_size=40,
...                      pre_positions=positions, post_positions=positions)
>>> result.n_connections
114
generate(pre_size, post_size, pre_positions=None, post_positions=None, **kwargs)[source]#

Generate axonal projection connections.

Return type:

ConnectionResult