К основному содержанию
скилл CX Codex

nv-segment-ct — скилл для Claude Code: сегментация КТ через VISTA3D

Запускает VISTA3D на КТ-объёмах в NIfTI и сохраняет карту меток с JSON-отчётом. Для исследовательских прогонов, не для клиники.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add NVIDIA/skills --skill nv-segment-ct -a claude-code
Открыть на GitHub

Что делает nv-segment-ct

Скилл оборачивает официальный пайплайн nvidia/NV-Segment-CT и вызывает scripts/run_vista3d.py. Вход — файл ct_volume в формате NIfTI, выход — label_map и result_json. Анатомии задаются числовыми ID VISTA3D: печень — 1, селезёнка — 3, правая почка — 5, левая почка — 14. Если пользователь называет органы словами, их нужно перевести в эти ID до запуска.

Внутри — тонкая обёртка. Инференс, препроцессинг и постпроцессинг целиком делегируются hugging_face_pipeline.HuggingFacePipelineHelper из bundle/, код там трогать не надо. Обёртка создаёт изолированное окружение в ~/.cache/nvidia-skills/venvs/nv-segment-ct-f9f5f51/, ставит зависимости из закреплённого requirements-файла и скачивает бандл модели с Hugging Face. Первый запуск обращается к huggingface.co и raw.githubusercontent.com.

Нужен Python 3.10 с поддержкой venv и NVIDIA GPU с CUDA; на CPU тоже пойдёт, но медленно. Закреплён transformers==4.46.3 — более новые версии этой библиотеки могут отключить старый бэкенд Torch 2.0.1, так что обновлять её в этом окружении не стоит. Валидация проверяет, что на каждую запрошенную анатомию есть хотя бы один воксель переднего плана: вывод может быть валиден по схеме и при этом пуст, если ID не совпадают с содержимым снимка. Результат не годится для клинической интерпретации или диагностики.

Какие задачи решает

  • сегментировать печень, селезёнку и почки на КТ-снимке
  • получить карту меток и JSON-отчёт по прогону VISTA3D
  • перевести названия органов в числовые ID классов VISTA3D
  • проверить, что модель нашла хотя бы один воксель на запрошенную анатомию
  • воспроизвести прогон в отдельном окружении, не трогая активное

Примеры запросов агенту

  • сегментируй селезёнку, печень, правую и левую почки на study.nii.gz
  • запусти scripts/run_vista3d.py на ct_volume.nii.gz с --label-prompts "1,3,5,14" и сложи результат в vista3d_outputs
  • проверь JSON из последнего прогона: есть ли передний план по всем запрошенным меткам

Как установить nv-segment-ct

1Через Skills CLI (Vercel)

npx skills add NVIDIA/skills --skill nv-segment-ct -a claude-code

2Вручную: положить файлы

~/.claude/skills/nv-segment-ct/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/nv-segment-ct/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о nv-segment-ct

Как установить nv-segment-ct в Claude?

Выполните npx skills add NVIDIA/skills --skill nv-segment-ct -a claude-code. Скилл появится в ~/.claude/skills/nv-segment-ct/SKILL.md.

Что делает nv-segment-ct?

Запускает VISTA3D на КТ-объёмах в NIfTI и записывает карту меток вместе с JSON-отчётом. Инференс выполняет официальный пайплайн NVIDIA, обёртка только готовит окружение и аргументы.

Какие ID меток нужны для печени, селезёнки и почек?

Печень — 1, селезёнка — 3, правая почка — 5, левая почка — 14. Для всех четырёх сразу значение --label-prompts будет "1,3,5,14".

Исходный текст

SKILL.md · Apache-2.0
---
name: nv-segment-ct
description: Used for running NV-Segment-CT VISTA3D on CT NIfTI volumes and recording label-map evidence.
license: Apache-2.0
allowed-tools: Bash
metadata:
  author: NVIDIA MedTech Team
  tags:
    - MedTech
    - CT
    - segmentation
---

# NV-Segment-CT

## Purpose
- Used for running NV-Segment-CT VISTA3D on CT NIfTI volumes and recording label-map evidence. Not for clinical interpretation.
- Use the wrapper exactly as documented; do not replace the upstream entrypoint with a handwritten implementation.
- Manifest I/O: inputs are `ct_volume`; outputs are `label_map` and `result_json`.

## Instructions
- Read `skill_manifest.yaml` before changing arguments, side effects, or validation gates.
- Run `scripts/run_vista3d.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_vista3d.py", args=[...])`; otherwise run the Bash/Python command shown below.
- Create the documented Python 3.10 virtual environment and invoke its binaries directly; do not install model dependencies into the caller's active environment.
- Check the emitted JSON and paired verifier guidance before treating the run as evidence.

## Available Scripts
| Script | Purpose | Arguments |
|---|---|---|
| `scripts/run_vista3d.py` | Primary entrypoint declared by skill_manifest.yaml. | `PATH_TO_CT.nii.gz [--output-dir OUT_DIR] [--label-prompts IDS]` |

