Zero Crossing Step Forward Algorithm

zero_cross_step_forward(signal: ndarray, threshold: float | list[float]) ndarray[source]

Perform Zero-Crossing Step-Forward (ZCSF) encoding on the input signal.

This function generates a spike train based on the positive values of the input signal that exceed a specified threshold. Negative values of the signal are zeroed out (half-wave rectification), and only positive spikes are considered.

Refer to the Zero-Crossing Step-Forward (ZCSF) Encoding for a detailed explanation of the ZCSF encoding algorithm.

Code Example:

import numpy as np
from spikify.encoding.temporal.contrast import zero_cross_step_forward
signal = np.array([-0.2, 0.1, 0.5, 0.0, 1.2, 0.3])
threshold = 0.4
encoded_signal = zero_cross_step_forward(signal, threshold)
Parameters:
  • signal (numpy.ndarray) – The input signal to be encoded. This should be a numpy ndarray.

  • threshold (float | list[float]) – The threshold value used to determine spike generation. Can be a float or a list of floats.

Returns:

A numpy array representing the encoded spike train.

Return type:

numpy.ndarray

Raises:
  • ValueError – If the input signal is empty.

  • TypeError – If the signal is not a numpy ndarray.