autods_pet.imaging.segmentation#

Thin wrapper around TotalSegmentator CLI.

autods_pet.imaging.segmentation.TOTSEG_FILENAME = 'TotSeg_multilabel.nii.gz'#

Default filename for the multilabel segmentation output.

autods_pet.imaging.segmentation.run_totalsegmentator(ct_path, output_dir, task='total', fast=False, output_filename=None)[source]#

Run TotalSegmentator on a CT image.

Uses the --ml flag to produce a single multilabel NIfTI file named TOTSEG_FILENAME inside output_dir.

Note

Paths are passed as subprocess arguments (list form, no shell). This mitigates OS command injection (CWE-78), but path traversal (CWE-22) is not validated. If this function is ever exposed via a network service, add explicit path validation.

Parameters:
  • ct_path (Path) – Path to the input CT NIfTI file.

  • output_dir (Path) – Directory where the segmentation output will be written.

  • task (str (default: 'total')) – TotalSegmentator task name (default "total").

  • fast (bool (default: False)) – If True, use the --fast flag for lower resolution but faster inference.

  • output_filename (str | None (default: None)) – Custom filename for the output segmentation file. When None (default), uses TOTSEG_FILENAME.

Returns:

Path to the output segmentation file.

Return type:

Path