Génération CT synthétique (rflow-ct)

VérifiéPrudence

Génère des volumes CT et masques synthétiques via le wrapper NV-Generate-CTMR rflow-ct, avec validation et sorties JSON.

Spar Skills Guide Bot
Data & IAAvancé
27/11/2026
Claude CodeCodexCursor
#synthetic-data#medical-imaging#ct-generation#nvidia#gpu-inference

Recommandé pour

Synthèse automatique

Ce skill encapsule l'outil NV-Generate-CTMR rflow-ct de NVIDIA pour produire des volumes CT synthétiques et leurs masques à partir d'un fichier de configuration d'inférence.

Points forts

  • Wrapper mince et documenté qui prend en charge la préparation de la config, les chemins de sortie, la correspondance des labels et les contrôles de validation
  • Séparation claire entre l'entrée principale (run_rflow_ct.py) et des helpers avancés (génération de masque MAISI, image CT seule, CT à partir d'un masque)
  • Mode préflight ne nécessitant que NumPy, NiBabel et Typer, ce qui permet de vérifier l'environnement avant de lancer l'inférence GPU
  • Avertissements explicites sur l'usage clinique et sur la nécessité d'une revue qualité des données synthétiques

Limites

  • Ce n'est qu'une surcouche : l'inférence, l'échantillonnage et le décodage sont entièrement délégués au dépôt NVIDIA-Medtech/NV-Generate-CTMR, qu'il ne faut pas modifier
  • Nécessite CUDA, environ 16 Go de VRAM pour une sortie 256³ par défaut, et un A100/H100 pour des tailles plus grandes
  • Les volumes générés ne sont pas utilisables comme données d'entraînement de production sans revue indépendante, et l'outil est exclu du déploiement clinique ou réglementaire
Quand l'utiliser

À utiliser lorsqu'il faut générer des volumes CT synthétiques et des masques étiquetés pour l'expérimentation ou la recherche en imagerie médicale, via le wrapper officiel rflow-ct.

Quand l'éviter

À éviter pour produire des données d'entraînement de production, pour un usage clinique ou diagnostique, ou sur une machine sans GPU CUDA disposant de la VRAM requise (NV_GENERATE_ROOT non défini).

Analyse de sécurité

Prudence
Score qualité84/100

The skill is a thin, well-documented wrapper that clones a pinned NVIDIA upstream repo, pip-installs its requirements, downloads model data, and runs inference. These are powerful operations (network, shell, pip, GPU), but they serve a legitimate documented purpose and the text explicitly forbids destructive cleanup of the output dir. No curl|sh, no base64 payloads, no secret exfiltration, and no attempts to override safety instructions were found, so it rates caution rather than risky.

Points d'attention
  • •Uses Bash to git clone and pip install -r requirements.txt from an upstream GitHub repo; despite a pinned commit, pip package versions are not pinned, introducing supply-chain/runtime drift risk.
  • •Downloads ~5.5 GB of model weights and datasets from huggingface.co and github.com at setup time (documented network access).
  • •Delegates execution to upstream third-party code (`python -m scripts.inference`) via a pinned checkout; trust depends on the upstream repo.
  • •Requires GPU/CUDA and writes to a caller-provided output dir and HuggingFace cache; no destructive or exfiltration behavior.
  • •Skill shells out to git clone of a GitHub repo and python -m pip install -r requirements.txt, giving the upstream project's pinned commit code execution in the user's environment (supply-chain surface, though pinned to commit 61c4ec7).
  • •Network egress to huggingface.co and github.com during setup, plus asset caching under ~/.cache/huggingface and ~/.cache/nvidia-skills — expected for model download but still external I/O.
  • •Requires a GPU/CUDA runtime and executes a large upstream inference pipeline (python -m scripts.inference) whose internals are outside the audited text.
  • •Sets and reads NV_GENERATE_ROOT / NV_GENERATE_COMMIT environment variables and writes into that directory tree and the caller's --output-dir.
