RadialPatches

RadialPatches#

class braintools.conn.RadialPatches(patch_radius, n_patches=1, prob=1.0, weight=None, delay=None, **kwargs)#

Radial patch connectivity where neurons connect within multiple localized spatial patches.

This class creates connections by forming multiple circular patches of connectivity for each presynaptic neuron. For each presynaptic neuron, the algorithm randomly selects patch centers from the postsynaptic population, then connects to all neurons within a specified radius of each center with a given probability. This pattern is useful for modeling clustered or patchy connectivity observed in cortical networks, such as long-range horizontal connections in visual cortex or patchy connectivity in association areas.

The connection generation process:

  1. For each presynaptic neuron, randomly select n_patches centers from the postsynaptic population

  2. For each patch center, identify all postsynaptic neurons within patch_radius

  3. Connect to each candidate neuron with probability prob

  4. Remove duplicate connections (a neuron may appear in multiple patches)

Parameters:
  • patch_radius (float | Quantity) – Radius of each circular patch. Neurons within this distance from a patch center are candidates for connection. Should have spatial units (e.g., 50 * u.um) if positions have units, or be a scalar if positions are unitless.

  • n_patches (int) –

    Number of random patches to create for each presynaptic neuron. For example:

    • n_patches=1: Single patch per neuron

    • n_patches=3: Three distinct patches per neuron

    • Larger values create more distributed connectivity patterns

    If n_patches exceeds the postsynaptic population size, it is automatically limited to the population size.

  • prob (float) –

    Connection probability within each patch (range: 0.0 to 1.0). For example:

    • prob=1.0: Connect to all neurons within patch radius (deterministic)

    • prob=0.5: Connect to each neuron with 50% probability (stochastic)

    • prob=0.1: Sparse connectivity within patches

    This enables control over connection density within patches.

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

    Initializer for synaptic weights. Supports:

    • Constant values (e.g., 1.0 * u.nS)

    • Stochastic initializers (e.g., Normal, Uniform, LogNormal)

    • Distance-dependent weight distributions

    • None for unweighted connections

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

    Initializer for synaptic transmission delays. Supports:

    • Constant values (e.g., 1.0 * u.ms)

    • Stochastic delay distributions

    • Distance-proportional delays

    • None for connections without explicit delays

  • **kwargs – Additional arguments passed to PointConnectivity, such as seed for reproducible random number generation.

Returns:

Connection result containing pre/post indices, weights, delays, and metadata about the radial patch connectivity pattern.

Return type:

ConnectionResult

Raises:

ValueError – If pre_positions or post_positions are not provided when generating connections.

Notes

  • This connectivity pattern requires neuron positions via pre_positions and post_positions arguments when calling the connector

  • Position arrays should have shape (n_neurons, n_dimensions) with consistent units

  • Patch centers are selected randomly without replacement for each presynaptic neuron

  • Duplicate connections (from overlapping patches) are automatically removed

  • The actual number of connections is stochastic and depends on:

    • Spatial distribution of neurons

    • Number and radius of patches

    • Connection probability prob

    • Random patch center selection

  • Empty connection results are returned if no connections are established

  • This pattern models the patchy horizontal connectivity observed in cortical circuits

See also

DistanceDependent

General distance-based connectivity

Gaussian

Gaussian distance-dependent connectivity

Exponential

Exponential distance-dependent connectivity

Examples

Basic radial patch connectivity:

>>> import brainunit as u
>>> import numpy as np
>>> from braintools.conn import RadialPatches
>>> from braintools.init import Constant
>>>
>>> # Create random 2D positions
>>> positions = np.random.uniform(0, 1000, (500, 2)) * u.um
>>>
>>> # Three patches per neuron with 50um radius
>>> patches = RadialPatches(
...     patch_radius=50 * u.um,
...     n_patches=3,
...     prob=0.5,
...     weight=Constant(1.0 * u.nS),
...     seed=42
... )
>>>
>>> result = patches(
...     pre_size=500,
...     post_size=500,
...     pre_positions=positions,
...     post_positions=positions
... )

Dense patches with deterministic connectivity:

>>> # Connect to all neurons within patch radius
>>> dense_patches = RadialPatches(
...     patch_radius=75 * u.um,
...     n_patches=2,
...     prob=1.0,  # Deterministic connectivity
...     weight=Constant(1.5 * u.nS),
...     delay=Constant(1.0 * u.ms)
... )

Sparse, distributed patches:

>>> from braintools.init import Normal
>>>
>>> # Many small, sparse patches
>>> sparse_patches = RadialPatches(
...     patch_radius=30 * u.um,
...     n_patches=5,  # More patches
...     prob=0.2,  # Sparse within each patch
...     weight=Normal(mean=2.0*u.nS, std=0.4*u.nS),
...     seed=42
... )

Modeling cortical horizontal connections:

>>> # Model patchy long-range connections in visual cortex
>>> # Neurons at similar locations
>>> local_positions = np.random.randn(300, 2) * 100 * u.um
>>>
>>> # Create patchy connectivity pattern
>>> horizontal_conn = RadialPatches(
...     patch_radius=80 * u.um,  # Size of patches
...     n_patches=4,  # Multiple patches per neuron
...     prob=0.6,  # Moderate connection probability
...     weight=Normal(mean=1.0*u.nS, std=0.2*u.nS),
...     delay=Constant(2.0 * u.ms),  # Longer delay for horizontal connections
...     seed=42
... )
>>>
>>> result = horizontal_conn(
...     pre_size=300,
...     post_size=300,
...     pre_positions=local_positions,
...     post_positions=local_positions
... )

Projections between different populations:

>>> # Different source and target populations
>>> source_positions = np.random.uniform(0, 500, (200, 2)) * u.um
>>> target_positions = np.random.uniform(500, 1000, (300, 2)) * u.um
>>>
>>> # Cross-population patchy connectivity
>>> projection = RadialPatches(
...     patch_radius=60 * u.um,
...     n_patches=3,
...     prob=0.4,
...     weight=Constant(0.8 * u.nS)
... )
>>>
>>> result = projection(
...     pre_size=200,
...     post_size=300,
...     pre_positions=source_positions,
...     post_positions=target_positions
... )

3D spatial connectivity:

>>> # Patches in 3D space (e.g., cortical columns)
>>> positions_3d = np.random.randn(400, 3) * np.array([100, 100, 200]) * u.um
>>>
>>> patches_3d = RadialPatches(
...     patch_radius=100 * u.um,  # Spherical patches in 3D
...     n_patches=2,
...     prob=0.7,
...     weight=Constant(1.2 * u.nS)
... )
>>>
>>> result = patches_3d(
...     pre_size=400,
...     post_size=400,
...     pre_positions=positions_3d,
...     post_positions=positions_3d
... )
generate(**kwargs)[source]#

Generate radial patch connections.

Return type:

ConnectionResult