DICOM Data Elements and Tags

Section 10 of 27
37% complete

DICOM data elements are the building blocks of DICOM files and messages. Understanding tags is essential for effective DICOM development.

Tag Anatomy

A DICOM tag consists of a Group and Element number, each 2 bytes (16 bits):

DICOM Tag Anatomysaravanansubramanian.comevery attribute is addressed by a 4-digit Group and 4-digit Element in hexExample — Patient NameGROUP0010,ELEMENT0010functional area · Patientspecific attribute · Patient NameTAG IN CODE”00100010”8 hex digits · no comma · concatenated Group + Element

Group Categories

DICOM organizes attributes into groups by functional area. Memorizing the main group numbers helps you quickly locate relevant attributes when working with DICOM data. Each group serves a specific purpose in describing different aspects of the imaging study.

DICOM Group Number Ranges
=========================

Group 0000-0001:  Command elements (network)
Group 0002:       File Meta Information
Group 0004-0007:  Directory Structuring (DICOMDIR)
Group 0008:       Identifying Information
Group 0010:       Patient Information
Group 0018:       Acquisition Parameters
Group 0020:       Relationship (UIDs, numbers)
Group 0028:       Image Presentation
Group 0032:       Study Content
Group 0038:       Visit Information
Group 0040:       Procedure/Protocol
Group 7FE0:       Pixel Data
Group FFFE:       Item/Sequence delimiters

Even Groups (Standard DICOM)

Standard DICOM tags use even group numbers and are defined in the DICOM standard. These tags have consistent meanings across all implementations, enabling interoperability between different vendors and systems. Understanding the common tags in each group allows you to extract and manipulate imaging metadata effectively.

Group 0008: Identifying Information

Group 0008 contains identification attributes including dates, times, modality, and SOP information. These tags help identify what the study is and when it was performed.

// Character Set
dicomImage.Attributes["00080005"].Value = "ISO_IR 100"; // Specific Character Set

// SOP Information
dicomImage.Attributes["00080016"].Value = sopClassUID;   // SOP Class UID
dicomImage.Attributes["00080018"].Value = sopInstanceUID; // SOP Instance UID

// Date/Time
dicomImage.Attributes["00080020"].Value = "20240115";    // Study Date
dicomImage.Attributes["00080030"].Value = "143000";      // Study Time

// Study Identification
dicomImage.Attributes["00080050"].Value = "ACC123";      // Accession Number
dicomImage.Attributes["00080060"].Value = "CT";          // Modality
dicomImage.Attributes["00080070"].Value = "SIEMENS";     // Manufacturer
dicomImage.Attributes["00080090"].Value = "Dr. Smith";   // Referring Physician

Group 0010: Patient Information

Group 0010 contains patient demographic information. These attributes identify the patient and are typically Protected Health Information (PHI) that must be handled according to privacy regulations when anonymizing files.

// Patient Demographics
dicomImage.Attributes["00100010"].Value = "Doe^John^A"; // Patient Name
dicomImage.Attributes["00100020"].Value = "12345678";   // Patient ID
dicomImage.Attributes["00100030"].Value = "19800515";   // Birth Date
dicomImage.Attributes["00100040"].Value = "M";          // Sex

// Patient Characteristics
dicomImage.Attributes["00101010"].Value = "044Y";       // Patient Age
dicomImage.Attributes["00101020"].Value = "1.75";       // Patient Size (meters)
dicomImage.Attributes["00101030"].Value = "75";         // Patient Weight (kg)

Group 0018: Acquisition Parameters

Group 0018 contains technical parameters describing how the image was acquired. These include scanner settings like kVp, mA, slice thickness, and protocol information. This data is essential for quality control and understanding image characteristics.

// Exam Parameters
dicomImage.Attributes["00180015"].Value = "CHEST";       // Body Part Examined
dicomImage.Attributes["00180050"].Value = "5.0";         // Slice Thickness (mm)
dicomImage.Attributes["00180060"].Value = "120";         // KVP (kilovolt peak)
dicomImage.Attributes["00181030"].Value = "Routine";     // Protocol Name
dicomImage.Attributes["00181151"].Value = "100";         // X-Ray Tube Current (mA)

Group 0020: Relationship Information

Group 0020 contains UIDs and numbers that establish relationships between studies, series, and instances. These attributes define the hierarchical structure of imaging data and are critical for proper organization in PACS systems.

// UIDs
dicomImage.Attributes["0020000D"].Value = studyUID;      // Study Instance UID
dicomImage.Attributes["0020000E"].Value = seriesUID;     // Series Instance UID

