Medical imaging classical features and engineered preprocessing
Overview
This skill is not a “legacy methods collection.” It defines a classical-and-engineered pipeline:
- Geometry-aware preprocessing (orientation, affine, spacing, origin, interpolation discipline).
- Registration / normalization with selective use of ANTsPy (high-quality paths only).
- Handcrafted radiomics with IBSI-aligned definitions and CLEAR-aligned reporting when studies are published or reviewed.
- DICOM-semantic I/O (SEG/SR) where coded concepts, UIDs, frame of reference, and provenance matter as much as pixels.
ANTsPy is selective: use for demanding registration, template construction, or biologically constrained normalization—not “default every task.”
Canonical anchors: references/reference.md.
Workflow inheritance
For complex tasks, first apply the global codex-workflow-protocol skill. This skill only adds domain-specific knowledge, gates, and validation requirements. It must not weaken the global completion, escalation, or verification rules.
When to Use This Skill
Use when you:
- Build preprocessing that must match deep learning tensors 1:1 in physical space.
- Extract radiomics for statistics or downstream Bayes—protocol sensitivity is part of the design.
- Read/write DICOM with audit-ready metadata (multi-frame, orientation, FoR).
- Compare classical registration baselines (ANTs/SyN, elastix) and bias correction (N4ITK).
Core Tooling / Preferred Stack
| Tool |
Responsibility |
| SimpleITK |
Image I/O (often via file readers), filtering, resampling, transforms, and ITK-style registration primitives; enforce physical-space consistency. |
| PyRadiomics |
Handcrafted radiomic feature extraction from aligned image + mask under a frozen parameter file. |
| pydicom |
Low-level DICOM parsing, tag access, de-identification hooks, raw pixel pathways. |
| highdicom |
Higher-level DICOM objects (e.g., SEG, SR patterns) with semantic coding support—use when outputs must be standards-compliant, not “just numpy masks.” |
| ANTsPy |
Python binding to ANTs; SyN-class deformable registration, template-building workflows, paired with CLI/scripted ANTs tools when needed. |
Classical algorithm / preprocessing anchors (not always installed libraries)
| Anchor |
Role |
| elastix |
Widely used intensity-based registration toolbox—second classical line next to ANTs/SyN for fair comparisons. |
| N4ITK |
MRI bias-field correction anchor—call via SimpleITK (N4BiasFieldCorrectionImageFilter pattern) in pipelines that need it. |
| SyN / ANTs |
Diffeomorphic registration lineage—understand connection when using ANTsPy APIs. |
Workflow / Decision Rules
Geometry and interpolation
- Never silently change origin / direction / spacing; log them on every derived volume.
- Choose interpolation explicitly: linear for resampled intensities in many radiomics settings; nearest for labels; document deviations.
- ROI / mask: define morphological handling (re-segmentation after resampling, boundary voxels, hollow structures).
Registration / normalization
- Default mindset: know both ANTs/SyN (via ANTsPy) and elastix as classical comparators—pick per modality/task with documented rationale.
- MRI bias: if intensity non-uniformity is plausible, plan for N4 (or justify omission per protocol).
- ANTsPy for high-stakes alignment (template construction, longitudinal alignment) — not for every trivial rigid step unless justified.
Radiomics (PyRadiomics + IBSI)
- PyRadiomics ≠ automatic IBSI compliance. Treat IBSI as the standardization target: resampling, interpolation, intensity discretization/binning, re-segmentation, ROI definition, aggregation, and harmonization.
- IBSI website / phantom benchmarks (https://theibsi.github.io/) are calibration resources, not optional reading.
- Studies without IBSI/CLEAR context carry elevated reproducibility risk—state limitations explicitly.
DICOM semantics and provenance
- Do not only export mask pixels. For SEG/SR: maintain coded concepts, UIDs, frame of reference, algorithm identification, and provenance suitable for audit.
- Validate metadata completeness before batch processing (missing orientation, inconsistent series descriptions, mixed FoR).
Reporting / QC (CLEAR)
- For radiomics study design, manuscripts, or internal QA, apply CLEAR as a default reporting checklist (endorsed guideline—see references).
Classical baselines and standardization (reproducibility anchors)
Hard rules:
- Registration: besides ANTsPy, know elastix as a classic alternative baseline when comparing pipelines.
- MRI preprocessing: N4ITK is the default bias correction anchor—acknowledge when skipped.
- Radiomics: IBSI-compliant preprocessing/feature definition is a priority, not an appendix.
- PyRadiomics parameters must be version-controlled; document resampling, interpolation, binning, re-segmentation, ROI rules, aggregation, harmonization.
- Outputs without IBSI/CLEAR discipline → treat reproducibility risk as high by default.
- Classical pipeline = geometry + preprocessing provenance + features + DICOM semantics—not “run one extractor.”
Common Pitfalls / Validation Notes
- Domain shift across scanners/protocols/reconstruction kernels without harmonization or explicit limitation in reporting.
- Radiomics on misregistered masks or inconsistent intensity scales.
- Saving SEG without meaningful concept codes and FoR linkage.
- Using ANTsPy everywhere “because it’s strong”—costly, may be unnecessary for simple rigid steps.
- Assuming highdicom removes the need for domain expert review of coded attributes.
References
Canonical and anchor literature is maintained in references/reference.md.
1---2name: medical-imaging-classical-features3description: Use when enforcing reproducible medical-imaging preprocessing, physical-space geometry, classical registration baselines, radiomics protocols, or DICOM SEG/SR provenance.4license: Apache-2.05---6# Medical imaging classical features and engineered preprocessing78## Overview910This skill is **not** a “legacy methods collection.” It defines a **classical-and-engineered** pipeline:1112- **Geometry-aware preprocessing** (orientation, affine, spacing, origin, interpolation discipline). 13- **Registration / normalization** with **selective** use of **ANTsPy** (high-quality paths only). 14- **Handcrafted radiomics** with **IBSI-aligned** definitions and **CLEAR-aligned** reporting when studies are published or reviewed. 15- **DICOM-semantic I/O** (SEG/SR) where **coded concepts, UIDs, frame of reference, and provenance** matter as much as pixels.1617**ANTsPy** is **selective**: use for **demanding registration, template construction, or biologically constrained normalization**—not “default every task.”1819Canonical anchors: [references/reference.md](references/reference.md).2021## Workflow inheritance2223For complex tasks, first apply the global `codex-workflow-protocol` skill. This skill only adds domain-specific knowledge, gates, and validation requirements. It must not weaken the global completion, escalation, or verification rules.2425## When to Use This Skill2627Use when you:2829- Build **preprocessing** that must match **deep learning** tensors 1:1 in physical space. 30- Extract **radiomics** for statistics or downstream Bayes—**protocol sensitivity** is part of the design. 31- Read/write **DICOM** with **audit-ready metadata** (multi-frame, orientation, FoR). 32- Compare **classical registration** baselines (**ANTs/SyN**, **elastix**) and **bias correction** (**N4ITK**).3334## Core Tooling / Preferred Stack3536| Tool | Responsibility |37|------|----------------|38| **SimpleITK** | Image I/O (often via file readers), **filtering**, **resampling**, **transforms**, and ITK-style **registration primitives**; enforce physical-space consistency. |39| **PyRadiomics** | **Handcrafted radiomic** feature extraction from aligned image + mask under a **frozen parameter file**. |40| **pydicom** | Low-level **DICOM parsing**, tag access, de-identification hooks, raw pixel pathways. |41| **highdicom** | Higher-level **DICOM objects** (e.g., SEG, SR patterns) with **semantic** coding support—use when outputs must be **standards-compliant**, not “just numpy masks.” |42| **ANTsPy** | Python binding to **ANTs**; **SyN**-class deformable registration, **template-building** workflows, paired with CLI/scripted ANTs tools when needed. |4344### Classical algorithm / preprocessing anchors (not always installed libraries)4546| Anchor | Role |47|--------|------|48| **elastix** | Widely used **intensity-based registration** toolbox—**second classical line** next to ANTs/SyN for fair comparisons. |49| **N4ITK** | **MRI bias-field correction** anchor—call via **SimpleITK** (`N4BiasFieldCorrectionImageFilter` pattern) in pipelines that need it. |50| **SyN / ANTs** | Diffeomorphic registration lineage—understand connection when using **ANTsPy** APIs. |5152## Workflow / Decision Rules5354### Geometry and interpolation5556- **Never** silently change **origin / direction / spacing**; log them on every derived volume. 57- Choose **interpolation** explicitly: **linear** for resampled intensities in many radiomics settings; **nearest** for labels; document deviations. 58- **ROI / mask**: define **morphological handling** (re-segmentation after resampling, boundary voxels, hollow structures).5960### Registration / normalization6162- **Default mindset:** know **both** **ANTs/SyN (via ANTsPy)** and **elastix** as **classical** comparators—pick per modality/task with **documented rationale**. 63- **MRI bias:** if intensity non-uniformity is plausible, **plan for N4** (or justify omission per protocol). 64- **ANTsPy** for **high-stakes alignment** (template construction, longitudinal alignment) — **not** for every trivial rigid step unless justified.6566### Radiomics (PyRadiomics + IBSI)6768- **PyRadiomics ≠ automatic IBSI compliance.** Treat **IBSI** as the **standardization target**: resampling, interpolation, intensity discretization/binning, re-segmentation, ROI definition, aggregation, and harmonization. 69- **IBSI website / phantom benchmarks** ([https://theibsi.github.io/](https://theibsi.github.io/)) are **calibration resources**, not optional reading. 70- Studies without **IBSI/CLEAR context** carry **elevated reproducibility risk**—state limitations explicitly.7172### DICOM semantics and provenance7374- **Do not** only export mask pixels. For **SEG/SR**: maintain **coded concepts**, **UIDs**, **frame of reference**, **algorithm identification**, and **provenance** suitable for audit. 75- Validate **metadata completeness** before batch processing (missing orientation, inconsistent series descriptions, mixed FoR).7677### Reporting / QC (CLEAR)7879- For radiomics **study design, manuscripts, or internal QA**, apply **CLEAR** as a **default reporting checklist** (endorsed guideline—see references).8081## Classical baselines and standardization (reproducibility anchors)8283**Hard rules:**84851. **Registration:** besides **ANTsPy**, know **elastix** as a **classic alternative baseline** when comparing pipelines. 862. **MRI preprocessing:** **N4ITK** is the default **bias correction anchor**—acknowledge when skipped. 873. **Radiomics:** **IBSI-compliant** preprocessing/feature definition is a **priority**, not an appendix. 884. **PyRadiomics parameters** must be **version-controlled**; document **resampling, interpolation, binning, re-segmentation, ROI rules, aggregation, harmonization**. 895. **Outputs without IBSI/CLEAR discipline** → treat **reproducibility risk** as **high** by default. 906. **Classical pipeline** = **geometry + preprocessing provenance + features + DICOM semantics**—not “run one extractor.”9192## Common Pitfalls / Validation Notes9394- **Domain shift** across scanners/protocols/reconstruction kernels without **harmonization** or **explicit limitation** in reporting. 95- **Radiomics** on **misregistered** masks or **inconsistent** intensity scales. 96- **Saving SEG** without **meaningful concept codes** and **FoR** linkage. 97- Using **ANTsPy everywhere** “because it’s strong”—**costly**, may be **unnecessary** for simple rigid steps. 98- Assuming **highdicom** removes the need for **domain expert review** of coded attributes.99100## References101102Canonical and anchor literature is maintained in [references/reference.md](references/reference.md).