LEADTOOLS Medical (Leadtools.Dicom assembly)

SetPresentationStateInformation Method

Show in webframe
Example 







"Presentation State Module" attributes
Sets the attributes of the "Presentation State Module".
Syntax
public void SetPresentationStateInformation( 
   DicomPresentationStateInformation presentationStateInformation
)
'Declaration
 
Public Sub SetPresentationStateInformation( _
   ByVal presentationStateInformation As DicomPresentationStateInformation _
) 
'Usage
 
Dim instance As DicomDataSet
Dim presentationStateInformation As DicomPresentationStateInformation
 
instance.SetPresentationStateInformation(presentationStateInformation)
public void SetPresentationStateInformation( 
   DicomPresentationStateInformation presentationStateInformation
)

            
public void setPresentationStateInformation(DicomPresentationStateInformation presentationStateInformation)
 function Leadtools.Dicom.DicomDataSet.SetPresentationStateInformation( 
   presentationStateInformation 
)
public:
void SetPresentationStateInformation( 
   DicomPresentationStateInformation^ presentationStateInformation
) 

Parameters

presentationStateInformation
"Presentation State Module" attributes
Remarks
This method will set the attributes of the "Presentation State Module".
Example
Copy Code  
Imports Leadtools
Imports Leadtools.Dicom

