pydicom.encaps.fragment_frame

pydicom.encaps.fragment_frame(frame: bytes, nr_fragments: int = 1) Generator[bytes, None, None][source]

Yield one or more fragments from frame.

New in version 1.2.

Parameters
  • frame (bytes) – The data to fragment.

  • nr_fragments (int, optional) – The number of fragments (default 1).

Yields

bytes – The fragmented data, with all fragments as an even number of bytes greater than or equal to two.

Notes

  • All items containing an encoded fragment shall be made of an even number of bytes greater than or equal to two.

  • The last fragment of a frame may be padded, if necessary to meet the sequence item format requirements of the DICOM Standard.

  • Any necessary padding may be appended after the end of image marker.

  • Encapsulated Pixel Data has the Value Representation OB.

  • Values with a VR of OB shall be padded with a single trailing NULL byte value (0x00) to achieve even length.

References

DICOM Standard, Part 5, Section 6.2 and Annex A.4