axon_sdk.primitives package

Submodules

axon_sdk.primitives.elements module

Neuron and Synapse Primitives

Defines core primitives for STICK-based spiking networks:
  • AbstractNeuron: A base class implementing neuron dynamics and synaptic event integration.

  • ExplicitNeuron: A concrete subclass with spike tracking and output synapses.

  • Synapse: Represents a connection between two neurons with a type, weight, and delay.

class axon_sdk.primitives.elements.AbstractNeuron(Vt, tm, tf, Vreset=0.0, neuron_name: str | None = None, parent_mod_id: str | None = None, additional_info: str | None = None)[source]

Bases: object

Base class for neurons in the STICK model.

Implements gated synaptic integration and threshold-based spike logic.

Vt

Spike threshold voltage.

Type:

float

Vreset

Voltage after reset.

Type:

float

tm

Membrane time constant.

Type:

float

tf

Time constant for ‘gf’ decay.

Type:

float

V

Membrane potential.

Type:

float

ge

Excitatory conductance.

Type:

float

gf

Gated conductance.

Type:

float

gate

Gating input level.

Type:

float

uid

Unique identifier for neuron.

Type:

str

receive_synaptic_event(synapse_type, weight)[source]

Apply a synaptic event to update internal state variables.

Parameters:
  • synapse_type (str) – Type of synapse (‘V’, ‘ge’, ‘gf’, ‘gate’).

  • weight (float) – Synaptic weight.

Raises:

ValueError – If synapse type is not recognized.

property uid: str

Returns: str: Unique identifier of this neuron instance.

update_and_spike(dt) tuple[float, bool][source]

Update the neuron’s membrane potential and internal state.

Parameters:

dt (float) – Time increment in milliseconds.

Returns:

(Updated voltage, Spike flag).

Return type:

tuple[float, bool]

class axon_sdk.primitives.elements.ExplicitNeuron(Vt: float, tm: float, tf: float, Vreset: float = 0.0, neuron_name: str | None = None, parent_mod_id: str | None = None, additional_info: str | None = None)[source]

Bases: AbstractNeuron

A fully defined neuron used in simulations with connection and spike history.

spike_times

Timestamps of all emitted spikes.

Type:

list[float]

out_synapses

Outgoing synapses from this neuron.

Type:

list[Synapse]

receive_synaptic_event(synapse_type, weight)

Apply a synaptic event to update internal state variables.

Parameters:
  • synapse_type (str) – Type of synapse (‘V’, ‘ge’, ‘gf’, ‘gate’).

  • weight (float) – Synaptic weight.

Raises:

ValueError – If synapse type is not recognized.

reset()[source]

Reset internal neuron state after a spike.

property uid: str

Returns: str: Unique identifier of this neuron instance.

update_and_spike(dt) tuple[float, bool]

Update the neuron’s membrane potential and internal state.

Parameters:

dt (float) – Time increment in milliseconds.

Returns:

(Updated voltage, Spike flag).

Return type:

tuple[float, bool]

class axon_sdk.primitives.elements.Synapse(pre_neuron: ExplicitNeuron, post_neuron: ExplicitNeuron, weight: float, delay: float, synapse_type: str)[source]

Bases: object

A synaptic connection between two neurons in the network.

pre_neuron

Source neuron.

Type:

ExplicitNeuron

post_neuron

Destination neuron.

Type:

ExplicitNeuron

type

Synapse type (‘V’, ‘ge’, ‘gf’, or ‘gate’).

Type:

str

weight

Synaptic weight.

Type:

float

delay

Transmission delay in milliseconds.

Type:

float

uid

Unique synapse ID.

Type:

str

property uid: str

Returns: str: Unique identifier for this synapse.

axon_sdk.primitives.encoders module

Data Encoding

This module defines the DataEncoder class for converting continuous values into spike intervals and decoding them back, based on the timing interval coding scheme used in the STICK model.

Classes:
  • DataEncoder: Encodes/decodes values as timing intervals between two spikes.

class axon_sdk.primitives.encoders.DataEncoder(Tmin=10.0, Tcod=100.0)[source]

Bases: object

Encodes values into inter-spike intervals and decodes them back.

The STICK model uses spike timing to represent scalar values in a time-based manner. This class provides conversion from values ∈ [0, 1] to spike timings and vice versa.

Tmin

Minimum inter-spike interval, corresponding to value 0.

Type:

float

Tcod

Encoding range for values in milliseconds.

Type:

float

Tmax

Maximum spike interval (Tmin + Tcod), corresponding to value 1.

Type:

float

decode_interval(spiking_interval: float) float[source]

Decode an inter-spike interval back into a normalized value.

Parameters:

spiking_interval (float) – The time between two spikes.

Returns:

A value in [0, 1] corresponding to the spike interval.

Return type:

float

encode_value(value: float) tuple[float, float][source]

Encode a value into a pair of spike times.

The spike interval encodes the magnitude of the value. The first spike is always at t=0.

Parameters:

value (float) – A normalized value in the range [0, 1].

Returns:

A pair of spike times (t0, t1) such that (t1 - t0) encodes the value.

Return type:

tuple[float, float]

Raises:

AssertionError – If the value is not in [0, 1].

axon_sdk.primitives.events module

Spike Event Scheduling

Defines event queue infrastructure for managing timed spike events in STICK-based spiking neural networks.

Classes:
  • SpikeEvent: Represents a scheduled synaptic event.

  • SpikeEventQueue: Priority queue for time-ordered spike events.

