# LabelOverlay Image saved as DICOM series

**URL:** <https://discourse.slicer.org/t/labeloverlay-image-saved-as-dicom-series/27725>\
**Category:** Support\
**Tags:** segmentation, dicom, labelmap\
**Created:** [February 9, 2023, 5:33pm UTC](https://discourse.slicer.org/t/labeloverlay-image-saved-as-dicom-series/27725 "2023-02-09T17:33:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Franciska](https://avatars.discourse-cdn.com/v4/letter/f/b38774/32.png) [@Franciska](https://discourse.slicer.org/u/Franciska)\
**Post date:** [February 9, 2023, 5:33pm UTC](https://discourse.slicer.org/t/labeloverlay-image-saved-as-dicom-series/27725/1 "2023-02-09T17:33:37Z")

</div>

Hi!

I have a DICOM series, and with the segmentations I create a LabelOverlay Image. When I write it out as a DICOM series, I modified the following datatags in the created image, to get an RGB image.:

```auto
  image_slice.SetMetaData("0028|0002", str(3)) #Samples per Pixel Attribute
  image_slice.SetMetaData("0028|0004", "RGB")

```

The LabelOverlay is saved as DICOM series, but Slicer is not able to load it, it gives the following ERROR: Could not load: prediction as a Scalar Volume.  
When I check one pixel of the LabelOverlay Image it is in fact not a scalar, but (255,255,255). I though setting the samples per pixel attribute to 3 will fix this.  
What tag should I modify to be able to load the LabelOverlay DICOM series into slicer?

---

<div class="post-metadata">

**Author:** ![Franciska](https://avatars.discourse-cdn.com/v4/letter/f/b38774/32.png) [@Franciska](https://discourse.slicer.org/u/Franciska)\
**Post date:** [February 13, 2023, 2:52pm UTC](https://discourse.slicer.org/t/labeloverlay-image-saved-as-dicom-series/27725/2 "2023-02-13T14:52:57Z")

</div>

The slices one-by-one are loaded properly, and look good in Slicer. If I drag the whole Series into the DICOM database it looks like one Serie, with several slices. The DICOM metadata looks good, (modality is set to “OT”, SOPInstance UID, InstanceNumber,ImagePositionPatient and Instance CreationTime are different to each slice, the other attributes are the same for all).

All in all, the DICOM slices seems to be good, however, Slicer can’t load them in together, as a Serie.

These attributes are fixed for all slice to be the same as in the original DICOM serie:

```
        "0010|0010", # Patient Name
        "0010|0020", # Patient ID    
        "0020|0011", # Series Number
        "0010|0030", # Patient Birth Date
        "0020|000d", # Study Instance UID, for machine consumption
        "0020|0010", # Study ID, for human consumption
        "0008|0020", # Study Date
        "0008|0030", # Study Time
        "0008|0050", # Accession Number
        "0008|1030", # Study Description

```

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [February 13, 2023, 4:35pm UTC](https://discourse.slicer.org/t/labeloverlay-image-saved-as-dicom-series/27725/3 "2023-02-13T16:35:33Z")

</div>

Hi - it’s not clear to me how you are creating these label overlay images - i.e. what software is used and what how you expect to use them. But it sounds like you want segmentation objects and would be able to use the code and methods described [in the DCMQI project](https://github.com/QIICR/dcmqi).

---

<div class="post-metadata">

**Author:** ![Franciska](https://avatars.discourse-cdn.com/v4/letter/f/b38774/32.png) [@Franciska](https://discourse.slicer.org/u/Franciska)\
**Post date:** [February 13, 2023, 4:47pm UTC](https://discourse.slicer.org/t/labeloverlay-image-saved-as-dicom-series/27725/4 "2023-02-13T16:47:05Z")

</div>

Hi! Sorry I really wasn’t clear enough. I am generating these images with SimpleITK. I also posted my problem (and my script) in the [simpleitk forum](https://discourse.itk.org/t/saving-labeloverlay-image-as-dicom-series/5689/6).

I want to use this to be able to visualize several segmentations on the CT scan, in the same DICOM Series file. (without opening several files together.) It works perfectly if I save my results in a nii.gz format, but unfortunately it is a requierment to save them as a DICOM series.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [February 13, 2023, 5:13pm UTC](https://discourse.slicer.org/t/labeloverlay-image-saved-as-dicom-series/27725/5 "2023-02-13T17:13:03Z")

</div>

Ah, okay, yes, that helps. The DCMQI code should let you do this in a straightforward way. You can create a set of segments with appropriate labels and colors. The code can take your nii.gz file as input and you can use a json file to specify the metadata.

---

<div class="post-metadata">

**Author:** ![Franciska](https://avatars.discourse-cdn.com/v4/letter/f/b38774/32.png) [@Franciska](https://discourse.slicer.org/u/Franciska)\
**Post date:** [February 14, 2023, 8:38am UTC](https://discourse.slicer.org/t/labeloverlay-image-saved-as-dicom-series/27725/6 "2023-02-14T08:38:12Z")

</div>

Thanks, I’ll take a look at it!

---

<div class="post-metadata">

**Author:** ![Franciska](https://avatars.discourse-cdn.com/v4/letter/f/b38774/32.png) [@Franciska](https://discourse.slicer.org/u/Franciska)\
**Post date:** [February 14, 2023, 11:56am UTC](https://discourse.slicer.org/t/labeloverlay-image-saved-as-dicom-series/27725/7 "2023-02-14T11:56:22Z")

</div>

I also uploaded example files [here](https://easyupload.io/m/gpj0qm).  
NLST\_56831\_result contains the DICOM series, that gives  
` ERROR: Could not load: prediction as a Scalar Volume`  
while it can load the slices individually perfectly fine.

---

<div class="post-metadata">

**Author:** ![Franciska](https://avatars.discourse-cdn.com/v4/letter/f/b38774/32.png) [@Franciska](https://discourse.slicer.org/u/Franciska)\
**Post date:** [February 14, 2023, 3:43pm UTC](https://discourse.slicer.org/t/labeloverlay-image-saved-as-dicom-series/27725/8 "2023-02-14T15:43:33Z")

</div>

And the other weird thing is that when I drag the directory into Slicer, and it asks me to select a reader, if I select Any Data instead of Load directory into DICOM database, it loads it!

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [February 14, 2023, 8:59pm UTC](https://discourse.slicer.org/t/labeloverlay-image-saved-as-dicom-series/27725/9 "2023-02-14T20:59:19Z")

</div>

You’ll need to read through the DCMQI documentation that I linked above to learn about how dicom segmentation objects are created. Once you do this, and you have the Quantitative Reporting extension installed in Slicer then you can work with these data formats directly.

If you are still having trouble, you could join the Imaging Data Commons (IDC) office hours described [at this post](https://discourse.canceridc.dev/t/idc-may-2022-release-idc-community-office-hours/276). The IDC has examples for encoding segmentation results in dicom.
