aeye-lab / pymovements

A python package for processing eye movement data
https://pymovements.readthedocs.io
MIT License
61 stars 12 forks source link

Add support for inferring number of components on non-standard columns #524

Open dkrako opened 1 year ago

dkrako commented 1 year ago

Description of the problem

The number of components of a GazeDataFrame is currently only inferred using the columns pixel, position, velocity, acceleration.

If a user would want to use a non-standard column only, like pixel_velocity, the inference wouldn't work. But if the user would have specified just one of the mentioned columns, everything would work out.

Description of a solution

We could try to solve this in the current frame of using polars.list, but to me it seems most reasonable to implement #453 The n_components argument is really just needed for internal usage as a workaround as during the time of RD struct didn't seem that well developed.

After implementing #453 we would need n_components anymore for internal usage. We could then decide how to deal with it.

As a workaround, users can still write something like

gaze.n_components = 2

Also, n_components is mostly used for transformation functions.

Additionally for non-standard columns a user could still explicitly pass n_components:

gaze.pix2deg(pixel_column='my_input', position_column='my_output', n_components=4)

So the workflow is not completely broken and a comfortable workaround exists.

Context

Originally requested by @prassepaul in https://github.com/aeye-lab/pymovements/pull/521#discussion_r1322455437