Modified Hough Spiker (MHSA) Encoding¶
The Modified Hough Spiker Algorithm (MHSA) is a threshold-based improvement over the original Hough Spiker Algorithm (HSA).
The original HSA is very strict: it only emits a spike if the signal is greater than or equal to the FIR filter coefficients at every single point in the current window. Even a tiny dip below the filter at one position prevents spike detection.
MHSA relaxes this rule by allowing a small amount of accumulated error where the signal falls below the filter. It calculates the total shortfall (sum of the positive differences where the filter exceeds the signal) across the window. If this total error stays below a predefined threshold, a spike is still emitted, and the filter is subtracted from the signal segment as usual.
This modification makes the algorithm more flexible and robust to noise, variations, or imperfect matches between signal and filter shape.
Like HSA, MHSA requires:
Non-negative FIR filter coefficients (negative values cause failure)
Input signal normalized to [0, 1] (automatic shifting and normalization are typically applied)
Algorithm Overview
Error Accumulation For each possible starting time in the signal, compute the accumulated error as the sum of (filter - signal) only where filter > signal (positive differences only).
Threshold Check If the total accumulated error ≤ threshold, emit a positive spike at that time and subtract the filter pattern from the signal segment.
Iteration Continue with the updated signal until the end of the sequence.
Detailed Pseudocode
1MHSA Encoding Algorithm
2input: s signal, fir filter, thr threshold
3L = length(s)
4F = length(h)
5out = zeros(L)
6for t = 0 to L-F
7 error = 0
8 for j = 0 to F
9 if t+j <= L
10 error += max(0, fir(j) - s(t+j))
11 end if
12 end for
13 if error <= thr
14 out(t) = 1
15 for j = 0 to F
16 if t+j <= L
17 s(t+j) -= fir(j)
18 end if
19 end for
20 end if
21end for
22output: out
Advantages
Significantly better reconstruction quality than original HSA.
Much more flexible — detects spikes even with small noise or shape variations.
Smooth threshold optimization landscape — less sensitive to exact threshold value.
Disadvantages
Reconstruction biased high (tends to exceed original signal) due to relaxed error tolerance.
Errors larger at higher signal amplitudes and accumulate over time.
Still restricted to non-negative FIR filters — limits filter design options.
Input preprocessing (shift/normalize to [0, 1]) may introduce artifacts for arbitrary signals.
For a practical implementation in Python, see the Modified Hough Spiker Function.
References
Schrauwen, B., Van Campenhout, J. (2003). “HSA: A Progressive Subtraction Technique for Spike Detection.” Neurocomputing.
Petro, P., et al. (2021). “Modified HSA with Thresholding for Enhanced Spike Detection.” Signal Processing Letters.