ktk.TimeSeries.trim_events#

TimeSeries.trim_events(*, in_place=False)[source]#

Delete the events that are outside the TimeSeries’ time vector.

Parameters

in_place (bool) – Optional. True to modify and return the original TimeSeries. False to return a modified copy of the TimeSeries while leaving the original TimeSeries intact. Default is False.

Returns

The TimeSeries without the trimmed events.

Return type

TimeSeries

Example

>>> ts = ktk.TimeSeries(time = np.arange(10))
>>> ts.time
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> ts = ts.add_event(-2)
>>> ts = ts.add_event(0)
>>> ts = ts.add_event(5)
>>> ts = ts.add_event(9)
>>> ts = ts.add_event(10)
>>> ts.events
[TimeSeriesEvent(time=-2, name='event'),
 TimeSeriesEvent(time=0, name='event'),
 TimeSeriesEvent(time=5, name='event'),
 TimeSeriesEvent(time=9, name='event'),
 TimeSeriesEvent(time=10, name='event')]
>>> ts = ts.trim_events()
>>> ts.events
[TimeSeriesEvent(time=0, name='event'),
 TimeSeriesEvent(time=5, name='event'),
 TimeSeriesEvent(time=9, name='event')]