Skip to main content

Digital Diffeomorphism: Non-diffeomorphic volume and Non-diffeomorphic area

This is an implementation of the non-diffeomorphic volume and non-diffeomorphic area computation we introduced in our paper:

"On Finite Difference Jacobian Computation in Deformable Image Registration." Liu, Yihao, Chen, Junyu, Wei, Shuwen, Carass, Aaron, and Prince, Jerry. The International Journal of Computer Vision (2024).

Motivation

The Jacobian determinant $|J|$ of spatial transformations is a widely used measure in deformable image registration, but the details of its computation are often overlooked. Contrary to what one might expect, when approximated using the central difference, the number of pixels/voxels with negative $|J|$ does not reflect if the transformation is diffeomorphic or not.

The example above demonstrate a failure case of the central difference based $|J|$. The center pixel has central difference based $|J|=1$ but it is not diffeomorphic. In fact, the transformation at the center pixel has no effect on the computation of central difference based $|J|$, even if it moves outside the field of view.

We proposed the definition of digital diffeomorphism that solves several errors that inherent in the central difference based $|J|$. We further propose to use non-diffeomorphic volume (NDV) and non-diffeomorphic area (NDA) to measure the irregularity of 3D/2D transformations. The proposed NDV and NDA also measures the severity of the irregularity whereas the central difference approximated $|J|$ is only a binary indicator.

The center pixel in all three cases shown above would be considered diffeomorphic because of the checkerboard problem. The forward difference based $|J|$ is able to identiy that (b) and (c) exhibit folding, but only NDA can provide the observation that the non-diffeomorphic space caused by the transformation shown in (c) is larger than (b). The transformation shown in (b) is obviously more favorable than the one shown in (c) in terms of regularity. As such it is important for us to be able to draw distinctions between there two senarios.

Getting Started

Installation

The easiest way to install the package is through the following command:

pip install digital-diffeomorphism

To install from the source:

git clone https://github.com/yihao6/digital_diffeomorphism.git

cd digital_diffeomorphism

python setup.py install

Usage

To evaluate a 3D sampling grid with dimension $H\times W\times D\times 3$

ndv grid_3d.nii.gz

This will calculate

  1. non-diffeomorphic volume; and
  2. non-diffeomorphic voxels computed by the central difference.

If the transformation is stored as a displacement field:

ndv disp_3d.nii.gz --disp

Use '--gpu' option to enable GPU acceleration:

ndv grid_3d.nii.gz --gpu
# or
ndv disp_3d.nii.gz --disp --gpu

To evaluate a 2D sampling grid with dimension $H\times W\times 2$

nda grid_2d.nii.gz

This will calculate

  1. non-diffeomorphic area; and
  2. non-diffeomorphic pixels computed by the central difference.

If the transformation is stored as a displacement field:

ndv disp_2d.nii.gz --disp

Example inputs can be found at https://iacl.ece.jhu.edu/index.php?title=Digital_diffeomorphism

Potential Pitfalls

  1. Several packages implement spatial transformations using a normalized sampling grid. For example, torch.nn.functional.grid_sample. In this package, we use un-normalized coordinates to represent transformations. Therefore, the input sampling grid or displacement field should be in voxel or pixel units. In case the input is normalized, it must be unnormalized prior to using this package.

Citation

If you use this code, please cite our paper.

@article{liu2024finite,
  title={On finite difference jacobian computation in deformable image registration},
  author={Liu, Yihao and Chen, Junyu and Wei, Shuwen and Carass, Aaron and Prince, Jerry},
  journal={International Journal of Computer Vision},
  pages={1--11},
  year={2024},
  publisher={Springer}
}

Metadata

Release files for digital-diffeomorphism 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for digital-diffeomorphism 1.1.1
File Size Uploaded Provenance
digital_diffeomorphism-1.1.1.tar.gz 11.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for digital-diffeomorphism 1.1.1
File Interpreter ABI Platform
digital_diffeomorphism-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 23.0 kB

Release files / digital_diffeomorphism-1.1.1.tar.gz

Download URL digital_diffeomorphism-1.1.1.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d368287a588254f69a581be6a6fb6fd6ee4928fd7c1217ef9388d0ed4c45b104
BLAKE2b-256 checksum
How to use checksums
6343369af97fec28949cca6d340ea8af2a09f3dfe05e308b81446c644e261929
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.19

Release files / digital_diffeomorphism-1.1.1-py3-none-any.whl

Download URL digital_diffeomorphism-1.1.1-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6fdd8ea5bf83438a8bf46a38e971e7b1f844345dd5e20ac0e9bee46c2e13badc
BLAKE2b-256 checksum
How to use checksums
e8ea2639bdae5a67de596e7f75ae5d8b81dae6369815dc123b23f0e69c193c14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.19

Security for digital-diffeomorphism 1.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page