TorchMorph
January 14, 2026 ยท View on GitHub
TorchMorph is a PyTorch utility library developed for handling coordinate mappings between images (2D or 3D).
Developed originally for medical imaging, this library provides a set of classes and functions for handling spatial coordinate transformations.
The most powerful feature of this library is the ability to easily compose transformations lazily and resample them to different coordinate systems as well as sampler classes for sampling volumes defined on regular grids such that the optimal method (either slicing operation, convolution, or torch.grid_sample) is used based on the sampling locations.
The main idea was to develop a library that allows handling of the coordinate mappings as if they were mathematical functions, without losing much performance compared to more manual implementation.
Installation
Install using pip by running the command
pip install torchmorph
Requirements
Python 3.8+PyTorch 2.0+nibabelmatplotlib(optional)ninja(optional)
Documentation
For a quick start tutorial, see quick_start.ipynb. For API reference, go to https://honkamj.github.io/torchmorph/.
Publication
If you use TorchMorph, please cite the SITReg paper (see bibtex):
- SITReg: Multi-resolution architecture for symmetric, inverse consistent, and topology preserving image registration
Joel Honkamaa, Pekka Marttinen
The Journal of Machine Learning for Biomedical Imaging (MELBA) (10.59275/j.melba.2024-276b)
License
TorchMorph is released under the MIT license.