Step Forward Algorithm
- step_forward(signal: ndarray, threshold: float | list[float]) ndarray[source]¶
Perform Step-Forward encoding on the input signal.
This function takes a continuous signal and converts it into a spike train using a dynamically updated baseline and threshold-based approach. A spike is generated when the signal exceeds or drops below the dynamically adjusted baseline (Base) by the specified Threshold.
Refer to the Step Forward Encoding for a detailed explanation of the Step-Forward encoding algorithm.
Code Example:
import numpy as np from spikify.encoding.temporal.contrast import step_forward signal = np.array([0.1, 0.3, 0.4, 0.2, 0.5, 0.6]) threshold = 0.2 encoded_signal = 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(s) for spike detection. Can be a float or a list of floats.
- Returns:
A numpy array representing the encoded spike train.
- Return type:
- Raises:
ValueError – If the input signal is empty.
TypeError – If the signal is not a numpy ndarray.