pynetdicom.dsutils.encode

pynetdicom.dsutils.encode(ds: Dataset, is_implicit_vr: bool, is_little_endian: bool, deflated: bool = False) bytes | None[source]

Encode a pydicom Dataset ds.

Changed in version 1.5: Added deflated keyword parameter

Parameters:
  • ds (pydicom.dataset.Dataset) – The dataset to encode

  • is_implicit_vr (bool) – The element encoding scheme the dataset will be encoded with, True for implicit VR, False for explicit VR.

  • is_little_endian (bool) – The byte ordering the dataset will be encoded in, True for little endian, False for big endian.

  • deflated (bool, optional) – True if the dataset is to be encoded using Deflated Explicit VR Little Endian transfer syntax (default False).

Returns:

The encoded dataset as bytes (if successful) or None if the encoding failed.

Return type:

bytes or None