Zero Crossing Step Forward Algorithm
- zero_cross_step_forward(signal: ndarray, threshold: float | int | list[float | int] | ndarray) 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.encoders.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 | int | list[float | int] | numpy.ndarray) – Threshold(s) for spike generation; scalar or 1D sequence matching features.
- Returns:
A numpy array representing the encoded spike train.
- Return type:
- Raises:
ValueError – If the input signal is empty or if the threshold dimensions do not match the signal features.
TypeError – If the threshold parameter is of invalid dimension.