Comment cette analyse est faite

Exemples

Generate a CT volume with mask
Run scripts/run_rflow_ct.py with my config_infer_override JSON, write outputs to ./runs/ct_demo_01, and use random seed 42. Then check the result JSON.
List available anatomies
Use scripts/list_anatomies.py to list the controllable anatomies for the chest region so I can pick one for my config.
Preflight the environment
Run scripts/run_ct_mask.py with my REQUEST.json in --preflight-only mode to confirm the wrapper starts before I schedule the full GPU run.

name: nv-generate-ct-rflow description: Used for generating synthetic CT volumes and masks with NV-Generate-CTMR rflow-ct. Not for production training data without review. license: Apache-2.0 allowed-tools: Bash permissions: [env, file_read, file_write, network, shell] metadata: author: NVIDIA MedTech Team tags: - MedTech - CT - generation

NV-Generate-CT (rflow-ct)

Purpose

  • Used for generating synthetic CT volumes and masks with NV-Generate-CTMR rflow-ct. Not for production training data without review.
  • Use the wrapper exactly as documented; do not replace the upstream entrypoint with a handwritten implementation.
  • Do not write custom inference code for normal runs. The wrapper owns config staging, output paths, label mapping evidence, and validation.
  • Manifest I/O: inputs are config_infer_override; outputs are synthetic_ct_volumes and result_json.

Instructions

  • Read skill_manifest.yaml before changing arguments, side effects, or validation gates.
  • Run scripts/run_rflow_ct.py through the documented command below; keep outputs under a caller-provided run directory.
  • If a host agent exposes run_script, use run_script("scripts/run_rflow_ct.py", args=[...]); otherwise run the Bash/Python command shown below.
  • For generation, use the upstream runtime requirements. For a preflight, the wrapper needs only NumPy, NiBabel, and Typer to start. Pass the caller’s config, output directory, and seed to the same entrypoint.
  • Do not add rm, mkdir, or any cleanup of --output-dir; the wrapper creates it. Use a fresh --output-dir instead of deleting one.
  • Check the emitted JSON and paired verifier guidance before treating the run as evidence.

Available Scripts

| Script | Purpose | Arguments | |---|---|---| | scripts/_anatomy.py | Internal helper used by the primary entrypoint. | Imported only; do not call directly. | | scripts/_summary_card.py | Internal helper used by the primary entrypoint. | Imported only; do not call directly. | | scripts/list_anatomies.py | Helper command for catalog or anatomy lookup. | [--region REGION] [--filter TEXT] [--controllable] | | scripts/run_rflow_ct.py | Primary entrypoint declared by skill_manifest.yaml. | CONFIG_INFER.json --output-dir OUT_DIR [--random-seed N] [--version rflow-ct] [--yes] | | scripts/run_ct_mask.py | Advanced diagnostic helper for standalone raw MAISI mask generation. | REQUEST.json --output-dir OUT_DIR [--random-seed N] [--preflight-only] [--yes] | | scripts/run_ct_from_mask.py | Advanced helper for CT image generation from a MAISI label mask. | REQUEST.json --output-dir OUT_DIR [--random-seed N] [--yes] | | scripts/run_ct_image.py | Advanced helper for CT image-only generation without paired labels. | MODEL_CONFIG.json --output-dir OUT_DIR [--version rflow-ct] [--random-seed N] [--yes] |

Prerequisites

  • Required environment variables: NV_GENERATE_ROOT.
  • Runtime requirements: GPU/CUDA when declared by the manifest; Python packages listed in runtime.side_effects.pip_packages.
  • Side effects: writes generated outputs under the caller's --output-dir, may cache model assets under ~/.cache/huggingface/, and may contact https://huggingface.co or https://github.com during setup.
  • Run commands from the repository root unless an existing section below says otherwise.