// Numbers
dicomImage.Attributes["00200010"].Value = "12345";       // Study ID
dicomImage.Attributes["00200011"].Value = "1";           // Series Number
dicomImage.Attributes["00200013"].Value = "1";           // Instance Number

// Spatial Information
dicomImage.Attributes["00200032"].Value = "-125\\-125\\80";   // Image Position
dicomImage.Attributes["00200037"].Value = "1\\0\\0\\0\\1\\0"; // Image Orientation

Group 0028: Image Presentation

Group 0028 describes the image dimensions, pixel format, and display characteristics. These attributes are essential for correctly interpreting and rendering the pixel data. Window/level values determine how raw pixel values map to displayed grayscale.

// Image Dimensions
dicomImage.Attributes["00280002"].Value = "1";           // Samples Per Pixel
dicomImage.Attributes["00280004"].Value = "MONOCHROME2"; // Photometric Interpretation
dicomImage.Attributes["00280008"].Value = "100";         // Number of Frames
dicomImage.Attributes["00280010"].Value = "512";         // Rows
dicomImage.Attributes["00280011"].Value = "512";         // Columns

// Pixel Characteristics
dicomImage.Attributes["00280030"].Value = "0.70\\0.70";  // Pixel Spacing (mm)
dicomImage.Attributes["00280100"].Value = "16";          // Bits Allocated
dicomImage.Attributes["00280101"].Value = "12";          // Bits Stored
dicomImage.Attributes["00280102"].Value = "11";          // High Bit
dicomImage.Attributes["00280103"].Value = "0";           // Pixel Representation

// Window/Level
dicomImage.Attributes["00281050"].Value = "40";          // Window Center
dicomImage.Attributes["00281051"].Value = "400";         // Window Width
dicomImage.Attributes["00281052"].Value = "-1024";       // Rescale Intercept
dicomImage.Attributes["00281053"].Value = "1";           // Rescale Slope

Group 7FE0: Pixel Data

Group 7FE0 contains the actual image pixel data. The size and format of this data depends on the image dimensions, bit depth, and transfer syntax (compression). This is typically the largest element in a DICOM file.

// Pixel Data - the actual image
// Format depends on transfer syntax and image characteristics
dicomImage.Attributes["7FE00010"].Value = pixelBytes; // Pixel Data

Odd Groups (Private Tags)

Private tags are used by manufacturers for proprietary data that is not part of the DICOM standard. These tags enable vendors to store additional information specific to their equipment while still maintaining DICOM compliance. When processing DICOM files, you should preserve private tags unless specifically required to remove them.

// Private tags use odd group numbers
// Format: (GGGG,EEEE) where GGGG is odd

// Example: Siemens private tags
dicomImage.Attributes["00091010"].Value = "SIEMENS CSA HEADER"; // Private Creator

// Private Creator identifies the owner
// Must check before accessing private data
if (dicomImage.Attributes.Contains("00091010"))
{
    string privateCreator = dicomImage.Attributes["00091010"].Value.ToString();
    if (privateCreator == "SIEMENS CSA HEADER")
    {
        // Safe to access Siemens private tags in group 0009
        // Access private data elements...
    }
}

Private Tag Structure

DICOM Private Tag Organizationsaravanansubramanian.coman odd-numbered group holds creator IDs and the manufacturer’s private data elementsGroup 00XX (odd)private groupElement 0010–00FFPrivate Creator IDsidentifies who owns the private dataElement 1000–XXFFPrivate Data Elementsmanufacturer-specific dataEXAMPLE — SIEMENS CSA HEADER(0009,0010) = “SIEMENS CSA HEADER”Creator ID(0009,1010) = <binary data>Private data(0009,1011) = <binary data>Private data

Common DICOM Tags Reference

Defining tag constants in a centralized class improves code maintainability and reduces errors from typos in tag strings. The following reference class provides commonly used tags organized by DICOM hierarchy level.

public static class DicomTags
{
    // Patient Level
    public const string PatientName = "00100010";
    public const string PatientID = "00100020";
    public const string PatientBirthDate = "00100030";
    public const string PatientSex = "00100040";
    public const string PatientAge = "00101010";
    public const string PatientWeight = "00101030";

    // Study Level
    public const string StudyInstanceUID = "0020000D";
    public const string StudyDate = "00080020";
    public const string StudyTime = "00080030";
    public const string AccessionNumber = "00080050";
    public const string StudyDescription = "00081030";
    public const string ReferringPhysicianName = "00080090";
    public const string StudyID = "00200010";

    // Series Level
    public const string SeriesInstanceUID = "0020000E";
    public const string Modality = "00080060";
    public const string SeriesNumber = "00200011";
    public const string SeriesDescription = "0008103E";
    public const string BodyPartExamined = "00180015";
    public const string ProtocolName = "00181030";

