Anonymizer Class

Summary
Provides support for anonymized DICOM files.
Syntax
C#
C++/CLI
[DefaultMemberAttribute("Item")] 
public class Anonymizer : NotifyPropertyChanged 
[DefaultMemberAttribute("Item")] 
public ref class Anonymizer : public NotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanged   
Remarks

The Anonymizer class provides you with the ability to anonymize DICOM files using macros. The Anonymizer is created with default macros that can be replaced or you can add your own.

Example

This example anonymizes a dataset using the DICOM Anonymization basic profile.

C#
using Leadtools.Dicom.Common.Anonymization; 
using Leadtools.Dicom; 
 
 
public void AnonymizationSample() 
{ 
   Anonymizer anonymizer = new Anonymizer(true); 
   string dicomFileNameIn = Path.Combine(LEAD_VARS.ImagesDir,"DICOM", "image3.dcm"); 
 
   anonymizer.Progress += new EventHandler<ProgressEventArgs>(anonymizer_Progress); 
   anonymizer.BeforeTagAnonymization += new EventHandler<BeforeTagAnonymizationEventArgs>(anonymizer_BeforeTagAnonymization); 
   DicomEngine.Startup(); 
   using (DicomDataSet source = new DicomDataSet()) 
   { 
      string oldPatientId = string.Empty; 
 
      source.Load(dicomFileNameIn, DicomDataSetLoadFlags.None); 
      oldPatientId = source.GetValue<string>(DicomTag.PatientID, string.Empty); 
      anonymizer.Anonymize(source); 
 
      // 
      // The values should not be equal because the anonymizer has provided another patient ID using the DICOM Anonymization basic profile. 
      // By default the following macro is provided for patient id: ${random_string} 
      // 
             
      Assert.IsTrue(oldPatientId != source.GetValue<string>(DicomTag.PatientID, string.Empty), "The values should not be equal because the anonymizer has provided another patient ID using the DICOM Anonymization basic profile."); 
   } 
 
   DicomEngine.Shutdown(); 
} 
 
void anonymizer_BeforeTagAnonymization(object sender, BeforeTagAnonymizationEventArgs e) 
{ 
   Console.WriteLine(string.Format("Tag: {0}, Current Value: {1}, New Value: {0} ", e.Element.Tag, e.CurrentValue, e.NewValue)); 
} 
 
void anonymizer_Progress(object sender, ProgressEventArgs e) 
{ 
   Console.WriteLine("Progress: " + e.Progress.ToString()); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

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