Limitations

  • This is a thin wrapper. Inference, sampling, and decoding are delegated entirely to NVIDIA-Medtech/NV-Generate-CTMR's scripts.inference. Do not modify code under $NV_GENERATE_ROOT.
  • rflow-ct requires CUDA and ≈ 16 GB VRAM minimum for the default 256³ output_size. Larger output_size (e.g. 512×512×768) needs an A100/H100.
  • Output volumes are synthetic. They are not safe to use as training data for production medtech models without an independent quality review.
  • Not for clinical deployment, clinical interpretation, autonomous diagnosis, regulatory submission.

Troubleshooting

| Error | Cause | Fix | |---|---|---| | Missing dependency or import error | Runtime package drift from skill_manifest.yaml. | Install the packages declared in the manifest or use the documented setup command. | | Empty or schema-invalid output | Wrong input path, unsupported modality, or upstream failure. | Re-run with a known fixture and inspect the wrapper JSON plus stderr. | | Validation gate failure | Output violated a declared engineering invariant. | Keep the failed evidence pack and use the gate message to repair inputs or wrapper code. |

Wraps the upstream NVIDIA-Medtech/NV-Generate-CTMR rectified-flow synthesis pipeline. The wrapper does not reimplement diffusion, sampling, or autoencoder decoding — it shells out to the upstream scripts.inference entry point exactly as the project's README documents and inspects the produced image/mask pairs.

Preconditions

  1. If NV_GENERATE_ROOT already names a local checkout, the wrapper uses it and records its current commit in the result. Otherwise, create the recommended pinned default checkout (one-time):

    if [ -z "${NV_GENERATE_ROOT:-}" ]; then
      export NV_GENERATE_COMMIT=61c4ec709b84cad468852243c48e250bec732074
      export NV_GENERATE_ROOT="$HOME/.cache/nvidia-skills/upstreams/NV-Generate-CTMR-61c4ec7"
      if [ ! -d "$NV_GENERATE_ROOT/.git" ]; then
        git clone https://github.com/NVIDIA-Medtech/NV-Generate-CTMR.git "$NV_GENERATE_ROOT"
        git -C "$NV_GENERATE_ROOT" checkout --detach "$NV_GENERATE_COMMIT"
      fi
    fi
    python -m pip install -r "$NV_GENERATE_ROOT/requirements.txt"
    
  2. Download the rflow-ct weights and the mask-candidate datasets into the clone (one-time, ≈ 5.5 GB):

    cd "$NV_GENERATE_ROOT"
    python -m scripts.download_model_data --version rflow-ct --root_dir "./"
    

    The mask candidates (datasets/all_masks_flexible_size_and_spacing_4000) condition the diffusion sampler; omitting them via --model_only will make the inference script fail with a missing-file error at startup. The anatomy-size condition file is also part of the full CT download and is needed for controllable mask generation.

  3. NVIDIA GPU with ≥ 16 GB VRAM and CUDA. There is no CPU fallback.

For agent-generated user run commands, prefer the short wrapper command in Usage. Do not prepend clone or model-download setup steps when NV_GENERATE_ROOT or the repo-local upstream cache is already present. In a fresh Python environment, still include python -m pip install -r "$NV_GENERATE_ROOT/requirements.txt" before the wrapper unless the active environment has already proven those imports are available; cached weights do not imply cached Python packages. Run the wrapper from the medical-AI-skills repo root. If setup requires cd "$NV_GENERATE_ROOT", return to the Medical AI Skills repo before invoking skills/nv-generate-ct-rflow/scripts/run_rflow_ct.py.

Usage

export NV_GENERATE_ROOT="${NV_GENERATE_ROOT:-$HOME/.cache/nvidia-skills/upstreams/NV-Generate-CTMR-61c4ec7}" && \
python -m pip install -r "$NV_GENERATE_ROOT/requirements.txt" && \
python skills/nv-generate-ct-rflow/scripts/run_rflow_ct.py \
  PATH_TO_CONFIG_INFER.json \
  --output-dir runs/nv_generate_ct_rflow_demo \
  --random-seed 0 \
  --version rflow-ct

