Seeking sample SR (Basic Text structured report).

783 views
Skip to first unread message

Rachel Cohen Yeshurun

unread,
Apr 14, 2021, 1:21:13 AM4/14/21
to Fellow Oak DICOM
I am a C# developer - goal is to convert an XML file to DICOM.
I haven't found a way to do this using the Fellow Oak toolkit.

I thought that if only I had a Basic Text SR dicom document, I could reverse engineer it to see how to build a dicom file from a text file - and that would be good enough for converting XML to dicom.

Haven't found any SR samples online and the one link given as answer to a similar post a few years ago in this group does not work.

Thanks,
Rachel Yeshurun

Rachel Cohen Yeshurun

unread,
Apr 19, 2021, 8:50:07 AM4/19/21
to Fellow Oak DICOM
Thanks to 
I have managed to create a 'hello world' sample SR (attached)
It opens in MicroDicom viewer but not in the https://dicom.innolitics.com/ browser.
Perhaps the code used to create this sample SR is incorrect. In any case, since there is a dearth of information on how to actually build an SR using fo-dicom, here is some working code in C#

            var dataset = new DicomDataset
            {
                { DicomTag.SOPClassUID, DicomUID.BasicTextSRStorage},
                { DicomTag.SOPInstanceUID,  DicomUID.Generate()},
                { DicomTag.StudyInstanceUID, DicomUID.Generate()},
                { DicomTag.SeriesInstanceUID, DicomUID.Generate()},
                { DicomTag.MediaStorageSOPClassUID,  DicomUID.MediaStorageDirectoryStorage },
                { DicomTag.MediaStorageSOPInstanceUID,  DicomUID.Generate() },
                { DicomTag.TransferSyntaxUID, DicomTransferSyntax.ExplicitVRLittleEndian },
                { DicomTag.ImplementationClassUID,  DicomImplementation.ClassUID },
                { DicomTag.ImplementationVersionName,  DicomImplementation.Version },
                { DicomTag.Modality, "SR" },
            };

            try
            {
                // Create the root content item which is the title
                DicomCodeItem titleCode = new DicomCodeItem("121144", "DCM", "Document Title");

                // 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);

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

Note that the code is missing the end of sequence delimeters tags. I haven't yet figured out how to add these. This might be why the innolitics browser can't parse the resulting dicom file.

sr_basic.dcm

Hanier Abreu

unread,
Nov 9, 2022, 9:57:26 AM11/9/22
to Fellow Oak DICOM
Hello, 
My name is Hanier, nice to meet you...
I was looking for information about dicom sr in c# and I found this code that you shared for the creation of a dicom sr in this language.
I would like to have your help if possible since I am developing my undergraduate thesis on this topic.
I am working on a platform that uses C# as the programming language.
The idea is to get that system to create DICOM SR and also digitally sign them.
But the problem is that I can't find a C# library that has implemented methods that solve my problem.
I found a library (DCMTK) that does everything I need, but it's developed in C++ and I don't know how to use it for C#.

Thanks in advance for your help

Maximiliano Schimmel

unread,
Sep 12, 2024, 4:30:58 PMSep 12
to Fellow Oak DICOM
Thanks a lot for your explanation.
I can see your example and I'm working on it.
Reply all
Reply to author
Forward
0 new messages