LaurelBridge.DCF.Examples.DatasetDump Namespace

DICOM Connectivity Framework V3.4
The DatasetDump example demonstates how to use DCF to dump a dataset header.

Public classProgram
The ToString method of DicomDataSet is used to convert an object instance to a human readable string.

Behind the scenes, the ToString method uses the DataSetDumper class which uses DataSetDumperOptions to provide extensive control over the formatting and output options. The second output demonstrates how to get the file offsets for a chapter 10 file.


DatasetDump Sample Code
public class Program
    private static readonly long TooBigToBuffer = IntPtr.Size == 4 ? 100 * 1024 * 1024 : 1024 * 1024 * 1024;

    /// <summary>
    /// Main entry point for DatasetDump.
    /// </summary>
    /// <param name="args">command line arguments</param>
    public static void Main(string[] args)
            string fileName = args.Length > 0 ? args[0] : "mr-knee.dcm";
            // EnableStreamingMode is the default, but just in case somebody changed it
            DicomSessionSettings ss = new DicomSessionSettings() { EnableStreamingMode = true };
            using (DicomFileInput dfi = new DicomFileInput(fileName, ss))
                DicomDataSet dds = dfi.ReadDataSet();
                // If we want the first few pixels to be dumped, expand the streaming mode data,
                // which will cause encapsulated data to be decoded.  But don't do this unless
                // the transfer syntax of the dataset is one that can be decoded.
                // Also check if we have a pixel data element that is too big to buffer.
                DicomElement pixelData = dds.GetElement(Tags.PixelData);
                bool expandPixelData =
                    (pixelData == null || pixelData.LongLength < TooBigToBuffer);
                if (expandPixelData)
            using (DicomFileInput dfi = new DicomFileInput(fileName, ss))
                // also have to tell the file input to track element offsets
                // the element offsets are stored in the dataset object
                dfi.TrackElementOffsets = true;
                DicomDataSet dds = dfi.ReadDataSet();
                // set the dumper options for this dataset to show element offsets and not to show hex values
                dds.DumperOptions = new DataSetDumperOptions() { ShowElementOffsets = true, ShowHexValues = false };
                Console.WriteLine("With element offsets and no hex values{0}{1}", Environment.NewLine, dds);
        catch (Exception e)
            Console.WriteLine("Exception caught during execution: {0}", e);

        if (Debugger.IsAttached)
            Console.Write("Press any key to continue . . . ");

    /// <summary>
    /// These are the transfer syntax uids that DCF can decode out of the box.
    /// </summary>
    private static readonly List<string> DecodableTsUids = new List<string>
        // Implicit and Explicit Little Endian
        Uids.ILE, Uids.ELE,
        // Big Endian is deprecated but there are still plenty in the field
        // Run Length Encoded
        // Jpeg flavors
        Uids.Jpeg50, Uids.Jpeg51, Uids.Jpeg57, Uids.Jpeg70,
        // Jpeg 2000 flavors
        Uids.J2k90, Uids.J2k91