pymovements.Gaze.clear_events#

Gaze.clear_events() → None[source]#

Clear event DataFrame.

Unlike assigning a bare Events instance, this preserves trial_columns in the emptied event DataFrame, with dtypes taken from samples, so that subsequent per-trial event detection via detect() keeps working.

Examples

>>> import polars as pl
>>> from pymovements import Events, Gaze
>>> gaze = Gaze(
...     samples=pl.DataFrame({'x': [0.1, 0.2], 'y': [0.3, 0.4], 'trial': [1, 2]}),
...     pixel_columns=['x', 'y'],
...     trial_columns=['trial'],
...     events=Events(name='fixation', onsets=[0], offsets=[1], trials=[1]),
... )
>>> gaze.clear_events()
>>> gaze.events.frame.is_empty()
True
>>> dict(gaze.events.frame.schema)
{'trial': Int64, 'name': String, 'onset': Int64, 'offset': Int64, 'duration': Int64}