Add DicomSequence to DicomSequence|

523 views
Skip to first unread message

Dr. Cuauhtémoc Rossell

unread,
May 3, 2016, 5:41:01 PM5/3/16
to Fellow Oak DICOM
I am working in structured report and need to include Image references.
I think this has to be in the ContenSequence (DicomSequence)
Image references is another Sequence (ReferencedSOPSequence)
I cant´t find a way to add a Sequence to another Sequence

Thanks in advance

Anders Gustafsson Cureos AB

unread,
May 4, 2016, 1:17:23 AM5/4/16
to Fellow Oak DICOM
Hello Cuauhtémoc,

Could you please show what you have tried so far?

Regards,
Anders @ Cureos

Anders Gustafsson Cureos AB

unread,
May 4, 2016, 4:58:05 AM5/4/16
to Fellow Oak DICOM
Please note that you will not insert a sequence directly inside a sequence; you are inserting a sequence to one item of the outer sequence.

This code shows you schematically one way you can do it:

            var seq = new DicomSequence(DicomTag.BeamSequence, new DicomDataset[5]);
            seq.Items[0].Add(
                new DicomSequence(
                    DicomTag.WedgeSequence,
                    new DicomDataset(new DicomIntegerString(DicomTag.WedgeNumber, 1))));

Regards,
Anders

Dr. Cuauhtémoc Rossell

unread,
May 4, 2016, 12:06:36 PM5/4/16
to Fellow Oak DICOM
I Anders, thank you for the response, now I can add a DicomSequence to another DicomSequence!!
However the result isn't as expected, here is the code:


DicomDataset dataset = new DicomDataset();  

...  

DicomSequence ds = new DicomSequence(DicomTag.ContentSequence, dds);

....

// Imágenes clave

ds.Items[0].Add(createKeyImageReference("1.2.840.10008.5.1.4.1.1.1", cSOPInstanceUID.ToString(), "Referencia a la imagen"));

dataset.Add(ds);

..

// Creation of the sequence

private DicomSequence createKeyImageReference(string classUID, string SOPInstanceUID, string reference)

{


DicomDataset ds = new DicomDataset();

ds.Add(DicomTag.ReferencedSOPClassUID, classUID);

ds.Add(DicomTag.ReferencedSOPInstanceUID, SOPInstanceUID);

ds.Add(DicomTag.ValueType, DicomValueType.Image);

ds.Add(DicomTag.ConceptNameCodeSequence, creaCodeItem("55113-5", "LN", reference));

DicomSequence sq = new DicomSequence(DicomTag.ReferencedSOPSequence, ds);

return sq;

}


This is an actual dump of the DICOM-SR (dcm4chee)


Content Sequence(0040,A730)SQ-1
>Item #1
>Referenced SOP Sequence(0008,1199)SQ-1
>>Item #1
>>Referenced SOP Class UID(0008,1150)UI261.2.840.10008.5.1.4.1.1.1
>>Referenced SOP Instance UID(0008,1155)UI64SOP Instance UID [1.2.826.0.1.3680043.9.3094.635979721795253653]
>>Value Type(0040,A040)CS6Image
>>Concept Name Code Sequence(0040,A043)SQ-1
>>>Item #1
>>>Code Value(0008,0100)SH855113-5
>>>Coding Scheme Designator(0008,0102)SH2LN
>>>Code Meaning(0008,0104)LO22Referencia a la imagen



and this is an extract of the DICOM Structured Reporting of Dr. Clunie (my hero!) abot the same subject


(0008,1199) Referenced SOP Sequence
(fffe,e000) Item
(0008,1150) Referenced SOP Class UID “1.2.840.10008.5.1.4.1.1.12.1”
(0008,1155) Referenced SOP Instance UID “1.2.3.4”
(0008,1160) Referenced Frame Number “34”
(0008,1199) Referenced SOP Sequence
(fffe,e000) Item
(0008,1150) Referenced SOP Class UID “1.2.840.10008.5.1.4.1.1.11.1”
(0008,1155) Referenced SOP Instance UID “1.2.3.5”
(fffe,e00d) Item Delimitation Item
(fffe,e0dd) Sequence Delimitation Item
(fffe,e00d) Item Delimitation Item
(fffe,e0dd) Sequence Delimitation Item
(0040,a040) Value Type “IMAGE”
(0040,a043) Concept Name Code Sequence
(fffe,e000) Item
(0008,0100) Code Value “209801”
(0008,0102) Coding Scheme Designator “99PMP”
(0008,0104) Code Meaning “End Systole”
(fffe,e00d) Item Delimitation Item
(fffe,e0dd) Sequence Delimitation Ítem


there are some differences and the reference to images is not showing. What is wrong?

You can find the SR generated if need more information.


Best regards, Cuauhtémoc


1.2.826.0.1.3680043.9.3094.635979721795253653.dcm

Dr. Cuauhtémoc Rossell

unread,
May 5, 2016, 11:40:10 AM5/5/16
to Fellow Oak DICOM
Some changes, not expected result:

private DicomSequence createKeyImageReference(string classUID, string SOPInstanceUID, string reference)

