←Select platform

FromAnnContainerToDataSet(DicomDataSet,DicomElement,AnnContainer,FromAnnContainerToDataSetOptions) Method

Summary

Converts all the LEAD Annotation objects in an AnnContainer into one or more DICOM annotation objects, and adds (overwrites or appends) the result in a Leadtools.Dicom.DicomDataSet.

Syntax
C#
C++/CLI

Parameters

ds

The Leadtools.Dicom.DicomDataSet where the resulting DICOM Annotation objects are stored.

graphicAnnotationSequenceItem

The specific Leadtools.Dicom.DicomElement where the resulting DICOM Annotation objects are stored.

annContainer

The Leadtools.Annotations.Engine.AnnContainer that contains a list of Leadtools.Annotations.Engine.AnnObject objects that are to be converted.

options

options that determine if annotations are appended to existing ds, or if ds is overwritten.

Return Value

A Leadtools.Dicom.DicomDataSet of type DicomUidType.GrayscaleSoftcopyPresentationStateStorage containing all the annotations in annContainer.

Remarks

This method converts a LEAD Leadtools.Annotations.Engine.AnnContainer of Leadtools.Annotations.Engine.AnnObject objects into one or more DICOM annotation objects (text, graphic, and compound graphic), and stores (overwrites or appends) the result inside the ds parameter.

If the resulting DICOM annotation object is:

  • Compound Graphic , it will be added under the Compound Graphic Sequence and for backward compatibility (as per the DICOM Specification) it will also be added under the Graphic Object Sequence.
  • Text Object , it will be added under the Text Object Sequence.
  • Graphic Object , it will be added under the Graphic Object Sequence.

The dsImage is a Leadtools.Dicom.DicomDataSet that contains an image on which the annotations are to be rendered.

Patient, Study, and series information is copied from dsImage and stored in the resulting ds, including:

Patient Information:

  • (0010,0010) PatientName
  • (0010,0021) IssuerOfPatientID
  • (0010,0030) PatientBirthDate
  • (0010,0040) PatientSex
  • (0010,0032) PatientBirthTime
  • (0010,1000) OtherPatientIDs
  • (0010,1001) OtherPatientNames
  • (0010,2160) EthnicGroup
  • (0010,4000) PatientComments
  • (0010,2201) PatientSpeciesDescription
  • (0010,2292) PatientBreedDescription
  • (0010,2297) ResponsiblePerson
  • (0010,2298) ResponsiblePersonRole
  • (0010,2299) ResponsibleOrganization
  • (0012,0062) PatientIdentityRemoved

PatientStudy Information:

  • (0010,1010) PatientAge
  • (0010,1020) PatientSize
  • (0010,1030) PatientWeight
  • (0010,2180) Occupation
  • (0010,21B0) AdditionalPatientHistory
  • (0038,0010) AdmissionID
  • (0010,2203) PatientSexNeutered

Study Information:

  • (0020,000D) StudyInstanceUID
  • (0008,0020) StudyDate
  • (0008,0030) StudyTime
  • (0008,1030) StudyDescription
  • (0040,050A) AccessionNumber
  • (0008,0090) ReferringPhysicianName
  • (0008,0092) ReferringPhysicianAddress
  • (0008,0094) ReferringPhysicianTelephoneNumbers
  • (0008,1060) NameOfPhysicianReadingStudy
  • (0020,0010) StudyID

Series Information:

  • (0020,0060) Laterality
  • (0040,0006) PerformingPhysicianName
  • (0072,0002) ProtocolName
  • (0008,103E) SeriesDescription
  • (0008,1070) OperatorName
  • (0018,0015) BodyPartExamined
  • (0018,5100) PatientPosition
  • (0010,2210) AnatomicalOrientationType

Pass FromAnnContainerToDataSetOptions.Create to overwrite any existing annotations in ds.

Pass FromAnnContainerToDataSetOptions.Append to append to any existing annotations in ds.

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 22.0.2023.1.26
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 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.