Modified Hough Spiker Algorithm

modified_hough_spiker(signal: ndarray, window_length: int | list[int], threshold: float | list[float], window_type: Literal['barthann', 'brthan', 'bth', 'bartlett', 'bart', 'brt', 'blackman', 'black', 'blk', 'blackmanharris', 'blackharr', 'bkh', 'bohman', 'bman', 'bmn', 'boxcar', 'box', 'ones', 'rect', 'rectangular', 'cosine', 'halfcosine', 'exponential', 'poisson', 'flattop', 'flat', 'flt', 'hamming', 'hamm', 'ham', 'hann', 'han', 'lanczos', 'sinc', 'nuttall', 'nutl', 'nut', 'parzen', 'parz', 'par', 'taylor', 'taylorwin', 'triangle', 'triang', 'tri', 'tukey', 'tuk'] = 'boxcar') 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 | list[int]) – The length of the boxcar filter window. Can be a int or a list of ints.

  • threshold (float or list of float) – The threshold value for error accumulation. Can be a float or a list/array of floats.

Returns:

A 1D numpy array representing the detected spikes.

Return type:

numpy.ndarray

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.