BindCondData#
- class brainpy.mixin.BindCondData[source]#
Mixin for binding temporary conductance data.
This mixin provides an interface for temporarily storing conductance data, which is useful in synaptic models where conductance values need to be passed between computation steps without being part of the permanent state.
- Variables:
_conductance (
Any, optional) – Temporarily bound conductance data.
Examples
Using conductance binding in a synapse:
>>> import brainstate >>> import jax.numpy as jnp >>> >>> class ConductanceBasedSynapse(brainstate.mixin.BindCondData): ... def __init__(self): ... self._conductance = None ... ... def compute(self, pre_spike): ... if pre_spike: ... # Bind conductance data temporarily ... self.bind_cond(0.5) ... ... # Use conductance if available ... if self._conductance is not None: ... current = self._conductance * (0.0 - (-70.0)) ... # Clear after use ... self.unbind_cond() ... return current ... return 0.0 >>> >>> synapse = ConductanceBasedSynapse() >>> current = synapse.compute(pre_spike=True)
Managing conductance in a network:
>>> class SynapticConnection(brainstate.mixin.BindCondData): ... def __init__(self, g_max): ... self.g_max = g_max ... self._conductance = None ... ... def prepare_conductance(self, activation): ... # Bind conductance based on activation ... g = self.g_max * activation ... self.bind_cond(g) ... ... def apply_conductance(self, voltage): ... if self._conductance is not None: ... current = self._conductance * voltage ... self.unbind_cond() ... return current ... return 0.0