torchio
Tools for medical image processing with PyTorch
What it is and what it does
TorchIO is a specialized library for working with 3D medical images in PyTorch-based deep learning pipelines. It handles the full workflow from loading medical image formats (via nibabel) through preprocessing, augmentation, and sampling patches for training. The library includes both standard transforms—affine transformations, flips, noise injection—and domain-specific operations that simulate real MRI artifacts like magnetic field inhomogeneity effects and k-space motion artifacts, making it valuable for training models on realistic medical imaging data.
The package is designed for efficiency in patch-based training, where 3D volumes are sampled into smaller regions for memory-constrained training. It integrates with PyTorch's ecosystem and provides a queue-based sampling mechanism for iterative training workflows. With 13 runtime dependencies including torch, scipy, nibabel, and rich, it brings together the tools needed for medical image I/O, numerical operations, and user-friendly progress reporting in a single coherent interface.
Use it for:
- Train deep learning models on 3D MRI or CT scans with realistic medical image augmentation.
- Preprocess volumetric medical images for patch-based segmentation or classification tasks.
- Simulate MRI artifacts during training to improve model robustness to real acquisition imperfections.
- Load and normalize medical images in standard formats for PyTorch pipelines.
- Sample spatial patches from large 3D volumes for memory-efficient training on GPUs.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
TorchIO reads, preprocesses, augments, and samples 3D medical images for deep learning with PyTorch, offering both standard computer vision transforms and domain-specific medical imaging operations like MRI artifact simulation.
Yes. TorchIO is actively maintained, permissively licensed, and has low install friction. It fills a genuine gap for medical imaging practitioners using PyTorch by providing domain-specific transforms and efficient 3D I/O that would otherwise require custom code. The library is well-established with strong community adoption (2431 stars) and no known security vulnerabilities. Install it if you're building medical imaging models with PyTorch.
Install
torchio on PyPI
pip
pip install torchiouv
uv add torchiopoetry
poetry add torchioInstalling torchio
Before you install
Low friction installation with a pure-Python wheel. Active maintenance with a recent release and 2431 GitHub stars. Depends on established libraries like torch, numpy, scipy, and nibabel for medical image I/O.
License in practice
Apache-2.0 permissive license allows use in commercial and proprietary projects with minimal restrictions, requiring only attribution and a copy of the license.
Quickstart
pip install torchio
import torchio as tio
image = tio.ScalarImage('path/to/image.nii.gz')
transform = tio.Compose([
tio.RandomAffine(),
tio.RandomFlip()
])
transformed = transform(image)
Requires torch and nibabel to be installed; torch installation can be system-specific depending on GPU support.
Verify before relying
- Whether patch-based training queue integrates seamlessly with standard PyTorch DataLoader workflows.
- Performance characteristics when processing very large volumetric datasets or working with limited GPU memory.
- Actual monthly download volume and user base size beyond the GitHub star count.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 13 — deprecated, einops, humanize, jaxtyping, nibabel, numpy, packaging, rich, scipy, simpleitk, torch, tqdm, typer |
| Maintenance | actively maintained — 73 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 91,096/month — #13,541 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: torchio-1.2.1-py3-none-any.whl
Keywords: medical, image processing, pytorch, augmentation, mri
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
batchgeneratorsv2Reimplemented data augmentation transforms for…
permissive · top 15,000 on PyPI
monaiMONAI is a PyTorch-based framework for building…
permissive · top 15,000 on PyPI
batchgeneratorsbatchgenerators provides data augmentation…
permissive · top 15,000 on PyPI
torchtexttorchtext provides text datasets, preprocessing…
permissive · top 15,000 on PyPI
TotalSegmentatorAutomated segmentation of anatomical structures…
permissive · top 15,000 on PyPI
torchvisionTorchvision provides pre-built datasets, model…
permissive · top 1,000 on PyPI
torch-audiomentationsProvides PyTorch-native audio data augmentation…
permissive · top 5,000 on PyPI
torchxrayvisionTorchXRayVision provides pre-trained deep…
permissive · top 15,000 on PyPI
metaflow-torchrunProvides a Metaflow decorator that integrates…
unclear · top 15,000 on PyPI