-
Notifications
You must be signed in to change notification settings - Fork 41
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
[DAR-4932][External] correct pixdim application in mask to polygon #968
[DAR-4932][External] correct pixdim application in mask to polygon #968
Conversation
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.
The pixdims are (0.7986109, 0.798611, 6.0000024)
, so this test covers the code changes as pixdims[0]!=pixdims[1]
. Due to the fix, the expected outputs needed to be recreated.
@@ -376,7 +376,7 @@ def adjust_for_pixdims(x, y, pixdims): | |||
else: | |||
return {"x": y, "y": x} | |||
else: | |||
return {"x": y * pixdims[1], "y": x * pixdims[0]} | |||
return {"x": y * pixdims[0], "y": x * pixdims[1]} |
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.
This is the real change in logic.
|
||
data_array = reoriented_img.get_fdata() | ||
pixdims = reoriented_img.header.get_zooms() | ||
|
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.
These changes to process_nifti
are unrelated and make the function more explicitly able to handle arbitrarily oriented outputs, even though this is not needed for importing to a fixed orientation of LPI.
Before, the pixdims were taken from volume reoriented to RAS, meaning the output orientation needed to be in RAS order as well for the pixdims to be ordered correctly. Now the output's axes can be any order.
Problem
When
pixdims[0]
≠pixdims[1]
, 3D mask annotations are incorrectly scaled when imported as polygons from a NifTI file. This is due to applying the pixdims to the incorrect axes.Solution
The key thing to note is that in the 2D mask slice arrays:
But in visualisation space, the columns represent the x axis and the rows represent the y axis, which is why we switch x and y. Now, since the pixdims entries correspond to the axes of visualisation, not array index axes, we need to switch the application of the
pixdims
.Changelog
Correct import of 3D NifTI masks to polygons when pixdims vary across axes.