-
Notifications
You must be signed in to change notification settings - Fork 30
Refactor labelling code in preparation to support transformed layers #9023
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
Open
philippotto
wants to merge
38
commits into
master
Choose a base branch
from
rotated-annotation
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
74f8f3e
wip
philippotto 5ee1c8f
clean up
philippotto 52da095
rename volume layer to section labeler
philippotto 5bfa780
rename section labeling module
philippotto adc5b63
update comment
philippotto 1cce98f
more private methods
philippotto 756fe62
refactor fast/non-fast 3d coordinate functions in section labeling
philippotto dc237b9
move get3DCoordinateFromLocal2D into voxel buffer and add getTopLeft3…
philippotto 98fbefe
implement wip for TransformedSectionLabeler
philippotto 3369292
rename addToLayer
philippotto 0680b2d
adapt plane to rotation
philippotto 104c0d7
fix annotation contour in transformed layer
philippotto b573f93
format
philippotto ae6d11b
use adapted plane when applying voxel buffer
philippotto ec73778
refactor; hardcode transformed plane; fix brush scaling; add debug ou…
philippotto 4851335
add and fix tests
philippotto 4efe594
clean up
philippotto b37dc7f
clean up
philippotto 9d78d13
fix tests
philippotto 346ae66
disable annotation for rotated layers again
philippotto 42431fa
more clean up
philippotto e958267
add missing import
philippotto b92cd53
format
philippotto e816c6f
remove layer pos from status bar again
philippotto 520ca70
remove more console.logs
philippotto c624d9b
remove import
philippotto 227bc61
clean up
philippotto 204d929
refactor
philippotto 668d77b
fix tests
philippotto 60992be
incorporate some feedback
philippotto 0cbd82e
fix layer vs world space
philippotto ee102fe
misc
philippotto 0fb28a6
format
philippotto 8e8a002
Merge branch 'master' into rotated-annotation
philippotto 5f3b01f
remove unused is swap property
philippotto baa06b8
improve global vs layer space in naming
philippotto c1b6907
extend comment
philippotto be6c6e9
add todo comments
philippotto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -140,6 +140,9 @@ vi.mock("antd", () => { | |
| Form: { | ||
| Item: {}, | ||
| }, | ||
| Typography: { | ||
| Text: {}, | ||
| }, | ||
| }; | ||
| }); | ||
|
|
||
|
|
||
201 changes: 201 additions & 0 deletions
201
frontend/javascripts/test/model/transformed_section_labeler.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,201 @@ | ||
| import { getRotationalTransformation } from "dashboard/dataset/dataset_rotation_form_item"; | ||
| import type { CoordinateTransformation } from "types/api_types"; | ||
| import { IdentityTransform, type OrthoView } from "viewer/constants"; | ||
| import { combineCoordinateTransformations } from "viewer/model/accessors/dataset_layer_transformation_accessor"; | ||
| import BoundingBox from "viewer/model/bucket_data_handling/bounding_box"; | ||
| import type { Transform } from "viewer/model/helpers/transformation_helpers"; | ||
| import { mapTransformedPlane as originalMapTransformedPlane } from "viewer/model/volumetracing/section_labeling"; | ||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| const mapTransformedPlane = (plane: OrthoView, transform: Transform) => { | ||
| const [transformedPlane, adaptFn] = originalMapTransformedPlane(plane, transform); | ||
| const adaptedScale = adaptFn([0, 1, 2]); | ||
| return [transformedPlane, adaptedScale]; | ||
| }; | ||
|
|
||
| describe("TransformedSectionLabeler", () => { | ||
| it("Identity transform should result in identity mapping of plane", async () => { | ||
| expect(mapTransformedPlane("PLANE_XY", IdentityTransform)).toEqual(["PLANE_XY", [0, 1]]); | ||
| expect(mapTransformedPlane("PLANE_YZ", IdentityTransform)).toEqual(["PLANE_YZ", [2, 1]]); | ||
| expect(mapTransformedPlane("PLANE_XZ", IdentityTransform)).toEqual(["PLANE_XZ", [0, 2]]); | ||
| }); | ||
|
|
||
| it("Rotation by 90deg around X should be handled correctly", async () => { | ||
| const rotationalTransform = combineCoordinateTransformations( | ||
| getRotationalTransformation(new BoundingBox({ min: [5, 10, 15], max: [105, 115, 120] }), { | ||
| x: { rotationInDegrees: 90, isMirrored: false }, | ||
| y: { rotationInDegrees: 0, isMirrored: false }, | ||
| z: { rotationInDegrees: 0, isMirrored: false }, | ||
| }), | ||
| [1, 2, 3], | ||
| ); | ||
|
|
||
| expect(mapTransformedPlane("PLANE_XY", rotationalTransform)).toEqual(["PLANE_XZ", [0, 1]]); | ||
| expect(mapTransformedPlane("PLANE_YZ", rotationalTransform)).toEqual(["PLANE_YZ", [1, 2]]); | ||
| expect(mapTransformedPlane("PLANE_XZ", rotationalTransform)).toEqual(["PLANE_XY", [0, 2]]); | ||
| }); | ||
|
|
||
| it("[L4] Rotation by 90deg around X should be handled correctly", async () => { | ||
| const coordinateTransformations = [ | ||
| { | ||
| matrix: [ | ||
| [1, 0, 0, -1529], | ||
| [0, 1, 0, -1478], | ||
| [0, 0, 1, -1476], | ||
| [0, 0, 0, 1], | ||
| ], | ||
| type: "affine" as const, | ||
| }, | ||
| { | ||
| matrix: [ | ||
| [1, 0, 0, 0], | ||
| [0, 0, -1, 0], | ||
| [0, 1, 0, 0], | ||
| [0, 0, 0, 1], | ||
| ], | ||
| type: "affine" as const, | ||
| }, | ||
| { | ||
| matrix: [ | ||
| [1, 0, 0, 1529], | ||
| [0, 1, 0, 1478], | ||
| [0, 0, 1, 1476], | ||
| [0, 0, 0, 1], | ||
| ], | ||
| type: "affine" as const, | ||
| }, | ||
| ] as CoordinateTransformation[]; | ||
|
|
||
| const rotationalTransform = combineCoordinateTransformations( | ||
| coordinateTransformations, | ||
| [11, 19, 28], | ||
| ); | ||
|
|
||
| expect(mapTransformedPlane("PLANE_XY", rotationalTransform)).toEqual(["PLANE_XZ", [0, 1]]); | ||
| expect(mapTransformedPlane("PLANE_YZ", rotationalTransform)).toEqual(["PLANE_YZ", [1, 2]]); | ||
| expect(mapTransformedPlane("PLANE_XZ", rotationalTransform)).toEqual(["PLANE_XY", [0, 2]]); | ||
| }); | ||
|
|
||
| it.skip("[L4] Rotation by 90deg around Y should be handled correctly", async () => { | ||
| // TODO: Implement in a follow-up. | ||
| }); | ||
|
|
||
| it("[L4] Rotation by 90deg around Z should be handled correctly", async () => { | ||
philippotto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const coordinateTransformations = [ | ||
| { | ||
| type: "affine" as const, | ||
| matrix: [ | ||
| [1, 0, 0, -1529], | ||
| [0, 1, 0, -1478], | ||
| [0, 0, 1, -1476], | ||
| [0, 0, 0, 1], | ||
| ], | ||
| }, | ||
| { | ||
| type: "affine" as const, | ||
| matrix: [ | ||
| [1, 0, 0, 0], | ||
| [0, 1, 0, 0], | ||
| [0, 0, 1, 0], | ||
| [0, 0, 0, 1], | ||
| ], | ||
| }, | ||
| { | ||
| type: "affine" as const, | ||
| matrix: [ | ||
| [1, 0, 0, 0], | ||
| [0, 1, 0, 0], | ||
| [0, 0, 1, 0], | ||
| [0, 0, 0, 1], | ||
| ], | ||
| }, | ||
| { | ||
| type: "affine" as const, | ||
| matrix: [ | ||
| [0, -1, 0, 0], | ||
| [1, 0, 0, 0], | ||
| [0, 0, 1, 0], | ||
| [0, 0, 0, 1], | ||
| ], | ||
| }, | ||
| { | ||
| type: "affine" as const, | ||
| matrix: [ | ||
| [1, 0, 0, 1529], | ||
| [0, 1, 0, 1478], | ||
| [0, 0, 1, 1476], | ||
| [0, 0, 0, 1], | ||
| ], | ||
| }, | ||
| ] as CoordinateTransformation[]; | ||
|
|
||
| const rotationalTransform = combineCoordinateTransformations( | ||
| coordinateTransformations, | ||
| [11, 19, 28], | ||
| ); | ||
|
|
||
| expect(mapTransformedPlane("PLANE_XY", rotationalTransform)).toEqual(["PLANE_XY", [1, 0]]); | ||
| expect(mapTransformedPlane("PLANE_YZ", rotationalTransform)).toEqual(["PLANE_XZ", [1, 2]]); | ||
| expect(mapTransformedPlane("PLANE_XZ", rotationalTransform)).toEqual(["PLANE_YZ", [2, 0]]); | ||
| }); | ||
|
|
||
| // Todo #8965. Does not work yet | ||
| it.skip("[L4] Rotation by 90deg around all axes should be handled correctly", async () => { | ||
| const coordinateTransformations = [ | ||
| { | ||
| type: "affine", | ||
| matrix: [ | ||
| [1, 0, 0, -1529], | ||
| [0, 1, 0, -1478], | ||
| [0, 0, 1, -1476], | ||
| [0, 0, 0, 1], | ||
| ], | ||
| }, | ||
| { | ||
| type: "affine", | ||
| matrix: [ | ||
| [1, 0, 0, 0], | ||
| [0, 0, -1, 0], | ||
| [0, 1, 0, 0], | ||
| [0, 0, 0, 1], | ||
| ], | ||
| }, | ||
| { | ||
| type: "affine", | ||
| matrix: [ | ||
| [0, 0, 1, 0], | ||
| [0, 1, 0, 0], | ||
| [-1, 0, 0, 0], | ||
| [0, 0, 0, 1], | ||
| ], | ||
| }, | ||
| { | ||
| type: "affine", | ||
| matrix: [ | ||
| [0, -1, 0, 0], | ||
| [1, 0, 0, 0], | ||
| [0, 0, 1, 0], | ||
| [0, 0, 0, 1], | ||
| ], | ||
| }, | ||
| { | ||
| type: "affine", | ||
| matrix: [ | ||
| [1, 0, 0, 1529], | ||
| [0, 1, 0, 1478], | ||
| [0, 0, 1, 1476], | ||
| [0, 0, 0, 1], | ||
| ], | ||
| }, | ||
| ] as CoordinateTransformation[]; | ||
|
|
||
| const rotationalTransform = combineCoordinateTransformations( | ||
| coordinateTransformations, | ||
| [11, 19, 28], | ||
| ); | ||
|
|
||
| expect(mapTransformedPlane("PLANE_XY", rotationalTransform)).toEqual(["PLANE_YZ", [0, 1]]); | ||
| expect(mapTransformedPlane("PLANE_YZ", rotationalTransform)).toEqual(["PLANE_XY", [2, 1]]); | ||
| expect(mapTransformedPlane("PLANE_XZ", rotationalTransform)).toEqual(["PLANE_XZ", [2, 0]]); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this description not start with a
[L4]?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because in this test, I created transforms that don't have anything to do with L4. in the other tests, I specifically added transforms that work for the L4 dataset so that I could check in the browser, that everything works as expected (and then could hardcode the expected values into the tests).