aeye-lab / pymovements

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

feature: add resample() transformation function #720

Open jakobchwastek opened 2 months ago

jakobchwastek commented 2 months ago

Description

The resample transformation function offers multiple ways to adjust the sampling rate of gaze data. This function enables the adjustment of temporal frequency through both upsampling and downsampling. Additionally, it enables achieving a constant sampling rate for gaze data with inconsistent timestamps.

Resampling can be applied to both GazeDataFrame and entire Dataset. By default, it interpolates all columns of the resampled data frame. When applied to a GazeDataFrame containing multiple trials, the function resamples the data frame grouped by trial_columns. We exclude trial_columns from the interpolation in transforms.resample, as interpolation is not applicable to these columns. After processing, we fill the trial_columns.

The new sampling rate determined by the resampling process is stored in the Experiment object of the GazeDataFrame.

The resampling function processes timestamps with microsecond precision, supporting only sampling rates that divide 1,000,000.

Supported strategies for filling column values in newly created rows through resampling include forward filling, backward filling, linear interpolation, and nearest value interpolation.

Fixes issue #689.

Implemented changes

Type of change

How Has This Been Tested?

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (cb32c39) to head (9d25122).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #720 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 60 60 Lines 2823 2820 -3 Branches 715 741 +26 ========================================= - Hits 2823 2820 -3 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.