braintools.conn module#

Modular Connectivity System for Neural Network Generation.

This module provides a comprehensive, modular system for building connectivity patterns across different types of neural models. The system is designed with complete decoupling between model types to ensure clean, specialized implementations.

Supported Model Types:

  • Point Neurons: Single-compartment integrate-and-fire models

  • Multi-Compartment Models: Detailed morphological neuron models

Key Features:

  • Direct Class Access: All connectivity patterns available as classes

  • Biological Realism: Realistic parameters and constraints for each model type

  • Spatial Awareness: Position-dependent connectivity with proper units

  • Composable Patterns: Combine and transform connectivity patterns

  • Extensible Design: Easy to add custom patterns for any model type

Quick Start:

import brainunit as u
from braintools.conn import Random, ExcitatoryInhibitory, AxonToDendrite

# Point neuron random connectivity
random_conn = Random(prob=0.1)
result = random_conn(pre_size=1000, post_size=1000)

# E-I network dynamics
ei_conn = ExcitatoryInhibitory(
    exc_ratio=0.8,
    exc_prob=0.1,
    inh_prob=0.2,
    exc_weight=1.0 * u.nS,
    inh_weight=-0.8 * u.nS
)
result = ei_conn(pre_size=1000, post_size=1000)

# Multi-compartment axon-to-dendrite connectivity
axon_dend = AxonToDendrite(
    connection_prob=0.1,
    weight_distribution='lognormal',
    weight_params={'mean': 2.0 * u.nS, 'sigma': 0.5}
)
result = axon_dend(pre_size=100, post_size=100)

Point Neuron Connectivity:

import numpy as np
import brainunit as u
from braintools.conn import Random, DistanceDependent, ExcitatoryInhibitory

# Realistic synaptic connectivity with proper units
from braintools.init import LogNormal, Normal
ampa_conn = Random(
    prob=0.05,
    weight=LogNormal(mean=1.0 * u.nS, sigma=0.5),
    delay=Normal(mean=1.5 * u.ms, std=0.3 * u.ms)
)

# Spatial connectivity
positions = np.random.uniform(0, 1000, (500, 2)) * u.um
spatial_conn = DistanceDependent(
    sigma=100 * u.um,
    decay='gaussian',
    max_prob=0.3
)
result = spatial_conn(500, 500, positions, positions)

# E-I network with Dale's principle
ei_network = ExcitatoryInhibitory(
    exc_ratio=0.8,
    exc_prob=0.1,
    inh_prob=0.2,
    exc_weight=1.0 * u.nS,
    inh_weight=-0.8 * u.nS
)

Modular connectivity system for building neural network connection patterns across different types of neural models. The system provides specialized implementations for point neurons and multi-compartment models with direct class access.

Base Classes and Results#

Core infrastructure for connectivity patterns and results.

ConnectionResult

Universal container for connectivity results across all neuron model types.

Connectivity

Abstract base class for all connectivity patterns.

PointConnectivity

Base class for point neuron connectivity patterns.

MultiCompartmentConnectivity

Base class for multi-compartment neuron connectivity patterns.

ScaledConnectivity

Connectivity with scaled weights or delays.

CompositeConnectivity

Composite connectivity created by combining patterns.

Point Neuron Connectivity#

Connectivity patterns for single-compartment point neuron models.

Basic Patterns#

Simple connectivity patterns including random and deterministic connections.

Random

Random connectivity with fixed connection probability.

FixedProb

Alias for Random connectivity with fixed probability (Random).

AllToAll

Fully connected network where every neuron connects to every other neuron.

OneToOne

One-to-one connectivity where neuron i connects to neuron i.

Spatial Patterns#

Distance-dependent and spatially-structured connectivity patterns.

DistanceDependent

Distance-dependent connectivity for spatially arranged point neurons.

Gaussian

Gaussian distance-dependent connectivity for spatially organized neural networks.

Exponential

Exponential distance-dependent connectivity for spatially organized neural networks.

Ring

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

Grid2d

Two-dimensional grid connectivity for spatially arranged neural populations.

