Configuration Options (pydicom.config)

pydicom configuration options

class pydicom.config.Settings[source]

Collection of several configuration values. Accessed via the singleton settings.

Added in version 2.3.

property infer_sq_for_un_vr: bool

If True, and the VR of a known data element is encoded as UN in an explicit encoding for an undefined length data element, the VR is changed to SQ per PS 3.5, section 6.2.2. Can be set to False where the content of the tag shown as UN is not DICOM conformant and would lead to a failure if accessing it.

property reading_validation_mode: int

Defines behavior of validation while reading values, compared with the DICOM standard, e.g. that DS strings are not longer than 16 characters and contain only allowed characters. The default (WARN) is to issue a warning in the case of an invalid value, RAISE will raise an error in this case, and IGNORE will bypass the validation (with the exception of some encoding errors).

property writing_validation_mode: int

Defines behavior for value validation while writing a value. See Settings.reading_validation_mode.


The global configuration object of type Settings to access some of the settings.


Set to True to allow DSdecimal instances to be created using floats; otherwise, they must be explicitly converted to str, with the user explicitly setting the precision of digits and rounding.


If invalid VR encountered, assume file switched to implicit VR


Convert a field VR to "UN" and return bytes if bytes length is invalid.


Set to a callable function to be called from dcmread() every time a RawDataElement has been returned, before it is added to the Dataset.


Set the keyword arguments passed to data_element_callback().


Set to True to convert the value(s) of elements with a VR of DA, DT and TM to, datetime.datetime and datetime.time respectively.

debug([debug_on, default_handler])

Turn on/off debugging of DICOM file reading and writing.




Imitate the behavior for the next major version of pydicom.


Handlers for converting (7FE0,0010) Pixel Data.


Reset the data_element_callback() function to the default.


If True (default), the 'str' and 'repr' methods of Dataset begin with a separate section displaying the file meta information data elements


Set DS class to be derived from decimal.Decimal or float.


Set whether multi-valued elements with VR of DS will be numpy arrays


Set using DS_decimal() to control if elements with a VR of DS are represented as Decimal.


Set to False to avoid IS values being returned as numpy ndarray objects.


Set using the function DS_numpy() to control whether arrays of VR DS are returned as numpy arrays.


Use the information within JPEG 2000 data to correct the returned pixel data


Control the behavior when invalid keys are used with __contains__() (e.g. 'invalid' in ds).


Control the behavior when setting a Dataset attribute that's not a known element keyword.


If one of the validation modes is set to this value, no value validation will be performed.


If one of the validation modes is set to this value, a warning is issued if a value validation error occurs.


If one of the validation modes is set to this value, an exception is raised if a value validation error occurs.