-
-
Notifications
You must be signed in to change notification settings - Fork 705
BUG: Jacobian determinant filter results depended on index space orientation #5390
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
base: main
Are you sure you want to change the base?
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.
Thanks for tackling this. I did not have a good look. I still have some remarks.
Modules/Filtering/DisplacementField/test/itkDisplacementFieldJacobianDeterminantFilterTest.cxx
Outdated
Show resolved
Hide resolved
Modules/Filtering/DisplacementField/test/itkDisplacementFieldJacobianDeterminantFilterTest.cxx
Show resolved
Hide resolved
Thanks, I'll update on both of these points |
@hjmjohnson Why are we merging main into branches. I thought our standard work flow was to rebase, to avoid an ugly commit history to extraneous merges? |
9dd0051
to
5f0446b
Compare
It was a mistake. It tried using "gh pr update-branch" which did not do what I wanted. I have re-pushed the changes without the merge. |
The gradient is calculated in a neighborhood defined in index space. DisplacementFieldTransform accounts for this by multiplying rows of the gradient by the direction matrix. DisplacementFieldJacobianDeterminantFilter did not, hence its determinants were different for the same physical transformation under different voxel index ordering. DisplacementFieldJacobianDeterminantFilter is now fixed to use the direction matrix. The test is updated to check that the determinant for a given displacement field is consistent at the same point in physical space, regardless of how the index space is oriented. More details in issue InsightSoftwareConsortium#5358.
5f0446b
to
b084fc0
Compare
Fixing #5358
I updated the ITK test to check the determinants after permuting or flipping the index space, and updating the header to compensate. I think I've done this correctly, at least I can now get the same answer as with an identity transform.
I did some more tests in some sample data I made for debugging ANTs jacobians (linked in the issue).
This PR makes the filter more comparable to what you would get by iterating over the displacement field voxels and calling the
ComputeJacobianWithRespectToPosition
function at each point. It's not exactly the same, because the finite difference sampling scheme is not the same, although the filter allows users to set custom weights, so maybe it could be made more similar.One other thing (which I can fix): in the test, the seeming typo variable name "dispacementfield" was used throughout one function, I thought it might be intentional, so I didn't change it. But happy to update if needed.