braintools.cogtask.label

Contents

braintools.cogtask.label#

braintools.cogtask.label(value)[source]#

Create an output label specification.

Parameters:

value (int | str | Callable[[Context], int]) –

  • int: Static label value

  • str: Context key containing the label

  • callable: Function (ctx) -> label

Returns:

Label function (ctx, feature) -> int

Return type:

Callable[[Context, Feature | None], int]

Examples

>>> outputs={'label': label(0)}  # Static fixation label
>>> outputs={'label': label('ground_truth')}  # From context
>>> outputs={'label': label(lambda ctx: ctx['choice'] + 1)}  # Custom