Threshold Based Representation Algorithm
- threshold_based_representation(signal: ndarray, factor: float | list[float]) ndarray[source]¶
Perform Threshold-Based Representation (TBR) encoding on the input signal.
This function takes a continuous signal and converts it into a spike train using a fixed threshold based on the signal’s variations. A spike is generated when the variation exceeds the computed threshold.
Refer to the Threshold-Based Representation (TBR) Encoding for a detailed explanation of the TBR encoding algorithm.
Code Example:
import numpy as np from spikify.encoding.temporal.contrast import threshold_based_representation signal = np.array([0.1, 0.3, 0.4, 0.2, 0.5, 0.6]) factor = 0.5 encoded_signal = threshold_based_representation(signal, factor)
- Parameters:
signal (numpy.ndarray) – The input signal to be encoded. This should be a numpy ndarray.
factor (float | list[float]) – The factor value (γ) that controls the noise-reduction threshold. 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.