## Prerequisites
- Runtime requirements: Python 3.10 with `venv` support and GPU/CUDA when declared by the manifest. Model packages come from the pinned upstream requirements file; only wrapper-specific packages are added locally.
- Side effects: creates an isolated environment under
  `~/.cache/nvidia-skills/venvs/nv-segment-ct-f9f5f51/`, writes the downloaded
  bundle under `skills/nv-segment-ct/bundle/`, may cache model assets under
  `~/.cache/huggingface/`, and may contact `https://huggingface.co` and
  `https://raw.githubusercontent.com` during first setup; the optional spleen
  fixture fetcher downloads MSD09 from
  `https://msd-for-monai.s3-us-west-2.amazonaws.com`.
- Run commands from the repository root unless an existing section below says otherwise.

## Limitations
- This is a thin wrapper. Inference, preprocessing, and postprocessing are delegated entirely to the official `hugging_face_pipeline.HuggingFacePipelineHelper` in bundle/. Do not modify code under bundle/.
- `transformers==4.46.3` is the wrapper compatibility overlay tested with the upstream requirements' Torch 2.0.1; newer Transformers releases can disable that older Torch backend.
- The pinned upstream requirements include Torch 2.0.1. Use only the pinned NVIDIA model assets; do not load untrusted checkpoints in this legacy reproduction environment.
- Device auto-detected (cuda if available, else cpu); `--device` flag overrides.
- Output may be schema-valid but semantically empty (e.g. label prompts that do not match the input anatomy). Sanity gates assert at least one foreground voxel per requested anatomy.
- Not for clinical deployment, clinical interpretation, autonomous diagnosis, regulatory submission.

## Troubleshooting
| Error | Cause | Fix |
|---|---|---|
| `ensurepip is not available` while creating the environment | The host Python installation omitted its OS `venv` package. | Install the matching Python 3.10 venv support package or create the same isolated environment with `virtualenv -p python3.10`. |
| 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/NV-Segment-CT` helper. The wrapper does not
reimplement VISTA3D inference.


## Exact Runnable Surface

For CT segmentation user runs, use this repo-root wrapper path exactly:

```bash
"$NV_SEGMENT_CT_VENV/bin/python" skills/nv-segment-ct/scripts/run_vista3d.py PATH_TO_CT.nii.gz --label-prompts "1,3,5,14" --output-dir OUT_DIR
```

Do not invent `infer.py`, `Medical AI Skills run`, `python -m nv_segment_ct`, or anatomy-name-only flags. For spleen, liver, right kidney, and left kidney, the required VISTA3D label IDs are exactly `1,3,5,14`.

## Preconditions

The skill assumes a Python 3.10 interpreter with `venv` support. Its documented
command creates a dedicated environment and installs the model dependencies
from `NV-Segment-CT/requirements.txt` at the immutable NVIDIA-Medtech commit
`f9f5f51b589e5dc9c23c453cf5138398e4084056`. The Hugging Face bundle itself
does not ship a `requirements.txt`.

Two one-time downloads (the documented command does the first one; the
fixture fetch is a separate step you run when bootstrapping):

```bash
# Spleen example fixture from Decathlon MSD09 (~1.5 GB tar, ~11 MB
# fixture extracted into skills/nv-segment-ct/fixtures/spleen_03.nii.gz):
python skills/nv-segment-ct/fixtures/fetch_spleen_fixture.py
```

Both downloads (the bundle below, and the fixture) are gitignored
(Medical AI Skills policy: no medical data or model weights in git). The fetch
script is idempotent and caches the tar under
`.workbench_data/datasets/` so re-runs are no-ops.

Runtime needs an NVIDIA GPU with CUDA. CPU fallback is supported but slow.

## Usage

From the skills repository root, run the complete bootstrap. Invoke the virtual
environment's binaries directly so the caller's active environment is not
modified:

```bash
export NV_SEGMENT_CT_VENV="${NV_SEGMENT_CT_VENV:-$HOME/.cache/nvidia-skills/venvs/nv-segment-ct-f9f5f51}"
export NV_SEGMENT_CT_REQUIREMENTS="${NV_SEGMENT_CT_REQUIREMENTS:-https://raw.githubusercontent.com/NVIDIA-Medtech/NV-Segment-CTMR/f9f5f51b589e5dc9c23c453cf5138398e4084056/NV-Segment-CT/requirements.txt}"

if [ ! -x "$NV_SEGMENT_CT_VENV/bin/python" ]; then
  python3.10 -m venv "$NV_SEGMENT_CT_VENV"
fi

"$NV_SEGMENT_CT_VENV/bin/python" -m pip install \
  -r "$NV_SEGMENT_CT_REQUIREMENTS" \
  "transformers==4.46.3" \
  "typer>=0.9"

"$NV_SEGMENT_CT_VENV/bin/hf" download nvidia/NV-Segment-CT \
  --revision afb51518689f71e6abb367ee6301b2cd0225c66a \
  --local-dir skills/nv-segment-ct/bundle/

"$NV_SEGMENT_CT_VENV/bin/python" skills/nv-segment-ct/scripts/run_vista3d.py PATH_TO_CT.nii.gz \
  --label-prompts "1,3,5,14" \
  --output-dir vista3d_outputs