Replace PATH_TO_CONFIG_INFER.json with the user's actual request/config path. Do not copy the fixture path from this document unless the user explicitly asked to run that fixture. If the user says "the case request is at runs/.../chest_lung_tumor_controllable.json", that exact path is the first positional argument to scripts/run_rflow_ct.py.

The fixture argument is a config_infer.json override file: it can replace num_output_samples, body_region, anatomy_list, controllable_anatomy_size, output_size, and spacing. Pass default to use the upstream config verbatim. The wrapper stages the override into the upstream tree before running.

Fixture catalog

fixtures/ ships curated configs for common paired synthesis use cases: chest lung lobes, chest with controllable lung tumor, abdomen solid organs, abdomen with controllable hepatic tumor, head + cervical spine, pelvis. See fixtures/README.md for the full table.

Helper commands

# Browse the 132-class label_dict grouped by body region.
python skills/nv-generate-ct-rflow/scripts/list_anatomies.py --region chest
python skills/nv-generate-ct-rflow/scripts/list_anatomies.py --controllable
python skills/nv-generate-ct-rflow/scripts/list_anatomies.py --filter tumor

# Validate a fixture and preview cost without launching inference.
NV_GENERATE_ROOT=$HOME/.cache/nvidia-skills/upstreams/NV-Generate-CTMR-61c4ec7 \
  python skills/nv-generate-ct-rflow/scripts/run_rflow_ct.py \
    skills/nv-generate-ct-rflow/fixtures/abdomen_liver_spleen.json \
    --output-dir runs/preview --preflight-only

Advanced helpers stay inside this skill for debugging and less-common CT generation modes. Use them only when the user explicitly asks for that mode:

# Raw MAISI mask diagnostic, useful for checking lung tumor -> label 23.
python skills/nv-generate-ct-rflow/scripts/run_ct_mask.py \
  skills/nv-generate-ct-rflow/fixtures/ct_mask_lung_tumor.json \
  --output-dir runs/ct_mask_debug --preflight-only

# CT image from an existing MAISI label mask with body label 200.
python skills/nv-generate-ct-rflow/scripts/run_ct_from_mask.py \
  skills/nv-generate-ct-rflow/fixtures/ct_from_mask_request_example.json \
  --output-dir runs/ct_from_mask_demo

# CT image-only generation without paired labels.
python skills/nv-generate-ct-rflow/scripts/run_ct_image.py \
  skills/nv-generate-ct-rflow/fixtures/ct_image_only_default.json \
  --output-dir runs/ct_image_only_demo --version rflow-ct

For a preflight, run this from the installed skill directory. The upstream source checkout supplies the anatomy dictionary and default configs. A preflight checks for CUDA and model data without downloading weights.

python scripts/run_rflow_ct.py PATH_TO_CONFIG_INFER.json \
  --output-dir OUT_DIR --random-seed 0 --preflight-only

Report the emitted JSON, including prerequisite failures. For a missing checkout, only the request fields supplied by the caller can be checked. Confirm runtime and VRAM estimates on the target GPU before generation.

The wrapper runs preflight on every invocation (regardless of --preflight-only): config-schema bounds, anatomy names matched against the upstream label_dict, body_region in the supported set, controllable_anatomy_size constraints, upstream CT output-size/spacing contracts, body-region-aware x/y FOV minimums, dataset presence under $NV_GENERATE_ROOT/datasets/, CUDA available, and an estimated peak VRAM / wall-time. Runs estimated to exceed 5 min wall-time or 30 GB VRAM peak require --yes to proceed.

Each invocation runs python -m scripts.inference -t configs/config_network_rflow.json -i configs/config_infer.json -e configs/environment_rflow-ct.json --random-seed <s> --version rflow-ct. Output evidence records the upstream git commit, model checkpoint hashes, the rendered config, per-sample image/mask geometry, mask label set, image HU range summary, and per-class voxel volumes.

