braintools.cogtask.cos_sin

Contents

braintools.cogtask.cos_sin#

braintools.cogtask.cos_sin(key, num_dirs, repeats=1, *, base_value=0.0, map_to_01=True)[source]#

Encode a discrete direction index into repeated [cos(theta), sin(theta)] features.

Output dim: 2 * repeats

[cos(theta)] repeated ‘repeats’ times, then [sin(theta)] repeated ‘repeats’ times.

Parameters:
  • key (str) – Context key containing discrete direction index (int).

  • num_dirs (int) – Number of discrete directions (e.g., num_stimuli).

  • repeats (int) – How many duplicated cos features and sin features.

  • base_value (float) – Baseline after mapping to [0,1]. Ignored if map_to_01=False.

  • map_to_01 (bool) – If True, map cos/sin from [-1,1] to [0,1], then to [base_value, 1]. If False, keep raw cos/sin in [-1,1].

Return type:

Callable[[Context, Feature], Array]

Notes

  • This encoder ignores feature.num (it will validate it equals 2*repeats).