pynapple.process.randomize#

Functions to shuffle timestamps to create surrogate datasets.

Functions

jitter_timestamps(ts[, max_jitter, ...])

Jitters each time stamp independently of random amounts uniformly drawn between -max_jitter and max_jitter.

resample_timestamps(ts)

Resamples the timestamps in the time support, with uniform distribution.

shift_timestamps(ts[, min_shift, max_shift])

Shifts all the time stamps of a random amount between min_shift and max_shift, wrapping the end of the time support to the beginning.

shuffle_ts_intervals(ts[, min_shift, max_shift])

Randomizes the timestamps by shuffling the intervals between them.

pynapple.process.randomize.jitter_timestamps(ts, max_jitter=None, keep_tsupport=False)[source]#

Jitters each time stamp independently of random amounts uniformly drawn between -max_jitter and max_jitter.

Parameters:
  • ts (Ts or TsGroup) – The timestamps to jitter. If TsGroup, jitter is applied to each element of the group.

  • max_jitter (float) – maximum jitter

  • keep_tsupport (bool, optional) – If True, keep time support of the input. The number of timestamps will not be conserved. If False, the time support is inferred from the jittered timestamps. The number of tmestamps is conserved. (default: False)

Returns:

The jittered timestamps

Return type:

Ts or TsGroup

pynapple.process.randomize.resample_timestamps(ts)[source]#

Resamples the timestamps in the time support, with uniform distribution.

Parameters:

ts (Ts or TsGroup) – The timestamps to resample. If TsGroup, each Ts object in the group is independently resampled, in the time support of the whole group.

Returns:

The resampled timestamps

Return type:

Ts or TsGroup

pynapple.process.randomize.shift_timestamps(ts, min_shift=0.0, max_shift=None)[source]#

Shifts all the time stamps of a random amount between min_shift and max_shift, wrapping the end of the time support to the beginning.

Parameters:
  • ts (Ts or TsGroup) – The timestamps to shift. If TsGroup, shifts all Ts in the group independently.

  • min_shift (float, optional) – minimum shift (default: 0 )

  • max_shift (float, optional) – maximum shift, (default: length of time support)

Returns:

The randomly shifted timestamps

Return type:

Ts or TsGroup

pynapple.process.randomize.shuffle_ts_intervals(ts, min_shift=0.0, max_shift=None)[source]#

Randomizes the timestamps by shuffling the intervals between them.

Parameters:

ts (Ts or TsGroup) – The timestamps to randomize. If TsGroup, randomizes all Ts in the group independently.

Returns:

The randomized timestamps, with shuffled intervals

Return type:

Ts or TsGroup