←Select platform

FromDataSetToAnnContainer(DicomDataSet,DicomElement,DicomDataSet) Method

Summary

Converts all the Graphic Annotation Sequence (DICOM Annotations) stored in a Leadtools.Dicom.DicomDataSet into a LEAD AnnContainer that contains LEAD Leadtools.Annotations.Engine.AnnObject objects.

Syntax
C#
C++/CLI
public:  
   AnnContainer^ FromDataSetToAnnContainer( 
      DicomDataSet^ ds, 
      DicomElement^ graphicAnnSqItem, 
      DicomDataSet^ dsImage 
   ) 

Parameters

ds

The Leadtools.Dicom.DicomDataSet that contains the Graphic Annotation Sequence (DICOM Annotation) being converted.

graphicAnnSqItem

Pointer to an item element under the "Graphic Annotation Sequence" (0070,0001) in the "Graphic Annotation Module".

dsImage

A Leadtools.Dicom.DicomDataSet that contains an image. Only those annotations associated with the SOPInstanceUID of dsImage will be converted. All other annotations will be ignored.

Return Value

A LEAD AnnContainer that contains the LEAD AnnObject.

Remarks

This method takes Leadtools.Dicom.DicomDataSet as input, and converts all the DICOM annotations stored in the Graphic Annotation Sequence into LEAD annotations.

The LEAD annotations are returned as an AnnContainer.

Note that this method preserves any ruler calibrations, as the ruler calibration is stored in the AnnContainer.

The ds can contain annotations associated with more than one DICOM Image (i.e., SOPInstanceUID). This overload only converts those annotations associated with the SOPInstanceUID of dsImage.

All other annotations will be ignored.

Example
C#
using Leadtools; 
using Leadtools.Dicom; 
using Leadtools.Dicom.Annotations; 
using Leadtools.Annotations; 
using Leadtools.Annotations.Engine; 
 
