pydicom.hooks.raw_element_value_fix_separator

pydicom.hooks.raw_element_value_fix_separator(raw: RawDataElement, data: dict[str, Any], *, encoding: str | MutableSequence[str] | None = None, ds: Dataset | None, separator: str | bytes = b',', target_VRs: tuple[str, ...] | None = None, **kwargs: Any) None[source]

Convenience function to fix values with an invalid multivalue separator.

Added in version 3.0.

Alternative callback function for the "raw_element_value" hook.

Example

Fix DS and IS elements that use an invalid “:” character as the multivalue separator:

from pydicom import dcmread
from pydicom.hooks import hooks, raw_element_value_fix_separator

hooks.register_callback(
    "raw_element_value",
    raw_element_value_fix_separator,
)
hooks.register_kwargs(
    "raw_element",
    {"target_VRs": ("DS", "IS"), "separator": b":"},
)

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.

  • separator (str | bytes, optional) – The invalid separator character to be replaced by an ASCII backslash (0x5C).

  • target_VRs (tuple[str, ...], optional) – The VRs the fix should apply.

  • **kwargs (dict[str, Any]) – Additional keyword arguments.