Moving Window Algorithm
- moving_window(signal: ndarray, window_length: int) ndarray[source]¶
Perform Moving Window encoding on the input signal.
This function takes a continuous signal and converts it into a spike train using a moving window and threshold-based approach. A spike is generated when the signal exceeds the calculated Base plus or minus a specified Threshold.
Refer to the Moving Window Encoding for a detailed explanation of the Moving Window encoding algorithm.
Code Example:
import numpy as np from spikify.encoding.temporal.contrast import moving_window signal = np.array([0.1, 0.3, 0.2, 0.5, 0.8, 1.0]) window_length = 3 encoded_signal = moving_window(signal, window_length) encoded_signal
- Parameters:
signal (numpy.ndarray) – The input signal to be encoded. This should be a numpy ndarray.
window_length (int) – The size of the sliding window for calculating the base mean.
- Returns:
A 1D numpy array representing the encoded spike train.
- Return type:
- Raises:
ValueError – If the input signal is empty.
ValueError – If the window length is greater than the length of the signal.
TypeError – If the signal is not a numpy ndarray.