superneuromat.Neuron#

class superneuromat.Neuron(model: SNN, idx: int)[source]#

Accessor Class for Neurons in SNNs

Warning

Instances of Neurons are created at access time and are not unique. Multiple instances of this class may be created for the same neuron on the SNN. To test for equality, use == instead of is.

Attributes:
leak

The amount by which the internal state of this neuron is pushed towards its reset state.

refractory_period

The number of time steps for which this neuron should be in its refractory period.

refractory_state

The remaining number of time steps for which this neuron is in its refractory period.

reset_state

The charge state of this neuron immediately after spiking.

spikes

A vector of the spikes that have been emitted by this neuron.

state

The charge state of this neuron.

threshold

The > threshold value for this neuron to spike.

Methods

add_spike(time[, value])

Queue a spike to be sent to this Neuron.

add_spikes(spikes[, time_offset, exist])

Add a time-series of spikes to this neuron.

connect_child(child[, weight, delay, ...])

Connect this neuron to a child neuron.

connect_parent(parent[, weight, delay, ...])

Connect this neuron to a parent neuron.

info()

Returns a string containing information about this neuron.

info_row()

Returns a string containing information about this neuron for use in a table.

spikes_str([max_steps, use_unicode])

Returns a pretty string of the spikes that have been emitted by this neuron.

row_cont

row_header

add_spike(time: int, value: float = 1.0, **kwargs)[source]#

Queue a spike to be sent to this Neuron.

Parameters:
  • time (int) – The number of time_steps until the spike is sent.

  • value (float, default=1.0) – The value of the spike.

  • exist (str, default='error') – Action if a queued spike already exists at the given time step. Should be one of [‘error’, ‘overwrite’, ‘add’, ‘dontadd’].

add_spikes(spikes: list[float] | list[tuple[int, float]] | ~numpy.ndarray[(<class 'int'>,), ~numpy.dtype] | ~numpy.ndarray[(<class 'int'>, 2), ~numpy.dtype], time_offset: int = 0, exist: str = 'error')[source]#

Add a time-series of spikes to this neuron.

Parameters:
  • spikes (numpy.typing.ArrayLike)

  • time_offset (int, default=0) – The number of time steps to offset the spikes by.

  • exist (str, default='error') – Action if a queued spike already exists at the given time step. Should be one of [‘error’, ‘overwrite’, ‘add’, ‘dontadd’].

Examples

If the input is a list of floats, it will be interpreted as a time-series of spikes to be fed in, one after the other.

neuron.add_spikes([0.0, 1.0, 2.0, 3.0])
# is equivalent to
for i in range(4):
    neuron.add_spike(i, i)

However, 0.0-valued spikes are not added unless exist='overwrite'.

If you would like to send a set of spikes at particular times, you can use a list of tuples:

neuron.add_spikes([
    (1, 1.0),
    (3, 3.0),
])

Note

The times and values will be cast to SNN.default_dtype.

Changed in version v3.2.0: Returns the Synapse object created.

connect_child(child, weight: float = 1.0, delay: int = 1, stdp_enabled: bool = False, exist='error') Synapse[source]#

Connect this neuron to a child neuron.

Parameters:
  • child (Neuron | int) – The child neuron that will receive the spikes from this neuron.

  • weight (float, default=1.0) – The weight of the synapse connecting this neuron to the child.

  • delay (int, default=1) – The delay of the synapse connecting this neuron to the child.

  • stdp_enabled (bool, default=False) – If True, enable STDP learning on the synapse connecting this neuron to the child.

Returns:

connect_parent(parent, weight: float = 1.0, delay: int = 1, stdp_enabled: bool = False, exist='error') Synapse[source]#

Connect this neuron to a parent neuron.

Parameters:
  • parent (Neuron | int) – The parent neuron that will send spikes to this neuron.

  • weight (float, default=1.0) – The weight of the synapse connecting the parent to this neuron.

  • delay (int, default=1) – The delay of the synapse connecting the parent to this neuron.

  • stdp_enabled (bool, default=False) – If True, enable STDP learning on the synapse connecting the parent to this neuron.

Returns:

idx[source]#

The index of this neuron in the SNN.

info()[source]#

Returns a string containing information about this neuron.

The order of the fields is the same as in SNN.neuron_info() but without the spikes column.

info_row()[source]#

Returns a string containing information about this neuron for use in a table.

This function is used to generate rows for SNN.neuron_info().

property leak: float[source]#

The amount by which the internal state of this neuron is pushed towards its reset state.

property refractory_period: int[source]#

The number of time steps for which this neuron should be in its refractory period.

property refractory_state: float[source]#

The remaining number of time steps for which this neuron is in its refractory period.

property reset_state: float[source]#

The charge state of this neuron immediately after spiking.

property spikes: bool]] | list[source]#

A vector of the spikes that have been emitted by this neuron.

spikes_str(max_steps=10, use_unicode=True)[source]#

Returns a pretty string of the spikes that have been emitted by this neuron.

Parameters:
  • max_steps (int | None, default=10) – Limits the number of steps which will be included. If limited, only a total of max_steps first and last steps will be included.

  • use_unicode (bool, default=True) – If True, use unicode characters to represent spikes. Otherwise fallback to ascii characters.

property state: float[source]#

The charge state of this neuron.

property threshold: float[source]#

The > threshold value for this neuron to spike.