braintools.cogtask.match_label

Contents

braintools.cogtask.match_label#

braintools.cogtask.match_label(match_key, match_label=1, nonmatch_label=2)[source]#

Create a label for match/non-match tasks.

Parameters:
  • match_key (str) – Context key containing boolean match status (True/False).

  • match_label (int) – Label for match trials (default 1).

  • nonmatch_label (int) – Label for non-match trials (default 2).

Returns:

Label function (ctx, feature) -> int

Return type:

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

Examples

>>> from braintools.cogtask import Context, match_label
>>> spec = match_label('is_match')  # e.g. outputs={'label': spec}
>>> ctx = Context()
>>> ctx['is_match'] = True
>>> int(spec(ctx, None))
1
>>> ctx['is_match'] = False
>>> int(spec(ctx, None))
2
>>> int(match_label('is_match', match_label=3, nonmatch_label=4)(ctx, None))
4