RadialPatches

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

ClusteredRandom

Random connectivity with spatial clustering and distance-dependent connection enhancement.

Topological Patterns#

Complex network topology patterns based on graph theory.

SmallWorld

Watts-Strogatz small-world network topology.

ScaleFree

Barabási-Albert scale-free network with preferential attachment.

Regular

Regular network where all neurons have the same degree.

ModularRandom

Modular network with intra-module and inter-module random connectivity.

ModularGeneral

Modular network using Connectivity instances for both intra and inter-module patterns.

HierarchicalRandom

Hierarchical network with multiple levels and asymmetric feedforward/feedback connections.

CorePeripheryRandom

Core-periphery network with densely connected core and sparse periphery.

Biological Patterns#

Biologically-inspired connectivity patterns following neural principles.

ExcitatoryInhibitory

Standard excitatory-inhibitory network following Dale's principle.

Kernel-Based Connectivity#

Connectivity patterns using convolution kernels for spatial receptive fields.

Conv2dKernel

Convolutional kernel connectivity for spatially arranged point neurons.

GaussianKernel

Gaussian kernel connectivity for center-surround receptive fields.

GaborKernel

Gabor kernel connectivity for orientation-selective receptive fields.

DoGKernel

Difference of Gaussians (DoG) kernel for center-surround receptive fields.

MexicanHat

Mexican hat (Laplacian of Gaussian) connectivity pattern.

SobelKernel

Sobel edge detection kernel for orientation-selective connectivity.

LaplacianKernel

Laplacian kernel for edge detection connectivity.

CustomKernel

Custom kernel connectivity using user-defined kernel function.

Multi-Compartment Connectivity#

Connectivity patterns for detailed multi-compartment neuron models with compartment-specific targeting.

Compartment Constants#

Predefined constants for identifying neural compartments.

SOMA

int([x]) -> integer int(x, base=10) -> integer

BASAL_DENDRITE

int([x]) -> integer int(x, base=10) -> integer

APICAL_DENDRITE

int([x]) -> integer int(x, base=10) -> integer

AXON

int([x]) -> integer int(x, base=10) -> integer

Basic Compartment Patterns#

Fundamental patterns for compartment-specific connectivity.

CompartmentSpecific

General compartment-specific connectivity pattern.

AllToAllCompartments

All-to-all compartment connectivity.

CustomCompartment

Custom compartment connectivity using user-defined function.

Anatomical Targeting Patterns#

Connectivity patterns based on anatomical organization.

SomaToDendrite

Specialized connectivity from soma to dendritic compartments.

AxonToSoma

Specialized connectivity from axon to soma compartments.

DendriteToSoma

Specialized connectivity from dendrites to soma.

AxonToDendrite

Specialized connectivity from axon to dendritic compartments.

DendriteToDendrite

Dendrite-to-dendrite connectivity patterns.

Morphology-Aware Patterns#

Patterns that utilize detailed morphological information.

ProximalTargeting

Connectivity targeting proximal dendritic compartments.

DistalTargeting

Connectivity targeting distal dendritic compartments.

BranchSpecific

Branch-specific dendritic targeting.

MorphologyDistance

Distance-dependent connectivity based on detailed morphology.

Dendritic Patterns#

Specialized patterns for dendritic targeting and integration.

DendriticTree

Dendritic tree connectivity patterns with branch-specific targeting.

BasalDendriteTargeting

Specific targeting of basal dendrites.

ApicalDendriteTargeting

Specific targeting of apical dendrites.

DendriticIntegration

Dendritic integration connectivity patterns.

Axonal Patterns#

Patterns for axonal projection and arborization.

AxonalProjection

Axonal projection patterns with topographic organization.

AxonalBranching

Axonal branching patterns.

AxonalArborization

Axonal arborization patterns.

TopographicProjection

Topographic projection patterns.

Synaptic Patterns#

Patterns for synaptic placement and organization.

SynapticPlacement

Synaptic placement rules.

SynapticClustering

Synaptic clustering patterns.