Bens Spiker Algorithm (BSA) uses Finite Impulse Response (FIR) filter to try a reverse convolution of the
stimulation (converting spikes to analog values). A principle borrowed from unpublished modified
Hough Spiker Algorithm (HSA) [2].
The defaults for threshold, filter_length and cutoff are not taken from the paper; the best values
depend on the signal. They were chosen empirically, by how well the spikes reconstruct EEG (tests/test-data)
and smooth synthetic signals. For other data, tune them by reconstruction error, for example the signal-to-noise
ratio between the normalised input and the spikes convolved with the filter.
Parameters:
data (ndarray) – See :py:mod: nucube.utils.ReadCSV.get_samples()
threshold (float) – Threshold level for spike. It can also be a list of threshold according to the numbers of input features.
It is subtracted, as in the paper: a spike fires when error1<=error2-threshold. Some other
implementations multiply instead (error2*threshold), so their thresholds are not comparable.
filter_length (int) – Number of taps in the FIR filter. Longer filters follow slower changes in the signal.
cutoff (float) – Cutoff frequency of the FIR filter, as a fraction of the Nyquist frequency.
Each feature has a baseline that starts at its first value. When the signal rises above baseline+threshold
a positive spike (1) is emitted and the baseline moves up by threshold; when it falls below
baseline-threshold a negative spike (-1) is emitted and the baseline moves down. The spikes can be
decoded back to a staircase approximation of the signal: firstvalue+threshold*cumulativesumofspikes.
The threshold is in the units of the data and is the only parameter. By default it is set for each feature of
every sample to 1.5 times the mean absolute change between time steps. This factor is not taken from the paper; it
was chosen empirically, by how well the spikes reconstruct EEG (tests/test-data).
Parameters:
data (ndarray) – See :py:mod: nucube.utils.ReadCSV.get_samples()
threshold (float) – Threshold in the units of the data. It can also be a list of threshold according to the numbers of input
features. If not given, it is 1.5 times the mean absolute change between time steps, for each feature of
every sample.