Generated banner for Nv Generate Ct Rflow
Generated logo for Nv Generate Ct Rflow

Nv Generate Ct Rflow

NVIDIAOfficialCreated by NVIDIA MedTech Team

  • Skill
  • Tool integration
  • Science and research
  • Apache-2.0
  • Medium risk
  • Has scripts

From the author

Used for generating synthetic CT volumes and masks with NV-Generate-CTMR rflow-ct. Not for production training data without review.
— the description by NVIDIA MedTech Team

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

The nv-generate-ct-rflow skill provides a standardized interface for the NVIDIA-Medtech NV-Generate-CTMR rectified-flow synthesis pipeline. It manages configuration staging, output path handling, and validation for generating synthetic CT volumes and paired masks. The skill includes helper utilities for anatomy lookup, diagnostic mask generation, and image-only synthesis, while delegating core inference and sampling to the upstream repository.

What it does

  • Generates synthetic CT volumes and corresponding label masks.
  • Supports controllable anatomy generation for specific tumor types.
  • Provides diagnostic tools for raw mask generation and image-from-mask synthesis.
  • Validates input configurations against schema bounds and anatomy constraints.
  • Produces summary cards for visual inspection of generated outputs.
  • Maps paired output labels back to standard MAISI label IDs.

When to use it

  • When you need to generate synthetic CT image data for research purposes.
  • When you require paired CT volumes and segmentation masks.
  • When you need to perform controllable synthesis of specific anatomical regions or tumors.
  • When you need to validate configuration files before executing large-scale inference.

Advantages

  • Automates environment setup and dependency management for the upstream pipeline.
  • Ensures consistent output structure and metadata recording.
  • Provides built-in preflight checks to prevent common configuration errors.
  • Simplifies complex inference workflows through standardized wrapper commands.

Usage examples

“Generate a synthetic CT volume using the chest lung tumor controllable configuration.”
The agent executes the wrapper script with the specified configuration, producing synthetic CT volumes and masks in the designated output directory.
“List all available chest anatomies for generation.”
The agent runs the anatomy lookup tool and returns a list of 132-class labels grouped by the chest region.
“Validate the abdomen liver and spleen configuration without running full inference.”
The agent performs a preflight check on the configuration file and reports any schema or constraint violations without generating image data.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/nvidia/nv-generate-ct-rflow/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip nv-generate-ct-rflow.zip -d .agents/skills

Documentation by NVIDIA MedTech Team

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.

  • Emit a single bash code block, and keep the python -m pip install -r "$NV_GENERATE_ROOT/requirements.txt" step in that same command — the runtime may be a fresh environment without nibabel/MONAI, so dropping the install fails with ModuleNotFoundError.

  • 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

ScriptPurposeArguments
scripts/_anatomy.pyInternal helper used by the primary entrypoint.Imported only; do not call directly.
scripts/_summary_card.pyInternal helper used by the primary entrypoint.Imported only; do not call directly.
scripts/list_anatomies.pyHelper command for catalog or anatomy lookup.[--region REGION] [--filter TEXT] [--controllable]
scripts/run_rflow_ct.pyPrimary entrypoint declared by skill_manifest.yaml.CONFIG_INFER.json --output-dir OUT_DIR [--random-seed N] [--version rflow-ct] [--yes]
scripts/run_ct_mask.pyAdvanced 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.pyAdvanced helper for CT image generation from a MAISI label mask.REQUEST.json --output-dir OUT_DIR [--random-seed N] [--yes]
scripts/run_ct_image.pyAdvanced 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

ErrorCauseFix
Missing dependency or import errorRuntime package drift from skill_manifest.yaml.Install the packages declared in the manifest or use the documented setup command.
Empty or schema-invalid outputWrong input path, unsupported modality, or upstream failure.Re-run with a known fixture and inspect the wrapper JSON plus stderr.
Validation gate failureOutput 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

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.

Files

tests/test_run_rflow_ct.py

# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Unit tests for skills/nv-generate-ct-rflow/scripts/run_rflow_ct.py.

