Time To First Spike Algorithm
- time_to_first_spike(signal: ndarray, interval: int) ndarray[source]¶
Perform time-to-first-spike encoding on the input signal.
This function encodes the input signal by computing the time to the first spike based on a dynamically decaying threshold, following an exponential function. The time to the first spike is determined by the value of the signal relative to this threshold.
Refer to the Time-to-First-Spike Encoding for a detailed explanation of the Time-to-First-Spike Encoding Algorithm.
Code Example:
import numpy as np from spikify.encoding.temporal.global_referenced import time_to_first_spike signal = np.array([0.1, 0.2, 0.3, 1.0, 0.5, 0.3, 0.1, 0.2]) interval = 4 encoded_signal = time_to_first_spike(signal, interval)
- Parameters:
signal (numpy.ndarray) – The input signal to be encoded.This should be a numpy ndarray.
interval (int) – The size of the interval used for encoding.
- Returns:
A 1D numpy array representing the time-to-first-spike encoded spike train.
- Return type:
- Raises:
ValueError – If the input signal is empty or if the interval is not a multiple of the signal length.