nv-generate-ct-rflow
Original:🇺🇸 English
Translated
12 scripts
Used for generating synthetic CT volumes and masks with NV-Generate-CTMR rflow-ct. Not for production training data without review.
3installs
Sourcenvidia/skills
Added on
NPX Install
npx skill4agent add nvidia/skills nv-generate-ct-rflowTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →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 ; outputs are
config_infer_overrideandsynthetic_ct_volumes.result_json
Instructions
- Read before changing arguments, side effects, or validation gates.
skill_manifest.yaml - Run through the documented command below; keep outputs under a caller-provided run directory.
scripts/run_rflow_ct.py - If a host agent exposes , use
run_script; otherwise run the Bash/Python command shown below.run_script("scripts/run_rflow_ct.py", args=[...]) - Emit a single bash code block, and keep the step in that same command — the runtime may be a fresh environment without
python -m pip install -r "$NV_GENERATE_ROOT/requirements.txt"/MONAI, so dropping the install fails withnibabel.ModuleNotFoundError - Do not add ,
rm, or any cleanup ofmkdir; the wrapper creates it. Use a fresh--output-dirinstead of deleting one.--output-dir - Check the emitted JSON and paired verifier guidance before treating the run as evidence.
Available Scripts
| Script | Purpose | Arguments |
|---|---|---|
| Internal helper used by the primary entrypoint. | Imported only; do not call directly. |
| Internal helper used by the primary entrypoint. | Imported only; do not call directly. |
| Helper command for catalog or anatomy lookup. | |
| Primary entrypoint declared by skill_manifest.yaml. | |
| Advanced diagnostic helper for standalone raw MAISI mask generation. | |
| Advanced helper for CT image generation from a MAISI label mask. | |
| Advanced helper for CT image-only generation without paired labels. | |
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 , may cache model assets under
--output-dir, and may contact~/.cache/huggingface/orhttps://huggingface.coduring setup.https://github.com - 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 . Do not modify code under $NV_GENERATE_ROOT.
scripts.inference - 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 | 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
rectified-flow synthesis pipeline. The wrapper does not reimplement diffusion,
sampling, or autoencoder decoding — it shells out to the upstream
entry point exactly as the project's README documents and
inspects the produced image/mask pairs.
NVIDIA-Medtech/NV-Generate-CTMRscripts.inferencePreconditions
-
Clone the upstream repo and pointat it (one-time):
NV_GENERATE_ROOTbashtest -d "$HOME/nv-generate-ctmr/.git" || \ git clone https://github.com/NVIDIA-Medtech/NV-Generate-CTMR.git $HOME/nv-generate-ctmr export NV_GENERATE_ROOT=$HOME/nv-generate-ctmr pip install -r "$NV_GENERATE_ROOT/requirements.txt" -
Download theweights and the mask-candidate datasets into the clone (one-time, ≈ 5.5 GB):
rflow-ctbashcd "$NV_GENERATE_ROOT" python -m scripts.download_model_data --version rflow-ct --root_dir "./"The mask candidates () condition the diffusion sampler; omitting them viadatasets/all_masks_flexible_size_and_spacing_4000will 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.--model_only -
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
or the repo-local upstream cache is already present. In a fresh Python
environment, still include
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 , return to the Medical AI Skills repo before invoking
.
NV_GENERATE_ROOTpip install -r "$NV_GENERATE_ROOT/requirements.txt"cd "$NV_GENERATE_ROOT"skills/nv-generate-ct-rflow/scripts/run_rflow_ct.pyUsage
bash
export NV_GENERATE_ROOT="${NV_GENERATE_ROOT:-$HOME/nv-generate-ctmr}" && \
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-ctReplace 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
", that exact path is the first
positional argument to .
PATH_TO_CONFIG_INFER.jsonruns/.../chest_lung_tumor_controllable.jsonscripts/run_rflow_ct.pyThe fixture argument is a override file: it can replace
, , , ,
, and . Pass to use the upstream config
verbatim. The wrapper stages the override into the upstream tree before
running.
config_infer.jsonnum_output_samplesbody_regionanatomy_listcontrollable_anatomy_sizeoutput_sizespacingdefaultFixture catalog
fixtures/fixtures/README.mdHelper commands
bash
# 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/nv-generate-ctmr \
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-onlyAdvanced helpers stay inside this skill for debugging and less-common CT
generation modes. Use them only when the user explicitly asks for that mode:
bash
# 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-ctThe wrapper runs preflight on every invocation (regardless of
): 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
, CUDA available, and an estimated peak VRAM /
wall-time. Runs estimated to exceed 5 min wall-time or 30 GB VRAM peak require
to proceed.
--preflight-only$NV_GENERATE_ROOT/datasets/--yesEach invocation runs . 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.
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-ctWhen is non-empty, upstream ignores the broader
for the saved paired label map and filters labels to the
controllable anatomy names. The saved paired label values are local
ordinals, not raw MAISI label IDs. Read in
to map saved output labels back to source labels; for example,
output label can represent MAISI label ().
For curated lung-tumor examples, prefer a controllable size around or
larger; smaller requests such as can produce absent or extremely small
label-23 components for some seeds.
controllable_anatomy_sizeanatomy_list1..Noutput.output_label_mappingresult_json123lung tumor0.50.2For FOV and setup details, see . For
advanced helper label-space details, see
and .
references/fov-and-downloads.mdreferences/ct-mask-label-space.mdreferences/ct-from-mask-format.mdVisual sample card
Alongside the NIfTI pairs, the wrapper writes 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 to skip.
summary.html--no-summary-cardAnatomy 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_v1Not for clinical interpretation, training data for production deployment, or
any non-synthetic-research use.