eelbrain.pipeline.LabelVar

class eelbrain.pipeline.LabelVar(source, codes, default=True, task=None, fnmatch=False)[source]

Variable assigning labels to values

Parameters:
  • source (str) – Variable supplying the values (e.g., "value").

  • codes (dict[str | float | tuple[str, ...] | tuple[float, ...], str | float]) – Mapping values in source to values in the new variable. The type of the values determines whether the output is a Factor (str values) or a Var (numerical values). Keys are matched against source as it is in the data: converted to str where source is a Factor (1 and 1. both spell the label '1'), and to numbers where it is a Var ('1' matches the value 1). This covers a value column that a BIDS *_events.tsv file provides as strings. In a numeric source, missing values (n/a) are NaN and can be matched with a float('nan') or 'nan' key. Keys that become identical through this conversion (e.g., 1 and '1') are rejected.

  • default (str | float | bool | None) – Label for values not in codes. By default, this is '' for categorial and 0 for numerical output. Set to False to pass through unlabeled input values.

  • task (str) – Only apply the variable to events from this task.

  • fnmatch (bool) – Treat keys in codes as fnmatch patterns.

Notes

With source='subject' the definition spans subjects (it lists a value for each of them), which defers it to the point where different subjects’ data are combined; see GroupVar for the implications. Only that exact source is deferred: a source that merely involves the subject, such as 'subject%value', is applied per subject like any other event variable, and so any subject’s entry invalidates every subject’s events.