NV-Segment-CT

SegmentNVSegmentCT runs NVIDIA’s NV-Segment-CT model (a VISTA3D derivative finetuned on CT scans) and groups its labelmap into the anatomy masks used by MONAI Physio workflows. It covers 117 “segment everything” classes (132 addressable via label prompt) and supports only automatic (label-prompt) segmentation - there is no point-click interactive branch exposed here.

Warning

The NV-Segment-CT weights are released under the NVIDIA Open Model License Agreement (research use only, not for clinical use); the surrounding bundle code is Apache 2.0. NV-Segment-CTMR’s weights carry a different restrictive license (NVIDIA OneWay Non-Commercial License) - both models are research-use-only, just under different named terms, so check the license text for your use case. Use SegmentChestTotalSegmentator if you need no license restriction at all - its default task set is unrestricted; only its optional heartchambers_highres and tissue_4_types tasks (set_has_academic_license(True)) require a TotalSegmentator academic license.

Class Reference

class monai_physio.SegmentNVSegmentCT(log_level=20)[source]

Bases: SegmentAnatomyBase

CT segmentation using NVIDIA’s NV-Segment-CT model.

NV-Segment-CT is a VISTA3D-architecture network finetuned on CT scans. It covers 117 “segment everything” classes (132 addressable via label prompt) and, like NV-Segment-CTMR, supports only automatic (label-prompt) segmentation - there is no point-click interactive branch exposed here.

Model weights (~872 MB) are downloaded from hf_repo_id on the first call to segmentation_method() and cached by huggingface_hub thereafter.

Labelmap ids are the model’s published class indices, used verbatim.

Anatomy groups (heart, major_vessels, lung, bone, soft_tissue) are populated into SegmentAnatomyBase.taxonomy, reusing the names the TotalSegmentator and NV-Segment-CTMR backends use so downstream consumers see the same group keys.

Licensing:

The NV-Segment-CT weights are released under the NVIDIA Open Model License Agreement (research use only, not for clinical use); the surrounding bundle code is Apache 2.0. license_warning is logged at WARNING on the first call to segmentation_method().

target_spacing

1.5mm, matching the model bundle’s internal resampling, so the image is interpolated once rather than twice.

Type:

float

model_cache_dir

Download destination passed to huggingface_hub. None uses the default Hugging Face cache.

Type:

Optional[str]

hf_repo_id

Hugging Face repository holding the bundle and weights.

Type:

str

hf_revision

Pinned commit of hf_repo_id to download.

Type:

str

hf_allow_patterns

Files pulled from hf_repo_id.

Type:

tuple[str, …]

license_warning

Banner logged at WARNING on first use.

Type:

str

The anatomy labels populated by this class are accessed through the inherited SegmentAnatomyBase.taxonomy (taxonomy.labels_in_group("heart") etc.).

Note

SegmentAnatomyBase.fast_mode is ignored: this model has a single network and no reduced-accuracy variant.

Example

>>> segmenter = SegmentNVSegmentCT()
>>> result = segmenter.segment(ct_image)
>>> labelmap = result['labelmap']
>>> heart_labelmap = result['heart']
__init__(log_level=20)[source]

Initialize the NV-Segment-CT-based segmentation.

Populates SegmentAnatomyBase.taxonomy with the model’s class indices, then calls SegmentAnatomyBase._finalize_other_group() over the model’s full [1, 133) class index space so unclaimed ids end up in the other group. Constructing the class downloads nothing; weights are fetched lazily by segmentation_method().

Parameters:

log_level (int | str) – Logging level (default: logging.INFO)

segmentation_method(preprocessed_image)[source]

Run NV-Segment-CT on the preprocessed image and return the result.

The model’s Hugging Face pipeline reads and writes NIfTI files, so the image is written to a temporary file and the prediction read back with ITK. That round trip also handles the coordinate-system conversion between ITK (LPS) and the bundle’s internal RAS orientation.

The bundle inverts its own preprocessing before saving, so the prediction is returned on the same grid as preprocessed_image.

Parameters:

preprocessed_image (itk.image) – The preprocessed CT image with isotropic spacing

Returns:

The segmentation labelmap with NV-Segment-CT class

indices, as uint8.

Return type:

itk.image

Raises:

RuntimeError – If the model pipeline produced no output volume.

Note

Requires a CUDA GPU; the segmentation runs on whichever CUDA device is current in this process.

Example

>>> labelmap = segmenter.segmentation_method(preprocessed_ct)

Basic Usage

import itk

from monai_physio import SegmentNVSegmentCT

image = itk.imread("chest_ct.nrrd")
segmenter = SegmentNVSegmentCT()

masks = segmenter.segment(image)

heart = masks["heart"]
lungs = masks["lung"]
labelmap = masks["labelmap"]

itk.imwrite(labelmap, "labelmap.nrrd", compression=True)

NV-Segment-CT is CT-only: unlike SegmentNVSegmentCTMRI there is no set_modality() call or MRI code path.

Returned Keys

For this segmenter, segment() returns a dictionary with the following keys:

  • labelmap

  • heart

  • major_vessels

  • lung

  • bone

  • soft_tissue

  • other

Label Ids

Label ids are the model’s own published class indices, used verbatim (see NV-Segment-CT/configs/label_dict.json in https://github.com/NVIDIA-Medtech/NV-Segment-CTMR), which run to 132. For example, 6 is the aorta and 115 the heart. The full group->id mapping is available through the segmenter’s taxonomy attribute (segmenter.taxonomy.labels_in_group("heart"), segmenter.taxonomy.all_labels()).

Operational Notes

The first call to segment() downloads ~872 MB of model weights from https://huggingface.co/nvidia/NV-Segment-CT into the Hugging Face cache (override the destination with the model_cache_dir attribute). Inference requires a CUDA GPU.

See Also