jaxley.synapses.DynamicSynapse#

class DynamicSynapse(nonlinearity=<PjitFunction of <function sigmoid>>, name=None)[source]#

Bases: Synapse

A state-based synapse with fixed time constant.

Unlike the ConductanceSynapse, this synapse contains a synaptic state. However, unlike in the IonotropicSynapse, the synaptic state approaches its steady-state with a constant (i.e., not voltage dependent) time constant.

This synapse implements the following equations:

\[I = \overline{g}\, \cdot s\, \cdot (E - V_{\text{post}})\]
\[\tau \frac{\text{d}s}{\text{d}t} = \sigma\!\left(\frac{V_{\text{pre}} - V_{\text{thr}}}{\Delta}\right) - s,\]

where \(\mathrm{\sigma}(\cdot)\) is a nonlinearity such as a ReLU, Sigmoid, or TanH. By default, it is a sigmoid, but it can be modified by the user.

More informally: This synapse has a state which defines its conductance. The state approaches a nonlinear map of the voltage with a time constant which is not voltage-dependent. The current is conductance-based, i.e., it depends on a reversal potential.

The synaptic parameters are:
  • gS: the maximal conductance \(\overline{g}\) (uS).

  • tau: the time constant \(\tau\) (\(ms\)).

  • v_th: the threshold at which the synapse becomes active \(V_{\text{thr}}\) (mV).

  • delta: The inverse of the slope of the activation \(\Delta\) (mV).

The inserted cellular parameters are:
  • e_syn: The synaptic reversal potential \(E\) (mV). This synapse uses the pre-synaptic reveral potential to compute the current, thereby directly enforcing Dale’s law.

The synaptic state is:
  • s: the activity level of the synapse.

Example usage

Insert a synapse with a sigmoid nonlinearity (the default) and change parameters and initial state.

import jaxley as jx
from jaxley.connect import connect
from jaxley.synapses import DynamicSynapse

cell = jx.Cell()
net = jx.Network([cell for _ in range(2)])

# Connect neurons with the `DynamicSynapse`.
connect(net.cell(0), net.cell(1), DynamicSynapse())

# Set parameters.
net.set("DynamicSynapse_gS", 0.0001)  # Maximal conductance.
net.set("DynamicSynapse_e_syn", 10.0)  # Reversal potential.
net.set("DynamicSynapse_tau", 4.0)  # Time constant.
net.set("DynamicSynapse_v_th", -40.0)  # Threshold.
net.set("DynamicSynapse_delta", 10.0)  # 1 / slope of activation.

# Set the initial state.
net.set("DynamicSynapse_s", 0.1)

Insert a synapse with a ReLU nonlinearity.

import jaxley as jx
from jaxley.connect import connect
from jaxley.synapses import DynamicSynapse
from jax.nn import relu

cell = jx.Cell()
net = jx.Network([cell for _ in range(2)])

# Connect neurons with the `DynamicSynapse`.
connect(net.cell(0), net.cell(1), DynamicSynapse(relu))

Insert a synapse with a custom nonlinearity.

import jaxley as jx
from jaxley.connect import connect
from jaxley.synapses import DynamicSynapse

cell = jx.Cell()
net = jx.Network([cell for _ in range(2)])

def nonlinearity(x):
    return x ** 2

# Connect neurons with the `DynamicSynapse`.
connect(net.cell(0), net.cell(1), DynamicSynapse(nonlinearity))
Parameters:
synapse_params = None#
synapse_states = None#
update_states(synapse_states, synapse_params, pre_voltage, post_voltage, pre_states, post_states, pre_params, post_params, delta_t)[source]#

Return updated synapse state and current.

Parameters:
Return type:

Dict

compute_current(synapse_states, synapse_params, pre_voltage, post_voltage, pre_states, post_states, pre_params, post_params, delta_t)[source]#

Return current through one synapse in nA.

Internally, we use jax.vmap to vectorize this function across many synapses.

Parameters:
  • states – States of the synapse.

  • pre_voltage (Array) – Voltage of the presynaptic compartment, shape ().

  • post_voltage (Array) – Voltage of the postsynaptic compartment, shape ().

  • params – Parameters of the synapse. Conductances in uS.

  • synapse_states (dict[str, Array])

  • synapse_params (dict[str, Array])

  • pre_states (dict[str, Array])

  • post_states (dict[str, Array])

  • pre_params (dict[str, Array])

  • post_params (dict[str, Array])

  • delta_t (float)

Returns:

Current through the synapse in nA, shape ().

Return type:

float

change_name(new_name)#

Change the synapse name.

Parameters:

new_name (str) – The new name of the channel.

Returns:

Renamed channel, such that this function is chainable.

property name: str | None#