simpleitk
Use SimpleITK for medical-image IO, image metadata, NumPy conversion, filtering, segmentation, registration, transforms, and source-build troubleshooting.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- simpleitk
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use SimpleITK for medical-image IO, image metadata, NumPy conversion, filtering, segmentation, registration, transforms, and source-build troubleshooting.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/repo-provenance.md2.8 KB
- 参考文档references/repo-routing-metadata.json498 B
- 参考文档references/source-evidence-map.md3.9 KB
- 参考文档references/troubleshooting.md5.1 KB
- 脚本scripts/check_simpleitk_env.py5.3 KB
03 SKILL.md 正文
SimpleITK Repo Skill
Use this repo skill when a task names SimpleITK, simpleitk, import SimpleITK as sitk, medical-image IO, DICOM series, image spacing/origin/direction, NumPy image conversion, SimpleITK filters, segmentation, registration, transforms, resampling, or SimpleITK source builds and wrapping.
Start Here
- Read references/repo-provenance.md before deciding whether this skill is current for a SimpleITK checkout or whether
refresh-repo-skillis needed. - Read references/source-evidence-map.md to see which source, docs, examples, tests, scripts, and existing skills informed this self-contained skill.
- Read references/troubleshooting.md for cross-cutting install/import/version, optional feature, ImageIO, and workflow routing failures.
- Run scripts/check_simpleitk_env.py to inspect a local
SimpleITKinstall, NumPy bridge, ImageIO discovery, registration availability, and optional elastix wrappers without needing source data.
Installation and Import
For ordinary Python usage, prefer a binary install before attempting source builds:
python -m pip install --upgrade pip
python -m pip install simpleitk
python - <<'PY'
import SimpleITK as sitk
print(sitk.Version())
PY
Use conda-forge consistently when the project is conda-based:
conda create --name sitk python=3.11 simpleitk --channel conda-forge --override-channels
conda activate sitk
Import the Python package with import SimpleITK as sitk; the distribution name is simpleitk.
Route by Task
| User task | Read this sub-skill |
|---|---|
Construct sitk.Image, preserve spacing/origin/direction, inspect pixel IDs, convert to or from NumPy, debug shape reversal |
image-core |
| Read/write MHA, NRRD, NIfTI, PNG, DICOM series, metadata tags, transforms, or ImageIO backends | io-and-data |
| Apply filters, smooth/threshold images, run morphology, connected components, segmentation, N4, or label statistics | filtering-segmentation |
| Configure transforms, resampling, registration metrics/optimizers, callbacks, reproducibility, or optional elastix/transformix workflows | registration-transforms |
Install/build SimpleITK, choose PyPI vs conda vs source/SuperBuild, inspect CMake WRAP_*, enable optional wrappers, or run maintainer checks |
builds-and-wrapping |
Core Rules
- Treat a SimpleITK image as a physical object: preserve
GetOrigin(),GetSpacing(), andGetDirection()when replacing pixels or moving through NumPy. - Remember axis order: SimpleITK indexes are
(x, y, z, ...); NumPy arrays from SimpleITK are reversed spatially, such as(z, y, x)for a 3D scalar image. - Use
sitk.ImageFileReader().GetRegisteredImageIOs()andsitk.ImageFileWriter().GetRegisteredImageIOs()for registered ImageIO discovery in Python examples. - Use
.mhaor.nrrdfor deterministic smoke tests; avoid lossy formats such as JPEG when pixel equality matters. - Cast registration inputs deliberately to
sitk.sitkFloat32orsitk.sitkFloat64when a metric or optimizer requires floating-point images. - For label images, use nearest-neighbor interpolation during resampling; use linear interpolation for intensities unless a workflow says otherwise.
- Treat
ElastixImageFilterandTransformixImageFilteras optional build-dependent APIs; absence in a binary install is an installation/build feature issue, not necessarily a typo.
Source Build Guardrails
Do not start a source build for ordinary SimpleITK API usage. Source builds use native C++/CMake/SWIG tooling and can fetch/build ITK or other dependencies. Route source-build, SuperBuild, wrapping, and optional elastix requests to builds-and-wrapping, and ask before running expensive or mutating commands.
Self-Containment
This skill distills repository docs, examples, tests, source code, and an installed-package inspection into bundled references and scripts. Runtime instructions here do not require access to the original SimpleITK checkout.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).