# Saving DICOMsegmentations - Interoperability with OHIF

**URL:** <https://discourse.slicer.org/t/saving-dicomsegmentations-interoperability-with-ohif/29037>\
**Category:** Support\
**Created:** [April 21, 2023, 7:57am UTC](https://discourse.slicer.org/t/saving-dicomsegmentations-interoperability-with-ohif/29037 "2023-04-21T07:57:52Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ksidis](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ksidis/32/65544_2.png) [@ksidis](https://discourse.slicer.org/u/ksidis)\
**Post date:** [April 21, 2023, 7:57am UTC](https://discourse.slicer.org/t/saving-dicomsegmentations-interoperability-with-ohif/29037/1 "2023-04-21T07:57:52Z")

</div>

I am using 3Dslicer with the Monailabel plugin to run some segmentation models. The result is then exported as DICOMSegmentation and saved to an Orthanc PACS. Up to this point we were using OHIF v2 to visualise the images along with the segmentations. However we have noticed that this is not working for OHIF v3.3. It throws some error about missing SpacingBetweenSlices tag. Anyway, my question is the following do we know whether OHIF v3.3 is capable to read DICOMSegmentations stored using 3DSlicer? Is there a way to tweak the way the segmentations are stored so they will be read by OHIF v3.3?

Thank you.

---

<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:** [April 23, 2023, 8:02pm UTC](https://discourse.slicer.org/t/saving-dicomsegmentations-interoperability-with-ohif/29037/2 "2023-04-23T20:02:03Z")

</div>

I saw your [issue](https://github.com/OHIF/Viewers/issues/3335) on OHIF github about this. It would be great if you could provide some example data (no PHI, just phantom or dummy data) to illustrate the issue and we can get to the bottom of this.

---

<div class="post-metadata">

**Author:** ![ksidis](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ksidis/32/65544_2.png) [@ksidis](https://discourse.slicer.org/u/ksidis)\
**Post date:** [April 24, 2023, 9:41am UTC](https://discourse.slicer.org/t/saving-dicomsegmentations-interoperability-with-ohif/29037/3 "2023-04-24T09:41:17Z")

</div>

Right after posting this, I had a closer look into the console errors while reading the images with OHIF and tried [this “Hail Mary” solution](https://github.com/OHIF/Viewers/issues/3335) which worked. For my tests I am using [this](https://wiki.cancerimagingarchive.net/display/Public/QIN+LUNG+CT#19039647a520d4e15ee04e84bf26ec185e5403b7) open access dataset, the latest version of 3DSlicer for windows and macOS, and the latest stable release of monai label. I hope that helps.

---

<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:** [April 24, 2023, 4:30pm UTC](https://discourse.slicer.org/t/saving-dicomsegmentations-interoperability-with-ohif/29037/4 "2023-04-24T16:30:47Z")

</div>

Interesting - thanks for the info. But are you saying the issue is with the segmentations on TCIA? I thought you were saying that SEGs from the current version of Slicer weren’t working. Can you post an example of the specific file that requires the change in OHIF?

---

<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:** [April 24, 2023, 5:34pm UTC](https://discourse.slicer.org/t/saving-dicomsegmentations-interoperability-with-ohif/29037/5 "2023-04-24T17:34:56Z")

</div>

Also @ksidis is the SEG generated by MONAI Label or exported from Slicer?

---

<div class="post-metadata">

**Author:** ![ksidis](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ksidis/32/65544_2.png) [@ksidis](https://discourse.slicer.org/u/ksidis)\
**Post date:** [April 25, 2023, 8:20am UTC](https://discourse.slicer.org/t/saving-dicomsegmentations-interoperability-with-ohif/29037/6 "2023-04-25T08:20:21Z")

</div>

Apologies for not being clear.

I meant I am simply using open access dicom images and segment them using 3Dslicer with monai label.  
The result of the segmentation causes OHIF v3.3 to crash. Please find an example image exported from my pacs [here](https://drive.google.com/file/d/108VsooMsjAIE1Q-IH_gb3__oj2om4Dyn/view?usp=sharing)

My understanding is that monai label simply provides the segmentation mask and 3DSlicer exports that to a DICOMSeg object.

---

<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:** [April 26, 2023, 2:56pm UTC](https://discourse.slicer.org/t/saving-dicomsegmentations-interoperability-with-ohif/29037/7 "2023-04-26T14:56:01Z")

</div>

Thanks for sharing this. I can see with dcmdump that the seg says it’s made with dcmqi from QIICR:

```auto
(0008,0060) CS [SEG] # 4, 1 Modality
(0008,0070) LO [QIICR] # 6, 1 Manufacturer

```

It appears to have valid SpacingBetweenSlices, so it’s not clear why you needed to patch OHIF.

```auto
      (fffe,e000) na (Item with undefined length #=3) # u/l, 1 Item
        (0018,0050) DS [5.000000e+00] # 12, 1 SliceThickness
        (0018,0088) DS [5.000000e+00] # 12, 1 SpacingBetweenSlices
        (0028,0030) DS [6.132812e-01\6.132812e-01] # 26, 2 PixelSpacing
      (fffe,e00d) na (ItemDelimitationItem) # 0, 0 ItemDelimitationItem

```

I wonder if it’s related to this bug: [Fix: reading sequences with undefined length items - length value of item delimitation tag and new item tag will be used to detect the length of the sequence more precise by kursawero · Pull Request #346 · dcmjs-org/dcmjs · GitHub](https://github.com/dcmjs-org/dcmjs/pull/346)

Would you be able to test OHIF using the latest dcmjs?

---

<div class="post-metadata">

**Author:** ![ksidis](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ksidis/32/65544_2.png) [@ksidis](https://discourse.slicer.org/u/ksidis)\
**Post date:** [April 26, 2023, 5:56pm UTC](https://discourse.slicer.org/t/saving-dicomsegmentations-interoperability-with-ohif/29037/8 "2023-04-26T17:56:13Z")

</div>

Hey @pieper, thx for looking into this. Yes I can confirm that the tag is there, so there might be some issue with their DICOM library because the property inside OHIF is null. I’ll try and find some time to test your suggestion.

---

<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:** [April 26, 2023, 6:09pm UTC](https://discourse.slicer.org/t/saving-dicomsegmentations-interoperability-with-ohif/29037/9 "2023-04-26T18:09:13Z")

</div>

Thanks for looking into it. I’m pretty sure the OHIF v3 code uses dcmjs before that fix was release so there’s a good chance updating the dependency will work. Let us know how it goes.

---

<div class="post-metadata">

**Author:** ![igoroctaviano](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/igoroctaviano/32/65826_2.png) [@igoroctaviano](https://discourse.slicer.org/u/igoroctaviano)\
**Post date:** [April 28, 2023, 8:15pm UTC](https://discourse.slicer.org/t/saving-dicomsegmentations-interoperability-with-ohif/29037/10 "2023-04-28T20:15:27Z")

</div>

@ksidis @pieper turns out that the problem was not in dcmjs but OHIF.  
The logic was getting the tag value from the first image metadata.

I opened a PR to extract it from the SEG’s shared group seq / pixel measures seq.

> <https://github.com/OHIF/Viewers/pull/3344/files>
>
> Update displaySet metadata parsing logic to extract SpacingBetweenSlices
> from S…haredFunctionalGroupsSequence / PixelMeasuresSequence
> 
> ✅ Closes: https://github.com/OHIF/Viewers/issues/3335

---

<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:** [April 28, 2023, 8:24pm UTC](https://discourse.slicer.org/t/saving-dicomsegmentations-interoperability-with-ohif/29037/11 "2023-04-28T20:24:34Z")

</div>

Thanks @igoroctaviano !
