skillfed

torchio

Tools for medical image processing with PyTorch

torchio v1.2.1 91.1K downloads/30d#13,541 on PyPI2,431
Permissive license Apache-2.0 Active released

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 torchio

uv

uv add torchio

poetry

poetry add torchio

Installing 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

Development Status :: 4 - BetaEnvironment :: ConsoleIntended Audience :: Science/ResearchNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Scientific/EngineeringTopic :: Scientific/Engineering :: Artificial IntelligenceTopic :: Scientific/Engineering :: Image ProcessingTopic :: Scientific/Engineering :: Medical Science Apps.Typing :: Typed

Tags

3D medical image preprocessing pytorchmedical image augmentation deep learningMRI image processing toolsvolumetric medical image loadingpatch-based medical image sampling
medical-imaging3d-volumetricdata-augmentation

More Scientific/Engineering packages