Hough Spiker Algorithm

hough_spiker(signal: ndarray, window_length: int | list[int], 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]

Perform spike detection using the Hough Spiker Algorithm (HSA).

This function detects spikes in an input signal by performing a progressive subtraction operation, where the signal is compared with a convolution result using a boxcar filter. If the signal value exceeds the filter result, the signal is modified by subtracting the filter, and a spike is recorded.

Refer to the Hough Spiker Encoding for a detailed explanation of the HSA.

Code Example

import numpy as np
from spikify.encoding.temporal.deconvolution import hough_spiker
signal = np.array([0.1, 0.2, 4.1, 1.0, 3.0, 0.3, 0.1])
window_length = 3
spikes = hough_spiker(signal, window_length)
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.

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.