pydicom.hooks.Hooks¶
- class pydicom.hooks.Hooks[source]¶
- Management class for callback functions. - Added in version 3.0. - Warning - New instances of this class should not be created, instead use the instance imported with - from pydicom.hooks import hooks.- Available Hooks - For conversion of raw element data to - DataElementusing- convert_raw_data_element():- "raw_element_vr": function to perform VR lookups for raw elements, default- raw_element_vr().
- "raw_element_value": function to convert raw element values to types appropriate for the VR, default- raw_element_value().
- "raw_element_kwargs": kwargs- dictpassed to the callback functions.
 - Methods - __init__()- Initialize a new - Hooksinstance.- register_callback(hook, func)- Register the callback function func to a hook. - register_kwargs(hook, kwargs)- Register a kwargs - dictto be passed to the corresponding callback function(s).- register_callback(hook: str, func: Callable) None[source]¶
- Register the callback function func to a hook. - Example - 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 ) kwargs = {"target_VRs": ("DS", "IS")} hooks.register_kwargs("raw_element_kwargs", kwargs) ds = dcmread("path/to/dataset.dcm") - Parameters:
- hook (str) – The name of the hook to register the function to, allowed values - "raw_element_vr"and- "raw_element_value".
- func (Callable) – The callback function to use with the hook. Only one callback function can be used per hook. For details on the required function signatures please see the documentation for the corresponding calling function.