pydicom.encaps.parse_fragments

pydicom.encaps.parse_fragments(buffer: bytes | bytearray | ReadableBuffer, *, endianness: str = '<') tuple[int, list[int]][source]

Return the number of fragments and their positions in buffer.

New in version 3.0.

Parameters:
  • buffer (bytes | bytearray | readable buffer) – A buffer containing the encapsulated frame data, starting at the first byte of item tag for a fragment, such as after the end of the Basic Basic Offset Table. May be bytes, bytearray or an object with read(), tell() and seek() methods. If the latter then the offset will be reset to the starting position afterwards.

  • endianness (str, optional) – If "<" (default) then the encapsulated data uses little endian encoding, otherwise if ">" it uses big endian encoding.

Returns:

The number of fragments and the absolute offset position of the first byte of the item tag for each fragment in buffer.

Return type:

tuple[int, list[int]]