Value Representation
DICOM header fields contain, in the great majority of cases, Value Representation (VR) codes that provide information about the type of the data that is stored or its expected format.
The following table provides an overview of the expected return types by VR:
VR |
Name |
pydicom |
dicom_parser |
Comments |
---|---|---|---|---|
AE |
Application Entity |
|||
AS |
Age String |
Age in years. |
||
AT |
Attribute Tag |
|||
CS |
Code String |
Values will, by default, be converted to verbose values (if available). |
||
DA |
Date |
|||
DS |
Decimal String |
|||
DT |
Date Time |
|||
FL |
Floating Point Single |
|||
FD |
Floating Point Double |
|||
IS |
Integer String |
|||
LO |
Long String |
|||
LT |
Long Text |
|||
OB |
Other Byte |
|||
OD |
Other Double |
|||
OF |
Other Float |
|||
OL |
Other Long |
|||
OV |
Other 64-bit Very Long |
|||
OW |
Other Word |
|||
PN |
Person Name |
|||
SH |
Short String |
|||
SL |
Signed Long |
|||
SQ |
Sequence of Items |
|||
SS |
Signed Short |
|||
ST |
Short Text |
|||
SV |
Signed 64-bit Very Long |
|||
TM |
Time |
|||
UC |
Unlimited Characters |
|||
UI |
Unique Identifier (UID) |
|||
UL |
Unsigned Long |
|||
UN |
Unknown |
|||
UR |
URI/URL |
|||
US |
Unsigned Short |
|||
UT |
Unlimited Text |
|||
UV |
Unsigned 64-bit Very Long |
Examples
Decimal String
Image Frequency String to float:
>>> raw_value = image.header.raw['ImagingFrequency'].value
>>> raw_value
"123.25993"
>>> type(raw_value)
str
>>> parsed_value = image.header.get('ImagingFrequency')
>>> parsed_value
123.25993
>>> type(parsed_value)
float
Age String
Age String (AS) to float:
>>> raw_value = image.header.raw['PatientAge'].value
>>> raw_value
"027Y"
>>> type(raw_value)
str
>>> parsed_value = image.header.get('PatientAge')
>>> parsed_value
27.0
>>> type(parsed_value)
float
Date String
Date String (DA) to datetime.date using the Header
class’s indexing operator/subscript notation:
>>> raw_value = image.header.raw['PatientBirthDate'].value
>>> raw_value
"19901214"
>>> type(raw_value)
str
>>> parsed_value = image.header['PatientBirthDate']
>>> parsed_value
datetime.date(1990, 12, 14)
>>> type(parsed_value)
datetime.date
Code String
Code String (CS) to a verbose value or set of values:
>>> raw_value = image.header.raw['SequenceVariant'].value
>>> raw_value
['SP', 'OSP']
>>> type(raw_value)
pydicom.multival.MultiValue
>>> parsed_value = image.header['SequenceVariant']
>>> parsed_value
{'Oversampling Phase', 'Spoiled'}
>>> type(parsed_value)
set