Public Sub DicomPresStateSample()
   'Make sure to initialize the DICOM engine, this needs to be done only once 
   'In the whole application
   DicomEngine.Startup()

   Dim dicomDataset As DicomDataSet = New DicomDataSet()
   Using (dicomDataset)
      dicomDataset.Initialize(DicomClassType.GrayscaleSoftcopyPresentationState, DicomDataSetInitializeType.ExplicitVRLittleEndian)
      Dim presentationStateInfo As DicomPresentationStateInformation = New DicomPresentationStateInformation()
      presentationStateInfo.InstanceNumber = 1
      presentationStateInfo.PresentationLabel = "Label"
      presentationStateInfo.PresentationDescription = "Description"
      presentationStateInfo.PresentationCreator = "Creator"
      Dim presentationCreationDate As DicomDateValue = New DicomDateValue()
      presentationCreationDate.Year = 2004
      presentationCreationDate.Month = 1
      presentationCreationDate.Day = 8
      Dim presentationCreationTime As DicomTimeValue = New DicomTimeValue()
      presentationCreationTime.Hours = 2
      presentationCreationTime.Minutes = 3
      presentationCreationTime.Seconds = 5
      presentationStateInfo.PresentationCreationDate = presentationCreationDate
      presentationStateInfo.PresentationCreationTime = presentationCreationTime
      dicomDataset.SetPresentationStateInformation(presentationStateInfo)

      Dim presentationStateInfo1 As DicomPresentationStateInformation = dicomDataset.GetPresentationStateInformation()
      Debug.Assert(Not presentationStateInfo1 Is Nothing)
      Debug.Assert(presentationStateInfo1.InstanceNumber = 1)

      'RemovePresStateImageRefBySOPInstance can be used to remove indivual referened images
      dicomDataset.RemoveAllPresentationStateImageReferences()
      Debug.Assert(dicomDataset.GetPresentationStateImageReferenceCount(Nothing) = 0)
      ' We can also load the dataset first and then call AddPresStateImageRefByDS
      dicomDataset.AddPresentationStateImageReference(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE3.dcm"), Nothing, 0)

      ' We can also add the presentation state using a stream
      Using stream As New FileStream(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE3.dcm"), FileMode.Open)
         dicomDataset.AddPresentationStateImageReference(stream, Nothing, 0)
      End Using

      'We can also use FindNextPresStateRefSeriesItem to iteratate through all items
      Dim item As DicomElement = dicomDataset.FindFirstPresentationStateReferencedSeriesItem()

      Dim imageRefSOPInstanceUID As String = dicomDataset.GetPresentationStateImageReferenceSOPInstance(item, 0)
      Debug.Assert(Not imageRefSOPInstanceUID Is Nothing)
      Dim item1 As DicomElement = dicomDataset.GetPresentationStateImageReference(imageRefSOPInstanceUID)
      Debug.Assert(Not item1 Is Nothing)

      dicomDataset.Save(Path.Combine(LEAD_VARS.ImagesDir, "PresentationState.dcm"), DicomDataSetSaveFlags.None)
   End Using

   DicomEngine.Shutdown()
End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Dicom;

public void DicomPresStateSample()
{
   //Make sure to initialize the DICOM engine, this needs to be done only once 
   //In the whole application
   DicomEngine.Startup();
   using (DicomDataSet dicomDataset = new DicomDataSet())
   {
      dicomDataset.Initialize(DicomClassType.GrayscaleSoftcopyPresentationState, DicomDataSetInitializeType.ExplicitVRLittleEndian);
      DicomPresentationStateInformation presentationStateInfo = new DicomPresentationStateInformation();
      presentationStateInfo.InstanceNumber = 1;
      presentationStateInfo.PresentationLabel = "Label";
      presentationStateInfo.PresentationDescription = "Description";
      presentationStateInfo.PresentationCreator = "Creator";
      DicomDateValue presentationCreationDate = new DicomDateValue();
      presentationCreationDate.Year = 2004;
      presentationCreationDate.Month = 1;
      presentationCreationDate.Day = 8;
      DicomTimeValue presentationCreationTime = new DicomTimeValue();
      presentationCreationTime.Hours = 2;
      presentationCreationTime.Minutes = 3;
      presentationCreationTime.Seconds = 5;
      presentationStateInfo.PresentationCreationDate = presentationCreationDate;
      presentationStateInfo.PresentationCreationTime = presentationCreationTime;
      dicomDataset.SetPresentationStateInformation(presentationStateInfo);

      DicomPresentationStateInformation presentationStateInfo1 = dicomDataset.GetPresentationStateInformation();
      Debug.Assert(presentationStateInfo1 != null);
      Debug.Assert(presentationStateInfo1.InstanceNumber == 1);

      //RemovePresStateImageRefBySOPInstance can be used to remove indivual referened images
      dicomDataset.RemoveAllPresentationStateImageReferences();
      Debug.Assert(dicomDataset.GetPresentationStateImageReferenceCount(null) == 0);
      // We can also load the dataset first and then call AddPresStateImageRefByDS
      dicomDataset.AddPresentationStateImageReference(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE3.dcm"), null, 0);

      // We can also add the presentation state using a stream
      using (FileStream stream = new FileStream(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE3.dcm"), FileMode.Open))
      {
         dicomDataset.AddPresentationStateImageReference(stream, null, 0);
      }

      //We can also use FindNextPresStateRefSeriesItem to iterate through all items
      DicomElement item = dicomDataset.FindFirstPresentationStateReferencedSeriesItem();

      string imageRefSOPInstanceUID = dicomDataset.GetPresentationStateImageReferenceSOPInstance(item, 0);
      Debug.Assert(imageRefSOPInstanceUID != null);
      DicomElement item1 = dicomDataset.GetPresentationStateImageReference(imageRefSOPInstanceUID);
      Debug.Assert(item1 != null);

      dicomDataset.Save(Path.Combine(LEAD_VARS.ImagesDir, "PresentationState.dcm"), DicomDataSetSaveFlags.None);
   }
   DicomEngine.Shutdown();
}

static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
using Leadtools.Dicom.Constants;
using Leadtools;
using Leadtools.Dicom;

      
public async void DicomPresStateSample()
{
   //Make sure to initialize the DICOM engine, this needs to be done only once 
   //In the whole application
   DicomEngine.Startup();
   using (DicomDataSet dicomDataset = new DicomDataSet())
   {
      dicomDataset.Initialize(DicomClassType.GrayscaleSoftcopyPresentationState, DicomDataSetInitializeType.ExplicitVRLittleEndian);
      DicomPresentationStateInformation presentationStateInfo = new DicomPresentationStateInformation();
      presentationStateInfo.InstanceNumber = 1;
      presentationStateInfo.PresentationLabel = "Label";
      presentationStateInfo.PresentationDescription = "Description";
      presentationStateInfo.PresentationCreator = "Creator";
      DicomDateValue presentationCreationDate = new DicomDateValue();
      presentationCreationDate.Year = 2004;
      presentationCreationDate.Month = 1;
      presentationCreationDate.Day = 8;
      DicomTimeValue presentationCreationTime = new DicomTimeValue();
      presentationCreationTime.Hours = 2;
      presentationCreationTime.Minutes = 3;
      presentationCreationTime.Seconds = 5;
      presentationStateInfo.PresentationCreationDate = presentationCreationDate;
      presentationStateInfo.PresentationCreationTime = presentationCreationTime;
      dicomDataset.SetPresentationStateInformation(presentationStateInfo);
      DicomPresentationStateInformation presentationStateInfo1 = dicomDataset.GetPresentationStateInformation();
      Debug.Assert(presentationStateInfo1 != null);
      Debug.Assert(presentationStateInfo1.InstanceNumber == 1);

      //RemovePresStateImageRefBySOPInstance can be used to remove indivual referened images
      dicomDataset.RemoveAllPresentationStateImageReferences();
      Debug.Assert(dicomDataset.GetPresentationStateImageReferenceCount(null) == 0);
      // We can also load the dataset first and then call AddPresStateImageRefByDS
      dicomDataset.AddPresentationStateImageReference(@"ms-appx:///IMAGE3.dcm", null, 0);

      // We can also add the presentation state using a stream
      string filePath = @"Assets\IMAGE3.dcm";
      StorageFile file = await Tools.AppInstallFolder.GetFileAsync(filePath);
      ILeadStream stream = LeadStreamFactory.Create(file);
      using (IDisposable disposable = stream as IDisposable)
      {
         dicomDataset.AddPresentationStateImageReference(stream, null, 0);
      }

      //We can also use FindNextPresStateRefSeriesItem to iterate through all items
      DicomElement item = dicomDataset.FindFirstPresentationStateReferencedSeriesItem();

      string imageRefSOPInstanceUID = dicomDataset.GetPresentationStateImageReferenceSOPInstance(item, 0);
      Debug.Assert(imageRefSOPInstanceUID != null);
      DicomElement item1 = dicomDataset.GetPresentationStateImageReference(imageRefSOPInstanceUID);
      Debug.Assert(item1 != null);

      string dicomFileNameOutput = "PresentationState.dcm";
      StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(dicomFileNameOutput);
      ILeadStream streamOutput = LeadStreamFactory.Create(saveFile);
      using (IDisposable disposableOUT = streamOutput as IDisposable)
      {
         await dicomDataset.SaveAsync(streamOutput, DicomDataSetSaveFlags.None);
      }
   }
   DicomEngine.Shutdown();
}
using Leadtools;
using Leadtools.Dicom;
using Leadtools.Examples;

public void DicomPresStateSample(Stream dicomStream, Stream outputStream)
{
   //Make sure to initialize the DICOM engine, this needs to be done only once 
   //In the whole application
   DicomEngine.Startup();
   using (DicomDataSet dicomDataset = new DicomDataSet())
   {
      dicomDataset.Initialize(DicomClassType.GrayscaleSoftcopyPresentationState, DicomDataSetInitializeType.ExplicitVRLittleEndian);
      DicomPresentationStateInformation presentationStateInfo = new DicomPresentationStateInformation();
      presentationStateInfo.InstanceNumber = 1;
      presentationStateInfo.PresentationLabel = "Label";
      presentationStateInfo.PresentationDescription = "Description";
      presentationStateInfo.PresentationCreator = "Creator";
      DicomDateValue presentationCreationDate = new DicomDateValue();
      presentationCreationDate.Year = 2004;
      presentationCreationDate.Month = 1;
      presentationCreationDate.Day = 8;
      DicomTimeValue presentationCreationTime = new DicomTimeValue();
      presentationCreationTime.Hours = 2;
      presentationCreationTime.Minutes = 3;
      presentationCreationTime.Seconds = 5;
      presentationStateInfo.PresentationCreationDate = presentationCreationDate;
      presentationStateInfo.PresentationCreationTime = presentationCreationTime;
      dicomDataset.SetPresentationStateInformation(presentationStateInfo);
      DicomPresentationStateInformation presentationStateInfo1 = dicomDataset.GetPresentationStateInformation();
      Debug.Assert(presentationStateInfo1 != null);
      Debug.Assert(presentationStateInfo1.InstanceNumber == 1);

      //RemovePresStateImageRefBySOPInstance can be used to remove indivual referened images
      dicomDataset.RemoveAllPresentationStateImageReferences();
      Debug.Assert(dicomDataset.GetPresentationStateImageReferenceCount(null) == 0);
      // We can also load the dataset first and then call AddPresStateImageRefByDS
      dicomDataset.AddPresentationStateImageReference(dicomStream, null, 0);

      //We can also use FindNextPresStateRefSeriesItem to itertate throgh all items
      DicomElement item = dicomDataset.FindFirstPresentationStateReferencedSeriesItem();

      string imageRefSOPInstanceUID = dicomDataset.GetPresentationStateImageReferenceSOPInstance(item, 0);
      Debug.Assert(imageRefSOPInstanceUID != null);
      DicomElement item1 = dicomDataset.GetPresentationStateImageReference(imageRefSOPInstanceUID);
      Debug.Assert(item1 != null);

      dicomDataset.Save(outputStream, DicomDataSetSaveFlags.None);
   }
   DicomEngine.Shutdown();
}
Imports Leadtools
Imports Leadtools.Dicom

Public Sub DicomPresStateSample(ByVal dicomStream As Stream, ByVal outputStream As Stream)
   'Make sure to initialize the DICOM engine, this needs to be done only once 
   'In the whole application
   DicomEngine.Startup()
   Using dicomDataset As DicomDataSet = New DicomDataSet()
      dicomDataset.Initialize(DicomClassType.GrayscaleSoftcopyPresentationState, DicomDataSetInitializeType.ExplicitVRLittleEndian)
      Dim presentationStateInfo As DicomPresentationStateInformation = New DicomPresentationStateInformation()
      presentationStateInfo.InstanceNumber = 1
      presentationStateInfo.PresentationLabel = "Label"
      presentationStateInfo.PresentationDescription = "Description"
      presentationStateInfo.PresentationCreator = "Creator"
      Dim presentationCreationDate As DicomDateValue = New DicomDateValue()
      presentationCreationDate.Year = 2004
      presentationCreationDate.Month = 1
      presentationCreationDate.Day = 8
      Dim presentationCreationTime As DicomTimeValue = New DicomTimeValue()
      presentationCreationTime.Hours = 2
      presentationCreationTime.Minutes = 3
      presentationCreationTime.Seconds = 5
      presentationStateInfo.PresentationCreationDate = presentationCreationDate
      presentationStateInfo.PresentationCreationTime = presentationCreationTime
      dicomDataset.SetPresentationStateInformation(presentationStateInfo)
      Dim presentationStateInfo1 As DicomPresentationStateInformation = dicomDataset.GetPresentationStateInformation()
      Debug.Assert(Not presentationStateInfo1 Is Nothing)
      Debug.Assert(presentationStateInfo1.InstanceNumber = 1)

      'RemovePresStateImageRefBySOPInstance can be used to remove indivual referened images
      dicomDataset.RemoveAllPresentationStateImageReferences()
      Debug.Assert(dicomDataset.GetPresentationStateImageReferenceCount(Nothing) = 0)
      ' We can also load the dataset first and then call AddPresStateImageRefByDS
      dicomDataset.AddPresentationStateImageReference(dicomStream, Nothing, 0)

      'We can also use FindNextPresStateRefSeriesItem to itertate throgh all items
      Dim item As DicomElement = dicomDataset.FindFirstPresentationStateReferencedSeriesItem()

      Dim imageRefSOPInstanceUID As String = dicomDataset.GetPresentationStateImageReferenceSOPInstance(item, 0)
      Debug.Assert(Not imageRefSOPInstanceUID Is Nothing)
      Dim item1 As DicomElement = dicomDataset.GetPresentationStateImageReference(imageRefSOPInstanceUID)
      Debug.Assert(Not item1 Is Nothing)

      dicomDataset.Save(outputStream, DicomDataSetSaveFlags.None)
   End Using
   DicomEngine.Shutdown()
End Sub
Requirements

Target Platforms

See Also

Reference

DicomDataSet Class
DicomDataSet Members
GetPresentationStateInformation Method
AddPresentationStateImageReference(String,Int32[],Int32) Method
AddPresentationStateImageReference(DicomDataSet,Int32[],Int32) Method
RemovePresentationStateImageReference Method
RemoveAllPresentationStateImageReferences Method
GetPresentationStateImageReferenceSOPInstance Method
GetPresentationStateImageReferenceCount Method
FindFirstPresentationStateReferencedSeriesItem Method
FindNextPresentationStateReferencedSeriesItem Method
GetPresentationStateImageReference Method

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.

Leadtools.Dicom requires a Medical toolkit server license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features