Converters
Converter registry – maps Python types to NRRD I/O operations.
- Functions:
register_converter: Register a new ImageConverter for a custom type. find_image_converter: Look up the converter for a given object by type. find_converter_for_type: Reverse lookup – find converter that produces a target type.
- Built-in converters (registered at import time):
NumpyConverter: numpy.ndarray (always available). SitkConverter: SimpleITK.Image (registered if SimpleITK is installed). MLArrayConverter: mlarray.MLArray (registered if mlarray is installed).
- class mitk_workbench_remote.converters.ImageConverter(*args, **kwargs)
Bases:
ProtocolProtocol for converting between external image types and Image.
- extract_geometry(obj)
Extract spatial geometry (spacing, origin, direction) from the object.
- mitk_workbench_remote.converters.register_converter(converter)
Register a new ImageConverter.
Thread-safe. Converters should be registered before any concurrent image operations; registrations that race with lookups may not be visible immediately.
- Return type:
- mitk_workbench_remote.converters.find_image_converter(obj)
Find the first converter that can handle the given object.
- Return type:
- mitk_workbench_remote.converters.find_converter_for_type(target_type)
Find a converter that produces the given target type via from_image.
- Return type:
Interop with the mitk package
MitkImageConverter is auto-registered whenever the mitk package is
importable. It enables transparent use of mitk.Image objects with
DataNode.get_data() / DataNode.set_data() and Image.to_mitk().
See Interop with the mitk package for the full guide.
- class mitk_workbench_remote.converters._mitk.MitkImageConverter
Bases:
objectConverter for
mitk.Imageobjects (native MITK Python binding).Auto-registered when the
mitkpackage is importable. Provides round-trip fidelity for geometry (spacing, origin, direction) and pixel data. Properties are extracted via the binding’sget_property()coercion path (propertyToPythonValue) for known types, falling back toBaseProperty.to_json()for unknown types.- from_image(image)
- Return type:
Image