pydicom.encaps.generate_fragmented_frames

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

Yield fragmented pixel data frames from buffer.

New in version 3.0.

Note

When the Basic Offset Table is empty and the Extended Offset Table isn’t supplied then more fragmented frames may be yielded than given by number_of_frames provided there are sufficient excess fragments available.

Parameters:
  • buffer (bytes | bytearray | readable buffer) – A buffer containing the encapsulated frame data, positioned at the first byte of the basic offset table. May be bytes, bytearray or an object with read(), tell() and seek() methods. If the latter then the final position depends on how many fragmented frames have been yielded.

  • number_of_frames (int, optional) – Required for multi-frame data when the Basic Offset Table is empty, the Extended Offset Table has not been supplied and there are multiple frames. This should be the value of (0028,0008) Number of Frames or the expected number of frames in the encapsulated data.

  • extended_offsets (tuple[list[int], list[int]] or tuple[bytes, bytes], optional) – The (offsets, lengths) of the Extended Offset Table as taken from (7FE0,0001) Extended Offset Table and (7FE0,0002) Extended Offset Table Lengths as either the raw encoded values or a list of their decoded equivalents.

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

Yields:

tuple[bytes, …] – An encapsulated pixel data frame, with the contents of the tuple the frame’s fragmented encoded data.