EventDataFrame#

class pymovements.EventDataFrame(*args: Any, **kwargs: Any)[source]#

A data structure for event data.

Deprecated since version v0.23.0: Please use Events instead. This module will be removed in v0.28.0.

Each row has at least an event name with its onset and offset specified.

Parameters:
  • data (pl.DataFrame | None) – A dataframe to be transformed to a polars dataframe. This argument is mutually exclusive with all the other arguments. (default: None)

  • name (str | list[str] | None) – Name of events. (default: None)

  • onsets (list[int] | np.ndarray | None) – List of onsets. (default: None)

  • offsets (list[int] | np.ndarray | None) – List of offsets. (default: None)

  • trials (list[int | float | str] | np.ndarray | None) – List of trial identifiers. (default: None)

  • trial_columns (list[str] | str | None) – List of trial columns in passed dataframe.

frame#

A dataframe of events.

Type:

pl.DataFrame

trial_columns#

The name of the trial columns in the data frame. If not None, processing methods will be applied to each trial separately.

Type:

list[str] | None

Raises:

ValueError – If list of onsets is passed but not a list of offsets, or vice versa, or if length of onsets does not match length of offsets.

Examples

We define an event dataframe with given names of events and lists of onsets and offsets. Durations are computed automatically.

>>> event = Events(
...    name=['fixation', 'fixation', 'fixation', 'fixation', ],
...    onsets=[1988147, 1988351, 1988592, 1988788],
...    offsets=[1988322, 1988546, 1988736, 1989013]
... )
>>> event
shape: (4, 4)
┌──────────┬─────────┬─────────┬──────────┐
│ name     ┆ onset   ┆ offset  ┆ duration │
│ ---      ┆ ---     ┆ ---     ┆ ---      │
│ str      ┆ i64     ┆ i64     ┆ i64      │
╞══════════╪═════════╪═════════╪══════════╡
│ fixation ┆ 1988147 ┆ 1988322 ┆ 175      │
│ fixation ┆ 1988351 ┆ 1988546 ┆ 195      │
│ fixation ┆ 1988592 ┆ 1988736 ┆ 144      │
│ fixation ┆ 1988788 ┆ 1989013 ┆ 225      │
└──────────┴─────────┴─────────┴──────────┘

Methods

Attributes