eelbrain.table.difference

eelbrain.table.difference(y, x, c1, c0, match, sub=None, ds=None)

Subtract data in one cell from another

Parameters
  • y (Union[NDVar, Var, str]) – Dependent variable.

  • x (Union[Factor, Interaction, NestedEffect, str]) – Model for subtraction, providing categories to compute c1 - c0.

  • c1 (Union[str, Tuple[str, ...]]) – Name of the cell in x that forms the minuend.

  • c0 (Union[str, Tuple[str, ...]]) – Name of the cell in x that is to be subtracted from c1.

  • match (Union[Factor, Interaction, NestedEffect, str]) – Units over which measurements were repeated. c1 - c0 will be calculated separately for each level of match (e.g. "subject", or "subject % condition").

  • sub (Union[Var, ndarray, str, None]) – Only include a subset of the data.

  • ds (Optional[Dataset]) – If a Dataset is specified other arguments can be str instead of data-objects and will be retrieved from ds.

Returns

Dataset with the difference between c1 and c0 on y.

Return type

diff

Examples

ERP difference wave: assuming a dataset ds with EEG data (ds['eeg']), a variable named 'condition' with levels 'expected' and 'unexpected', and multiple subjects, the following will generate the unexpected - expected difference waves:

>>> diff = table.difference('eeg', 'condition', 'unexpected', 'expected',
... 'subject', ds=ds)

If ds also contains a different factor crossed with condition, called 'word' with levels 'verb' abd 'adjective', then separate difference waves for verbs and adjectives can be computed with:

>>> diff = table.difference('eeg', 'condition', 'unexpected', 'expected',
... 'subject % word', ds=ds)

Given the latter, the difference of the difference waves could be computed with:

>>> diffdiff = table.difference('eeg', 'word', 'verb', 'adjective',
... 'subject', ds=diff)