data_elements

Module contents

Subclasses of the DataElement class. Each subclass represents one of the value-representation (VR) types as defined by the DICOM standard.

Submodules

dicom_parser.data_elements.age_string module

Definition of the AgeString class, representing a single “AS” data element.

class dicom_parser.data_elements.age_string.AgeString(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

N_IN_YEAR = {'D': 365.2422, 'M': 12, 'W': 52.1429, 'Y': 1}
VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Age String'

The VR value of data elements represented by this class.

parse_value(value: str) float

Converts an Age String element’s representation of age into a float representing years.

Parameters

value (str) – Age String value

Returns

Age in years

Return type

float

dicom_parser.data_elements.application_entity module

Definition of the ApplicationEntity class, representing a single “AE” data element.

class dicom_parser.data_elements.application_entity.ApplicationEntity(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Application Entity'

The VR value of data elements represented by this class.

dicom_parser.data_elements.attribute_tag module

Definition of the AttributeTag class, representing a single “AT” data element.

class dicom_parser.data_elements.attribute_tag.AttributeTag(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Attribute Tag'

The VR value of data elements represented by this class.

dicom_parser.data_elements.code_string module

Definition of the CodeString class, representing a single “CS” data element.

class dicom_parser.data_elements.code_string.CodeString(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

TAG_TO_ENUM = {('0008', '0060'): <enum 'Modality'>, ('0010', '0040'): <enum 'Sex'>, ('0018', '0020'): <enum 'ScanningSequence'>, ('0018', '0021'): <enum 'SequenceVariant'>, ('0018', '5100'): <enum 'PatientPosition'>}

Most code strings have a set of valid values. This dictionary checks parsed values against Enums of the valid values associated by tag.

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Code String'

The VR value of data elements represented by this class.

parse_value(value: str) str

Tries to return a parsed value using the appropriate values Enum (see TAG_TO_ENUM).

Parameters

value (str) – Raw “CS” data element value

Returns

Parsed “CS” data element value

Return type

str

parse_with_enum(value: str, enum: enum.Enum) str

Tries to return the verbose value of a “CS” data element using the appropriate Enum (see TAG_TO_ENUM).

Parameters
  • value (str) – Raw “CS” data element value

  • enum (Enum) – This data element’s values Enum

Returns

Parsed “CS” data element value

Return type

str

static warn_invalid_code_string_value(exception: KeyError, enum: enum.Enum) None

Displays a warning for invalid Code String (CS) values.

Parameters
  • exception (KeyError) – The exception raised when trying to parse the invalid value

  • enum (enum.Enum) – An Enum representing the element’s valid values

dicom_parser.data_elements.date module

Definition of the Date class, representing a single “DA” data element.

class dicom_parser.data_elements.date.Date(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Date'

The VR value of data elements represented by this class.

parse_value(value: str) None.datetime.date

Converts the DICOM standard’s date string representation into an instance of Python’s datetime.date.

Parameters

value (str) – Raw “DA” data element value

Returns

Parsed date

Return type

datetime.date

Raises

ValueError – Failure to parse date from raw value

dicom_parser.data_elements.date_time module

Definition of the DateTime class, representing a single “DT” data element.

class dicom_parser.data_elements.date_time.DateTime(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Date Time'

The VR value of data elements represented by this class.

dicom_parser.data_elements.decimal_string module

Definition of the DecimalString class, representing a single “DS” data element.

class dicom_parser.data_elements.decimal_string.DecimalString(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Decimal String'

The VR value of data elements represented by this class.

parse_value(value: str) float

Returns the parsed “DS” data element’s value.

Warning

Invalid values (values raising a TypeError or ValueError when passed to float) will return None.

Parameters

value (str) – Raw “DS” data element value

Returns

Parsed decimal

Return type

float

dicom_parser.data_elements.floating_point_double module

Definition of the FloatingPointDouble class, representing a single “FD” data element.

class dicom_parser.data_elements.floating_point_double.FloatingPointDouble(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Floating Point Double'

The VR value of data elements represented by this class.

dicom_parser.data_elements.floating_point_single module

Definition of the FloatingPointSingle class, representing a single “FL” data element.

class dicom_parser.data_elements.floating_point_single.FloatingPointSingle(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Floating Point Single'

The VR value of data elements represented by this class.

dicom_parser.data_elements.integer_string module

Definition of the IntegerString class, representing a single “IS” data element.

class dicom_parser.data_elements.integer_string.IntegerString(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Integer String'

The VR value of data elements represented by this class.

parse_value(value: str) int

Returns the parsed “IS” data element’s value.

Warning

Invalid values (values raising a TypeError or ValueError when passed to int) will return None.

Parameters

value (str) – Raw “IS” data element value

Returns

Parsed integer

Return type

int

dicom_parser.data_elements.long_string module

Definition of the LongString class, representing a single “LO” data element.

class dicom_parser.data_elements.long_string.LongString(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Long String'

The VR value of data elements represented by this class.

dicom_parser.data_elements.long_text module

Definition of the LongText class, representing a single “LT” data element.

class dicom_parser.data_elements.long_text.LongText(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Long Text'

The VR value of data elements represented by this class.

dicom_parser.data_elements.other_64bit_very_long module

Definition of the Other64bitVeryLong class, representing a single “OV” data element.

class dicom_parser.data_elements.other_64bit_very_long.Other64bitVeryLong(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Other 64-bit Very Long'

The VR value of data elements represented by this class.

dicom_parser.data_elements.other_byte module

Definition of the OtherByte class, representing a single “OB” data element.

class dicom_parser.data_elements.other_byte.OtherByte(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Other Byte'

The VR value of data elements represented by this class.

dicom_parser.data_elements.other_double module

Definition of the OtherDouble class, representing a single “OD” data element.

class dicom_parser.data_elements.other_double.OtherDouble(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Other Double'

The VR value of data elements represented by this class.

dicom_parser.data_elements.other_float module

Definition of the OtherFloat class, representing a single “OF” data element.

class dicom_parser.data_elements.other_float.OtherFloat(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Other Float'

The VR value of data elements represented by this class.

dicom_parser.data_elements.other_long module

Definition of the OtherLong class, representing a single “OL” data element.

class dicom_parser.data_elements.other_long.OtherLong(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Other Long'

The VR value of data elements represented by this class.

dicom_parser.data_elements.other_word module

Definition of the OtherWord class, representing a single “OW” data element.

class dicom_parser.data_elements.other_word.OtherWord(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Other Word'

The VR value of data elements represented by this class.

parse_value(value: bytes) list

Returns the parsed “OW” data element value.

Parameters

value (bytes) – Raw “OW” data element value

Returns

Parsed value

Return type

list

dicom_parser.data_elements.person_name module

Definition of the PersonName class, representing a single “PN” data element.

class dicom_parser.data_elements.person_name.PersonName(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

COMPONENTS = ('name_prefix', 'given_name', 'middle_name', 'family_name', 'name_suffix')

Person name components as defined by the DICOM standard.

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Person Name'

The VR value of data elements represented by this class.

parse_value(value: pydicom.valuerep.PersonName) dict

Returns a dictionary representation of the “PN” data element’s value.

Parameters

value (PydicomPersonName) – pydicom’s “PN” data element representation

Returns

Parsed person name components

Return type

dict

dicom_parser.data_elements.private_data_element module

Definition of the PrivateDataElement class, representing a single “UN” data element.

class dicom_parser.data_elements.private_data_element.PrivateDataElement(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Unknown'

The VR value of data elements represented by this class.

parse_value(value: bytes) Any

Tries to parse private data element values using a custom method or by simply calling bytes.decode().

Parameters

value (bytes) – Raw private data element value

Returns

Parsed private data element value

Return type

Any

update_from_definition() None

Update this data element’s value_representation using a custom definition.

dicom_parser.data_elements.private_data_element.TAG_TO_DEFINITION = {('0019', '100a'): {'method': <function parse_siemens_number_of_slices_in_mosaic>}, ('0019', '100b'): {'method': <class 'float'>}, ('0019', '100c'): {'method': <class 'int'>}, ('0019', '100e'): {'method': <function parse_siemens_gradient_direction>}, ('0019', '1027'): {'method': <function parse_siemens_b_matrix>}, ('0019', '1028'): {'method': <function parse_siemens_bandwith_per_pixel_phase_encode>}, ('0019', '1029'): {'method': <function parse_siemens_slice_timing>}, ('0029', '1010'): {'method': <function parse_siemens_csa_header>}, ('0029', '1020'): {'method': <function parse_siemens_csa_header>}}

A dictionary matching private data elements to their appropriate parsing method.

dicom_parser.data_elements.sequence_of_items module

Definition of the SequenceOfItems class, representing a single “SQ” data element.

class dicom_parser.data_elements.sequence_of_items.SequenceOfItems(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Sequence of Items'

The VR value of data elements represented by this class.

parse_value(value: pydicom.dataset.Dataset) None

Raises NotImplementedError as “SQ” data elements in fact represent a nested header (see to_dataframe()).

Parameters

value (PydicomDataset) – Raw pydicom dataset

Raises

NotImplementedError – Invalid method

to_dataframe(**kwargs)

dicom_parser.data_elements.short_string module

Definition of the ShortString class, representing a single “SH” data element.

class dicom_parser.data_elements.short_string.ShortString(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Short String'

The VR value of data elements represented by this class.

dicom_parser.data_elements.short_text module

Definition of the ShortText class, representing a single “ST” data element.

class dicom_parser.data_elements.short_text.ShortText(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Short Text'

The VR value of data elements represented by this class.

dicom_parser.data_elements.signed_64bit_very_long module

Definition of the Signed64bitVeryLong class, representing a single “SV” data element.

class dicom_parser.data_elements.signed_64bit_very_long.Signed64bitVeryLong(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Signed 64-bit Very Long'

The VR value of data elements represented by this class.

dicom_parser.data_elements.signed_long module

Definition of the SignedLong class, representing a single “SL” data element.

class dicom_parser.data_elements.signed_long.SignedLong(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Signed Long'

The VR value of data elements represented by this class.

dicom_parser.data_elements.signed_short module

Definition of the SignedShort class, representing a single “SS” data element.

class dicom_parser.data_elements.signed_short.SignedShort(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Signed Short'

The VR value of data elements represented by this class.

dicom_parser.data_elements.time module

Definition of the Time class, representing a single “TM” data element.

class dicom_parser.data_elements.time.Time(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Time'

The VR value of data elements represented by this class.

parse_value(value: str) None.datetime.time

Converts the DICOM standard’s time string representation into an instance of Python’s datetime.time.

Parameters

value (str) – Raw “TM” data element value

Returns

Parsed time

Return type

datetime.time

Raises

ValueError – Failure to parse time from raw value

dicom_parser.data_elements.unique_identifier module

Definition of the UniqueIdentifier class, representing a single “UI” data element.

class dicom_parser.data_elements.unique_identifier.UniqueIdentifier(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Unique Identifer'

The VR value of data elements represented by this class.

dicom_parser.data_elements.unlimited_characters module

Definition of the UnlimitedCharacters class, representing a single “UC” data element.

class dicom_parser.data_elements.unlimited_characters.UnlimitedCharacters(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Unlimited Characters'

The VR value of data elements represented by this class.

dicom_parser.data_elements.unlimited_text module

Definition of the UnlimitedText class, representing a single “UT” data element.

class dicom_parser.data_elements.unlimited_text.UnlimitedText(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Unlimited Text'

The VR value of data elements represented by this class.

dicom_parser.data_elements.unsigned_64bit_very_long module

Definition of the Unsigned64bitVeryLong class, representing a single “UV” data element.

class dicom_parser.data_elements.unsigned_64bit_very_long.Unsigned64bitVeryLong(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Unsigned 64-bit Very Long'

The VR value of data elements represented by this class.

dicom_parser.data_elements.unsigned_long module

Definition of the UnsignedLong class, representing a single “UL” data element.

class dicom_parser.data_elements.unsigned_long.UnsignedLong(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Unsigned Long'

The VR value of data elements represented by this class.

dicom_parser.data_elements.unsigned_short module

Definition of the UnsignedShort class, representing a single “US” data element.

class dicom_parser.data_elements.unsigned_short.UnsignedShort(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Unsigned Short'

The VR value of data elements represented by this class.

dicom_parser.data_elements.url module

Definition of the Url class, representing a single “UR” data element.

class dicom_parser.data_elements.url.Url(raw: pydicom.dataelem.DataElement)

Bases: dicom_parser.data_element.DataElement

VALUE_REPRESENTATION: dicom_parser.utils.value_representation.ValueRepresentation = 'Universal Resource'

The VR value of data elements represented by this class.