Table of Contents

Struct DicomTag

Namespace
Egami.Formats.Extended.Dicom
Assembly
Egami.Formats.Extended.dll

A DICOM data element tag: a group and an element number (PS3.5 section 7.1). Public tags have even groups and are named in PS3.6's data dictionary; odd groups are private.

[Experimental("EGAMIX001", UrlFormat = "https://github.com/inexin/Egami/blob/main/docs/articles/formats/dicom.md")]
public readonly record struct DicomTag : IComparable<DicomTag>, IEquatable<DicomTag>
Implements
Inherited Members

Examples

DicomTag tag = DicomTag.FromKeyword("PixelSpacing");             // (0028,0030)
string? keyword = new DicomTag(0x6002, 0x3000).Keyword;          // OverlayData: repeating groups match
bool isPrivate = new DicomTag(0x0009, 0x1001).IsPrivate;
Console.WriteLine($"{tag} {tag.Name}");

Constructors

DicomTag(ushort, ushort)

Initializes a tag from its group and element numbers.

public DicomTag(ushort group, ushort element)

Parameters

group ushort

The group number, such as 0x0010 for patient information.

element ushort

The element number within the group.

Properties

Element

Gets the element number.

public ushort Element { get; }

Property Value

ushort

Group

Gets the group number.

public ushort Group { get; }

Property Value

ushort

IsPrivate

Gets whether the tag is private: its group is odd.

public bool IsPrivate { get; }

Property Value

bool

IsRetired

Gets whether PS3.6 lists the tag as retired.

public bool IsRetired { get; }

Property Value

bool

Keyword

Gets the PS3.6 keyword, such as PatientName, or null for a tag the dictionary does not name.

public string? Keyword { get; }

Property Value

string

Name

Gets the PS3.6 name, such as Patient's Name, or null for a tag the dictionary does not name.

public string? Name { get; }

Property Value

string

Value

Gets the tag as one number, group in the high 16 bits.

public uint Value { get; }

Property Value

uint

Methods

CompareTo(DicomTag)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

public int CompareTo(DicomTag other)

Parameters

other DicomTag

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes other in the sort order.
Zero This instance occurs in the same position in the sort order as other.
Greater than zero This instance follows other in the sort order.

FromKeyword(string)

Returns the tag a PS3.6 keyword names.

public static DicomTag FromKeyword(string keyword)

Parameters

keyword string

The keyword, such as PatientName; case matters.

Returns

DicomTag

The tag.

Exceptions

ArgumentNullException

keyword is null.

KeyNotFoundException

PS3.6 has no such keyword.

ToString()

Returns the tag as PS3.6 writes it, such as (0010,0010).

public override string ToString()

Returns

string

The tag as text.

TryFromKeyword(string?, out DicomTag)

Looks up the tag a PS3.6 keyword names.

public static bool TryFromKeyword(string? keyword, out DicomTag tag)

Parameters

keyword string

The keyword, such as PatientName; case matters.

tag DicomTag

The tag, when found.

Returns

bool

Whether the keyword is in the dictionary. Keywords of repeating groups, such as OverlayData, give their first group.

Operators

operator >(DicomTag, DicomTag)

Compares two tags by group, then element.

public static bool operator >(DicomTag left, DicomTag right)

Parameters

left DicomTag

The first tag.

right DicomTag

The second tag.

Returns

bool

Whether left comes later.

operator >=(DicomTag, DicomTag)

Compares two tags by group, then element.

public static bool operator >=(DicomTag left, DicomTag right)

Parameters

left DicomTag

The first tag.

right DicomTag

The second tag.

Returns

bool

Whether left comes later or is the same.

operator <(DicomTag, DicomTag)

Compares two tags by group, then element.

public static bool operator <(DicomTag left, DicomTag right)

Parameters

left DicomTag

The first tag.

right DicomTag

The second tag.

Returns

bool

Whether left comes first.

operator <=(DicomTag, DicomTag)

Compares two tags by group, then element.

public static bool operator <=(DicomTag left, DicomTag right)

Parameters

left DicomTag

The first tag.

right DicomTag

The second tag.

Returns

bool

Whether left comes first or is the same.