autods_pet.ops.dicom_seg#

Read DICOM SEG segmentation objects as SimpleITK images.

This module lazily imports highdicom and pydicom so that the optional dependency is only required when a .dcm mask file is actually encountered.

autods_pet.ops.dicom_seg.is_dicom_seg(path)[source]#

Check whether path is a DICOM SEG file (header-only read).

Parameters:

path (Path) – Path to a .dcm file.

Returns:

True if the file’s SOPClassUID matches Segmentation Storage.

Return type:

bool

autods_pet.ops.dicom_seg.read_referenced_series_uids(path)[source]#

Read the ReferencedSeriesSequence SeriesInstanceUIDs from a DICOM SEG.

Header-only read; no highdicom dependency. Used by mask discovery to match a SEG file against the patient’s PET series.

Parameters:

path (Path) – Path to a DICOM SEG (.dcm) file.

Returns:

SeriesInstanceUID values referenced by the SEG. Empty list if the sequence is missing or the file cannot be parsed.

Return type:

list[str]

autods_pet.ops.dicom_seg.list_segments(path)[source]#

List all segments in a DICOM SEG file.

Parameters:

path (Path) – Path to a DICOM SEG (.dcm) file.

Returns:

Each dict has keys number, label, and description.

Return type:

list[dict[str, Any]]

autods_pet.ops.dicom_seg.read_dicom_seg(path, segment_label=None)[source]#

Read a DICOM SEG file and return the selected segment as a SimpleITK image.

Parameters:
  • path (Path) – Path to a DICOM SEG (.dcm) file.

  • segment_label (str | None (default: None)) – Label of the segment to extract. Required when the file contains more than one segment. Matched case-insensitively against each segment’s SegmentLabel attribute.

Returns:

Binary uint8 mask in LPS orientation (native DICOM / SimpleITK coordinate system).

Return type:

Any

Raises:
  • ModuleNotFoundError – If highdicom is not installed.

  • ValueError – If the file is not a valid DICOM SEG, the requested label is not found, or a multi-segment file is loaded without specifying a label.