Creating Frame-Specific DICOM Presentation State using DicomObjects

Sometimes we are asked about how to create frame-specific DICOM presentation state files for multiframe images. This is not difficult in DicomObjects and can by done in a slightly awkward way. Instead of adding the entire "Referenced Series Sequence" to the top level of the presentation state file, all you need to do is adding the "Referenced Frame Number" item into "Referenced Image Sequence" under "Graphic Annotation Sequence", as shown in the following picture:

Content inside the red box is the top level sequence which you don't need to add. All you need to do is find the "Graphic Annotation Sequence" (0070, 0001), then the "Referenced Image Sequence" (0008, 1140) and add the "Referenced Frame Number" (0008, 1160) into it.

Below is some simple vb6 code to show you how to do it:

   Dim ps As DicomDataSet
   DicomViewer1.CurrentImage.CurrentToPresentationState True
   Set ps = DicomViewer1.CurrentImage.PresentationState
       
   Dim graphicAnnoSQ As DicomDataSet
   Dim graphicAnnoSQItem As DicomDataSet
   Set graphicAnnoSQ = ps.Attributes(&H70, 1).Value
   Set graphicAnnoSQItem = graphicAnnoSQ(1)
   
   Dim refImageSQ As DicomDataSet
   Dim refImageSQItem As DicomDataSet
   
   Set refImageSQ = graphicAnnoSQItem.Attributes(&H8, &H1140).Value
   Set refImageSQItem = refImageSQ(1)
   refImageSQItem.Attributes.Add &H8, &H1160, 13

   ps.WriteFile psFilePath, True, "1.2.840.10008.1.2.1"

This should work equally well in the .NET version of DicomObjects. For future development in the .NET version, we may add in a new method DicomDataSet.PresentationStateByFrame, we can also combine multiple presentation state into one so that people don't have to load them all and change the DicomImage.PresentationState property every time the user changes the Frame.

Relevance: