braintools.cogtask.interval_of#
- braintools.cogtask.interval_of(elem, total)[source]#
Get slice for a named period in a sequence of periods.
- Parameters:
- Returns:
Slice object for accessing the period in time-indexed arrays.
- Return type:
Examples
>>> from braintools.cogtask import interval_of >>> periods = {'fixation': 10, 'stimulus': 20, 'delay': 15} >>> interval_of('stimulus', periods) slice(10, 30, None) >>> interval_of('delay', [('fixation', 10), ('stimulus', 20), ('delay', 15)]) slice(30, 45, None)