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

Document renaming of keypoints and individuals #298

Closed
niksirbi opened this issue Sep 3, 2024 · 1 comment · Fixed by #304
Closed

Document renaming of keypoints and individuals #298

niksirbi opened this issue Sep 3, 2024 · 1 comment · Fixed by #304
Labels
documentation Improvements or additions to documentation enhancement New optional feature

Comments

@niksirbi
Copy link
Member

niksirbi commented Sep 3, 2024

@Lauraschwarz brought to my attention that renaming keypoints/individuals could be useful in some workflows. For example they could load a dataset from file, rename things, and save it back to file.

This is possible with existing xarray functionality, but the syntax is not entirely obvious to those not familiar with xarray:

keypoint_names = ds.coords["keypoints"].values

# Create new keypoints with "snout" renamed to "nose"
new_keypoint_names = ["nose" if kp == "snout" else kp for kp in keypoint_names]

# Assign the modified values back to the Dataset
ds = ds.assign_coords(keypoints=new_keypoint_names)

We could document this workflow in one of our examples.

Alternatively, we could write convenience utilities (though these would be very thin wrappers), e.g.:

rename_keypoints(ds, {"snout": "nose", "tailbase": "tail_base"})
rename_individuals(ds, {"id1": "Alice", "id2": "Bob"})
@niksirbi niksirbi added documentation Improvements or additions to documentation enhancement New optional feature labels Sep 3, 2024
@niksirbi
Copy link
Member Author

niksirbi commented Sep 4, 2024

I've discussed this with Laura, and we think something like this would make a good new example for our docs. Perhaps something named "Converting pose tracks between formats", which will include:

  • loading pose tracks from one format (e.g. SLEAP)
  • some data wrangling, e.g. renaming and deleting of keypoints
  • saving to a different format(e.g DLC).

@niksirbi niksirbi linked a pull request Sep 12, 2024 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New optional feature
Projects
Development

Successfully merging a pull request may close this issue.

1 participant