These do NOT exercise the upstream NV-Generate-CTMR subprocess (that needs a
GPU + ~5GB of weights). They cover the wrapper's deterministic surface:
config override loading, pair scanning + summarization, and aggregate
verdicts.
"""

import importlib.util
import json
from pathlib import Path

import nibabel as nib
import numpy as np
import pytest

SCRIPT = Path(__file__).resolve().parents[1] / "scripts" / "run_rflow_ct.py"
spec = importlib.util.spec_from_file_location("run_rflow_ct", SCRIPT)
mod = importlib.util.module_from_spec(spec)
assert spec.loader is not None
spec.loader.exec_module(mod)


def _save_pair(
    out_dir: Path, stem: str, image: np.ndarray, mask: np.ndarray, affine: np.ndarray
) -> None:
    out_dir.mkdir(parents=True, exist_ok=True)
    nib.save(
        nib.Nifti1Image(image.astype(np.float32), affine), str(out_dir / f"{stem}_image.nii.gz")
    )
    nib.save(nib.Nifti1Image(mask.astype(np.int16), affine), str(out_dir / f"{stem}_label.nii.gz"))


def test_load_config_override_default_returns_empty():
    override, source = mod._load_config_override("default")
    assert override == {}
    assert source is None


def test_load_config_override_strips_comment_keys(tmp_path):
    p = tmp_path / "cfg.json"
    p.write_text(json.dumps({"_comment": "drop me", "num_output_samples": 2}))
    override, source = mod._load_config_override(str(p))
    assert override == {"num_output_samples": 2}
    assert source == str(p)


def test_load_config_override_rejects_unknown_key(tmp_path):
    import typer

    p = tmp_path / "bad.json"
    p.write_text(json.dumps({"num_output_samples": 1, "nonsense": 7}))
    with pytest.raises(typer.BadParameter):
        mod._load_config_override(str(p))


def test_stage_config_forces_caller_output_dir_when_upstream_cache_is_mutated(tmp_path):
    upstream = tmp_path / "upstream"
    configs = upstream / "configs"
    configs.mkdir(parents=True)
    stale_out = tmp_path / "stale_repeat"
    requested_out = tmp_path / "requested_repeat"
    (configs / "config_infer.json").write_text(
        json.dumps(
            {
                "num_output_samples": 1,
                "output_dir": str(stale_out),
                "spacing": [1.0, 1.0, 1.0],
            }
        )
    )
    (configs / "environment_rflow-ct.json").write_text(
        json.dumps({"output_dir": str(stale_out), "model_dir": "models"})
    )

    rendered_infer, rendered_env, infer_path, env_path = mod._stage_config(
        upstream,
        requested_out / "_staged_configs",
        {"spacing": [1.5, 1.5, 2.0]},
        requested_out,
        "rflow-ct",
    )

    assert rendered_infer["output_dir"] == str(requested_out)
    assert rendered_env["output_dir"] == str(requested_out)
    assert rendered_infer["spacing"] == [1.5, 1.5, 2.0]
    assert json.loads(infer_path.read_text())["output_dir"] == str(requested_out)
    assert json.loads(env_path.read_text())["output_dir"] == str(requested_out)


def test_validate_override_bounds_rejects_abdomen_head_sized_fov():
    errors = mod._validate_override_bounds(
        {
            "body_region": ["abdomen"],
            "anatomy_list": ["liver"],
            "output_size": [256, 256, 128],
            "spacing": [1.0, 1.0, 2.0],
        }
    )

    assert any("at least 384 mm" in e for e in errors)


def test_validate_override_bounds_infers_non_head_fov_from_anatomy_list():
    errors = mod._validate_override_bounds(
        {
            "body_region": [],
            "anatomy_list": ["liver"],
            "output_size": [256, 256, 128],
            "spacing": [1.0, 1.0, 2.0],
        }
    )

    assert any("non-head CT body regions/anatomies" in e for e in errors)


def test_validate_override_bounds_allows_head_256mm_fov():
    errors = mod._validate_override_bounds(
        {
            "body_region": ["head"],
            "anatomy_list": ["brain"],
            "output_size": [256, 256, 128],
            "spacing": [1.0, 1.0, 2.0],
        }
    )

    assert errors == []


def test_validate_override_bounds_rejects_ct_geometry_outside_upstream_contract():
    errors = mod._validate_override_bounds(
        {
            "output_size": [320, 384, 96],
            "spacing": [0.4, 0.6, 6.0],
        }
    )

    joined = " ".join(errors)
    assert "output_size[0] and output_size[1] must match" in joined
    assert "upstream-supported CT xy sizes" in joined
    assert "upstream-supported CT z sizes" in joined
    assert "spacing[0] and spacing[1] must match" in joined
    assert "upstream-supported CT xy range" in joined
    assert "upstream-supported CT z range" in joined


def test_summarize_pair_finds_label_and_matches_geometry(tmp_path):
    affine = np.diag([float("1.5"), float("1.5"), float("2.0"), float("1.0")])
    image = np.linspace(-1000, 500, num=4 * 4 * 4).reshape(4, 4, 4)
    mask = np.zeros((4, 4, 4), dtype=np.int16)
    mask[1:3, 1:3, 1:3] = 23
    _save_pair(tmp_path, "sample_20260519_120000_000000", image, mask, affine)

    image_path = tmp_path / "sample_20260519_120000_000000_image.nii.gz"
    rec = mod._summarize_pair(image_path)

    assert rec["image_readable"] is True
    assert rec["label_readable"] is True
    assert rec["image_shape"] == [4, 4, 4]
    assert rec["label_shape"] == [4, 4, 4]
    assert rec["shape_match"] is True
    assert rec["spacing_match"] is True
    assert rec["affine_match"] is True
    assert rec["image_hu_negative_present"] is True
    assert rec["image_hu_bone_present"] is True
    assert rec["image_nonconstant"] is True
    assert rec["label_ids_present"] == [23]
    assert rec["label_foreground_voxels"] == 8


def test_scan_outputs_accepts_prefix_image_label_names(tmp_path):
    affine = np.eye(4)
    image = np.linspace(-1000, 500, num=4 * 4 * 4).reshape(4, 4, 4)
    mask = np.zeros((4, 4, 4), dtype=np.int16)
    mask[0, 0, 0] = 1
    nib.save(nib.Nifti1Image(image.astype(np.float32), affine), str(tmp_path / "image_0000.nii.gz"))
    nib.save(nib.Nifti1Image(mask.astype(np.int16), affine), str(tmp_path / "label_0000.nii.gz"))

    image_paths = mod._scan_outputs(tmp_path)
    samples = [mod._summarize_pair(path) for path in image_paths]

    assert image_paths == [tmp_path / "image_0000.nii.gz"]
    assert samples[0]["label_path"] == str(tmp_path / "label_0000.nii.gz")
    assert samples[0]["shape_match"] is True


def test_summarize_pair_flags_constant_image(tmp_path):
    affine = np.eye(4)
    image = np.zeros((4, 4, 4), dtype=np.float32)
    mask = np.zeros((4, 4, 4), dtype=np.int16)
    _save_pair(tmp_path, "sample_const", image, mask, affine)
    rec = mod._summarize_pair(tmp_path / "sample_const_image.nii.gz")
    assert rec["image_nonconstant"] is False
    assert rec["image_hu_negative_present"] is False
    assert rec["image_hu_bone_present"] is False
    assert rec["label_foreground_voxels"] == 0


def test_summarize_pair_handles_missing_label(tmp_path):
    affine = np.eye(4)
    nib.save(
        nib.Nifti1Image(np.zeros((4, 4, 4), dtype=np.float32), affine),
        str(tmp_path / "sample_x_image.nii.gz"),
    )
    rec = mod._summarize_pair(tmp_path / "sample_x_image.nii.gz")
    assert rec["image_readable"] is True
    assert rec["label_readable"] is False
    assert rec["label_path"] is None


def test_aggregate_pass(tmp_path):
    affine = np.eye(4)
    img = np.array([-900.0, 300.0] * 32).reshape(4, 4, 4)
    mask = np.zeros((4, 4, 4), dtype=np.int16)
    mask[0, 0, 0] = 1
    _save_pair(tmp_path, "sample_a", img, mask, affine)
    _save_pair(tmp_path, "sample_b", img, mask, affine)
    samples = [mod._summarize_pair(p) for p in mod._scan_outputs(tmp_path)]
    agg = mod._aggregate(samples, None)
    assert agg["num_samples"] == 2
    assert agg["all_pairs_readable"] is True
    assert agg["all_geometry_consistent"] is True
    assert agg["any_foreground_present"] is True
    assert agg["all_images_nonconstant"] is True
    assert agg["all_images_hu_like"] is True
    assert agg["all_effective_anatomy_labels_present"] is True


def test_effective_label_mapping_preserves_maisi_id_for_controllable_request():
    rendered = {
        "anatomy_list": ["lung tumor", "heart"],
        "controllable_anatomy_size": [["lung tumor", 0.5]],
    }
    label_dict = {"lung tumor": 23, "heart": 2}

    assert mod._effective_anatomy_names(rendered) == ["lung tumor"]
    assert mod._expected_output_label_mapping(rendered, label_dict) == [
        {"anatomy": "lung tumor", "maisi_label_id": 23, "output_label_id": 1}
    ]


def test_aggregate_checks_saved_output_label_ordinals_not_raw_maisi_ids(tmp_path):
    affine = np.eye(4)
    img = np.array([-900.0, 300.0] * 32).reshape(4, 4, 4)
    mask = np.zeros((4, 4, 4), dtype=np.int16)
    mask[0, 0, 0] = 1
    _save_pair(tmp_path, "sample_lung_tumor", img, mask, affine)
    samples = [mod._summarize_pair(p) for p in mod._scan_outputs(tmp_path)]

    agg = mod._aggregate(
        samples,
        [{"anatomy": "lung tumor", "maisi_label_id": 23, "output_label_id": 1}],
    )

    assert agg["union_label_ids_present"] == [1]
    assert agg["expected_maisi_label_ids"] == [23]
    assert agg["expected_output_label_ids"] == [1]
    assert agg["missing_expected_output_label_ids"] == []
    assert agg["all_effective_anatomy_labels_present"] is True


def test_aggregate_reports_missing_expected_output_label(tmp_path):
    affine = np.eye(4)
    img = np.array([-900.0, 300.0] * 32).reshape(4, 4, 4)
    mask = np.zeros((4, 4, 4), dtype=np.int16)
    mask[0, 0, 0] = 1
    _save_pair(tmp_path, "sample_one_label", img, mask, affine)
    samples = [mod._summarize_pair(p) for p in mod._scan_outputs(tmp_path)]

    agg = mod._aggregate(
        samples,
        [
            {"anatomy": "lung tumor", "maisi_label_id": 23, "output_label_id": 1},
            {"anatomy": "heart", "maisi_label_id": 2, "output_label_id": 2},
        ],
    )

    assert agg["missing_expected_output_label_ids"] == [2]
    assert agg["all_effective_anatomy_labels_present"] is False
    assert mod._failure_reasons(0, samples, agg) == [
        "saved paired label map is missing expected output label id(s): [2]"
    ]


def test_curated_lung_tumor_fixture_uses_robust_size() -> None:
    fixture = (
        Path(__file__).resolve().parents[1] / "fixtures" / "chest_lung_tumor_controllable.json"
    )
    request = json.loads(fixture.read_text())

    assert request["controllable_anatomy_size"] == [["lung tumor", 0.5]]


def test_aggregate_flags_empty_foreground_and_constant_image(tmp_path):
    affine = np.eye(4)
    img = np.zeros((4, 4, 4), dtype=np.float32)
    mask = np.zeros((4, 4, 4), dtype=np.int16)
    _save_pair(tmp_path, "sample_z", img, mask, affine)
    samples = [mod._summarize_pair(p) for p in mod._scan_outputs(tmp_path)]
    agg = mod._aggregate(samples, None)
    assert agg["num_samples"] == 1
    assert agg["any_foreground_present"] is False
    assert agg["all_images_nonconstant"] is False
    assert agg["all_images_hu_like"] is False


def test_failure_reasons_report_upstream_failure_and_zero_samples():
    assert mod._failure_reasons(0, [{"image_readable": True}]) == []
    assert mod._failure_reasons(7, [{"image_readable": True}]) == [
        "upstream scripts.inference exited 7"
    ]
    assert mod._failure_reasons(0, []) == [
        "upstream scripts.inference produced zero image/label samples"
    ]
    assert mod._failure_reasons(7, []) == [
        "upstream scripts.inference exited 7",
        "upstream scripts.inference produced zero image/label samples",
    ]

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Declares allowed tools, Needs a command-line tool, Needs Python

Security

What our scanner noticed· Medium risk

  • Large base64-encoded blobs
  • Instructions that use the network
  • Scripts that your agent may run

This skill includes scripts that your agent may run. Read them before you use it.

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
NVIDIA MedTech Team
Publisher
NVIDIA (Official)
Source
NVIDIA/skills · skills/nv-generate-ct-rflow · commit fce3cca
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE-APACHE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by NVIDIA MedTech Team or NVIDIA.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download nv-generate-ct-rflow.zip