pydicom.pixels.utils.get_expected_length

pydicom.pixels.utils.get_expected_length(ds: Dataset, unit: str = 'bytes') int[source]

Return the expected length (in terms of bytes or pixels) of the Pixel Data.

Element

Required or optional

Tag

Keyword

Type

(0028,0002)

SamplesPerPixel

1

Required

(0028,0004)

PhotometricInterpretation

1

Required

(0028,0008)

NumberOfFrames

1C

Optional

(0028,0010)

Rows

1

Required

(0028,0011)

Columns

1

Required

(0028,0100)

BitsAllocated

1

Required

Parameters:
  • ds (Dataset) – The Dataset containing the Image Pixel module and Pixel Data.

  • unit (str, optional) – If 'bytes' then returns the expected length of the Pixel Data in whole bytes and NOT including an odd length trailing NULL padding byte. If 'pixels' then returns the expected length of the Pixel Data in terms of the total number of pixels (default 'bytes').

Returns:

The expected length of the Pixel Data in either whole bytes or pixels, excluding the NULL trailing padding byte for odd length data.

Return type:

int