innolitics / dicom-standard

The DICOM standard, in JSON format, parsed from the HTML version using Python scripts
MIT License
109 stars 16 forks source link

'Unable to parse error' on SR document, even though it opens in other DICOM viewers #61

Open rachelyeshurun opened 3 years ago

rachelyeshurun commented 3 years ago

@browser

Bug description The file browser did not recognize the Structured Report (SR) file as valid. However, the same file opened in MicroDicom viewer (attached screenshot and the dcm file itself)

Steps for reproduction

  1. Created a minimal SR using fo-toolkit. (in code)
  2. Saved to a dicom file (in code)
  3. Tried to open in browser using File Editor (beta)

Here's the code (C#) I used to build the file.

            var dataset = new DicomDataset
            {
                // type 1 attributes
                { DicomTag.SOPClassUID, DicomUID.BasicTextSRStorage},
                { DicomTag.SOPInstanceUID,  DicomUID.Generate()},
                { DicomTag.StudyInstanceUID, DicomUID.Generate()},
                { DicomTag.SeriesInstanceUID, DicomUID.Generate()},
                { DicomTag.Modality, "SR" },
            };

            try
            {
                // Create the root content item which is the title
                DicomCodeItem titleCode = new DicomCodeItem("121144", "DCM", "Document Title");
                //DicomContentItem titleValue = new DicomContentItem(titleCode, DicomRelationship.Contains, DicomValueType.Text, "A Very Simple Structured Report");

                //titleCode.Add(DicomTag.SequenceDelimitationItem, string.Empty);
                // Prepare the one content item 
                DicomCodeItem textCode = new DicomCodeItem("111412", "DCM", "Narrative Summary");
                DicomContentItem textItem = new DicomContentItem(textCode, DicomRelationship.Contains, DicomValueType.Text, "Hello World!!");

                // Now we can create a special content item called a 'structured report'
                DicomStructuredReport report = new DicomStructuredReport(titleCode, textItem);

                // We need to add the dataset with all the patient, study, series stuff to the report (not the other way around)
                report.Dataset.Add(dataset);

                // Save the dataset to a file
                DicomFile file = new DicomFile();
                file.Dataset.Add(report.Dataset);
                file.FileMetaInfo.TransferSyntax = DicomTransferSyntax.ImplicitVRLittleEndian; //Specify transfer syntax

                DicomIOWriter.DicomWriteOptions options = new DicomIOWriter.DicomWriteOptions();
                options.ExplicitLengthSequenceItems = true;
                options.ExplicitLengthSequences = true;
                file.Save(dicom_file, options);
            }
            catch (DicomStructuredReportException exception)
            {
                System.Diagnostics.Trace.WriteLine("");
                System.Diagnostics.Trace.WriteLine("----------------------------------------------------");
                System.Diagnostics.Trace.WriteLine("Error creating structured report ...");
                System.Diagnostics.Trace.WriteLine(exception.ToString());
                System.Diagnostics.Trace.WriteLine("----------------------------------------------------");
                System.Diagnostics.Trace.WriteLine("");
            }

Expected behavior

Browser should accept the file and show its tags in orange. Even if some tags are missing, should show missing tags in red.

Additional context (e.g. screenshots)

image

sr_basic.zip

image


p.s. I am a fan of this browser!! Keep up the great work!

johndgiese commented 3 years ago

Thank you for the kind words! We'll take a look at this bug once we have a break from client work.