Generated banner for Nv Generate Mr Brain
Generated logo for Nv Generate Mr Brain

Nv Generate Mr Brain

NVIDIAOfficialCreated by NVIDIA MedTech Team

  • Skill
  • Content generator
  • Science and research
  • Apache-2.0
  • Medium risk
  • Has scripts

From the author

Used for generating synthetic T1, T2, FLAIR, SWI, or MRA brain MRI volumes with NV-Generate-CTMR MR-Brain v1. Not for production training data.
— the description by NVIDIA MedTech Team

AutoGineer summary

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

This skill provides a standardized wrapper for the NVIDIA NV-Generate-CTMR MR-Brain v1 model, enabling the generation of synthetic T1, T2, FLAIR, SWI, and MRA brain MRI volumes. It manages configuration staging, output path handling, and validation, ensuring that generated volumes are accompanied by metadata. The tool is intended for research and development purposes and is not suitable for clinical deployment, autonomous diagnosis, or as production training data without independent quality review.

What it does

  • Generates synthetic 3D brain MRI volumes for various modalities.
  • Supports T1, T2, FLAIR, SWI, and MRA modalities, including skull-stripped variants.
  • Handles configuration overrides for dimensions, spacing, and inference parameters.
  • Validates output volumes against defined engineering invariants.
  • Provides a consistent command-line interface for model inference.
  • Automates the setup of required model checkpoints and dependencies.

When to use it

  • When you need to generate synthetic brain MRI data for research or testing.
  • When you need to experiment with different MRI modalities like T1, T2, or FLAIR.
  • When you require a standardized, reproducible workflow for MR-Brain v1 inference.
  • When you need to verify the output geometry and intensity ranges of synthetic volumes.

Advantages

  • Provides a clean, consistent wrapper for complex upstream diffusion models.
  • Automates dependency management and model checkpoint verification.
  • Ensures reproducible results through controlled configuration and random seeding.
  • Includes built-in validation to check the integrity of generated NIfTI volumes.

Usage examples

“Generate a synthetic T1 brain MRI volume using default settings.”
The agent executes the wrapper script with the specified modality and output directory, producing a synthetic NIfTI volume and a result JSON.
“Create a synthetic FLAIR brain MRI with a custom random seed.”
The agent runs the inference pipeline with the --modality mri_flair and --random-seed flags, ensuring a reproducible synthetic output.

Install

  1. Download the skill as a ZIP:

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

    mkdir -p .agents/skills && unzip nv-generate-mr-brain.zip -d .agents/skills

Documentation by NVIDIA MedTech Team

NV-Generate-MR-Brain

Purpose

  • Used for generating synthetic T1, T2, FLAIR, SWI, or MRA brain MRI volumes with NV-Generate-CTMR rflow-mr-brain v1. 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 model_config_override; outputs are synthetic_mr_brain_volumes and result_json.

Instructions

  • Read skill_manifest.yaml before changing arguments, side effects, or validation gates.

  • Run scripts/run_mr_brain.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_mr_brain.py", args=[...]); otherwise run the Bash/Python command shown below.

  • For a command-shape review, do not install packages, clone repositories, download weights, or start GPU inference. Emit only the exact wrapper command with the supplied config path plus explicit --output-dir, --modality, and --random-seed values.

  • For an executable run, 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.

  • If --modality mri_mra is selected, state that upstream reports sparse MRA training coverage and that output quality is not guaranteed.

  • 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.

Examples

Command-shape review only (no setup or execution):

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 1234

For an executable run, use the setup-aware command under Usage.

Available Scripts

ScriptPurposeArguments
scripts/run_mr_brain.pyPrimary entrypoint declared by skill_manifest.yaml.MODEL_CONFIG.json --output-dir OUT_DIR --modality mri_t1 [--random-seed N] [--yes]

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 --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.diff_model_infer. Do not modify code under $NV_GENERATE_ROOT or the repo-local fallback at .workbench_data/upstreams/NV-Generate-CTMR.

  • 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

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 MR brain image-only generation workflow. The wrapper does not reimplement diffusion sampling or autoencoder decoding. It stages config overrides, runs the documented python -m scripts.diff_model_infer command for rflow-mr-brain, then summarizes the generated NIfTI volume.

