ktk.TimeSeries.get_ts_between_events#

TimeSeries.get_ts_between_events(name1, name2, occurrence1=0, occurrence2=0, *, inclusive=False)[source]#

Get a TimeSeries between two specified events.

Parameters
  • name1 (str) – Name of the events to look for in the events list.

  • name2 (str) – Name of the events to look for in the events list.

  • occurrence1 (int) – Optional. i_th occurence of the event to look for in the events list, starting at 0.

  • occurrence2 (int) – Optional. i_th occurence of the event to look for in the events list, starting at 0.

  • inclusive (bool | tuple[bool, bool]) –

    Optional. Either a bool or a tuple of two bools. Used to specify which times are returned:

    • False or (False, False) (default): event1.time < time < event2.time

    • True or (True, True): event1.time <= time <= event2.time

    • (True, False): event1.time <= time < event2.time

    • (False, True): event1.time < time <= event2.time

Returns

A new TimeSeries that fulfils the specified conditions.

Return type

TimeSeries

Raises

TimeSeriesRangeError – If there is no data between the specified events.

Example

>>> ts = ktk.TimeSeries(time=np.arange(10)/10)
>>> ts = ts.add_event(0.2, "event")
>>> ts = ts.add_event(0.55, "event")
>>> ts.time
array([0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9])
>>> ts.get_ts_between_events("event", "event", 0, 1).time
array([0.3, 0.4, 0.5])
>>> ts.get_ts_between_events("event", "event", 0, 1,                                      inclusive=True).time
array([0.2, 0.3, 0.4, 0.5, 0.6])