--- id: torchio version: "1.2.1" license: Apache-2.0 license_treatment: permissive maintenance: active --- # torchio — Tools for medical image processing with PyTorch License: permissive · Maintenance: active · Downloads: 91.1K/mo ## 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 above — 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 pip install torchio uv add torchio 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_current - Install friction: low - Maintenance: active - Downloads: 91.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags 3D medical image preprocessing pytorch, medical image augmentation deep learning, MRI image processing tools, volumetric medical image loading, patch-based medical image sampling, medical-imaging, 3d-volumetric, data-augmentation [View on SkillFed](https://skillfed.io/packages/torchio) · [View on PyPI](https://pypi.org/project/torchio/)