Medical imaging deep learning
Overview
This skill encodes a general medical-imaging deep learning evidence standard:
- Custom research pipelines / transforms / deployment-oriented code paths → MONAI (PyTorch-first infrastructure).
- New segmentation task → nnU-Net as the default strong benchmark before claiming gains from custom architectures.
- Foundation / promptable segmentation → MedSAM when the problem matches prompt-based or zero-shot adaptation—not as a substitute for validation.
- Learning-based deformable registration → VoxelMorph as the primary deep anchor, always paired with classical registration (ANTs/SyN, elastix, etc.) for evidence—not optional.
- Mechanism claims → explicit completion gates before reporting a model as done.
High-visibility here means widely adopted benchmarks and seminal baselines (qualitative); do not invent citation counts.
Full 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:
- Design segmentation, registration, template-building, or DL-side QC for medical images.
- Choose between MONAI, nnU-Net, MedSAM, VoxelMorph, and historical CNN baselines (U-Net family).
- Define train/val/test, external validation, and leakage-safe splits.
- Compare against public benchmarks (MSD, BraTS, ACDC, KiTS, LiTS) when claiming generalization.
Avoid using this skill as a generic “list of cool models” checklist—bind decisions to validation obligations.
Core Tooling / Preferred Stack
| Tool |
Role |
Default stance |
| MONAI |
Training/eval infrastructure: transforms, datasets, networks, bundles, deployment hooks |
First choice for new code in a MONAI-first refactor |
| nnU-Net |
Self-configuring strong segmentation baseline |
Run first on a new segmentation task; benchmark before custom nets |
| MedSAM |
Foundation / promptable segmentation |
After positioning against classical CNN baselines + nnU-Net-class strong baselines; domain validation required |
| VoxelMorph |
Learning-based pairwise registration |
Never the only registration; pair with classical ANTs/SyN or elastix-style baselines |
Domain evidence labels for model changes
Use these labels as medical-imaging domain evidence labels inside model-change reports. They do not replace the global final status vocabulary from codex-workflow-protocol.
Every final report must still use one global final status: complete, partial_complete, qa_failed, blocked, or blocked_target_not_met. When useful, add one domain evidence label to explain the model mechanism evidence stage.
TRUE_DONE: the requested mechanism is implemented, trained or inferred as authorized, evaluated on the target split, and supported by checkpoint, prediction, metric, command/log, and same-split baseline evidence.
PARTIAL_MECHANISM_INCOMPLETE: code or experiments exist, but a core mechanism is missing, proxy-only, or below the required gate.
PREFLIGHT_SMOKE_ONLY: only import, shape, one-case, metadata, dryrun, readiness, or resource checks were completed.
NOT_DONE: no implementation, no run, failed run, stale evidence, or missing evidence.
Examples:
- If only import, shape, one-case, metadata, dryrun, readiness, or resource checks were completed, the global final status should usually be
partial_complete or qa_failed, with domain evidence label PREFLIGHT_SMOKE_ONLY.
- If code or experiments exist but the requested mechanism is missing, proxy-only, or below the required gate, the global final status should usually be
partial_complete or qa_failed, with domain evidence label PARTIAL_MECHANISM_INCOMPLETE.
- If no implementation, no run, failed run, stale evidence, or missing evidence exists, the global final status should usually be
partial_complete, qa_failed, or blocked, with domain evidence label NOT_DONE.
- If the requested mechanism is implemented, trained or inferred as authorized, evaluated on the target split, and supported by checkpoint, prediction, metric, command/log, and same-split baseline evidence, the global final status may be
complete, with domain evidence label TRUE_DONE.
Do not promote a task above the weakest required evidence stage. If training/evaluation was not run, do not label the domain evidence stage as TRUE_DONE.
Forbidden shallow substitutions
Never report these as completed mechanisms:
- Smoke, preflight, dryrun, import, shape, metadata, or one-case checks as model completion.
- A one-layer stem, shallow head, or 1x1 output head as a U-Net-like encoder-decoder.
- Translation, center crop, metadata copying, or resampling as completed registration or warping.
- A frame0, single-frame, or reference-only anatomy proxy as a temporal/video method.
- Logit mixing as a proposal, refinement, or cascade model.
- Hard-negative mining preflight as hard-negative training.
- Search, license notes, clone, import, or tensor-shape smoke as external-method integration.
- Local proxy metrics as challenge-grade or deployment-grade evidence without the target evaluator contract.
- Missing-modality samples as target hard negatives when the target label depends on that missing modality.
Canonical architecture baselines (not “instead of nnU-Net”)
- U-Net (2D): historical canonical CNN segmentation baseline.
- 3D U-Net: volumetric canonical baseline.
- UNETR / Swin UNETR: transformer-era strong baselines when the narrative involves global context / transformers—use to situate claims vs. MedSAM or custom attention architectures; do not imply they replace nnU-Net as the default segmentation benchmark.
Benchmark datasets / challenges (named anchors)
Use as evaluation anchors and literature positioning, not as “mandatory dependencies”:
- MSD — multi-task / multi-modality generalization benchmark.
- BraTS — brain tumor multimodal MRI segmentation.
- ACDC — cardiac MRI multi-structure segmentation/diagnosis benchmark.
- KiTS19 / LiTS — kidney/liver tumor CT benchmarks.
Workflow / Decision Rules
Segmentation
- Establish geometry once: consistent spacing, orientation, affine, origin; document resampling kernels.
- Patient-level splits only; no slice-level leakage across patients.
- Default benchmark order:
- nnU-Net strong baseline →
- optional U-Net / 3D U-Net historical baselines →
- MONAI custom method only with documented incremental value.
- If claiming transformer / foundation value: explicitly relate to UNETR / Swin UNETR / MedSAM lineages and justify why extra complexity is needed.
Segmentation architecture gate
When a task asks for U-Net-like, encoder-decoder, multiscale, cascade, proposal, or refinement behavior, the result must list:
- key classes/functions changed;
- feature scales and decoder/skip/refinement paths;
- input/output tensor shapes;
- checkpoint, prediction, metric, and same-split baseline paths;
- ablation or comparison showing the mechanism changed behavior.
If these are absent, label the domain evidence stage as PARTIAL_MECHANISM_INCOMPLETE or PREFLIGHT_SMOKE_ONLY.
Registration / template building
- VoxelMorph (or similar) must be reported against ANTs/SyN and/or elastix-class classical baselines on the same preprocessed images.
- Template building is a separate validated stage: inverse consistency, Jacobian plausibility, and downstream checks (warped-mask overlap, strain biomarker bias if applicable).
- Treat deformation-dependent phenotypes as high-risk—do not optimize Dice alone.
Registration / warping gate
Every registration claim must state:
- transform family: rigid, affine, deformable, SyN, B-spline, TPS, optical flow, feature-level warp, or translation baseline;
- moving and fixed images/frames, image space, interpolation, and label interpolation;
- plausibility checks such as inverse/roundtrip consistency, Jacobian/folding, landmark error, warped-mask consistency, or visual overlays;
- downstream task metric on the same split.
Translation-only work is a translation baseline, not registration completion.
Temporal / video imaging gate
For cine, video, 4D, longitudinal, or time-series imaging, report:
- reference frame or time point and why it was chosen;
- how non-reference frames are used;
- motion estimation, warping, temporal aggregation, or temporal consistency;
- whether the model has a head for the target clinical/anatomical task, not just an anatomy proxy;
- metrics against a single-frame/reference baseline.
Single-frame or reference-only evidence is a baseline/proxy, not temporal-method completion.
Missing-modality gate
For multimodal models, report:
- modality availability per split/subgroup;
- availability mask, routing, imputation, or dropout behavior;
- loss masks for targets that depend on a modality;
- target-available subgroup metrics and target-missing subgroup caveats.
If a target label depends on a modality, samples missing that modality must not be treated as default hard negatives for that target.
External method adapter gate
Separate stages clearly:
- resource search and paper/code triage;
- license/version/dependency check;
- clone/import/shape smoke;
- one-case adapter with input/output contract;
- fold0 or full validation metric on the same evaluator;
- rollback criteria and cleanup.
Only stage 5+ can be called an integrated method.
DL-side QC
- Failure review on held-out cases (visual overlays, worst-case mining).
- If using uncertainty / calibration: report reliability checks, not only AUC/Dice.
- DICOM → tensor paths must preserve consistency with classical preprocessing (same orientation convention as SimpleITK/ANTsPy stack).
When not to jump to foundation models / DL registration
- Small, single-site datasets with weak labels → foundation models overfit narratives easily; nnU-Net + classical baselines first.
- Regulatory or clinical claims without external validation → do not lead with MedSAM.
- Registration where topology must stay physiological → classical diffeomorphic/SyN-class methods often remain the safer default; learning methods need Jacobian / folding audits.
Benchmark expectations / evaluation baselines
Rules:
- Segmentation: nnU-Net is the default modern strong benchmark. U-Net / 3D U-Net are historical canonical baselines. Saying “we beat SOTA” against a weak custom baseline is invalid.
- Transformers / foundation claims: acknowledge UNETR / Swin UNETR and MedSAM as relevant comparators when scope overlaps.
- Multi-organ / multi-task generalization: cite MSD as the standard generalization anchor.
- Brain / heart / kidney / liver tumor or structure tasks: BraTS / ACDC / KiTS / LiTS are the default named benchmarks for positioning.
- Metrics: Dice alone is insufficient for high-stakes segmentation; add surface / Hausdorff-class metrics where applicable, calibration if probabilistic, OOD/generalization and failure analysis for real deployment narratives.
- Registration: VoxelMorph does not bypass classical registration; include Jacobian / folding / topology and landmark or downstream checks when available.
Evidence standard for model changes
Every model-change result must include:
- command/log, exit status, job ID if applicable, and elapsed time;
- checkpoint path, prediction path, metric path, and config/cache isolation;
- same-split baseline and target evaluator contract;
- failure analysis with surface/HD, component, calibration, subgroup, or remote false-positive metrics when they matter.
Dice alone is insufficient when boundary accuracy, topology, lesion/component burden, calibration, or false positives drive the task.
Common Pitfalls / Validation Notes
- Leakage via slice shuffling, repeated patients, or preprocessing computed on global stats.
- Mixing NIfTI/DICOM orientation fixes across modalities without a single library boundary.
- Reporting only in-distribution Dice with no external cohort.
- Template building without reporting smoothness / plausibility of mean shape and transforms.
- Treating MedSAM as “segmentation solved” without domain fine-tuning and external test.
References
Canonical papers and benchmark anchors are maintained in references/reference.md.
Read references/reference.md for detailed completion checklists and generic examples of shallow substitutions.
1---2name: medical-imaging-deep-learning3description: Use for medical-imaging deep learning tasks involving segmentation, MONAI/nnU-Net baselines, registration or warping, temporal/video imaging, missing-modality fusion, proposal/cascade/refinement models, external method adaptation, and validation evidence gates.4license: Apache-2.05---6# Medical imaging deep learning78## Overview910This skill encodes a general **medical-imaging deep learning evidence standard**:1112- **Custom research pipelines / transforms / deployment-oriented code paths → MONAI** (PyTorch-first infrastructure).13- **New segmentation task → nnU-Net as the default strong benchmark** before claiming gains from custom architectures.14- **Foundation / promptable segmentation → MedSAM** when the problem matches prompt-based or zero-shot adaptation—**not** as a substitute for validation.15- **Learning-based deformable registration → VoxelMorph** as the primary **deep** anchor, **always** paired with **classical** registration (ANTs/SyN, **elastix**, etc.) for evidence—not optional.16- **Mechanism claims → explicit completion gates** before reporting a model as done.1718**High-visibility** here means **widely adopted benchmarks and seminal baselines** (qualitative); do **not** invent citation counts.1920Full anchors: [references/reference.md](references/reference.md).2122## Workflow inheritance2324For 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.2526## When to Use This Skill2728Use when you:2930- Design **segmentation**, **registration**, **template-building**, or **DL-side QC** for medical images.31- Choose between **MONAI**, **nnU-Net**, **MedSAM**, **VoxelMorph**, and **historical CNN baselines** (U-Net family).32- Define **train/val/test**, **external validation**, and **leakage-safe** splits.33- Compare against **public benchmarks** (MSD, BraTS, ACDC, KiTS, LiTS) when claiming generalization.3435Avoid using this skill as a generic “list of cool models” checklist—**bind decisions to validation obligations**.3637## Core Tooling / Preferred Stack3839| Tool | Role | Default stance |40|------|------|-----------------------------|41| **MONAI** | Training/eval **infrastructure**: transforms, datasets, networks, bundles, deployment hooks | **First choice** for new code in a MONAI-first refactor |42| **nnU-Net** | Self-configuring **strong segmentation baseline** | **Run first** on a new segmentation task; **benchmark** before custom nets |43| **MedSAM** | **Foundation** / promptable segmentation | **After** positioning against classical CNN baselines + nnU-Net-class strong baselines; domain validation required |44| **VoxelMorph** | **Learning-based** pairwise registration | **Never** the only registration; **pair** with classical ANTs/SyN or elastix-style baselines |4546## Domain evidence labels for model changes4748Use these labels as medical-imaging domain evidence labels inside model-change reports. They do not replace the global final status vocabulary from `codex-workflow-protocol`.4950Every final report must still use one global final status: `complete`, `partial_complete`, `qa_failed`, `blocked`, or `blocked_target_not_met`. When useful, add one domain evidence label to explain the model mechanism evidence stage.5152- `TRUE_DONE`: the requested mechanism is implemented, trained or inferred as authorized, evaluated on the target split, and supported by checkpoint, prediction, metric, command/log, and same-split baseline evidence.53- `PARTIAL_MECHANISM_INCOMPLETE`: code or experiments exist, but a core mechanism is missing, proxy-only, or below the required gate.54- `PREFLIGHT_SMOKE_ONLY`: only import, shape, one-case, metadata, dryrun, readiness, or resource checks were completed.55- `NOT_DONE`: no implementation, no run, failed run, stale evidence, or missing evidence.5657Examples:5859- If only import, shape, one-case, metadata, dryrun, readiness, or resource checks were completed, the global final status should usually be `partial_complete` or `qa_failed`, with domain evidence label `PREFLIGHT_SMOKE_ONLY`.60- If code or experiments exist but the requested mechanism is missing, proxy-only, or below the required gate, the global final status should usually be `partial_complete` or `qa_failed`, with domain evidence label `PARTIAL_MECHANISM_INCOMPLETE`.61- If no implementation, no run, failed run, stale evidence, or missing evidence exists, the global final status should usually be `partial_complete`, `qa_failed`, or `blocked`, with domain evidence label `NOT_DONE`.62- If the requested mechanism is implemented, trained or inferred as authorized, evaluated on the target split, and supported by checkpoint, prediction, metric, command/log, and same-split baseline evidence, the global final status may be `complete`, with domain evidence label `TRUE_DONE`.6364Do not promote a task above the weakest required evidence stage. If training/evaluation was not run, do not label the domain evidence stage as `TRUE_DONE`.6566## Forbidden shallow substitutions6768Never report these as completed mechanisms:6970- Smoke, preflight, dryrun, import, shape, metadata, or one-case checks as model completion.71- A one-layer stem, shallow head, or 1x1 output head as a U-Net-like encoder-decoder.72- Translation, center crop, metadata copying, or resampling as completed registration or warping.73- A frame0, single-frame, or reference-only anatomy proxy as a temporal/video method.74- Logit mixing as a proposal, refinement, or cascade model.75- Hard-negative mining preflight as hard-negative training.76- Search, license notes, clone, import, or tensor-shape smoke as external-method integration.77- Local proxy metrics as challenge-grade or deployment-grade evidence without the target evaluator contract.78- Missing-modality samples as target hard negatives when the target label depends on that missing modality.7980### Canonical architecture baselines (not “instead of nnU-Net”)8182- **U-Net** (2D): historical canonical CNN segmentation baseline. 83- **3D U-Net**: volumetric canonical baseline. 84- **UNETR / Swin UNETR**: transformer-era **strong baselines** when the narrative involves **global context / transformers**—use to **situate** claims vs. MedSAM or custom attention architectures; **do not** imply they replace nnU-Net as the default segmentation benchmark.8586### Benchmark datasets / challenges (named anchors)8788Use as **evaluation anchors** and **literature positioning**, not as “mandatory dependencies”:8990- **MSD** — multi-task / multi-modality generalization benchmark. 91- **BraTS** — brain tumor multimodal MRI segmentation. 92- **ACDC** — cardiac MRI multi-structure segmentation/diagnosis benchmark. 93- **KiTS19** / **LiTS** — kidney/liver tumor CT benchmarks.9495## Workflow / Decision Rules9697### Segmentation98991. **Establish geometry** once: consistent **spacing, orientation, affine, origin**; document resampling kernels. 1002. **Patient-level splits** only; no slice-level leakage across patients. 1013. **Default benchmark order:** 102 - **nnU-Net** strong baseline → 103 - optional **U-Net / 3D U-Net** historical baselines → 104 - **MONAI** custom method **only with** documented incremental value. 1054. If claiming **transformer / foundation** value: explicitly relate to **UNETR / Swin UNETR / MedSAM** lineages and justify **why** extra complexity is needed.106107### Segmentation architecture gate108109When a task asks for **U-Net-like**, **encoder-decoder**, **multiscale**, **cascade**, **proposal**, or **refinement** behavior, the result must list:110111- key classes/functions changed;112- feature scales and decoder/skip/refinement paths;113- input/output tensor shapes;114- checkpoint, prediction, metric, and same-split baseline paths;115- ablation or comparison showing the mechanism changed behavior.116117If these are absent, label the domain evidence stage as `PARTIAL_MECHANISM_INCOMPLETE` or `PREFLIGHT_SMOKE_ONLY`.118119### Registration / template building120121- **VoxelMorph** (or similar) **must** be reported against **ANTs/SyN** and/or **elastix**-class classical baselines on the **same** preprocessed images. 122- **Template building** is a **separate validated stage**: inverse consistency, Jacobian plausibility, and **downstream** checks (warped-mask overlap, strain biomarker bias if applicable). 123- Treat **deformation-dependent phenotypes** as **high-risk**—do not optimize **Dice alone**.124125### Registration / warping gate126127Every registration claim must state:128129- transform family: rigid, affine, deformable, SyN, B-spline, TPS, optical flow, feature-level warp, or translation baseline;130- moving and fixed images/frames, image space, interpolation, and label interpolation;131- plausibility checks such as inverse/roundtrip consistency, Jacobian/folding, landmark error, warped-mask consistency, or visual overlays;132- downstream task metric on the same split.133134Translation-only work is a **translation baseline**, not registration completion.135136### Temporal / video imaging gate137138For cine, video, 4D, longitudinal, or time-series imaging, report:139140- reference frame or time point and why it was chosen;141- how non-reference frames are used;142- motion estimation, warping, temporal aggregation, or temporal consistency;143- whether the model has a head for the target clinical/anatomical task, not just an anatomy proxy;144- metrics against a single-frame/reference baseline.145146Single-frame or reference-only evidence is a baseline/proxy, not temporal-method completion.147148### Missing-modality gate149150For multimodal models, report:151152- modality availability per split/subgroup;153- availability mask, routing, imputation, or dropout behavior;154- loss masks for targets that depend on a modality;155- target-available subgroup metrics and target-missing subgroup caveats.156157If a target label depends on a modality, samples missing that modality must not be treated as default hard negatives for that target.158159### External method adapter gate160161Separate stages clearly:1621631. resource search and paper/code triage;1642. license/version/dependency check;1653. clone/import/shape smoke;1664. one-case adapter with input/output contract;1675. fold0 or full validation metric on the same evaluator;1686. rollback criteria and cleanup.169170Only stage 5+ can be called an integrated method.171172### DL-side QC173174- **Failure review** on held-out cases (visual overlays, worst-case mining). 175- If using **uncertainty / calibration**: report **reliability** checks, not only AUC/Dice. 176- **DICOM** → tensor paths must preserve **consistency** with classical preprocessing (same orientation convention as SimpleITK/ANTsPy stack).177178### When **not** to jump to foundation models / DL registration179180- **Small, single-site** datasets with **weak labels** → foundation models **overfit narratives** easily; **nnU-Net + classical baselines** first. 181- **Regulatory or clinical** claims without external validation → **do not** lead with MedSAM. 182- **Registration** where **topology** must stay physiological → **classical** diffeomorphic/SyN-class methods often remain the **safer default**; learning methods need **Jacobian / folding** audits.183184## Benchmark expectations / evaluation baselines185186**Rules:**1871881. **Segmentation:** **nnU-Net** is the default **modern strong benchmark**. **U-Net / 3D U-Net** are **historical canonical** baselines. Saying “we beat SOTA” **against a weak custom baseline** is invalid. 1892. **Transformers / foundation claims:** acknowledge **UNETR / Swin UNETR** and **MedSAM** as **relevant comparators** when scope overlaps. 1903. **Multi-organ / multi-task generalization:** cite **MSD** as the standard **generalization** anchor. 1914. **Brain / heart / kidney / liver** tumor or structure tasks: **BraTS / ACDC / KiTS / LiTS** are the **default named benchmarks** for positioning. 1925. **Metrics:** **Dice alone is insufficient** for high-stakes segmentation; add **surface / Hausdorff-class** metrics where applicable, **calibration** if probabilistic, **OOD/generalization** and **failure analysis** for real deployment narratives. 1936. **Registration:** **VoxelMorph** does **not** bypass **classical** registration; include **Jacobian / folding / topology** and **landmark or downstream** checks when available.194195## Evidence standard for model changes196197Every model-change result must include:198199- command/log, exit status, job ID if applicable, and elapsed time;200- checkpoint path, prediction path, metric path, and config/cache isolation;201- same-split baseline and target evaluator contract;202- failure analysis with surface/HD, component, calibration, subgroup, or remote false-positive metrics when they matter.203204Dice alone is insufficient when boundary accuracy, topology, lesion/component burden, calibration, or false positives drive the task.205206## Common Pitfalls / Validation Notes207208- **Leakage** via slice shuffling, repeated patients, or preprocessing computed on global stats. 209- **Mixing NIfTI/DICOM orientation fixes** across modalities without a single library boundary. 210- **Reporting only in-distribution Dice** with no **external** cohort. 211- **Template building** without reporting **smoothness / plausibility** of mean shape and transforms. 212- **Treating MedSAM** as “segmentation solved” without **domain fine-tuning** and **external** test.213214## References215216Canonical papers and benchmark anchors are maintained in [references/reference.md](references/reference.md).217218Read [references/reference.md](references/reference.md) for detailed completion checklists and generic examples of shallow substitutions.