pydicom.dataelem.convert_raw_data_element

pydicom.dataelem.convert_raw_data_element(raw: RawDataElement, *, encoding: str | MutableSequence[str] | None = None, ds: Dataset | None = None) DataElement[source]

Return a DataElement created from raw.

Added in version 3.0.

Customization Hooks

All callback functions for convert_raw_data_element() use the function signature:

def func(
    raw: RawDataElement,
    data: dict[str, Any],
    *,
    encoding: str | MutableSequence[str] | None = None,
    ds: pydicom.dataset.Dataset | None = None,
    **kwargs: dict[str, Any],
) -> None:
    ...

Where raw, encoding and ds are the objects passed to this function, data is a dict that’s persistent for each raw element and is used to store the results of the corresponding callback functions, and kwargs are keyword arguments passed by setting the "raw_element_kwargs" hook via register_kwargs().

Available hooks are (in order of execution):

  • "raw_element_vr": a function to perform the VR lookup for the raw element, required to add {"VR": str} to data.

  • "raw_element_value": a function to perform the conversion of the raw element bytes value to an appropriate type (such as int for VR US), required to add {"value": Any} to data.

register_callback() is used to set the callback function for a given hook, and only one callback can be set per hook.

Parameters:
Returns:

A DataElement instance created from raw.

Return type:

pydicom.dataelem.DataElement