Papers
Topics
Authors
Recent
Gemini 2.5 Flash
Gemini 2.5 Flash
110 tokens/sec
GPT-4o
56 tokens/sec
Gemini 2.5 Pro Pro
44 tokens/sec
o3 Pro
6 tokens/sec
GPT-4.1 Pro
47 tokens/sec
DeepSeek R1 via Azure Pro
28 tokens/sec
2000 character limit reached

TorchIO: A Python library for efficient loading, preprocessing, augmentation and patch-based sampling of medical images in deep learning (2003.04696v5)

Published 9 Mar 2020 in eess.IV, cs.AI, cs.CV, cs.LG, and stat.ML

Abstract: Processing of medical images such as MRI or CT presents unique challenges compared to RGB images typically used in computer vision. These include a lack of labels for large datasets, high computational costs, and metadata to describe the physical properties of voxels. Data augmentation is used to artificially increase the size of the training datasets. Training with image patches decreases the need for computational power. Spatial metadata needs to be carefully taken into account in order to ensure a correct alignment of volumes. We present TorchIO, an open-source Python library to enable efficient loading, preprocessing, augmentation and patch-based sampling of medical images for deep learning. TorchIO follows the style of PyTorch and integrates standard medical image processing libraries to efficiently process images during training of neural networks. TorchIO transforms can be composed, reproduced, traced and extended. We provide multiple generic preprocessing and augmentation operations as well as simulation of MRI-specific artifacts. Source code, comprehensive tutorials and extensive documentation for TorchIO can be found at https://torchio.rtfd.io/. The package can be installed from the Python Package Index running 'pip install torchio'. It includes a command-line interface which allows users to apply transforms to image files without using Python. Additionally, we provide a graphical interface within a TorchIO extension in 3D Slicer to visualize the effects of transforms. TorchIO was developed to help researchers standardize medical image processing pipelines and allow them to focus on the deep learning experiments. It encourages open science, as it supports reproducibility and is version controlled so that the software can be cited precisely. Due to its modularity, the library is compatible with other frameworks for deep learning with medical images.

User Edit Pencil Streamline Icon: https://streamlinehq.com
Authors (3)
  1. Fernando Pérez-García (16 papers)
  2. Rachel Sparks (18 papers)
  3. Sébastien Ourselin (38 papers)
Citations (387)

Summary

TorchIO: Addressing Complexities in Medical Image Processing Within Deep Learning Workflows

The paper presents TorchIO, an open-source Python library that aims to streamline workflows related to deep learning applications in medical imaging. The library is designed to address the specific challenges encountered when processing medical images such as MRIs and CT scans. Unlike standard 2D RGB images often used in computer vision, medical images present distinct problems including the necessity for metadata handling, high computational demands due to volumetric data, and limited availability of labeled datasets.

Methods and Features

TorchIO integrates smoothly with PyTorch, leveraging the robust functionality of widely-used medical imaging libraries like NiBabel and SimpleITK for efficient IO operations. The modular framework supports up to 4D images which include scalar images, label maps, and multi-channel data, making it applicable across a variety of imaging modalities. The data abstractions implemented—Image, Subject, and SubjectsDataset—allow for structured and scalable loading and managing of medical imaging data.

Patch-based sampling is a key feature designed to overcome computational limitations when dealing with large 3D medical image datasets. TorchIO provides several sampling strategies including UniformSampler and WeightedSampler for versatile patch extraction, which ensures efficient use of GPU resources during model training and inference. Moreover, the library incorporates a queue system to complement accelerated data pipeline processes by preloading and seamlessly managing patches.

Transformations and Augmentations

TorchIO provides a comprehensive suite of preprocessing and augmentation transforms, each catering specifically to the complexities inherent in medical images. Spatial and intensity transforms cover a range from histogram standardization to MRI-specific artifacts simulation such as k-space alterations causing spike and ghosting artifacts. The design of these transforms ensures not only preprocessing for uniform input for neural network training but also augmentation to synthetically expand the limited dataset sizes commonly a setback in medical imaging.

Following a dynamic and Pythonic API akin to PyTorch, the library allows researchers to compile transforms linearly through its Compose and OneOf classes. This results in an intuitive and efficient augmentation pipeline capable of modelling anatomical variations as well as simulating scanner-specific artifacts.

Practical Implications and Future Directions

TorchIO was engineered with open-science principles in mind, promoting experiment reproducibility and facilitating accurate citation through version-controlled releases. This alignment encourages the adoption of standardized pipelines, reducing redundancies and potential errors in self-coded preprocessing scripts. TorchIO ensures compatibility with other specialized frameworks like MONAI, making it an excellent choice for a wide range of applications and research endeavors in medical imaging.

Given its modular design, TorchIO can easily be extended to cover other medical imaging modalities beyond MRI, such as ultrasound (US) and computerized tomography (CT). In future work, providing more differentiable transforms that align with PyTorch's auto-differentiation capabilities could add further depth to its utility in scenarios like registration tasks.

In summary, TorchIO stands out as a powerful tool for researchers focusing on the intersection of deep learning and medical imaging. By mitigating intricacies related to medical image preprocessing and augmentation, it assists scientists in zeroing in on experimental designs aimed at advancing state-of-the-art technologies in medical diagnostics and beyond.