    // Instance Level
    public const string SOPClassUID = "00080016";
    public const string SOPInstanceUID = "00080018";
    public const string InstanceNumber = "00200013";
    public const string ImageType = "00080008";

    // Image Characteristics
    public const string Rows = "00280010";
    public const string Columns = "00280011";
    public const string BitsAllocated = "00280100";
    public const string BitsStored = "00280101";
    public const string PixelSpacing = "00280030";
    public const string SliceThickness = "00180050";

    // Window/Level
    public const string WindowCenter = "00281050";
    public const string WindowWidth = "00281051";
    public const string RescaleIntercept = "00281052";
    public const string RescaleSlope = "00281053";

    // Pixel Data
    public const string PixelData = "7FE00010";

    // Transfer Syntax
    public const string TransferSyntaxUID = "00020010";
}

Advanced Tag Operations

Working with DICOM tags in production code requires defensive programming techniques. Attributes may be missing, have unexpected types, or contain invalid values. The following utility class provides robust methods for accessing, validating, and manipulating DICOM attributes.

Safe Attribute Access

public class AdvancedTagOperations
{
    // Safely get attribute value with default
    public static T GetAttributeValue<T>(DicomImage image, string tag, T defaultValue)
    {
        if (!image.Attributes.Contains(tag))
            return defaultValue;

        try
        {
            var value = image.Attributes[tag].Value;
            if (value == null)
                return defaultValue;

            return (T)Convert.ChangeType(value, typeof(T));
        }
        catch
        {
            return defaultValue;
        }
    }

    // Check if required tags are present
    public static bool ValidateRequiredTags(DicomImage image, out List<string> missingTags)
    {
        missingTags = new List<string>();

        var requiredTags = new[]
        {
            DicomTags.SOPClassUID,
            DicomTags.SOPInstanceUID,
            DicomTags.StudyInstanceUID,
            DicomTags.SeriesInstanceUID,
            DicomTags.PatientName,
            DicomTags.PatientID
        };

        foreach (var tag in requiredTags)
        {
            if (!image.Attributes.Contains(tag) ||
                string.IsNullOrEmpty(image.Attributes[tag].Value?.ToString()))
            {
                missingTags.Add($"{tag} - {GetTagName(tag)}");
            }
        }

        return missingTags.Count == 0;
    }

    // Copy tags from one image to another
    public static void CopyTags(DicomImage source, DicomImage dest, params string[] tags)
    {
        foreach (var tag in tags)
        {
            if (source.Attributes.Contains(tag))
            {
                dest.Attributes[tag].Value = source.Attributes[tag].Value;
            }
        }
    }

    // Get all tags in a specific group
    public static Dictionary<string, string> GetGroupTags(DicomImage image, string group)
    {
        var result = new Dictionary<string, string>();

        foreach (var attr in image.Attributes)
        {
            string tag = attr.Tag.ToString();
            if (tag.StartsWith(group))
            {
                result[tag] = attr.Value?.ToString() ?? "(empty)";
            }
        }

        return result;
    }

    private static string GetTagName(string tag)
    {
        // Tag name lookup implementation
        return tag; // Simplified
    }
}

Usage Examples

These examples demonstrate practical use of the helper methods for common DICOM processing scenarios including data extraction, validation, and debugging.

// Get patient name with default
string patientName = AdvancedTagOperations.GetAttributeValue<string>(
    image, DicomTags.PatientName, "Unknown");

// Get rows as integer with default
int rows = AdvancedTagOperations.GetAttributeValue<int>(
    image, DicomTags.Rows, 512);

// Validate required tags
if (!AdvancedTagOperations.ValidateRequiredTags(image, out var missing))
{
    Console.WriteLine("Missing required tags:");
    foreach (var tag in missing)
    {
        Console.WriteLine($"  - {tag}");
    }
}

// Display all patient tags
var patientTags = AdvancedTagOperations.GetGroupTags(image, "0010");
foreach (var kvp in patientTags)
{
    Console.WriteLine($"{kvp.Key}: {kvp.Value}");
}

Summary

Understanding DICOM tags is fundamental:

  1. Tag Structure: (GGGG,EEEE) - Group and Element
  2. Even Groups: Standard DICOM attributes
  3. Odd Groups: Private/proprietary attributes
  4. Key Groups: 0008 (ID), 0010 (Patient), 0020 (Relationship), 0028 (Image), 7FE0 (Pixels)
  5. Safe Access: Always validate tag presence before access

Mastering tags enables effective DICOM data manipulation and interoperability.

Quiz: DICOM Data Elements and Tags

Question 1 of 4

What format does a DICOM tag follow?