Allow permanent dataset layer rotation in dataset settings
This PR adds new settings to the dataset settings for each layer. A interface (still in design process) enables the user to set a affine transformation matrix by letting the user define angles for each axis around which the dataset should be rotated.
- https://___.webknossos.xyz
Steps to test:
- abc
TODOs / Problems:
- [ ] Design a visualization of the result. For some first ideas look at the issue #7334
- [ ] The rotation should be done around the center of the dataset. For this, a translation by the dataset center is needed
- [ ] The interface works by defining Euler angles. The problem is that Euler angles are not deterministic / there are multiple ways to express a certain rotation with different Euler angle values. See: https://stackoverflow.com/questions/32235395/does-euler-angles-quaternion-euler-angles-always-result-in-an-equivalent-r
- This makes it hard to update the settings correctly -> a 180 degree rotation around y is equivalent to 180 on x and 180 on z axis :/
- A solution for this is needed as the interface currently is pretty quirky.
- [ ]
Issues:
- fixes #7334
(Please delete unneeded items, merge only when none are left open)
- [ ] Updated changelog
- [ ] Updated migration guide if applicable
- [ ] Updated documentation if applicable
- [ ] Adapted wk-libs python client if relevant API parts change
- [ ] Removed dev-only changes like prints and application.conf edits
- [ ] Considered common edge cases
- [ ] Needs datastore update after deployment
📝 Walkthrough
Walkthrough
This pull request introduces comprehensive changes to dataset layer transformations across multiple frontend files. The modifications focus on enhancing dataset rotation capabilities, reorganizing transformation-related functions, and improving the user interface for layer transformations. Key changes include creating a new dataset_layer_transformation_accessor.ts module, updating type definitions, and implementing rotation controls for dataset layers.
Changes
| File | Change Summary |
|---|---|
frontend/javascripts/oxalis/model/accessors/dataset_layer_transformation_accessor.ts |
New module created with comprehensive transformation handling functions. |
frontend/javascripts/dashboard/dataset/dataset_rotation_form_item.tsx |
Added components for managing dataset rotation along x, y, z axes. |
frontend/javascripts/dashboard/dataset/dataset_settings_data_tab.tsx |
Integrated axis rotation settings component. |
frontend/javascripts/oxalis/model/accessors/dataset_accessor.ts |
Removed functions related to coordinate transformations. |
| Multiple files | Relocated transformation-related imports from dataset_accessor to new transformation accessor module. |
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
| Rotate dataset layers (7334) | ✅ | |
| Persist rotation (7334) | ✅ | |
| Handle skeleton layer transformations (7334) | ✅ |
Possibly related PRs
- #8176: The main PR modifies the import of
flatToNestedMatrixfromdataset_accessortodataset_layer_transformation_accessor, which is also addressed in this PR that fixes a performance bottleneck related to tree deletions, indicating a shared focus on the dataset layer transformation functionality. - #8231: This PR includes fixes for performance issues when deleting multiple trees, which relates to the overall dataset management and transformation processes, similar to the changes made in the main PR regarding dataset handling.
- #8311: The main PR's changes to dataset transformations align with this PR's focus on supporting translations in OME-NGFF Zarr datasets, indicating a broader context of enhancing dataset transformation capabilities across multiple PRs.
Suggested labels
usability, bug, documentation
Poem
🐰 Rotation's dance, a matrix's grace,
Layers twirl in digital space
Transforms align with pixel's might
Bringing datasets to new height!
Code rabbits spin their magic wheel 🌀
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR. (Beta)@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
@philippotto This PR is ready for the first review round. To you have time to take on this task or should I ask daniel?
Yes, I can review it :)
@philippotto my newest changes should implement discussed changes and also fix the new position calculation after toggling which layer is rendered natively. Please have another look at my changes :pray:
From slack: https://scm.slack.com/archives/C5AKLAV0B/p1736434462796459
i just tested the rotation feature a bit and i noticed that e.g. the hovering of segment ids does not work if the segmentation layer is rotated. this was probably already broken independently of your PR (but i didn't notice it because the previous feature was not used in this context). you would probably have to consider the rotation matrix when looking up from mouse position to voxel position
Should be fixed now with commit 3f1bdb9e03063274f06824126c4a0f313e7c9bf9
From slack: https://scm.slack.com/archives/C5AKLAV0B/p1736434462796459
i just tested the rotation feature a bit and i noticed that e.g. the hovering of segment ids does not work if the segmentation layer is rotated. this was probably already broken independently of your PR (but i didn't notice it because the previous feature was not used in this context). you would probably have to consider the rotation matrix when looking up from mouse position to voxel position
Should be fixed now with commit 3f1bdb9
Hmm, still doesn't work for me? I tested it here: https://allowpermadatasetrotation.webknossos.xyz/datasets/l4_sample-677e47bc010000b800249ffc/view#3584,3584,1024,0,1.3
Hmm, still doesn't work for me? I tested it here: https://allowpermadatasetrotation.webknossos.xyz/datasets/l4_sample-677e47bc010000b800249ffc/view#3584,3584,1024,0,1.3
Oh well. Thanks for finding this. I still had a little logic bug (I applied the segmentation layer's transform instead of the inverse of the transform). The newest commit 3c06db5 should fix this. :tm:
Testing for me worked because I only had a 180 degree rotation for x configured and in that case applying the same rotation again instead of the inverse seems to result in the correct behaviour. As your test case was more complex and it worked for me locally with these settings, this should hopefully be fixed now :)
Great! Unfortunately, the context menu uses the wrong position apparently (e.g., load mesh or the segment id in the context menu footer is wrong). Can you have another look? :see_no_evil:
While working on this I also noticed that bounding boxes are not rotated :see_no_evil:? Should this be included here as well or in a follow up pr?
Same for meshes :see_no_evil:
Bummer! The layer bboxes are able to transform according to the active layer transform. user bounding boxes probably need to use the same transforms as the skeleton layer. meshes should use the same transforms as their segmentation layer. however, I would suggest to do this later as a follow-up pr, as you have other stuff on our plate, too. can you open an issue? :)
The issue is here: https://github.com/scalableminds/webknossos/issues/8340
And I found a but that toggling the skeleton layer crashed wk. I fixed this by disabling toggling skeleton layer / letting the user configure them as the active native layer. The mini discussion about this can be found here: https://scm.slack.com/archives/C083DBRCFC6/p1737378159151899
Moreover, the newest commits should hopefully fix all code locations that try to get the segmentation information based on a global position.
Please give this another PR testing try and check my newest changes :pray:
I am sorry, that this PR takes so many iterations.