nv-generate-mr-brain
Original:🇺🇸 English
Translated
2 scripts
Used for generating synthetic brain MRI volumes with NV-Generate-CTMR rflow-mr-brain. Not for production training data.
5installs
Sourcenvidia/skills
Added on
NPX Install
npx skill4agent add nvidia/skills nv-generate-mr-brainTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →NV-Generate-MR-Brain
Purpose
- Used for generating synthetic brain MRI volumes with NV-Generate-CTMR rflow-mr-brain. Not for production training data.
- 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, and validation.
- Manifest I/O: inputs are ; outputs are
model_config_overrideandsynthetic_mr_brain_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_mr_brain.py - If a host agent exposes , use
run_script; otherwise run the Bash/Python command shown below.run_script("scripts/run_mr_brain.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 |
|---|---|---|
| Primary entrypoint declared by skill_manifest.yaml. | |
Prerequisites
- 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 or the repo-local fallback at .workbench_data/upstreams/NV-Generate-CTMR.
scripts.diff_model_infer - rflow-mr-brain generates image-only synthetic brain MRI volumes. It does not emit paired segmentation masks.
- Output volumes are synthetic. They are not safe as training data for production medtech models without 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
MR brain image-only generation workflow. The wrapper does not reimplement
diffusion sampling or autoencoder decoding. It stages config overrides, runs
the documented command for
, then summarizes the generated NIfTI volume.
NVIDIA-Medtech/NV-Generate-CTMRpython -m scripts.diff_model_inferrflow-mr-brainExact Runnable Surface
For user run commands, use this repo-root wrapper path exactly:
bash
export NV_GENERATE_ROOT="${NV_GENERATE_ROOT:-.workbench_data/upstreams/NV-Generate-CTMR}" && \
python -m pip install -r "$NV_GENERATE_ROOT/requirements.txt" && \
python skills/nv-generate-mr-brain/scripts/run_mr_brain.py PATH_TO_MR_BRAIN_CONFIG.json --output-dir OUT_DIR --modality mri_t1 --random-seed 1234Do not invent , , , or commands. must be the user's supplied request path.
generate.shinfer.pyMedical AI Skills runpython -m nv_generate_mr_brainPATH_TO_MR_BRAIN_CONFIG.jsonPreconditions
Clone and install the upstream repo once. In this Medical AI Skills checkout, prefer
the repo-local cache path when it exists:
bash
mkdir -p .workbench_data/upstreams
test -d .workbench_data/upstreams/NV-Generate-CTMR/.git || \
git clone https://github.com/NVIDIA-Medtech/NV-Generate-CTMR.git \
.workbench_data/upstreams/NV-Generate-CTMR
export NV_GENERATE_ROOT=.workbench_data/upstreams/NV-Generate-CTMR
pip install -r "$NV_GENERATE_ROOT/requirements.txt"Download the MR-brain weights:
bash
cd "$NV_GENERATE_ROOT"
python -m scripts.download_model_data --version rflow-mr-brain --root_dir ./ --model_onlyRuntime needs an NVIDIA GPU with at least 16 GB VRAM. There is no CPU
fallback in the upstream path.
The wrapper also searches if
is unset or points at a stale clone.
.workbench_data/upstreams/NV-Generate-CTMRNV_GENERATE_ROOTFor agent-generated user run commands, use the command in Usage. Do not prepend
clone or model-download setup steps when the repo-local
upstream cache already exists. 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. If setup requires , return to the Medical AI Skills repo before invoking
.
pip install -r "$NV_GENERATE_ROOT/requirements.txt"cd "$NV_GENERATE_ROOT"skills/nv-generate-mr-brain/scripts/run_mr_brain.pyUsage
bash
export NV_GENERATE_ROOT="${NV_GENERATE_ROOT:-.workbench_data/upstreams/NV-Generate-CTMR}" && \
python -m pip install -r "$NV_GENERATE_ROOT/requirements.txt" && \
python skills/nv-generate-mr-brain/scripts/run_mr_brain.py \
PATH_TO_MR_BRAIN_CONFIG.json \
--output-dir runs/nv_generate_mr_brain_demo \
--modality mri_t1 \
--random-seed 1234Replace 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 request is at
", that exact path is the first positional
argument to .
PATH_TO_MR_BRAIN_CONFIG.jsonruns/.../default_mri_t1.jsonscripts/run_mr_brain.pySupported MR-brain modality names are , , ,
, , ,
, , and
. These map to the upstream
IDs documented in the README.
For FOV and setup details, see .
mrimri_t1mri_t2mri_flairmri_swimri_t1_skull_strippedmri_t2_skull_strippedmri_flair_skull_strippedmri_swi_skull_strippedconfigs/modality_mapping.jsonreferences/fov-and-downloads.mdThe fixture argument is a small JSON override for
. Pass to use
the upstream defaults plus the CLI modality and random seed. Common override
keys are , , , , and
.
configs/config_maisi_diff_model_rflow-mr-brain.jsondefaultdimspacingnum_inference_stepscfg_guidance_scalemodalityEach run records the staged config, model inventory, upstream command, output
geometry, spacing, affine, intensity range, and non-constant / finite-data
checks. Output volumes are synthetic and are not safe as production training
data without independent review.
Not for clinical interpretation, production deployment, autonomous diagnosis,
or regulatory submission.