Burst Coding Algorithm

burst_coding(signal: ndarray, n_max: int, t_min: int, t_max: int, interval_length: int) ndarray[source]

Perform Burst Coding (BC) on the input signal.

This function implements a biologically inspired burst coding scheme where each input intensity (normalized P ∈ [0, 1]) is converted into a burst of spikes:

  • Number of spikes N_s(P) = ceil(P * n_max)

  • ISI(P): Fixed at t_max when N_s = 1; otherwise linearly mapped between t_min (strong input) and t_max (weak input) for N_s > 1.

The signal is divided into non-overlapping blocks of length interval_length. The mean intensity per block determines the burst parameters (N_s and ISI). The burst is placed at regular intervals starting from the beginning of the output block.

Higher intensities produce bursts with more spikes and smaller ISIs. The interval_length must be large enough to fit the longest burst.

Note

  • BC requires normalized input signals between 0 and 1. If the input signal contains negative values, they are

    shifted to be non-negative and then normalized.

Refer to the Burst Coding (BC) for a detailed explanation of the Burst Coding Algorithm.

Code Example:

import numpy as np
from spikify.encoders.temporal.latency import burst_coding
np.random.seed(42)
signal = np.random.rand(16)
n_max = 4
t_min = 2
t_max = 6
length = 16
encoded_signal = burst_coding(signal, n_max, t_min, t_max, length)
Parameters:
  • signal (numpy.ndarray) – Input signal to encode (1D or 2D: timestamps × features).

  • n_max (int) – Maximum number of spikes in a burst (for P = 1). Must be ≥ 1.

  • t_min (int) – Minimum inter-spike interval (ISI) in time steps (for strong inputs with N_s > 1).

  • t_max (int) – Maximum inter-spike interval (ISI) in time steps (for weak inputs or N_s = 1).

  • interval_length (int) – Length of each output block corresponding to one input block. Must divide the signal length evenly and be large enough to fit the longest burst (approximately n_max * (t_min + 1)).

Returns:

A numpy array representing the encoded spike train.

Return type:

numpy.ndarray

Raises:

ValueError – If signal is empty, interval_length does not divide signal length, or interval_length is too small for the longest possible burst.