webknossos icon indicating copy to clipboard operation
webknossos copied to clipboard

Allow permanent dataset layer rotation in dataset settings

Open MichaelBuessemeyer opened this issue 1 year ago • 1 comments

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:


(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

MichaelBuessemeyer avatar Oct 30 '24 15:10 MichaelBuessemeyer

📝 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 flatToNestedMatrix from dataset_accessor to dataset_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?

❤️ Share
🪧 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 @coderabbitai in 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 @coderabbitai in 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 pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file 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.

coderabbitai[bot] avatar Oct 30 '24 15:10 coderabbitai[bot]

@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 avatar Dec 06 '24 14:12 philippotto

@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:

MichaelBuessemeyer avatar Dec 19 '24 13:12 MichaelBuessemeyer

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

MichaelBuessemeyer avatar Jan 10 '25 12:01 MichaelBuessemeyer

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

philippotto avatar Jan 13 '25 11:01 philippotto

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 :)

MichaelBuessemeyer avatar Jan 15 '25 15:01 MichaelBuessemeyer

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:

philippotto avatar Jan 17 '25 12:01 philippotto

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?

MichaelBuessemeyer avatar Jan 20 '25 10:01 MichaelBuessemeyer

Same for meshes :see_no_evil:

MichaelBuessemeyer avatar Jan 20 '25 10:01 MichaelBuessemeyer

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? :)

philippotto avatar Jan 20 '25 12:01 philippotto

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

MichaelBuessemeyer avatar Jan 20 '25 13:01 MichaelBuessemeyer

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.

MichaelBuessemeyer avatar Jan 20 '25 14:01 MichaelBuessemeyer