Exact Runnable Surface

For user run commands, use this repo-root wrapper path exactly:

export NV_GENERATE_ROOT="${NV_GENERATE_ROOT:-$HOME/.cache/nvidia-skills/upstreams/NV-Generate-CTMR-da438fe}" && \
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 1234

Do not invent generate.sh, infer.py, Medical AI Skills run, or python -m nv_generate_mr_brain commands. PATH_TO_MR_BRAIN_CONFIG.json must be the user's supplied request path.

Preconditions

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 once:

if [ -z "${NV_GENERATE_ROOT:-}" ]; then
  export NV_GENERATE_COMMIT=da438fec6484cdb6f421f8c7051d954ebefff730
  export NV_GENERATE_ROOT="$HOME/.cache/nvidia-skills/upstreams/NV-Generate-CTMR-da438fe"
  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
pip install -r "$NV_GENERATE_ROOT/requirements.txt"

The wrapper executes upstream code only when NV_GENERATE_ROOT is at the exact manifest commit and its tracked files are clean. Keep model weights untracked under models/, and use the wrapper override JSON instead of editing upstream configs. Child processes receive only an allowlist of runtime, CUDA, locale, and certificate variables; API keys, tokens, passwords, and unrelated parent environment values are not forwarded.

Download the reused autoencoder and MR-Brain v1 checkpoint from their exact manifest revisions:

python -m huggingface_hub.commands.huggingface_cli download \
  nvidia/NV-Generate-CT models/autoencoder_v1.pt \
  --revision 75ac080fb1083c403793563477724c038e7d430c \
  --local-dir "$NV_GENERATE_ROOT"
python -m huggingface_hub.commands.huggingface_cli download \
  nvidia/NV-Generate-MR-Brain models/diff_unet_3d_rflow-mr-brain_v1.pt \
  --revision ef9759bf221265b2704569cdeeac20bbf03b62ee \
  --local-dir "$NV_GENERATE_ROOT"

The wrapper verifies both downloaded files against their published Git LFS SHA-256 object IDs before launching inference.

Runtime needs an NVIDIA GPU with at least 16 GB VRAM. There is no CPU fallback in the upstream path.

The wrapper also searches .workbench_data/upstreams/NV-Generate-CTMR if NV_GENERATE_ROOT is unset or does not have the required upstream layout.

For 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 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. If setup requires cd "$NV_GENERATE_ROOT", return to the Medical AI Skills repo before invoking skills/nv-generate-mr-brain/scripts/run_mr_brain.py.

Usage

export NV_GENERATE_ROOT="${NV_GENERATE_ROOT:-$HOME/.cache/nvidia-skills/upstreams/NV-Generate-CTMR-da438fe}" && \
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 1234

Replace PATH_TO_MR_BRAIN_CONFIG.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 request is at runs/.../default_mri_t1.json", that exact path is the first positional argument to scripts/run_mr_brain.py.

Supported MR-brain modality names are mri, mri_t1, mri_t2, mri_flair, mri_mra, mri_swi, mri_t1_skull_stripped, mri_t2_skull_stripped, mri_flair_skull_stripped, mri_mra_skull_stripped, and mri_swi_skull_stripped. These map to the upstream configs/modality_mapping.json IDs documented in the README. For FOV and setup details, see references/fov-and-downloads.md.

The pinned v1 config ships axial T1w defaults of dim=[256,256,128], spacing=[0.94,0.94,1.36], 30 inference steps, and cfg_guidance_scale=2. Keep the staged config value unless a model-specific validation justifies an override; older examples may describe the v0 256^3/1 mm geometry or guidance scale 10. MRA is supported by v1, but the upstream training-data report contains few MRA scans, so output quality is not guaranteed.

The fixture argument is a small JSON override for configs/config_maisi_diff_model_rflow-mr-brain.json. Pass default to use the upstream defaults plus the CLI modality and random seed. Common override keys are dim, spacing, num_inference_steps, cfg_guidance_scale, and modality.

Each 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.

Files

skill_manifest.yaml

# 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.

