Export DICOM-SEG data

Hi everyone,

I cannot export DICOM SEG files from anonymized DICOM files.
It works without any problems with DICOM objects that have not been anonymized.

As an example, this dataset from the internet can be used to reproduce the problem.

I get the error message:

Segmentation object export failed.
Completed with errors:
Convert ITK image(s) into DICOM Segmentation Image standard error
Condition failed: Maximum VR length violated in /work Stable/S-1E-b/DCMQI/libsrc/ImageSEGConverter.cpp:112
Fatal error encountered.

Which Dicom field causes problems here?

In particular case maybe DS fields cause the problem, not 100% sure. S. dciodvfy. Completely clean files are seldom, there are very often warnings, BTW.

dciodvfy /home/r/Downloads/example-dicom-structural-master/dicoms/N2D_0001.dcm

Warning - Value dubious for this VR - (0x0010,0x0010) PN Patient's Name  PN [1] = <Jane_Doe> - Retired Person Name form
Error - Value invalid for this VR - (0x0010,0x1010) AS Patient's Age  AS [1] = <42> - Length invalid for this VR = 2, expected == 4
Error - Value invalid for this VR - (0x0018,0x0050) DS Slice Thickness  DS [1] = <0.666666686534882> - Length invalid for this VR = 17, expected <= 16
Error - Value invalid for this VR - (0x0018,0x0088) DS Spacing Between Slices  DS [1] = <0.666666686534882> - Length invalid for this VR = 17, expected <= 16
Error - Value invalid for this VR - (0x0020,0x0032) DS Image Position (Patient)  DS [1] = <-91.4495864331908> - Length invalid for this VR = 17, expected <= 16
Error - Value invalid for this VR - (0x0020,0x0032) DS Image Position (Patient)  DS [3] = <-142.505487236053> - Length invalid for this VR = 17, expected <= 16
Error - Value invalid for this VR - (0x0020,0x0037) DS Image Orientation (Patient)  DS [1] = <0.999032176441525> - Length invalid for this VR = 17, expected <= 16
Error - Value invalid for this VR - (0x0020,0x0037) DS Image Orientation (Patient)  DS [2] = <-0.0217883751691557> - Length invalid for this VR = 19, expected <= 16
Error - Value invalid for this VR - (0x0020,0x0037) DS Image Orientation (Patient)  DS [3] = <0.0382096472372976> - Length invalid for this VR = 18, expected <= 16
Error - Value invalid for this VR - (0x0020,0x0037) DS Image Orientation (Patient)  DS [4] = <0.026519476938784> - Length invalid for this VR = 17, expected <= 16
Error - Value invalid for this VR - (0x0020,0x0037) DS Image Orientation (Patient)  DS [5] = <0.991413870277297> - Length invalid for this VR = 17, expected <= 16
Error - Value invalid for this VR - (0x0028,0x0030) DS Pixel Spacing  DS [1] = <0.666666686534882> - Length invalid for this VR = 17, expected <= 16
Error - Value invalid for this VR - (0x0028,0x0030) DS Pixel Spacing  DS [2] = <0.699987828731537> - Length invalid for this VR = 17, expected <= 16
Error - Dicom dataset contains invalid data values for Value Representations
Warning - Retired attribute - (0x0010,0x1000) LO Other Patient IDs 
Warning - Dicom dataset contains retired attributes
MRImage
Error - Missing attribute Type 2C Conditional Element=<Laterality> Module=<GeneralSeries>
Error - Missing attribute Type 2C Conditional Element=<PatientPosition> Module=<GeneralSeries>
Error - Missing attribute Type 2 Required Element=<PositionReferenceIndicator> Module=<FrameOfReference>
Error - A value is required for value 3 in MR Images - attribute <ImageType>
Error - Missing attribute Type 1 Required Element=<ScanningSequence> Module=<MRImage>
Error - Missing attribute Type 1 Required Element=<SequenceVariant> Module=<MRImage>
Error - Missing attribute Type 2 Required Element=<ScanOptions> Module=<MRImage>
Error - Missing attribute Type 2 Required Element=<MRAcquisitionType> Module=<MRImage>
Error - Missing attribute Type 2C Conditional Element=<RepetitionTime> Module=<MRImage>
Error - Missing attribute Type 2 Required Element=<EchoTime> Module=<MRImage>
Error - Missing attribute Type 2 Required Element=<EchoTrainLength> Module=<MRImage>
Warning - Attribute is not present in standard DICOM IOD - (0x0010,0x1000) LO Other Patient IDs 
Warning - Attribute is not present in standard DICOM IOD - (0x0028,0x1052) DS Rescale Intercept 
Warning - Attribute is not present in standard DICOM IOD - (0x0028,0x1053) DS Rescale Slope 
Warning - Attribute is not present in standard DICOM IOD - (0x0028,0x1054) LO Rescale Type 
Warning - Dicom dataset contains attributes not present in standard DICOM IOD - this is a Standard Extended SOP Class
1 Like

Many errors are tolerated, but the geometry (origin, spacing, axis directions) are stored in invalid decimal string (DS) values that the DICOM writer cannot reproduce. So, it is not possible to use this messed up DICOM image as a reference image for a DICOM segmentation object.

I would recommend to contact the maintainers of the https://github.com/datalad/example-dicom-structural repository about the issue and see if they are willing to fix up the data set. At least they should describe these issues in the repository. Probably the culprit is the nifti2dicom utility that they used. The problem should be reported to the maintainers of nifti2dicom, too.

In the meantime, you can create a valid DICOM volume by loading the invalid DICOM into Slicer (it will tolerate it), then export it into DICOM within Slicer. Then load that DICOM volume and use that as master volume for the segmentation.

2 Likes

Thank you so much!!!. I will create a corresponding report.

The problem seems to occur with many data sets from the Internet. I couldn’t find one that would allow me to generate DICOM SEG files. Maybe because most of them created by nifti2dcm.

Regardless, the workaround you suggested works fine!

1 Like