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 buffered_read_size: int

Get or set the chunk size when reading from buffered DataElement values.

Parameters:

size (int) – The chunk size to use, must be greater than 0 (default 8192).

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.

  • WARN will emit a warning in the case of an invalid value (default)

  • RAISE will raise an error instead

  • 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.

settings

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

allow_DS_float

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.

assume_implicit_vr_switch

If invalid VR encountered, assume file switched to implicit VR

convert_wrong_length_to_UN

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

data_element_callback

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

data_element_callback_kwargs

Set the keyword arguments passed to data_element_callback().

datetime_conversion

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

debug([debug_on, default_handler])

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

enforce_valid_values

Deprecated.

future_behavior([enable_future])

Imitate the behavior for the next major version of pydicom.

pixel_data_handlers

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

reset_data_element_callback()

Reset the data_element_callback() function to the default.

show_file_meta

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

DS_decimal([use_Decimal_boolean])

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

DS_numpy([use_numpy])

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

use_DS_decimal

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

use_IS_numpy

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

use_DS_numpy

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

APPLY_J2K_CORRECTIONS

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

INVALID_KEY_BEHAVIOR

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

INVALID_KEYWORD_BEHAVIOR

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

IGNORE

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

WARN

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

RAISE

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