id: medagent.nv_generate_mr_brain
version: 0.1.0
upstream_refs:
  - kind: github_repo
    name: NVIDIA-Medtech/NV-Generate-CTMR
    repo_url: https://github.com/NVIDIA-Medtech/NV-Generate-CTMR
    git_commit: da438fec6484cdb6f421f8c7051d954ebefff730
    notes: Recommended v1 default for a new checkout; an explicit caller-provided NV_GENERATE_ROOT is accepted and recorded.
  - kind: huggingface_repo
    name: nvidia/NV-Generate-MR-Brain
    repo_id: nvidia/NV-Generate-MR-Brain
    revision: ef9759bf221265b2704569cdeeac20bbf03b62ee
    notes: Contains the immutable diff_unet_3d_rflow-mr-brain_v1.pt checkpoint.
  - kind: huggingface_repo
    name: nvidia/NV-Generate-CT
    repo_id: nvidia/NV-Generate-CT
    revision: 75ac080fb1083c403793563477724c038e7d430c
    notes: Supplies the immutable autoencoder_v1.pt reused by MR-Brain.
license: Apache-2.0
intended_use:
  summary: >
    Engineering-time wrapper around NVIDIA-Medtech/NV-Generate-CTMR's
    rflow-mr-brain v1 image-only synthesis workflow. Invokes
    `python -m scripts.diff_model_infer` with the upstream
    rflow-mr-brain configs and summarizes the generated NIfTI volume.
  scope: development
  not_for:
    - clinical deployment
    - clinical interpretation
    - autonomous diagnosis
    - regulatory submission
    - training data for production models

inputs:
  - name: model_config_override
    type: file_path
    formats:
      - json
    description: >
      JSON file overriding the nested diffusion_unet_inference block in
      configs/config_maisi_diff_model_rflow-mr-brain.json. The sentinel value
      `default` selects the upstream config plus CLI modality and random seed.

outputs:
  - name: synthetic_mr_brain_volumes
    type: directory_path
    description: Output directory containing generated MR brain NIfTI volumes.
  - name: result_json
    type: json
    schema: validators/output_schema.json

paired_verifiers:
  - id: medagent.verifiers.mr_synthesis_quality_v1
    status: implemented
    consumes: evidence_pack_dir
    purpose: >
      Re-reads generated MR brain NIfTI image artifacts and checks source-pack
      success, official upstream entrypoint, model inventory, modality/version
      identity, sample count, shape and spacing consistency, finite
      nonconstant nonnegative voxel values, aggregate-flag honesty, runtime
      identity, and non-clinical scope disclosure. This is an engineering
      floor, not anatomical realism or training-data approval.

