CompartmentSpecific#
- class braintools.conn.CompartmentSpecific(compartment_mapping, connection_prob=0.1, weight=None, delay=None, morphology_info=None, allow_self_connections=False, **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 (
Initialization|float|int|ndarray|Array|Quantity|None) – Weight initializer (e.g.braintools.init.Normal).delay (
Initialization|float|int|ndarray|Array|Quantity|None) – Delay initializer (e.g.braintools.init.Uniform).morphology_info (
Dict|None) – Information about neuron morphology structure.allow_self_connections (
bool) – Whether a neuron may connect to itself (autapse). WhenFalseand the pre/post populations have the same size, connections withpre_idx == post_idxare dropped regardless of compartment. DefaultFalse.
Examples
Axon-to-soma connections:
>>> import brainunit as u >>> from braintools.init import Normal >>> axon_soma = CompartmentSpecific( ... compartment_mapping={AXON: SOMA}, ... connection_prob=0.1, ... weight=Normal(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 ... )