pymovements.gaze.GazeDataFrame.__init__#
- GazeDataFrame.__init__(data: pl.DataFrame | None = None, experiment: Experiment | None = None, *, trial_columns: str | list[str] | None = None, time_column: str | None = None, pixel_columns: list[str] | None = None, position_columns: list[str] | None = None, velocity_columns: list[str] | None = None, acceleration_columns: list[str] | None = None)[source]#
Initialize a
pymovements.gaze.gaze_dataframe.GazeDataFrame.- Parameters:
data (pl.DataFrame) – A dataframe to be transformed to a polars dataframe.
experiment (Experiment) – The experiment definition.
time_column – The name if the timestamp column in the input data frame.
pixel_columns – The name of the pixel position columns in the input data frame. These columns will be nested into the column
pixel. If the list is empty or None, the nestedpixelcolumn will not be created.position_columns – The name of the dva position columns in the input data frame. These columns will be nested into the column
position. If the list is empty or None, the nestedpositioncolumn will not be created.velocity_columns – The name of the velocity columns in the input data frame. These columns will be nested into the column
velocity. If the list is empty or None, the nestedvelocitycolumn will not be created.acceleration_columns – The name of the acceleration columns in the input data frame. These columns will be nested into the column
acceleration. If the list is empty or None, the nestedaccelerationcolumn will not be created.
Notes
About using the arguments
pixel_columns,position_columns,velocity_columns, andacceleration_columns:By passing a list of columns as any of these arguments, these columns will be merged into a single column with the corresponding name , e.g. using pixel_columns will merge the respective columns into the column pixel.
The supported number of component columns with the expected order are:
zero columns: No nested component column will be created.
two columns: monocular data; expected order: x-component, y-component
four columns: binocular data; expected order: x-component left eye, y-component left eye, x-component right eye, y-component right eye,
six columns: binocular data with additional cyclopian data; expected order: x-component left eye, y-component left eye, x-component right eye, y-component right eye, x-component cyclopian eye, y-component cyclopian eye,
Examples
First let’s create an example DataFrame with three columns: the timestamp
tandxandyfor the pixel position.>>> df = pl.from_dict( ... data={'t': [1000, 1001, 1002], 'x': [0.1, 0.2, 0.3], 'y': [0.1, 0.2, 0.3]}, ... ) >>> df shape: (3, 3) ┌──────┬─────┬─────┐ │ t ┆ x ┆ y │ │ --- ┆ --- ┆ --- │ │ i64 ┆ f64 ┆ f64 │ ╞══════╪═════╪═════╡ │ 1000 ┆ 0.1 ┆ 0.1 │ │ 1001 ┆ 0.2 ┆ 0.2 │ │ 1002 ┆ 0.3 ┆ 0.3 │ └──────┴─────┴─────┘
We can now initialize our
GazeDataFrameby specyfing the names of the pixel position columns.>>> gaze = GazeDataFrame(data=df, pixel_columns=['x', 'y']) >>> gaze.frame shape: (3, 2) ┌──────┬────────────┐ │ t ┆ pixel │ │ --- ┆ --- │ │ i64 ┆ list[f64] │ ╞══════╪════════════╡ │ 1000 ┆ [0.1, 0.1] │ │ 1001 ┆ [0.2, 0.2] │ │ 1002 ┆ [0.3, 0.3] │ └──────┴────────────┘