Skip to content

BUG: Jacobian determinants incorrect for non-identity direction matrices#1887

Merged
cookpa merged 3 commits intomasterfrom
fix_fd_jac_vectors
May 29, 2025
Merged

BUG: Jacobian determinants incorrect for non-identity direction matrices#1887
cookpa merged 3 commits intomasterfrom
fix_fd_jac_vectors

Conversation

@cookpa
Copy link
Member

@cookpa cookpa commented May 23, 2025

Discussed in #1884

I added more examples with synthetic data at

https://github.com/cookpa/antsJacobianExample

I think the Jacobian matrix as well as the determinant were not properly computed in physical space. For some cases, these errors could cancel out leading to results that appear correct.

I've simplified the ANTs Jacobian filter to behave more like the itkDisplacementFieldTransform method, which works consistently well across different image orientations.

I would really like some validation on external real data, but don't have time to pursue that for a couple of weeks at least. Opening a draft PR for feedback

cookpa added 3 commits May 21, 2025 10:06
From cross-referencing with itkDisplacementFieldTransform, I believe the following issues were causing problems:

1. The displacement vectors were transformed by the direction matrix, but they are already in physical space
2. The jacobian matrix was transposed
3. A rotation was done to the final matrix to rebase to physical space, but I don't think that's right, ITK does a transform of the partial derivatives

My tests for all this is can integration over the jacobians in the fixed space accurately predict the expansion / contraction of a label image, across multiple configurations of the image direction matrix.

The "geometric" option for CreateJacobianDeterminantImage consistently has slightly larger prediction errors, but didn't have any of the massive discrepencies with non-identity direction matrices.
Removed some features because only one set of options are used in CreateJacobianDeterminantImage, and I don't have time to validate them all
@cookpa cookpa marked this pull request as ready for review May 29, 2025 14:12
@cookpa
Copy link
Member Author

cookpa commented May 29, 2025

Tested on brain data

https://upenn.box.com/s/xj5u142w1n634aob831o4f3pbi71yuds

I'm convinced now that this fix is necessary for correct determinants on non-axial data.

@cookpa cookpa merged commit 2641377 into master May 29, 2025
2 checks passed
@cookpa cookpa deleted the fix_fd_jac_vectors branch May 29, 2025 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant