CompartmentSpecific#

class braintools.conn.CompartmentSpecific(compartment_mapping, connection_prob=0.1, weight=None, delay=None, morphology_info=None, **kwargs)#

General compartment-specific connectivity pattern.

This is the base class for targeting specific compartments in multi-compartment neurons. It provides flexible mapping from source compartments to target compartments with customizable connection rules.

Parameters:
  • compartment_mapping (Dict[int | str, int | str | List[int | str]]) – Mapping from source compartment types to target compartment types. Keys and values can be compartment indices (int) or names (str).

  • connection_prob (float | Dict) – Connection probability. Can be global or per-compartment-pair.

  • weight_distribution (str or callable) – Weight distribution for connections.

  • weight_params (dict) – Parameters for weight distribution.

  • morphology_info (Dict | None) – Information about neuron morphology structure.

Examples

Axon-to-soma connections:

>>> import brainunit as u
>>> axon_soma = CompartmentSpecific(
...     compartment_mapping={AXON: SOMA},
...     connection_prob=0.1,
...     weight_distribution='normal',
...     weight_params={'mean': 2.0 * u.nS, 'std': 0.5 * u.nS}
... )
>>> result = axon_soma(pre_size=100, post_size=100)

Complex multi-compartment targeting:

>>> # Dendrites to soma, axon to dendrites
>>> multi_target = CompartmentSpecific(
...     compartment_mapping={
...         BASAL_DENDRITE: SOMA,
...         APICAL_DENDRITE: SOMA,
...         AXON: [BASAL_DENDRITE, APICAL_DENDRITE]
...     },
...     connection_prob={
...         (BASAL_DENDRITE, SOMA): 0.3,
...         (APICAL_DENDRITE, SOMA): 0.2,
...         (AXON, BASAL_DENDRITE): 0.05,
...         (AXON, APICAL_DENDRITE): 0.08
...     }
... )

Named compartment mapping:

>>> named_mapping = CompartmentSpecific(
...     compartment_mapping={
...         'axon': ['basal_dendrite', 'apical_dendrite'],
...         'basal_dendrite': 'soma'
...     },
...     connection_prob=0.1
... )
generate(pre_size, post_size, pre_positions=None, post_positions=None, **kwargs)[source]#

Generate compartment-specific connections.

Return type:

ConnectionResult