spiketools.utils.timestamps.compute_sample_durations

spiketools.utils.timestamps.compute_sample_durations(timestamps, align_output=True)[source]

Compute the time duration of each sample.

Parameters:
timestamps1d array

Timestamps, in seconds.

align_outputbool, optional, default: True

If True, aligns the output with the sampling of the input, to match length. To do so, value of 0 is appended to the output array.

Returns:
1d array

Time duration of each sampling bin.

Examples

Compute times between timestamp samples:

>>> timestamps = np.array([0, 1.0, 3.0, 6.0, 8.0, 9.0])
>>> compute_sample_durations(timestamps)
array([1., 2., 3., 2., 1., 0.])