Skip to content
Back to skills

Torchio

ASecurity

"Use TorchIO 2.0 for medical image loading, preprocessing,

  • 247 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 9, 2026
devopspythonbashazureapi

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 20 files and shows the line behind each finding

Scanned September 9, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill torchio --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Torchio?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Torchio
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-torchio/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-torchio)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: torchio
description: "Use TorchIO 2.0 for medical image loading, preprocessing,
  augmentation, patch-based training/inference, CLI conversion, and I/O
  troubleshooting."
disable-model-invocation: true
metadata:
  disco-role: operating
license: Apache 2.0
---

# TorchIO

Use this skill when working with TorchIO, a PyTorch-oriented library for 3D medical image loading, preprocessing, augmentation, patch sampling, dense inference, and command-line image utilities.

## Start Here

1. Confirm the package imports:
   ```python
   import torchio as tio
   print(tio.__version__)
   ```
2. Use TorchIO 2.0 names in generated code: `Flip`, `Affine`, `Noise`, `Motion`, `BiasField`, `Spike`, and `Ghosting` instead of old `Random*` class names.
3. Build in-memory images with `tio.ScalarImage(tensor)` or `tio.LabelMap(tensor)` using 4D `(C, I, J, K)` tensors.
4. Keep runtime examples self-contained with synthetic tensors or user-provided image paths; do not depend on TorchIO repository examples or tests.

## Route by Task

- **Data containers and validation**: use [data-model](sub-skills/data-model/SKILL.md) for `Image`, `ScalarImage`, `LabelMap`, `Subject`/`Study`, affines, points, bounding boxes, lazy/eager source handling, saving, and source-shape errors.
- **Preprocessing and augmentation**: use [transforms](sub-skills/transforms/SKILL.md) for transform families, `Compose`, `OneOf`, `SomeOf`, include/exclude routing, per-instance batches, history/inverse behavior, and MONAI/Cornucopia adapters.
- **Patch training and dense inference**: use [patch-workflows](sub-skills/patch-workflows/SKILL.md) for `GridSampler`, `UniformSampler`, `WeightedSampler`, `LabelSampler`, `Queue`, `SubjectsLoader`, `PatchLocation`, and `PatchAggregator`.
- **CLI, conversion, visualization, and remote I/O**: use [cli-and-io](sub-skills/cli-and-io/SKILL.md) for the `torchio` console entry point, `info`, `convert`, `transform`, `cache`, plotting/animation, NIfTI-Zarr, cloud/remote extras, and cache/download caveats.

## Shared References

- Read [API quick map](references/api-quick-map.md) when choosing which TorchIO class or sub-skill owns a task.
- Read [troubleshooting](references/troubleshooting.md) for install/import, optional dependency, API drift, tensor shape, CLI, and workflow-routing failures.
- Read [repo provenance](references/repo-provenance.md) before refreshing this skill against a newer TorchIO checkout.

## Safe Smoke Checks

Run the nearest bundled script after installing TorchIO and its base dependencies:

```bash
python sub-skills/data-model/scripts/data_model_smoke.py
python sub-skills/transforms/scripts/transform_history_smoke.py
python sub-skills/transforms/scripts/include_exclude_smoke.py
python sub-skills/patch-workflows/scripts/patch_workflow_smoke.py
python sub-skills/cli-and-io/scripts/torchio_cli_smoke.py --print-only
```

Use full CLI smoke only when local temporary file creation and NIfTI conversion are acceptable:

```bash
python sub-skills/cli-and-io/scripts/torchio_cli_smoke.py
```

## Install and Extras Guidance

- Base install should provide `torch`, `nibabel`, `SimpleITK`, `numpy`, `tyro`, `fsspec[http]`, and TorchIO core APIs.
- Optional extras are task-specific: `plot` for Matplotlib visualization, `video` for GIF/MP4 animation, `monai` and `cornucopia` for transform adapters, `zarr` for NIfTI-Zarr, and cloud extras for `s3`, `azure`, or `gcs` remote storage.
- CPU is sufficient for the skill workflows unless the user's own model or pipeline requires CUDA.

## Common Decisions

- Use `ScalarImage` for continuous intensity data and `LabelMap` for masks/segmentations so spatial transforms use correct interpolation.
- Use `Subject` to keep multiple images and metadata aligned through transforms and patch sampling.
- Use `include`/`exclude` transform arguments when only some image keys should change.
- Use `GridSampler` plus `PatchAggregator` for dense inference; use `Queue` plus random samplers for stochastic patch training.
- Use the CLI for one-off inspection/conversion and the Python API for pipelines that need precise parameter control, batching, or model integration.

Files in this skill

  • SKILL.md4.1 KB
  • references/api-quick-map.md2.4 KB
  • references/repo-provenance.md1.2 KB
  • references/repo-routing-metadata.json409 B
  • references/troubleshooting.md2.9 KB
  • sub-skills/cli-and-io/SKILL.md3 KB
  • sub-skills/cli-and-io/references/cli-reference.md4.9 KB
  • sub-skills/cli-and-io/references/io-backends.md5.8 KB
  • sub-skills/cli-and-io/references/troubleshooting.md5.3 KB
  • sub-skills/cli-and-io/scripts/torchio_cli_smoke.py5.7 KB
  • sub-skills/data-model/SKILL.md4.4 KB
  • sub-skills/data-model/references/api-reference.md8.6 KB
  • sub-skills/data-model/references/io-and-formats.md6.4 KB
  • sub-skills/data-model/references/troubleshooting.md6.6 KB
  • sub-skills/data-model/scripts/data_model_smoke.py5.7 KB
  • sub-skills/patch-workflows/SKILL.md3.2 KB
  • sub-skills/patch-workflows/references/api-reference.md5.9 KB
  • sub-skills/patch-workflows/references/troubleshooting.md5.7 KB
  • sub-skills/patch-workflows/references/workflows.md5.6 KB
  • sub-skills/patch-workflows/scripts/patch_workflow_smoke.py8.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…