Struct DicomTag
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
groupushortThe group number, such as 0x0010 for patient information.
elementushortThe element number within the group.
Properties
Element
Gets the element number.
public ushort Element { get; }
Property Value
Group
Gets the group number.
public ushort Group { get; }
Property Value
IsPrivate
Gets whether the tag is private: its group is odd.
public bool IsPrivate { get; }
Property Value
IsRetired
Gets whether PS3.6 lists the tag as retired.
public bool IsRetired { get; }
Property Value
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
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
Value
Gets the tag as one number, group in the high 16 bits.
public uint Value { get; }
Property Value
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
otherDicomTagAn 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 otherin the sort order.Zero This instance occurs in the same position in the sort order as other.Greater than zero This instance follows otherin the sort order.
FromKeyword(string)
Returns the tag a PS3.6 keyword names.
public static DicomTag FromKeyword(string keyword)
Parameters
keywordstringThe keyword, such as
PatientName; case matters.
Returns
- DicomTag
The tag.
Exceptions
- ArgumentNullException
keywordis 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
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
Returns
- bool
Whether
leftcomes later.
operator >=(DicomTag, DicomTag)
Compares two tags by group, then element.
public static bool operator >=(DicomTag left, DicomTag right)
Parameters
Returns
- bool
Whether
leftcomes later or is the same.
operator <(DicomTag, DicomTag)
Compares two tags by group, then element.
public static bool operator <(DicomTag left, DicomTag right)
Parameters
Returns
- bool
Whether
leftcomes first.
operator <=(DicomTag, DicomTag)
Compares two tags by group, then element.
public static bool operator <=(DicomTag left, DicomTag right)
Parameters
Returns
- bool
Whether
leftcomes first or is the same.