pynapple.core.ts_group.TsGroup.value_from#

TsGroup.value_from(tsd, ep=None)[source]#

Replace the value of each Ts/Tsd object within the Ts group with the closest value from tsd argument

Parameters:
  • tsd (Tsd) – The Tsd object holding the values to replace

  • ep (IntervalSet) – The IntervalSet object to restrict the operation. If None, the time support of the tsd input object is used.

Returns:

TsGroup object with the new values

Return type:

TsGroup

Examples

>>> import pynapple as nap
>>> import numpy as np
>>> tmp = { 0:nap.Ts(t=np.arange(0,200), time_units='s'),
1:nap.Ts(t=np.arange(0,200,0.5), time_units='s'),
2:nap.Ts(t=np.arange(0,300,0.25), time_units='s'),
}
>>> tsgroup = nap.TsGroup(tmp)
>>> ep = nap.IntervalSet(start=0, end=100, time_units='s')

The variable tsd is a time series object containing the values to assign, for example the tracking data:

>>> tsd = nap.Tsd(t=np.arange(0,100), d=np.random.rand(100), time_units='s')
>>> ep = nap.IntervalSet(start = 0, end = 100, time_units = 's')
>>> newtsgroup = tsgroup.value_from(tsd, ep)