Ring

Ring#

class braintools.conn.Ring(neighbors=2, weight=None, delay=None, bidirectional=True, **kwargs)#

Ring topology connectivity where neurons are arranged in a circular structure.

This class creates connections in a one-dimensional ring (circular) topology where each neuron connects to a specified number of neighboring neurons on each side. This pattern is commonly used to model spatially organized networks with periodic boundary conditions, such as orientation columns in visual cortex or head direction cells.

The connectivity pattern:

  • Each neuron at position i connects to neurons at positions (i ± k) mod N, for k in [1, neighbors]

  • Connections wrap around at the boundaries (periodic boundary conditions)

  • Optionally bidirectional, creating symmetric connectivity

Parameters:
  • neighbors (int) –

    Number of neighbors on each side to connect to. For example:

    • neighbors=1: Each neuron connects to its immediate neighbors (2 connections per neuron if bidirectional)

    • neighbors=2: Each neuron connects to 2 neighbors on each side (4 connections per neuron if bidirectional)

    • neighbors=N//2: Maximally connected ring topology

  • 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)

    • 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

    • None for connections without explicit delays

  • bidirectional (bool) – If True, connections are bidirectional (neuron i connects to i+k and i-k). If False, connections are unidirectional (only forward, i to i+k).

  • **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 ring connectivity pattern.

Return type:

ConnectionResult

Raises:

ValueError – If pre_size and post_size are not equal (ring topology requires same size).

Notes

  • Ring connectivity enforces pre_size == post_size as each neuron must have the same number of potential neighbors

  • The total number of connections is:

    • Bidirectional: N × 2 × neighbors

    • Unidirectional: N × neighbors

    where N is the population size

  • This topology is useful for modeling networks with periodic spatial structure

  • Self-connections are excluded (neurons do not connect to themselves)

  • The ring wraps around, so neuron 0 connects to neuron N-1 when neighbors > 0

See also

Grid2d

Two-dimensional grid connectivity

DistanceDependent

Distance-based connectivity for spatially embedded networks

Examples

Basic ring connectivity:

>>> import brainunit as u
>>> from braintools.conn import Ring
>>> from braintools.init import Constant
>>>
>>> # Each neuron connects to 2 neighbors on each side
>>> ring = Ring(neighbors=2, weight=Constant(1.0 * u.nS))
>>> result = ring(pre_size=100, post_size=100)
>>> print(f"Total connections: {len(result.pre_indices)}")  # 400 connections

Unidirectional ring (feed-forward):

>>> # Only forward connections
>>> ff_ring = Ring(
...     neighbors=1,
...     weight=Constant(1.5 * u.nS),
...     bidirectional=False
... )
>>> result = ff_ring(pre_size=100, post_size=100)
>>> print(f"Total connections: {len(result.pre_indices)}")  # 100 connections

Ring with stochastic weights:

>>> from braintools.init import Normal
>>>
>>> ring = Ring(
...     neighbors=3,
...     weight=Normal(mean=1.0*u.nS, std=0.2*u.nS),
...     delay=Constant(1.0 * u.ms),
...     seed=42
... )

Modeling orientation preference in visual cortex:

>>> # Ring of neurons representing orientation preferences
>>> n_orientations = 180  # One neuron per degree
>>>
>>> # Local connectivity in orientation space
>>> orientation_ring = Ring(
...     neighbors=10,  # Connect to neurons with similar orientations
...     weight=Constant(2.0 * u.nS),
...     delay=Constant(0.5 * u.ms),
...     bidirectional=True
... )
>>>
>>> result = orientation_ring(
...     pre_size=n_orientations,
...     post_size=n_orientations
... )
generate(**kwargs)[source]#

Generate ring connectivity.

Return type:

ConnectionResult