pydicom.hooks.raw_element_value_retry¶
- pydicom.hooks.raw_element_value_retry(raw: RawDataElement, data: dict[str, Any], *, encoding: str | MutableSequence[str] | None = None, ds: Dataset | None, target_VRs: dict[str, tuple[str, ...]] | None = None, **kwargs: Any) None [source]¶
Convenience function to retry value conversion using a different VR.
Added in version 3.0.
Alternative callback function for the
"raw_element_value"
hook.Example
Retry the value conversion for DS elements using US or SS:
from pydicom import dcmread from pydicom.hooks import hooks, raw_element_value_retry hooks.register_callback( "raw_element_value", raw_element_value_retry, ) hooks.register_kwargs( "raw_element", {"target_VRs": {"DS": ("US", "SS")}}, ) ds = dcmread("path/to/dataset.dcm")
- Parameters:
raw (RawDataElement) – The raw data element to determine the value for.
data (dict[str, Any]) – A dict to store the results of the value conversion, which should be added as
{"value": Any}
.encoding (str | MutableSequence[str] | None) – The character set encoding to use for text VRs.
target_VRs (dict[str, tuple[str, ...]], optional) – The
{VRs the fix should apply: tuple of alternative VRs to try}
.