eelbrain.pipeline.PrimaryEpoch

class eelbrain.pipeline.PrimaryEpoch(session, sel=None, **kwargs)

Epoch based on selecting events from a raw file

Parameters
  • session (str) – Session (raw file) from which to load data.

  • sel (str) – Expression which evaluates in the events Dataset to the index of the events included in this Epoch specification.

  • tmin (float) – Start of the epoch (default -0.1).

  • tmax (float) – End of the epoch (default 0.6).

  • samplingrate (scalar) – Target samplingrate. Needs to divide data samplingrate evenly (e.g. 200 for data sampled at 1000 Hz; default 200).

  • decim (int) – Alternative to samplingrate. Decimate the data by this factor (i.e., only keep every decim’th sample).

  • baseline (tuple) – The baseline of the epoch (default (None, 0); if tmin > 0: no baseline; if tmax < 0: the whole interval).

  • n_cases (int) – Expected number of epochs. If n_cases is defined, a RuntimeError error will be raised whenever the actual number of matching events is different.

  • trigger_shift (float | str) – Shift event triggers before extracting the data [in seconds]. Can be a float to shift all triggers by the same value, or a str indicating an event variable that specifies the trigger shift for each trigger separately. The trigger_shift applied after loading selected events. For secondary epochs the trigger_shift is applied additively with the trigger_shift of their base epoch.

  • post_baseline_trigger_shift (str) – Shift the trigger (i.e., where epoch time = 0) after baseline correction. The value of this entry has to be the name of an event variable providing for each epoch the actual amount of time shift (in seconds). If the post_baseline_trigger_shift parameter is specified, the parameters post_baseline_trigger_shift_min and post_baseline_trigger_shift_max are also needed, specifying the smallest and largest possible shift. These are used to crop the resulting epochs appropriately, to the region from new_tmin = epoch['tmin'] - post_baseline_trigger_shift_min to new_tmax = epoch['tmax'] - post_baseline_trigger_shift_max.

  • vars (dict) – Add new variables only for this epoch. Each entry specifies a variable with the following schema: {name: definition}. definition can be either a string that is evaluated in the events-Dataset`, or a (source_name, {value: code})-tuple. source_name can also be an interaction, in which case cells are joined with spaces ("f1_cell f2_cell").

Examples

Selecting events based on a categorial label:

PrimaryEpoch('session', "variable == 'label'")

Based on multiple categorial labels:

PrimaryEpoch('session', "variable.isin(['label1', 'label2'])")

Methods

as_dict()

as_dict_24()

Dict to be compared with Eelbrain 0.24 cache