Install & Compatibility
Where this runs
tested against v1.2.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
py 3.10
✕ build_error
✓ 86s
py 3.11
✕ build_error
✓ 80.7s
py 3.12
✕ build_error
✓ 71.5s
py 3.13
✕ build_error
✓ 67.9s
py 3.9
✕ build_error
✕ timeout
5299MB installed
● package 5299MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
SubjectsDataset
✓ from torchio import SubjectsDataset
✗ from torchio.data import SubjectsDataset
In older versions (pre-0.18), SubjectsDataset was in torchio.data. Now it's exposed at top level.
RandomAffine
✓ from torchio import RandomAffine
✗ from torchio.transforms import RandomAffine
import from torchio directly is recommended and stable.
Create a minimal Subject with random data and apply transforms.
import torchio as tio
import torch
# Create a subject with a 3D image
subject = tio.Subject(
img=tio.ScalarImage(tensor=torch.rand(1, 64, 64, 64)),
label=tio.LabelMap(tensor=torch.randint(0, 2, (1, 64, 64, 64))),
)
print(subject)
# Define a simple transform
transform = tio.Compose([
tio.RandomAffine(scales=(0.9, 1.2), degrees=10),
tio.RandomNoise(std=0.1),
])
# Apply transform
transformed = transform(subject)
print(transformed.shape)
Errors
Common errors & fixes
ImportError: cannot import name 'SubjectsDataset' from 'torchio'
Old import path from torchio.data; torchio v0.18+ moved SubjectsDataset to top-level.
fixUse 'from torchio import SubjectsDataset' instead of 'from torchio.data import SubjectsDataset'.
KeyError: 'img' or 'label' not found in Subject when loading from disk
Subject expects specific keys for images and labels, but the file may have different naming (e.g., 'image', 'seg').
fixEnsure the keys in the Subject dictionary match exactly. Use tio.ScalarImage(path) and assign to 'img' key.
RuntimeError: Expected 4D input but got 3D
TorchIO expects batch dimension (B, C, D, H, W) even for single images. Many transforms fail on 3D tensors.
fixAdd a batch dimension: tensor = tensor.unsqueeze(0) or use tio.ScalarImage with shape (1, C, D, H, W).
Upgrade
Version history
1.2.1latest on PyPI · released Jun 2, 2026
Audit
Dependencies
No dependency data recorded yet.