{

DicomSequence seq = new DicomSequence(DicomTag.ReferencedSOPSequence,

new DicomDataset(

new DicomUniqueIdentifier(DicomTag.ReferencedSOPClassUID, classUID),

new DicomUniqueIdentifier(DicomTag.ReferencedSOPInstanceUID, SOPInstanceUID),

new DicomIntegerString(DicomTag.ReferencedFrameNumber, "0")),

new DicomDataset(

new DicomCodeString(DicomTag.ValueType, DicomValueType.Image.ToString())));

seq.Items[0].Add(new DicomSequence(DicomTag.ConceptNameCodeSequence, creaCodeItem("121080", "DCM", reference)));

return seq;

}


partial dump of DICOM file (weasis):

(0040,A493) [CS] VerificationFlag: UNVERIFIED
(0040,A496) [CS] PreliminaryFlag: FINAL
(0040,A730) [SQ] ContentSequence: 9 items
--> ITEM #1
-->(0008,1199) [SQ] ReferencedSOPSequence: 2 items
----> ITEM #1
---->(0008,1150) [UI] ReferencedSOPClassUID: 1.2.840.10008.5.1.4.1.1.1
---->(0008,1155) [UI] ReferencedSOPInstanceUID: SOP Instance UID [1.2.826.0.1.3680043.9.3094.635980588647608207]
---->(0008,1160) [IS] ReferencedFrameNumber: 0
---->(0040,A043) [SQ] ConceptNameCodeSequence: 1 item
------> ITEM #1
------>(0008,0100) [SH] CodeValue: 121080
------>(0008,0102) [SH] CodingSchemeDesignator: DCM
------>(0008,0104) [LO] CodeMeaning: Referencia a la imagen
----> ITEM #2
---->(0040,A040) [CS] ValueType: Image
-->(0040,A010) [CS] RelationshipType: HAS OBS CONTEXT
-->(0040,A040) [CS] ValueType: PNAME
-->(0040,A043) [SQ] ConceptNameCodeSequence: 1 item
----> ITEM #1

Any ideas?

Cuauhtémoc Rossell

Anders Gustafsson Cureos AB

unread,
May 8, 2016, 6:06:39 AM5/8/16
to Fellow Oak DICOM
Hello again Cuauhtémoc!

Could you please pinpoint to one location where you have a clear inconsistency in the fo-dicom output? Generally, if you are having problems, I recommend that you do this in small steps until you encounter an inconsistency. 

Regards,
Anders @ Cureos

Dr. Cuauhtémoc Rossell

unread,
May 9, 2016, 10:29:21 AM5/9/16
to Fellow Oak DICOM
Hello Anders and hello to all the members

An now it is working!!

I have included the data as DicomDataset:

XmlNode nodeRef = xDoc.SelectSingleNode("//references");

if (nodeRef != null)

{

foreach (XmlNode nodo in nodeRef.ChildNodes)

{

string cMsg = nodo["message"].InnerText;

string SOPClassUID = nodo["uidClass"].InnerText;

string SOPInstanceUID = nodo["sopInstance"].InnerText;

string nFrame = nodo["frame"].InnerText;

ds.Items.Add(createKeyImageReference(SOPClassUID, SOPInstanceUID, cMsg, nFrame));

}

}


// Creation of the Dataset


private DicomDataset createKeyImageReference(string classUID, string SOPInstanceUID, string reference, string nFrame)





{



DicomDataset content = new DicomDataset();


content.Add(DicomTag.ConceptNameCodeSequence, creaCodeItem("121080", "DCM", reference));


content.Add(DicomTag.RelationshipType, "CONTAINS");


content.Add(DicomTag.ValueType, "IMAGE");


// datos de la imagen


content.Add(new DicomDataset(


new DicomSequence(


DicomTag.ReferencedSOPSequence,


new DicomDataset(


new DicomUniqueIdentifier(DicomTag.ReferencedSOPClassUID, classUID),


new DicomUniqueIdentifier(DicomTag.ReferencedSOPInstanceUID, SOPInstanceUID),


new DicomIntegerString(DicomTag.ReferencedFrameNumber, nFrame)))));


return content;




}


and the result (SR in Weasis):


The "links" really work.

Now, I would like to include Spatial Coordinates, have you ever tried this?


Thanks for your advice and inspiration


Cuauhtémoc

Anders Gustafsson Cureos AB

unread,
May 9, 2016, 1:41:08 PM5/9/16
to Fellow Oak DICOM
Cuauhtémoc,

great to hear that you finally got it working!

Personally, I have no experience with spatial coordinates, but maybe some other members of the community do?

Regards,
Anders

Dr. Cuauhtémoc Rossell

unread,
May 11, 2016, 10:14:21 AM5/11/16
to Fellow Oak DICOM

Hi to all members,
Is there any experience with Presentation State (creation, use) or Spatial Coordinates in SR?
Thanks in advance

Cuauhtémoc Rossell

Anders Gustafsson Cureos AB

unread,
May 12, 2016, 3:17:59 AM5/12/16
to Fellow Oak DICOM
Hello Cuauhtémoc,

there is currently a request #162 to apply presentation state to pixel data, but no work has been started yet. Maybe other members of the community have any general experience of presentation state?

Regards,
Anders @ Cureos
Reply all
Reply to author
Forward
0 new messages