braintools.cogtask.interval_of

Contents

braintools.cogtask.interval_of#

braintools.cogtask.interval_of(elem, total)[source]#

Get slice for a named period in a sequence of periods.

Parameters:
  • elem (str) – Name of the period to find.

  • total (Dict[str, int] | Sequence[Tuple[str, int]]) – Period definitions as {name: duration} or [(name, duration), …].

Returns:

Slice object for accessing the period in time-indexed arrays.

Return type:

slice

Examples

>>> periods = {'fixation': 10, 'stimulus': 20, 'delay': 15}
>>> interval_of('stimulus', periods)
slice(10, 30, None)