# segimage2itkimage

## `segimage2itkimage`

This tool can be used to convert DICOM Segmentation into volumetric segmentations stored as labeled pixels using research format, such as NRRD or NIfTI, and meta information stored in the JSON file format.

### Usage

```
   -t <nrrd|mhd|mha|nii|nifti|hdr|img>,  --outputType <nrrd|mhd|mha|nii
      |nifti|hdr|img>
     Output file format for the resulting image data. (default: nrrd)

   -p <std::string>,  --prefix <std::string>
     Prefix for output file.

   --outputDirectory <std::string>
     Directory to store individual segments saved using the output format
     specified files. When specified, file names will contain prefix,
     followed by the segment number.

   --inputDICOM <std::string>
     File name of the input DICOM Segmentation image object.
     
   --mergeSegments
     Save all segments into a single file. When segments are
     non-overlapping, output is a single 3D file. If overlapping segments
     are identified, multiple 3D files will be created each containing
     non-overlapping segments. Metadata JSON files will be created for each
     such 3D file. (value: 0)
```

## Examples of DICOM Segmentation objects

If you are looking for publicly available examples of segmentation objects, or other DICOM images, you should check out [NCI Imaging Data Commons](https://portal.imaging.datacommons.cancer.gov/) (IDC) (see documentation [here](https://learn.canceridc.dev/)).

Here are some representative examples of DICOM Segmentations:

* Segmentation of a lung nodule from the [DICOM-LIDC-IDRI-Nodules](https://doi.org/10.7937/TCIA.2018.h7umfurq) collection
  * viewer link: <https://viewer.imaging.datacommons.cancer.gov/v3/viewer/?StudyInstanceUIDs=1.3.6.1.4.1.14519.5.2.1.6279.6001.101324598070011890446155612648>
* TotalSegmentator segmentation results from the [TotalSegmentator-CT-Segmentations](https://doi.org/10.5281/zenodo.8347011) collection
  * viewer link: <https://viewer.imaging.datacommons.cancer.gov/v3/viewer/?StudyInstanceUIDs=1.2.840.113654.2.55.256011367872217445472654886973509892961>

To download the files for the studies listed above:

1. install `idc-index` package with `pip install --upgrade idc-index`
2. download the study by specifying `StudyInstanceUID` (listed in the URLs above after the '=' sign) with `idc download 1.2.840.113654.2.55.256011367872217445472654886973509892961`&#x20;
