HHTypedNeuron#
- class braincell.HHTypedNeuron(size, name=None, **ion_channels)#
Base class for Hodgkin-Huxley typed neuronal membrane dynamics.
Subclasses own the membrane voltage
Vand the integration scheme; this class owns the ion-channel container and the lifecycle calls that fan out to it.- Parameters:
size (
int|Sequence[int] |integer|Sequence[integer]) – The size of the simulation target: an int, or a tuple/list of ints read as(..., n_neuron, n_compartment).name (
str|None) – The name of the instance. A default is generated when omitted.**ion_channels – Ion channel instances to add to the neuron, keyed by attribute name.
- Raises:
ValueError – If
sizeis neither an int nor a non-empty tuple/list of ints.
- add(**elements)[source]#
Add ion channels to the neuron after construction.
- Parameters:
**elements – Ion channel instances to add, keyed by attribute name.
- Raises:
TypeError – If an element’s
root_typedoes not accept this neuron, or if it is not anIonChannel.
- compute_derivative(*args, **kwargs)[source]#
Fill in the derivative of every state this neuron integrates.
- Parameters:
*args – Positional arguments defined by the subclass.
**kwargs – Keyword arguments defined by the subclass.
- Raises:
NotImplementedError – Always, in the base class. Subclasses must override.
- current(*args, **kwargs)[source]#
Sum the membrane current contributed by every ion channel.
- Parameters:
*args – Positional arguments defined by the subclass.
**kwargs – Keyword arguments defined by the subclass.
- Returns:
Total membrane current, in the subclass’s current units.
- Return type:
brainunit.Quantity
- Raises:
NotImplementedError – Always, in the base class. Subclasses must override.
- get_spike(last_V, next_V)[source]#
Surrogate-gradient spike indicator at the
V_thcrossing.Uses
self.V_th(threshold voltage) andself.spk_fun(surrogate-gradient callable) supplied by subclasses. The product of rising- and falling-crossing terms produces a non-zero value only whenlast_V < V_th <= next_V.
- init_state(batch_size=None)[source]#
Allocate the state of every direct ion-channel child.
- Parameters:
batch_size (int, optional) – Leading batch dimension to allocate channel states with.
- Raises:
TypeError – If a child channel’s
root_typedoes not accept this neuron.
Notes
Channels are seeded from the current membrane potential
self.V.value, soVmust already be initialized.
- property n_compartment: int#
Number of compartments per neuron.
- Returns:
How many compartments – soma, dendrite, axon sections – each neuron in the group is divided into.
- Return type:
- Raises:
NotImplementedError – Always, in the base class. Subclasses must override.
- property pop_size: Tuple[int, ...]#
Neuron-population shape, that is
sizewithout the compartment axis.- Returns:
The population size in each dimension:
(100, 50)is a 2-D population of 100 by 50 neurons.- Return type:
- Raises:
NotImplementedError – Always, in the base class. Subclasses must override.
- post_integral(*args, **kwargs)[source]#
Run whatever must happen after each integration step.
Does nothing by default. Subclasses override it to publish spikes, clamp concentrations, or otherwise fix up state the solver wrote.
- Parameters:
*args – Positional arguments defined by the subclass.
**kwargs – Keyword arguments defined by the subclass.
- pre_integral(*args, **kwargs)[source]#
Run whatever must happen before each integration step.
- Parameters:
*args – Positional arguments defined by the subclass.
**kwargs – Keyword arguments defined by the subclass.
- Raises:
NotImplementedError – Always, in the base class. Subclasses must override.
- reset_state(batch_size=None)[source]#
Return every direct ion-channel child to its initial state.
- Parameters:
batch_size (int, optional) – Leading batch dimension to reset channel states with.
Notes
Unlike
init_state()this does not re-check hierarchies: the state already exists, so the check has already run.