class axon_sdk.primitives.events.SpikeEvent(time: float, affected_neuron: ExplicitNeuron, synapse_type: str, weight: float)[source]

Bases: object

Represents a scheduled synaptic event in the network.

time

Simulation time at which the event should occur.

Type:

float

affected_neuron

Neuron that receives the event.

Type:

ExplicitNeuron

synapse_type

Type of synaptic interaction (e.g., ‘ge’, ‘gf’, ‘gate’, ‘V’).

Type:

str

weight

Synaptic weight to apply during the event.

Type:

float

class axon_sdk.primitives.events.SpikeEventQueue[source]

Bases: object

Priority queue for managing time-sorted spike events.

Implements event insertion and retrieval of events scheduled up to the current simulation time.

add_event(time: float, neuron: ExplicitNeuron, synapse_type: str, weight: float)[source]

Add a new spike event to the queue.

Parameters:
  • time (float) – Scheduled time of the event.

  • neuron (ExplicitNeuron) – Target neuron.

  • synapse_type (str) – Synapse type.

  • weight (float) – Weight of the synaptic input.

pop_events(current_time) list[SpikeEvent][source]

Pop all events scheduled to occur up to the current simulation time.

Parameters:

current_time (float) – The current time in simulation.

Returns:

List of events to apply at this timestep.

Return type:

List[SpikeEvent]

axon_sdk.primitives.helpers module

Utilities

Common helper functions used throughout the Axon SDK.

axon_sdk.primitives.helpers.flatten_nested_list(nested_list: list) list[source]

Recursively flattens an arbitrarily nested list into a single flat list.

This function supports arbitrary nesting of Python lists and returns a single list containing all the elements in depth-first order.

Parameters:

nested_list (list) – A list that may contain other lists as elements.

Returns:

A flat list with all nested elements extracted.

Return type:

list

Example

>>> flatten_nested_list([1, [2, [3, 4], 5]])
[1, 2, 3, 4, 5]

axon_sdk.primitives.networks module

Spiking Network Composition

This module defines the SpikingNetworkModule class, a hierarchical container for building composable STICK-based spiking networks with neuron and subnetwork modularity.

Key components: - SpikingNetworkModule: Base class for defining networks with neurons and submodules. - flatten_nested_list: Utility to flatten arbitrarily nested lists.

class axon_sdk.primitives.networks.SpikingNetworkModule(module_name: str | None = None)[source]

Bases: object

Base class for constructing hierarchical spiking networks in the STICK model.

Each module can contain neurons and nested subnetworks, enabling compositional construction of larger networks.

_neurons

List of neurons directly in this module.

Type:

list[ExplicitNeuron]

_subnetworks

Nested submodules.

Type:

list[SpikingNetworkModule]

_uid

Globally unique identifier for this module.

Type:

str

_instance_count

Internal instance index.

Type:

int

add_neuron(Vt: float, tm: float, tf: float, Vreset: float = 0.0, neuron_name: str | None = None) ExplicitNeuron[source]

Create and add a neuron to this module.

Parameters:
  • Vt (float) – Threshold voltage.

  • tm (float) – Membrane time constant.

  • tf (float) – Synaptic decay time constant.

  • Vreset (float, optional) – Reset voltage after spike. Defaults to 0.0.

  • neuron_name (str, optional) – Optional name for this neuron.

Returns:

The newly created neuron.

Return type:

ExplicitNeuron

add_subnetwork(subnet: SpikingNetworkModule) None[source]

Add a nested spiking network module.

Parameters:

subnet (SpikingNetworkModule) – The submodule to add.

connect_neurons(pre_neuron: ExplicitNeuron, post_neuron: ExplicitNeuron, synapse_type: str, weight: float, delay: float)[source]

Connect two neurons via a synapse.

Parameters:
  • pre_neuron (ExplicitNeuron) – Presynaptic neuron.

  • post_neuron (ExplicitNeuron) – Postsynaptic neuron.

  • synapse_type (str) – Type of synapse (‘V’, ‘ge’, ‘gf’, ‘gate’, etc.).

  • weight (float) – Synaptic weight.

  • delay (float) – Synaptic delay in seconds.

property instance_count: int

Returns: int: Instance index assigned at construction.

property neurons: list[ExplicitNeuron]

Recursively collect all neurons from this module and its submodules.

Returns:

List of all neurons in the hierarchy.

Return type:

list[ExplicitNeuron]

property neurons_with_module_uid: dict[ExplicitNeuron, str]

Get a mapping from all neurons in the hierarchy to their parent module UID.

Returns:

Mapping from neuron to module UID.

Return type:

dict[ExplicitNeuron, str]

recurse_neurons_with_module_uid() list[dict[ExplicitNeuron, str]][source]

Recursively build a list of dictionaries mapping each neuron to its module UID.

Returns:

One dictionary per neuron/module pair.

Return type:

list[dict[ExplicitNeuron, str]]

property subnetworks: list[Self]

Returns: list[SpikingNetworkModule]: Submodules contained in this module.

property top_module_neurons: list[ExplicitNeuron]

Returns neurons belonging to current module, without taking submodules into account

property uid: str

Returns: str: Unique identifier of this module.

axon_sdk.primitives.networks.flatten_nested_list(nested_list: list) list[source]

Recursively flattens an arbitrarily nested list into a single list.

Parameters:

nested_list (list) – A list which may contain other lists as elements.

Returns:

A flat list containing all elements in order.

Return type:

list

Module contents