braintools.cogtask.von_mises

Contents

braintools.cogtask.von_mises#

braintools.cogtask.von_mises(key, coherence_key=None, kappa=2.0, base_value=0.5, max_coherence=100.0, as_index=True, num_dirs=None)[source]#

Von Mises (circular-normal) directional encoder.

Output is a normalized von Mises tuning curve in [base_value, 1].

Parameters:
  • key (str) – Context key holding the direction. When as_index=True (default) the value is an integer index in [0, num_dirs) and is converted to * idx / num_dirs. When as_index=False it is an angle in radians (matching circular).

  • coherence_key (str | None) – Context key with a coherence in [0, max_coherence]. If None the encoder uses max_coherence (full strength).

  • kappa (float) – Concentration parameter; higher values give sharper tuning.

  • base_value (float) – Floor of the response after normalization.

  • max_coherence (float) – Coherence normalization constant.

  • as_index (bool) – Interpret ctx[key] as an integer index rather than radians. The default matches the working-memory tasks which pass sample_idx.

  • num_dirs (int | None) – Number of discrete directions when as_index=True. Defaults to feature.num.

Return type:

Callable[[Context, Feature], Array]

Examples

>>> inputs={'motion': von_mises('direction', 'coherence', as_index=False)}
>>> inputs={'stimulus': von_mises('sample_idx', num_dirs=8)}