```

When the user names anatomies, translate them to VISTA3D class IDs before
running. For the common abdominal CT request:

| Anatomy | VISTA3D class ID |
|---|---:|
| liver | 1 |
| spleen | 3 |
| right kidney | 5 |
| left kidney | 14 |

For "segment the spleen, liver, right kidney, and left kidney", the correct
`--label-prompts` value is exactly `"1,3,5,14"`. Do not substitute kidney
IDs from another label dictionary; the wrapper validates the requested label
set and will mark the run invalid if the emitted mask contains labels outside
the requested set.

The install and download steps are load-bearing. The pinned upstream file owns
the model environment, while Transformers and Typer support this thin wrapper.
`hf download` pulls the ~832 MB model bundle into
`skills/nv-segment-ct/bundle/`; subsequent calls reuse the caches.

`label-prompts` are VISTA3D class IDs. The evidence output records input
geometry, output mask path, observed label IDs, unexpected labels,
per-class voxel counts, per-class physical volumes computed from the output
mask header spacing, runtime, model identity, and fixed code-derived artifact
checks such as mask shape, affine match, label set, foreground count, and
class-volume bounds.

Pass `--ground-truth PATH` to record a reference label-map path under
`input.ground_truth_path`. The skill does not compute Dice; that is the
paired verifier's job.

Anatomy plausibility (per-class volume bounds, fragmentation, bilateral
symmetry, liver larger than spleen) and optional per-class Dice/IoU against
the recorded ground truth are checked by
`verifiers/ct_segmentation_quality_v1`.

Not for clinical interpretation, production deployment, or non-CT modalities.

© NVIDIA MedTech Team · Apache-2.0 · NVIDIA/skills

Похожие скиллы

Всё по теме «ИИ и ML» →
imaging-data-commons K-Dense-AI Скилл для поиска и загрузки открытых данных медицинских изображений из репозитория NCI Imaging Data Commons. Работает с DICOM, КТ, МР, ПЭТ и цифровой патологией без аутентификации для базовых операций. CX Codex +1 1 900установок list-segment-builder aaron-he-zhu Скилл разбирает выгрузку из ESP, CRM или GA4 на поведенческие, RFM- и lifecycle-сегменты и собирает suppression-лист. Нужен до того, как вы начнёте рассылать. CX Codex +1 1 000установок pydicom K-Dense-AI Скилл для работы с локальными наборами DICOM: проверяет заголовки, извлекает метаданные и готовит пиксельные массивы. Защищает от утечки медицинских данных в логи. CX Codex +1 1 900установок medical-imaging-review luwill Помогает планировать и писать обзоры по ИИ в лучевой диагностике с аудитом цитат. Исключает метаанализ и статистическое объединение данных. CX Codex +1 691установок indexion-segment trkbt10 Режет документы на смысловые куски для RAG и эмбеддингов. Пригодится, когда текст надо разбить по смене темы, а не по количеству символов. CX Codex +1 4 900установок segment-anything-model Orchestra Research Скилл для работы с SAM: выделяет объекты на картинке по точке, рамке или маске и умеет находить все объекты сразу. CX Codex +1 985установок

Из того же набора178

nv-reason-cxr Скилл запускает смоук-тесты модели NV-Reason-CXR-3B для анализа рентгенограмм грудной клетки. Пригодится инженерам для валидации пайплайнов и проверки форматов JSON. CX Codex +1 1 800установок nv-generate-ct-rflow Скилл запускает генерацию синтетических КТ-объёмов и масок через rflow-ct. Результаты требуют независимой проверки перед использованием в обучении медицинских моделей. CX Codex +1 1 800установок nv-segment-ctmr Запускает NV-Segment-CTMR на NIfTI-объёмах КТ или МРТ и сохраняет карту меток вместе с JSON-отчётом. Для клинической трактовки не годится. CX Codex +1 1 800установок nv-generate-mr Генерирует синтетические 3D-томограммы тела (MRI) через модель NV-Generate-CTMR rflow-mr. Пригодится для синтеза медицинских объёмов T1 без разметки. CX Codex +1 1 800установок nv-generate-mr-brain-finetune Дообучает диффузионную модель NV-Generate-CTMR MR-Brain v1 на ваших NIfTI-снимках T1, T2, FLAIR, SWI или MRA. Сначала прогоняет проверку без GPU. CX Codex +1 1 800установок nv-generate-mr-brain Скилл запускает генерацию синтетических 3D-томограмм мозга (T1, T2, FLAIR, SWI, MRA) через модель NV-Generate-CTMR. Пригодится для подготовки тестовых объёмов NIfTI без реальных снимков. CX Codex +1 1 800установок tao-finetune-huggingface-model Запускает дообучение моделей HuggingFace на локальных видеокартах NVIDIA внутри контейнера NGC PyTorch, если для них нет отдельного скилла TAO. CX Codex +1 1 700установок hsb-app Скилл находит примеры приложений Holoscan Sensor Bridge на подключённом devkit, фильтрует их по железу и запускает в демо-контейнере. CX Codex +1 1 700установок

Спонсоры проекта

Компании, которые помогают держать аналитику открытой