SainsburyWellcomeCentre / aeon_mecha

Project Aeon's main library for interfacing with acquired data. Contains modules for raw data file io, data querying, data processing, data qc, database ingestion, and building computational data pipelines.
BSD 3-Clause "New" or "Revised" License
6 stars 6 forks source link

Add support for downsampling encoder data #407

Closed glopesdev closed 2 months ago

glopesdev commented 2 months ago

As described in #396, we introduce support for downsampling raw encoder data to 50Hz. Because the magnetic encoder reports absolute angular position, it is sufficient to decimate the data by resampling periodically in bins of 20ms and taking the first value.

In this version I have set the downsample parameter to True. This change may break old data analysis scripts so we should consider whether this is the right choice.

If ensuring backwards compatibility is important, we couls also set downsample=None as the default, and set downsample=True in the ingestion scripts.

Summary by CodeRabbit

github-actions[bot] commented 2 months ago

Image description CodeRabbit

Walkthrough

The proposed changes introduce a new feature to the Encoder class in the aeon/io/reader.py file, allowing for optional downsampling of encoder data to 50Hz. This is achieved by adding a new read method that performs this operation. The default behavior is to downsample, but this can be overridden. Corresponding updates have been made to the test suite in tests/io/test_api.py, including the addition of two new tests specifically designed to verify the correct functioning of the downsampling feature.

Changes

File Summary
aeon/io/reader.py Introduced a new read method in the Encoder class to support downsampling of encoder data to 50Hz. The downsample parameter defaults to True. This change may impact the behavior of the code and needs review.
tests/io/test_api.py Updated function calls to include a new downsample parameter with a default value of None. Added support for testing the downsampling feature by introducing a new parameter downsample to the aeon.load function calls in the test cases. Two new test functions test_load_encoder_with_downsampling and test_load_encoder_without_downsampling were added to verify the downsampling functionality.

Uplevel your code reviews with CodeRabbit Pro ### CodeRabbit Pro If you like this project, please support us by purchasing the [Pro version](https://coderabbit.ai). The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, CodeRabbit Pro is free for open source projects.
ttngu207 commented 2 months ago

I would also prefer the default downsample=True in the Encoder reader. Users can overwrite the default when they call the api.load() (passing in downsample=False)