question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid loading of segmentation with cropped in-plane data

See original GitHub issue

Bug Report

Describe the Bug

I am the author of pydicom-seg, a library for reading and writing DICOM-SEG in Python, and currently try to track down errors in using the generated DICOM-SEGs in OHIF/Viewer (https://github.com/razorx89/pydicom-seg/issues/20).

Currently, OHIF viewer does not correctly load DICOM-SEG data, which was cropped in-plane. The CT image has an in-plane resolution of 512x512, while the cropped segmentation has a resolution of 272x224. As you can see below, the 512x512 is shown correctly while the 272x224 is distorted. Cropping is intended to reduce the generated DICOM size, since for small segmented objects most of the frame data is only zeros.

ohif-cropped-seg-bug

It seems like an error in accessing the allocated segmentation buffer and thus assigning to the wrong voxels. In order to correctly assign the voxels, the PlanePositionSequence[0].ImagePositionPatient attribute in the PerFrameFunctionalGroupSequence as well as the Rows and Columns need to be used for computing the correct buffer indices.

Loading the DICOM-SEG using my package or via the conversion tool segimage2itkimage from QIICR/dcmqi, followed by resampling to the original CT image grid using SimpleITK, displays the correct segmentation in ITKSnap.

What steps can we follow to reproduce the bug?

Data credits go to: QIICR/dcmqi I prepared the ct-3slice scan, from dcmqi’s repository, with the corresponding liver.dcm segmentation as example.zip. The liver-nocrop.dcm is exported using my package without in-plane cropping, the liver-cropped.dcm is exported with cropped segmentation data.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:23 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
piepercommented, May 31, 2020

Yes, 24x38x3 works

image

1reaction
fedorovcommented, May 31, 2020

There is also this odd-sized sample dataset in dcmqi that we tested against BrainLab and I believe confirmed the encoding is correct (that is the one that we used to debug encoding bug in DCMTK): https://github.com/QIICR/dcmqi/tree/master/data/segmentations/24x38x3.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generated DICOM is not valid / OHIF Viewer fails to load #20
Invalid loading of segmentation with cropped in-plane data OHIF/Viewers#1761. Open. FIX: DICOM conformance / OHIF compatibility #21.
Read more >
Why am I getting the exception "Invalid Segments combination ...
Please make sure budget entities exists for the combination of segments you are trying to load the employees to. URL Name.
Read more >
Script repository - 3D Slicer documentation - Read the Docs
This code snippet uses Slicer DICOM browser built-in indexer to import DICOM files into the database. Images are not loaded into the scene,...
Read more >
Automatic prostate and prostate zones segmentation ... - Nature
Automatic segmentation such as that of the prostate and prostate zones from MR images facilitates many diagnostic and therapeutic ...
Read more >
Writing DICOM-SEG — pydicom-seg 0.2.0-dev documentation
Inplane cropping is performed over all segments present in the segmentation data. Since the DICOM standard requires encoded frames to have all the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found