Modified Hough Spiker Algorithm
- modified_hough_spiker(signal: ndarray, window_length: int, threshold: float) ndarray[source]¶
Detect spikes in a signal using the Modified Hough Spiker Algorithm.
This function detects spikes in an input signal by incorporating a threshold-based error accumulation mechanism. The signal is compared with a convolution result using a boxcar filter, and the error is accumulated over time. If the error remains within a specified threshold, a spike is detected, and the signal is modified.
Refer to the Modified Hough Spiker Encoding for a detailed explanation of the Modified Hough Spiker Algorithm.
Code Example:
import numpy as np from spikify.encoding.temporal.deconvolution import modified_hough_spiker signal = np.array([0.1, 0.2, 0.3, 1.0, 0.5, 0.3, 0.1]) window_length = 3 threshold = 0.5 spikes = modified_hough_spiker(signal, window_length, threshold)
- Parameters:
signal (numpy.ndarray) – The input signal to be analyzed. This should be a numpy ndarray.
window_length (int) – The length of the boxcar filter window.
threshold (float) – The threshold value for error accumulation.
- Returns:
A 1D numpy array representing the detected spikes.
- Return type:
- Raises:
ValueError – If the input signal is empty or if the window length is greater than the signal length.
TypeError – If the signal is not a numpy ndarray.