pydicom.encaps.get_frame_offsets

pydicom.encaps.get_frame_offsets(fp: DicomFileLike) Tuple[bool, List[int]][source]

Return a list of the fragment offsets from the Basic Offset Table.

Basic Offset Table

The Basic Offset Table Item must be present and have a tag (FFFE,E000) and a length, however it may or may not have a value.

Basic Offset Table with no value

Item Tag   | Length    |
FE FF 00 E0 00 00 00 00

Basic Offset Table with value (2 frames)

Item Tag   | Length    | Offset 1  | Offset 2  |
FE FF 00 E0 08 00 00 00 00 00 00 00 10 00 00 00

For single or multi-frame images with only one frame, the Basic Offset Table may or may not have a value. When it has no value then its length shall be 0x00000000.

For multi-frame images with more than one frame, the Basic Offset Table should have a value containing concatenated 32-bit unsigned integer values that are the byte offsets to the first byte of the Item tag of the first fragment of each frame as measured from the first byte of the first item tag following the Basic Offset Table Item.

All decoders, both for single and multi-frame images should accept both an empty Basic Offset Table and one containing offset values.

Changed in version 1.4: Changed to return (is BOT empty, list of offsets).

Parameters

fp (filebase.DicomFileLike) – The encapsulated pixel data positioned at the start of the Basic Offset Table. fp.is_little_endian should be set to True.

Returns

Whether or not the BOT is empty, and a list of the byte offsets to the first fragment of each frame, as measured from the start of the first item following the Basic Offset Table item.

Return type

bool, list of int

Raises

ValueError – If the Basic Offset Table item’s tag is not (FFEE,E000) or if the length in bytes of the item’s value is not a multiple of 4.

References

DICOM Standard, Part 5, Annex A.4