←Select platform

ElementValue Property

Summary

Gets or sets the string value of the DICOM element being read.

Syntax

C#
C++/CLI
public string ElementValue { get; set; } 
public:  
   property String^ ElementValue 
   { 
      String^ get() 
      void set(String^ value) 
   } 

Property Value

The string value of the DICOM element being read.

Remarks

If ElementDataType is ElementDataType.String, then this will be the value assigned to the DicomElement that will be created.

If ElementDataType is ElementDataType.Base64, then ElementValue contains a string that will be decoded accordingly, and then assigned to the DicomElement that will be created.

Modifying ElementValue changes the value that will be written for the DicomElement.

Example

C#
using Leadtools.Dicom; 
using Leadtools.Dicom.Common; 
using Leadtools.Dicom.Common.Extensions; 
using Leadtools; 
using Leadtools.Dicom.Common.Linq.BasicDirectory; 
using Leadtools.Dicom.Common.DataTypes; 
 
using Leadtools.Codecs; 
 
public void LoadJsonCallbackExample() 
{ 
   string dicomFileNameIn = Path.Combine(LEAD_VARS.ImagesDir,"DICOM", "image2.dcm"); 
   string jsonFileNameOut = Path.Combine(LEAD_VARS.ImagesDir, "test.json"); 
   string dicomFileNameOut = Path.Combine(LEAD_VARS.ImagesDir, "test.dcm"); 
 
   // Initialize DICOM engine 
   DicomEngine.Startup(); 
 
   DicomDataSet ds = new DicomDataSet(); 
 
   // Load an existing DICOM file 
   ds.Load(dicomFileNameIn, DicomDataSetLoadFlags.None); 
 
   // Save as JSON to a file with no binary data 
   // For the demo, keep the json output file size small by skipping the pixel data 
   // Use the SaveJsonCallback delegate to customize the json file 
   DicomDataSetSaveJsonFlags jsonFlags = 
      DicomDataSetSaveJsonFlags.IgnoreBinaryData | 
      DicomDataSetSaveJsonFlags.TrimWhiteSpace; 
 
   ds.SaveJson(jsonFileNameOut, jsonFlags); 
 
   // Use a LoadmlCallback to read the customized json file 
   ds.LoadJson(jsonFileNameOut, DicomDataSetLoadJsonFlags.None, MyLoadJsonBeforeElementCallback, MyLoadJsonAfterElementCallback); 
 
   // Save the result -- there will be no pixel data 
   ds.Save(dicomFileNameOut, DicomDataSetSaveFlags.None); 
 
   DicomEngine.Shutdown(); 
} 
 
private static bool MyLoadJsonBeforeElementCallback(LoadJsonBeforeElementData data) 
{ 
   // Remove Patient Birth Date 
   if (data.Tag == DicomTag.PatientBirthDate) 
   { 
      return false; 
   } 
 
   // Change the patient name 
   if (data.Tag == DicomTag.PatientName) 
   { 
      data.ElementValue = "NewLast^NewFirst"; 
   } 
 
   // Write the elements to the consolee that have child elements 
   if (data.HasChildElements) 
   { 
      Console.WriteLine("Element {0} has child elements.", data.Tag); 
   } 
   return true; 
} 
 
private static void MyLoadJsonAfterElementCallback(LoadJsonAfterElementData data) 
{ 
   if (data.DicomElement.Tag == DicomTag.PixelData) 
   { 
      // here you could call one of the following to set the pixel data 
      //    data.DicomDataSet.SetBinaryValue  
      //    data.DicomDataSet.SetImage() 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 

Requirements

Target Platforms

See Also

LoadBeforeElementData Class

LoadBeforeElementData Members

Leadtools.Dicom.Common.Extensions Namespace

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

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