# TotalSegmentator

> Segment major anatomical structures in CT and MR scans

- Category: Science & Biomedical AI / Medical Imaging
- Language: Python
- Repository: https://github.com/wasserth/TotalSegmentator
- Canonical page: https://ai-tldr.dev/tools/totalsegmentator/

## In short

TotalSegmentator is a tool for segmentation of most major anatomical structures in any CT or MR image. It takes a scan as input and outputs a labelled mask for each structure it finds, without any manual outlining. It sits in the Medical Imaging category of the Science & Biomedical AI tools and is open-source, written in Python.

## Overview

TotalSegmentator is a tool for segmentation of most major anatomical structures in any CT or MR image. It takes a scan as input and outputs a labelled mask for each structure it finds, without any manual outlining.

The default CT task covers 117 main classes, and a separate MR task covers 50 classes, so a single run can label organs, bones, vessels, and muscles across the body. It reads NIfTI files or DICOM folders and can write NIfTI, DICOM segmentation, or DICOM RT structure output.

The project is open source and is described in an associated Radiology AI paper. The authors state it is not a medical device and is not intended for clinical usage, so it is meant for research rather than direct patient care.

## What it does

- Segments over 100 anatomical structures, with 117 classes in the default CT task and 50 in the MR task
- Works on both CT and MR images, selecting the modality through the task option
- Runs from a single command line call or from a Python API
- Accepts NIfTI files or DICOM folders and zips as input
- Writes NIfTI by default, plus DICOM segmentation and DICOM RT structure output
- Offers a --fast lower resolution mode and a --statistics option that reports volume and mean intensity per class

## Getting started

Install the package with pip, then run segmentation on a scan from the command line or from Python.

1. Install TotalSegmentator

   Install the package from PyPI with pip.

```bash
pip install TotalSegmentator
```

2. Segment a CT image

   Point the CLI at a CT NIfTI file and choose an output folder for the masks.

```bash
TotalSegmentator -i ct.nii.gz -o segmentations
```

3. Segment an MR image

   Use the total_mr task to segment an MR image instead of CT.

```bash
TotalSegmentator -i mri.nii.gz -o segmentations --task total_mr
```

4. Run from Python

   Call the same segmentation from Python through the python_api module.

```python
from totalsegmentator.python_api import totalsegmentator

totalsegmentator(input_path, output_path)
```

## When to use it

- Automatically label organs and other structures across a batch of research CT or MR scans
- Measure the volume and mean intensity of each structure using the --statistics output
- Restrict a run to a few structures with --roi_subset to save runtime and memory
- Export masks as DICOM segmentation or RT structure for use in downstream research pipelines
