SingleCompartment#

class braincell.SingleCompartment(size, length=Quantity(10., "um"), radius=Quantity(5., "um"), C=Quantity(1., "uF / cm^2"), V_th=Quantity(0., "mV"), V_initializer=Uniform(low=-70 mV, high=-60. mV), spk_fun=ReluGrad(alpha=0.3, width=1.0), solver='rk2', name=None, **ion_channels)#

Base class to model conductance-based neurons with single compartment.

The standard formulation for a conductance-based point neuron model is given as

\[C_m {dV \over dt} = \sum_jg_j(E - V) + I_{ext}\]

where \(g_j=\bar{g}_{j} M^x N^y\) is the channel conductance, \(E\) is the reversal potential, \(M\) is the activation variable, \(N\) is the inactivation variable, \(\bar{g}_{j}\) is the maximum conductance.

\(M\) and \(N\) have the dynamics of

\[{braincell \over dt} = \phi_x {x_\infty (V) - x \over \tau_x(V)}\]

where \(x \in [M, N]\), \(\phi_x\) is a temperature-dependent factor, \(x_\infty\) is the steady state, and \(\tau_x\) is the time constant. Equivalently, the above equation can be written as:

\[\frac{d x}{d t}=\phi_{x}\left(\alpha_{x}(1-x)-\beta_{x} x\right)\]

where \(\alpha_{x}\) and \(\beta_{x}\) are rate constants.

The implementations of \(x\) please see braincell.ion, and braincell.channel modules.

Parameters:
  • size (int | Sequence[int] | integer | Sequence[integer]) – The network size of this neuron group.

  • length (Array | ndarray | bool | number | bool | int | float | complex | Quantity | Callable) – Compartment length used to compute membrane area. Default is 10 um

  • radius (Array | ndarray | bool | number | bool | int | float | complex | Quantity | Callable) – Compartment radius used to compute membrane area. Default is 5 um

  • C (Array | ndarray | bool | number | bool | int | float | complex | Quantity | Callable) – Membrane capacitance. Default is 1.0 uF/cm²

  • V_th (Array | ndarray | bool | number | bool | int | float | complex | Quantity | Callable) – Threshold voltage for spike detection. Default is 0.0 mV

  • V_initializer (Array | ndarray | bool | number | bool | int | float | complex | Quantity | Callable) – Initial membrane potential distribution. Default is uniform between -70 mV and -60 mV

  • spk_fun (Callable) – Spike function for threshold crossing detection. Default is ReLU gradient

  • solver (str | Callable) – Numerical integration method. Default is ‘rk2’ (second-order Runge-Kutta)

  • name (str | None) – The neuron group name.

  • **ion_channels (dict) – Additional ion channels to include in the neuron model

Notes

This class is subclassed from braincell.HHTypedNeuron.

property area#

Membrane area used to convert injected current into current density.

compute_derivative(I_ext=Quantity(0., 'nA / cm^2'))[source]#

Compute the derivative of the membrane potential.

This method calculates the derivative of the membrane potential considering external inputs, synaptic currents, and ion channel currents.

Parameters:

I_ext (float, optional) – External current input. Supports either current density or total current.

init_state(batch_size=None)[source]#

Initialize the state of the neuron.

This method sets up the initial membrane potential (V) of the neuron using the V_initializer and initializes other state variables through the parent class.

Parameters:

batch_size (int, optional) – The batch size for initialization. If None, no batch dimension is added.

Return type:

None

property n_compartment: int#

Get the number of compartments in this neuron model.

For the SingleCompartment model, this always returns 1 since it’s a point neuron model with only one compartment. Multi-compartment models would override this property to return their respective number of compartments.

Returns:

The number of compartments, which is 1 for SingleCompartment neurons.

Return type:

int

property pop_size: Tuple[int, ...]#

Get the population size of the neuron group.

This property returns the shape of the neuron population, which determines how many individual neurons are in this group. For example, a shape of (10,) means 10 neurons, while (2, 5) would represent a 2D grid of neurons.

Returns:

The shape of the neuron population as a tuple of integers.

Return type:

Tuple[int, …]

post_integral(I_ext=Quantity(0., 'nA / cm^2'))[source]#

Perform post-integration operations.

This method updates the membrane potential with delta inputs and calls the post_integral method of all associated ion channels.

Parameters:

I_ext (float, optional) – External current input. Default is 0 nA/cm^2.

pre_integral(I_ext=Quantity(0., 'nA / cm^2'))[source]#

Perform pre-integration operations.

This method calls the pre_integral method of all ion channels associated with this neuron before the main integration step.

Parameters:

I_ext (float, optional) – External current input. Default is 0 nA/cm^2.

reset_state(batch_size=None)[source]#

Reset the state of the neuron.

This method resets the membrane potential (V) to its initial value and reinitialized other state variables through the parent class.

Parameters:

batch_size (int, optional) – The batch size for resetting. If None, no batch dimension is added.

update(I_ext=Quantity(0., 'nA / cm^2'))[source]#

Update the neuron state and check for spikes.

This method performs the integration step to update the neuron’s state and checks if a spike has occurred.

Parameters:

I_ext (float, optional) – External current input. Default is 0 nA/cm^2.

Returns:

spike – An array indicating whether a spike occurred (1) or not (0) for each neuron.

Return type:

array-like