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:
Examples
>>> from braintools.cogtask import Context, label >>> ctx = Context() >>> ctx.update(ground_truth=1, choice=2) >>> label(0)(ctx, None) # static label, e.g. during fixation 0 >>> label('ground_truth')(ctx, None) # read from the context 1 >>> label(lambda ctx: ctx['choice'] + 1)(ctx, None) # custom rule 3