FeatureSet#

class braintools.cogtask.FeatureSet(*fts)[source]#

Collection of features with automatic index management.

Features in a set have their indices adjusted automatically to avoid overlap. Supports composition via +, -, | operators.

Examples

>>> fix = Feature(1, 'fixation')
>>> stim = Feature(8, 'stimulus')
>>> features = fix + stim  # Creates FeatureSet
>>> print(features['fixation'].i)  # slice(0, 1)
>>> print(features['stimulus'].i)  # slice(1, 9)
Parameters:

*fts – Features to include in the set.

copy()[source]#

Create a deep copy of this feature set.

Return type:

FeatureSet

shift(num)[source]#

Shift all indices by the given amount.

Warning

This method mutates the FeatureSet in-place, unlike __add__ which creates a copy. If you need to preserve the original FeatureSet, create a copy before calling shift().

Parameters:

num (int) – The amount to shift indices by (can be positive or negative).