LAUREL BRIDGE

LaurelBridge.DCFExamples.DicomDiff Namespace

DICOM Connectivity Framework V3.4
The DicomDiff example demonstrates how to use DCF to programmatically find differences between DICOM datasets.
Classes

  ClassDescription
Public classOptions
Command line options class for parsing user options for DicomDiff.
Public classProgram
Compare two Dicom datasets (given as input filenames) using the DicomComparer in the DCF library.
Remarks

Supported OS Platforms:

  • Windows - .Net Framework 4.7.2 64-bit and 32-bit
  • Windows - .Net Core 2.1 64-bit and 32-bit
  • Linux - .Net Core 2.1 64-bit

Examples

DicomDiff Sample Code
public class Program
{
    /// <summary>
    /// Main entry point for DicomDiff.
    /// </summary>
    /// <param name="args">command line arguments</param>
    public static void Main(string[] args)
    {
        try
        {
            Options options;
            if (!Options.TryParse(args, out options))
            {
                throw new ArgumentException("bad command line parameters");
            }

            Console.WriteLine("File1: {0}", options.File1);
            Console.WriteLine("File2: {0}", options.File2);

            using (DicomFileInput dfi1 = new DicomFileInput(options.File1))
            {
                DicomDataSet ds1 = dfi1.ReadDataSet();
                using (DicomFileInput dfi2 = new DicomFileInput(options.File2))
                {
                    DicomDataSet ds2 = dfi2.ReadDataSet();
                    DifferenceFlags flags = DifferenceFlags.Recurse | DifferenceFlags.VrTrim;
                    foreach (IDicomDifference diff in new DicomComparer(flags).GetDifferences(ds1, ds2))
                        Console.WriteLine(diff);
                }
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("Problem comparing datasets: {0}", e);
            Environment.ExitCode = 1;
        }
        finally
        {
            if (System.Diagnostics.Debugger.IsAttached)
            {
                Console.Write("Press any key to continue . . . ");
                Console.ReadKey();
            }
        }
    }
}