Waveform features

Features of waveforms (e.g waveform_snr).

elephant.waveform_features.waveform_snr(waveforms)[source]

Return the signal-to-noise ratio of the waveforms of one or more spike trains.

Signal-to-noise ratio is defined as the difference in mean peak-to-trough voltage divided by twice the mean SD. The mean SD is computed by measuring the SD of the spike waveform over all acquired spikes at each of the sample time points of the waveform and then averaging [1].

Parameters:
waveformsarray-like

A list or a quantity or a numpy array of waveforms of shape (n_waveforms, time) in case of a single spike train or (n_waveforms, n_spiketrains, time) in case of one or more spike trains.

Returns:
snrfloat or np.ndarray

Signal-to-noise ratio according to [1]. If the input waveforms shape is (n_waveforms, time) or (n_waveforms, 1, time), a single float is returned. Otherwise, if the shape is (n_waveforms, n_spiketrains, time), a numpy array of length n_spiketrains is returned.

Notes

The waveforms of a neo.SpikeTrain can be extracted as spiketrain.waveforms, if it’s loaded from a file, in which case you need to set load_waveforms=True in neo.read_block().

References

[1](1, 2) Hatsopoulos, N. G., Xu, Q. & Amit, Y. Encoding of Movement Fragments in the Motor Cortex. J. Neurosci. 27, 5105–5114 (2007).
elephant.waveform_features.waveform_width(waveform, cutoff=0.75)[source]

Calculate the width (trough-to-peak TTP) of a waveform.

Searches for an index of a minimum within first cutoff of the waveform vector, next for a maximum after the identified minimum, and returns the difference between them.

Parameters:
waveformarray-like

Time course of a single waveform. Accepts a list, a numpy array or a quantity.

cutofffloat, optional

Defines the normalized range [0, cutoff] of the input sequence for computing the minimum. Must be in [0, 1) range. Default: 0.75.

Returns:
widthint

Width of a waveform expressed as a number of data points

Raises:
ValueError

If waveform is not a one-dimensional vector with at least two numbers.

If cutoff is not in [0, 1) range.