pydicom.values.convert_numbers

pydicom.values.convert_numbers(byte_string: bytes, is_little_endian: bool, struct_format: str) → Union[str, int, float, List[Union[int, float]]][source]

Return a decoded numerical VR value.

Given an encoded DICOM Element value, use struct_format and the endianness of the data to decode it.

Parameters
  • byte_string (bytes) – The encoded numerical VR element value.

  • is_little_endian (bool) – True if the value is encoded as little endian, False otherwise.

  • struct_format (str) – The format of the numerical data encoded in byte_string. Should be a valid format for struct.unpack() without the endianness.

Returns

  • str – If there is no encoded data in byte_string then an empty string will be returned.

  • value – If byte_string encodes a single value then it will be returned.

  • list – If byte_string encodes multiple values then a list of the decoded values will be returned.