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

Ability to save multi-animal pose tracks to single-animal files #83

Merged
merged 11 commits into from
Nov 16, 2023

Conversation

DhruvSkyy
Copy link
Collaborator

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

What does this PR do?

This PR adds the functionality to save xarrays as a dictionary of individual pandas dataframes for to_dlc_df and as multiple files for each individual for to_dlc_file. This is based on the split_individuals: bool parameter, if True it will split the data for each individual, if false it will save it as a multi-animal file.

References

This PR addresses Issue #39.

How has this PR been tested?

The PR was tested on a Juypter Notebook against the four scenarios, (credit to @niksirbi):

  • The xarray.Dataset has multiple (>1) individuals and the user wants to save it to a multi-animal DeepLabCut dataframe. This currently works with the existing functions.
  • The xarray.Dataset has only 1 individual but the user still wants to save it to a multi-animal DeepLabCut dataframe, including the redundant "individuals" level. This also works currently.
  • The xarray.Dataset has a single individual and the user wants to save it to single-animal DeepLabCut dataframe (without the "individuals" level). This behaviour needs to be implemented, the output will be a single file.
  • The xarray.Dataset has multiple (>1) individuals and the user wants to split them for saving into multiple single-animal files. * This is the trickiest case to implement, as the dataset would have to be split across individuals (behind the scenes) and each part is then saved to a single-animal file as in case 3. The output should be as many files as there are individuals.

Todo

Need to write tests.

Checklist:

  • The code has been tested locally
  • Tests have been added to cover all new functionality
  • The documentation has been updated to reflect any changes
  • The code has been formatted with pre-commit

@DhruvSkyy DhruvSkyy changed the title refactored save poses Ability to save multi-animal pose tracks to single-animal files Nov 12, 2023
@niksirbi niksirbi linked an issue Nov 12, 2023 that may be closed by this pull request
Copy link
Member

@niksirbi niksirbi left a comment

Choose a reason for hiding this comment

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

Very well done @DruvSkyy 🎉

I like the current implementation of this feature. Thanks to our back-and-forth, we converged on something sensible I think.

I have left some minor comments for you to implement.

After that, I'll modify the tests to cover the new funcitonality. Let's see if they'll help us discover any bugs/edge cases.

movement/io/save_poses.py Outdated Show resolved Hide resolved
movement/io/save_poses.py Outdated Show resolved Hide resolved
movement/io/save_poses.py Outdated Show resolved Hide resolved
movement/io/save_poses.py Outdated Show resolved Hide resolved
movement/io/save_poses.py Outdated Show resolved Hide resolved
movement/io/save_poses.py Outdated Show resolved Hide resolved
movement/io/save_poses.py Outdated Show resolved Hide resolved
movement/io/save_poses.py Outdated Show resolved Hide resolved
movement/io/save_poses.py Outdated Show resolved Hide resolved
movement/io/save_poses.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Nov 15, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (3b61db6) 98.19% compared to head (2115b67) 98.34%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #83      +/-   ##
==========================================
+ Coverage   98.19%   98.34%   +0.14%     
==========================================
  Files           8        8              
  Lines         333      362      +29     
==========================================
+ Hits          327      356      +29     
  Misses          6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@niksirbi
Copy link
Member

Hey @DhruvSkyy, I've made the following modification to this PR:

  • I've reviewed all docstring and function/argument names in save_poses.py and made sure they are consistent throughout
  • I've fixed the tests that were failing
  • I've added new tests for the feature you've implemented. You can find these on tests/test_unit/test_save_poses.py, specifically:
    • test_auto_split_individuals
    • test_to_dlc_df_split_individuals
    • test_to_dlc_file_split_individuals

Take a look at the new tests and see if you can make sense of them. I'm happy to discuss these 1-to-1 if some things are unclear.

Other than that, this PR is now ready to merge I think, thanks a lot for your help!

@niksirbi niksirbi marked this pull request as ready for review November 15, 2023 17:59
@niksirbi niksirbi mentioned this pull request Nov 16, 2023
7 tasks
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@niksirbi niksirbi merged commit 1f2338c into neuroinformatics-unit:main Nov 16, 2023
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to save multi-animal pose tracks to single-animal files
2 participants