aeye-lab / pymovements

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

Add clip transformation #695

Closed dkrako closed 3 months ago

dkrako commented 4 months ago

Description of the problem

Due to artifacts and errors in measurements, gaze signal values can have outliers with extreme values.

Description of a solution

A clip transformation would be ideal to clip signals to a lower and upper bound.

Minimum acceptance criteria

Sample Code

A first code proposal could look like this:

@pm.gaze.transforms.register_transform
def clip(lower_bound, upper_bound, input_column, output_column, n_components):
    clipped = pl.concat_list(
        [
            pl.col(input_column).list.get(component).clip(lower_bound, upper_bound)
            for component in range(n_components)
        ],
    ).alias(output_column)
    return clipped