runtime:
  language: python
  python: ">=3.10"
  entrypoint: scripts/run_mr_brain.py
  args:
    - "${python}"
    - "${script}"
    - "${fixture}"
    - "--output-dir"
    - "${out}/samples"
    - "--modality"
    - "mri_t1"
  dependencies:
    nibabel: ">=4.0"
    numpy: ">=1.23"
    typer: ">=0.9"
    torch: ">=2.1"
    monai: ">=1.5"
  side_effects:
    pip_packages:
      - nibabel>=4.0
      - numpy>=1.23
      - typer>=0.9
      - torch>=2.1
      - "monai>=1.5"
      - scipy>=1.10
      - scikit-image>=0.20
      - einops>=0.7
      - huggingface_hub>=0.20
      - tqdm>=4.65
      - fire>=0.5
      - tensorboard>=2.14
      - PyYAML>=6.0
    local_writes:
      - {path: "<caller-provided --output-dir>", approx_mb_max: 4000}
    home_writes:
      - {path: ~/.cache/huggingface/, approx_mb_max: 6000}
    network_endpoints:
      - https://huggingface.co
      - https://github.com
    requires_docker: false
    requires_gpu: cuda
    environment:
      clean_environment_required: false
      clean_environment_recommended: true
      modifies_active_python_environment: true
      user_environment_modification_ok: true
      recommended_isolation: fresh venv or container for benchmarks; caller-selected env for interactive use
      notes: >
        Runtime setup commands may install packages into the active Python
        environment. That is acceptable only when the caller chooses that
        environment; benchmark and evidence runs should use a fresh per-run
        environment.
    env_required: []
    env_optional:
      - NV_GENERATE_ROOT
  external_assets:
    - kind: upstream_repo
      repo_url: https://github.com/NVIDIA-Medtech/NV-Generate-CTMR
      install_path: ~/.cache/nvidia-skills/upstreams/NV-Generate-CTMR-da438fe
      install_command: >
        git clone https://github.com/NVIDIA-Medtech/NV-Generate-CTMR.git $NV_GENERATE_ROOT &&
        git -C $NV_GENERATE_ROOT checkout --detach da438fec6484cdb6f421f8c7051d954ebefff730 &&
        pip install -r $NV_GENERATE_ROOT/requirements.txt
      contains:
        - scripts/diff_model_infer.py
        - scripts/download_model_data.py
        - configs/config_network_rflow.json
        - configs/environment_maisi_diff_model_rflow-mr-brain.json
        - configs/config_maisi_diff_model_rflow-mr-brain.json
        - configs/modality_mapping.json
    - kind: huggingface_repo
      repo_id: nvidia/NV-Generate-CT
      revision: 75ac080fb1083c403793563477724c038e7d430c
      install_path: $NV_GENERATE_ROOT/models/
      install_command: >
        python -m huggingface_hub.commands.huggingface_cli download
        nvidia/NV-Generate-CT models/autoencoder_v1.pt
        --revision 75ac080fb1083c403793563477724c038e7d430c
        --local-dir $NV_GENERATE_ROOT
      contains:
        - models/autoencoder_v1.pt
    - kind: huggingface_repo
      repo_id: nvidia/NV-Generate-MR-Brain
      revision: ef9759bf221265b2704569cdeeac20bbf03b62ee
      install_path: $NV_GENERATE_ROOT/models/
      install_command: >
        python -m huggingface_hub.commands.huggingface_cli download
        nvidia/NV-Generate-MR-Brain models/diff_unet_3d_rflow-mr-brain_v1.pt
        --revision ef9759bf221265b2704569cdeeac20bbf03b62ee
        --local-dir $NV_GENERATE_ROOT
      contains:
        - models/diff_unet_3d_rflow-mr-brain_v1.pt

limitations:
  - >
    This is a thin wrapper. Inference, sampling, and decoding are delegated
    entirely to NVIDIA-Medtech/NV-Generate-CTMR's `scripts.diff_model_infer`.
    Do not modify code under $NV_GENERATE_ROOT or the repo-local fallback at
    .workbench_data/upstreams/NV-Generate-CTMR.
  - >
    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.

validation:
  expected_runtime_seconds:
    min: 1.0
    max: 1800.0
    inference_path: runtime.subprocess_seconds
  sanity_checks:
    - {path: skill, eq: nv_generate_mr_brain}
    - {path: invocation.official_entrypoint, eq: "python -m scripts.diff_model_infer"}
    - {path: invocation.exit_code, eq: 0}
    - {path: invocation.upstream_identity.trusted, eq: true}
    - {path: invocation.model_inventory.all_present, eq: true}
    - {path: invocation.model_inventory.all_sha256_match, eq: true}
    - {path: output.num_samples, gte: 1}
    - {path: output.all_images_readable, eq: true}
    - {path: output.all_shapes_match_requested, eq: true}
    - {path: output.all_spacing_match_requested, eq: true}
    - {path: output.all_images_finite, eq: true}
    - {path: output.all_images_nonconstant, eq: true}
    - {path: output.all_images_nonnegative, eq: true}
  expected_cost:
    wall_seconds:        {max: 1800}
    cpu_seconds:         {max: 3600}
    rss_mb_peak:         {min: 500, max: 32000}
    gpu_seconds:         {max: 1800}
    gpu_memory_mb_peak:  {max: 48000}
  reproducibility:
    mode: preflight
    fixture: fixtures/default_mri_t1.json
    runs: 2
    reason: >
      End-to-end MR-brain synthesis repeatability requires CUDA, the
      NV-Generate-CTMR checkout, and downloaded model weights. The repository
      audit repeats the declared config/env boundary check; promoted evidence
      packs must compare generated image artifact hashes.

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 an API key, 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-mr-brain · 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-mr-brain.zip