pynapple.TsdFrame.time_diff#

TsdFrame.time_diff(align='center', epochs=None)[source]#

Computes the differences between subsequent timestamps.

Parameters:
  • align (str, optional) –

    Determines the time index of the resulting time differences:
    • ”start” : the start of the interval between two timestamps.

    • ”center” [default]: the center of the interval between two timestamps.

    • ”end” : the end of the interval between two timestamps.

  • epochs (IntervalSet, optional) – The epochs on which interspike intervals are computed. If None, the time support of the input is used.

Returns:

The time differences.

Return type:

Tsd

Examples

>>> import pynapple as nap
>>> import numpy as np
>>> tsdframe = nap.TsdFrame(t=[1, 3, 5, 6, 8, 12], d=np.ones((6, 2)))
>>> epochs = nap.IntervalSet(start=2, end=9, time_units='s')
>>> tsd_time_diffs = tsdframe.time_diff(align="center", epochs=epochs)
>>> tsd_time_diffs
Time (s)
----------  --
4            2
5.5          1
7            2
dtype: float64, shape: (3,)