// This example stores DICOM annotations for two different DICOM instances in the same DICOM presentation file 
// The DICOM annotations are then loaded separately for each DICOM instance 
// When running this sample, you must pass two different DICOM instances for the same PatientID 
// The following DICOM files can be used: 
//    1. C:\LEADTOOLSxx\Examples\DotNet\PACSFramework\CS\PACSDatabaseConfigurationDemo\Resources\cr1.dcm 
//    2. C:\LEADTOOLSxx\Examples\DotNet\PACSFramework\CS\PACSDatabaseConfigurationDemo\Resources\cr1.dcm 
private void DicomAnnotationsUtilities_FromAnnContainerToDataSet2(DicomDataSet dsImage1, DicomDataSet dsImage2, string outfilePresentationState) 
{ 
   // Create an AnnRectangleObject (rotated, filled) 
   AnnRectangleObject rectangleObject = new AnnRectangleObject(); 
   rectangleObject.Stroke.Stroke = AnnSolidColorBrush.Create("red"); 
   rectangleObject.Fill = AnnSolidColorBrush.Create("blue"); 
   rectangleObject.Points.Add(ConvertLeadPointD(100, 100)); 
   rectangleObject.Points.Add(ConvertLeadPointD(200, 100)); 
   rectangleObject.Points.Add(ConvertLeadPointD(200, 200)); 
   rectangleObject.Points.Add(ConvertLeadPointD(100, 200)); 
   rectangleObject.Rotate(45.0, ConvertLeadPointD(150, 150)); 
 
   // Create a polyline object 
   AnnPolylineObject polylineObject = new AnnPolylineObject(); 
   polylineObject.Stroke.Stroke = AnnSolidColorBrush.Create("red"); 
   polylineObject.Points.Clear(); 
   polylineObject.Points.Add(ConvertLeadPointD(300, 100)); 
   polylineObject.Points.Add(ConvertLeadPointD(400, 200)); 
 
   // Add them to the AnnContainer 
   AnnContainer annContainer = new AnnContainer(); 
   annContainer.Mapper = new AnnContainerMapper(96, 96, 96, 96); 
   annContainer.Children.Add(rectangleObject); 
   annContainer.Children.Add(polylineObject); 
 
   // Create a DicomDataSet 
   using (DicomDataSet dsPS = new DicomDataSet()) 
   { 
      dsPS.Initialize(DicomClassType.GrayscaleSoftcopyPresentationState, DicomDataSetInitializeFlags.AddMandatoryModulesOnly | DicomDataSetInitializeFlags.AddMandatoryElementsOnly); 
 
      // Delete the empty referenced Series Sequence 
      DicomElement referencedSeriesSequence = dsPS.FindFirstElement(null, DicomTag.ReferencedSeriesSequence, true); 
      if (referencedSeriesSequence != null) 
      { 
         dsPS.DeleteElement(referencedSeriesSequence); 
      } 
 
      // Add a new Referenced Series Sequence 
      dsPS.AddPresentationStateImageReference(dsImage1, null, 0); 
 
      // Set up the DicomAnnotationsUtilities converter 
      DicomAnnotationsUtilities du = new DicomAnnotationsUtilities(); 
 
      // Change the DICOM Unique Identifier Organization Root 
      // The SOPInstanceUID of the presentation state will start with this prefix 
      du.DicomUidOrgRoot = "1.2.840.1111.2222.3333"; 
 
      // Set defaults 
      du.UseMapper = true; 
      du.ContainerMapper = annContainer.Mapper; 
      du.DefaultObject = new DicomTextObject(); 
      du.ImageDpiX = 96.0; 
      du.ImageDpiY = 96.0; 
      du.DisplayWidth = 200; 
      du.DisplayHeight = 200; 
      du.LayerName = "Layer 0"; 
 
      // Set up the presentation state module 
      PresentationStateIdentificationModule ps = new PresentationStateIdentificationModule(); 
      ps.ContentCreatorName = "My Content Creator Name"; 
      ps.ContentDescription = "My Content Description"; 
      ps.ContentLabel = "My Content Label"; 
      DateTime now = DateTime.Now; 
      ps.CreationDate = new DicomDateValue(now); 
      ps.CreationTime = new DicomTimeValue(now); 
      ps.InstanceNumber = 123; 
 
      du.PresentationStateIdentification = ps; 
 
      // Convert LEAD annotations to DICOM annotations 
 
      // Note that dsImage1 and dsImage2 must have the same PatientID 
      // The images can be from different studies and series 
 
      // 1. Add annotations for dsImage1 
      du.FromAnnContainerToDataSet(dsPS, annContainer, dsImage1, string.Empty, string.Empty, FromAnnContainerToDataSetOptions.Create); 
 
 
      // 2. Add annotations for dsImage2 
      annContainer.Children.Clear(); 
 
      // Create an AnnEllipseObject (rotated, filled) 
      AnnEllipseObject ellipseObject = new AnnEllipseObject(); 
      ellipseObject.Stroke.Stroke = AnnSolidColorBrush.Create("red"); 
      ellipseObject.Fill = AnnSolidColorBrush.Create("yellow"); 
      ellipseObject.Points.Add(ConvertLeadPointD(100, 100)); 
      ellipseObject.Points.Add(ConvertLeadPointD(200, 100)); 
      ellipseObject.Points.Add(ConvertLeadPointD(200, 200)); 
      ellipseObject.Points.Add(ConvertLeadPointD(100, 200)); 
      annContainer.Children.Add(ellipseObject); 
 
 
      du.FromAnnContainerToDataSet(dsPS, annContainer, dsImage2, string.Empty, string.Empty, FromAnnContainerToDataSetOptions.Append); 
 
      // Save the presentation state 
      dsPS.Save(outfilePresentationState, DicomDataSetSaveFlags.None); 
 
      // Read the annotations for dsImage1 -- there should be two objects 
      AnnContainer annContainer1 = du.FromDataSetToAnnContainer(dsPS, null, dsImage1); 
      Debug.Assert(annContainer1.Children.Count == 2); 
 
      // Read the annotations for dsImage2 -- there should be one object 
      AnnContainer annContainer2 = du.FromDataSetToAnnContainer(dsPS, null, dsImage2); 
      Debug.Assert(annContainer2.Children.Count == 1); 
 
      MessageBox.Show("Presentation State Saved: " + outfilePresentationState); 
   } 
} 
 
LeadPointD ConvertLeadPointD(double x, double y) 
{ 
   double imageDpi = 96.0; 
   return new LeadPointD(x * 720.0 / imageDpi, y * 720.0 / imageDpi); 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Dicom.Annotations Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.