When controllable_anatomy_size is non-empty, upstream ignores the broader anatomy_list for the saved paired label map and filters labels to the controllable anatomy names. The saved paired label values are local 1..N ordinals, not raw MAISI label IDs. Read output.output_label_mapping in result_json to map saved output labels back to source labels; for example, output label 1 can represent MAISI label 23 (lung tumor). For curated lung-tumor examples, prefer a controllable size around 0.5 or larger; smaller requests such as 0.2 can produce absent or extremely small label-23 components for some seeds.

For FOV and setup details, see references/fov-and-downloads.md. For advanced helper label-space details, see references/ct-mask-label-space.md and references/ct-from-mask-format.md.

Visual sample card

Alongside the NIfTI pairs, the wrapper writes summary.html to the output directory: a per-sample mid-slice triptych (axial / coronal / sagittal) with label overlay, plus a table of the rendered config and verifier-facing aggregates. Lets you eyeball the result without firing up 3D Slicer. Pass --no-summary-card to skip.

Anatomy plausibility (label-set sanity, voxel HU range as CT, image/mask geometry match, declared output labels present, lung-lobe HU floor) is checked by verifiers/ct-synthesis-quality-v1.

Not for clinical interpretation, training data for production deployment, or any non-synthetic-research use.

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/synthetic-ct-generation-rflow-ct-mwyhd8cq/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/synthetic-ct-generation-rflow-ct-mwyhd8cq' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/synthetic-ct-generation-rflow-ct-mwyhd8cq/download' --output '.skill-downloads/synthetic-ct-generation-rflow-ct-mwyhd8cq/SKILL.md.part' && mv '.skill-downloads/synthetic-ct-generation-rflow-ct-mwyhd8cq/SKILL.md.part' '.skill-downloads/synthetic-ct-generation-rflow-ct-mwyhd8cq/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Outils déclarés par l’auteur (à vérifier dans votre agent) : Bash

Extrait original : Prerequisites
  • Required environment variables: NV_GENERATE_ROOT.
  • Runtime requirements: GPU/CUDA when declared by the manifest; Python packages listed in runtime.side_effects.pip_packages.
  • Side effects: writes generated outputs under the caller's --output-dir, may cache model assets under ~/.cache/huggingface/, and may contact https://huggingface.co or https://github.com during setup.
  • Run commands from the repository root unless an existing section below says otherwise.

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/synthetic-ct-generation-rflow-ct-mwyhd8cq/SKILL.md' && test -s '.skill-downloads/synthetic-ct-generation-rflow-ct-mwyhd8cq/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/nv-generate-ct-rflow' && cp -R '.skill-downloads/synthetic-ct-generation-rflow-ct-mwyhd8cq' '.claude/skills/nv-generate-ct-rflow'

Cursor
test -f '.skill-downloads/synthetic-ct-generation-rflow-ct-mwyhd8cq/SKILL.md' && test -s '.skill-downloads/synthetic-ct-generation-rflow-ct-mwyhd8cq/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/nv-generate-ct-rflow' && cp -R '.skill-downloads/synthetic-ct-generation-rflow-ct-mwyhd8cq' '.cursor/skills/nv-generate-ct-rflow'

Codex
test -f '.skill-downloads/synthetic-ct-generation-rflow-ct-mwyhd8cq/SKILL.md' && test -s '.skill-downloads/synthetic-ct-generation-rflow-ct-mwyhd8cq/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/nv-generate-ct-rflow' && cp -R '.skill-downloads/synthetic-ct-generation-rflow-ct-mwyhd8cq' '.agents/skills/nv-generate-ct-rflow'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/synthetic-ct-generation-rflow-ct-mwyhd8cq'

openskills read 'synthetic-ct-generation-rflow-ct-mwyhd8cq'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/synthetic-ct-generation-rflow-ct-mwyhd8cq/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires