Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for downsampling encoder data #407

Merged
merged 5 commits into from
Sep 18, 2024
Merged

Add support for downsampling encoder data #407

merged 5 commits into from
Sep 18, 2024

Conversation

glopesdev
Copy link
Contributor

@glopesdev glopesdev commented Sep 11, 2024

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

  • New Feature: Added a downsampling feature to the Encoder class in aeon/io/reader.py. This allows users to downsample encoder data to 50Hz, improving performance and reducing memory usage for large datasets.
  • Test: Extended test coverage in tests/io/test_api.py to include the new downsampling functionality. This ensures the feature works as expected and maintains the integrity of the data.
  • Refactor: Updated function calls within tests to include the new downsample parameter, enhancing the flexibility and usability of the testing suite.

@glopesdev glopesdev added the fix Pull request that fixes an issue label Sep 11, 2024
Copy link

github-actions bot commented Sep 11, 2024

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. 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.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

Commits Files that changed from the base of the PR and between a5bc419 and 00ead97 commits.
Files selected (1)
  • aeon/io/reader.py (2)
Review comments generated (2)
  • Review: 1
  • LGTM: 1

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

aeon/io/reader.py Show resolved Hide resolved
@ttngu207
Copy link
Contributor

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)

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

Commits Files that changed from the base of the PR and between 00ead97 and dfd2d02 commits.
Files selected (1)
  • tests/io/test_api.py (1)
Review comments generated (5)
  • Review: 5
  • LGTM: 0

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

tests/io/test_api.py Show resolved Hide resolved
tests/io/test_api.py Show resolved Hide resolved
tests/io/test_api.py Outdated Show resolved Hide resolved
tests/io/test_api.py Show resolved Hide resolved
tests/io/test_api.py Show resolved Hide resolved
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

Commits Files that changed from the base of the PR and between dfd2d02 and 9ad3dc0 commits.
Files selected (1)
  • tests/io/test_api.py (2)
Review comments generated (6)
  • Review: 2
  • LGTM: 4

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

tests/io/test_api.py Outdated Show resolved Hide resolved
tests/io/test_api.py Outdated Show resolved Hide resolved
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

Commits Files that changed from the base of the PR and between dfd2d02 and 3d88792 commits.
Files selected (1)
  • tests/io/test_api.py (2)
Review comments generated (5)
  • Review: 1
  • LGTM: 4

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

tests/io/test_api.py Outdated Show resolved Hide resolved
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

Commits Files that changed from the base of the PR and between 3d88792 and bd0d39e commits.
Files selected (1)
  • tests/io/test_api.py (2)
Review comments generated (5)
  • Review: 1
  • LGTM: 4

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

tests/io/test_api.py Outdated Show resolved Hide resolved
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

Commits Files that changed from the base of the PR and between 3d88792 and a45b16a commits.
Files selected (1)
  • tests/io/test_api.py (2)
Review comments generated (5)
  • Review: 1
  • LGTM: 4

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

tests/io/test_api.py Show resolved Hide resolved
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

Commits Files that changed from the base of the PR and between a45b16a and 222f502 commits.
Files selected (1)
  • tests/io/test_api.py (2)
Review comments generated (5)
  • Review: 1
  • LGTM: 4

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

tests/io/test_api.py Show resolved Hide resolved
@glopesdev glopesdev merged commit 871f342 into main Sep 18, 2024
6 of 8 checks passed
@glopesdev glopesdev deleted the gl-dev branch September 18, 2024 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Pull request that fixes an issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants