pymovements.gaze.Experiment.pos2vel#
- Experiment.pos2vel(arr: list[float] | list[list[float]] | np.ndarray, method: str = 'smooth', **kwargs: int | float | str) np.ndarray #
Compute velocity time series from 2-dimensional position time series.
- Methods ‘smooth’, ‘neighbors’ and ‘preceding’ are adapted from
Engbert et al.: Microsaccade Toolbox 0.9.
- Parameters:
arr (list[float] | list[list[float]] | np.ndarray) – Continuous 2D position time series.
method (str) – Computation method. See
pos2vel()
for details. (default: ‘smooth’)**kwargs (int | float | str) – Additional keyword arguments used for savitzky golay method.
- Returns:
Velocity time series in input_unit / sec
- Return type:
np.ndarray
- Raises:
ValueError – If selected method is invalid, input array is too short for the selected method or the sampling rate is below zero
Examples
>>> experiment = Experiment( ... screen_width_px=1280, ... screen_height_px=1024, ... screen_width_cm=38, ... screen_height_cm=30, ... distance_cm=68, ... origin='upper left', ... sampling_rate=1000.0, ... ) >>> arr = [[0., 0.], [1., 1.], [2., 2.], [3., 3.], [4., 4.], [5., 5.]] >>> experiment.pos2vel( ... arr=arr, ... method="smooth", ... ) array([[ 500., 500.], [1000., 1000.], [1000., 1000.], [1000., 1000.], [1000., 1000.], [ 500., 500.]])