Inference
As shown in the Getting Started page, the register_vols function is the main access point for inference.
Detailed instruction for different types of registration can be found in the affine registration and in the joint registration sections.
Large scale inference
When using the register_vols in default mode, the registration framework is loaded for each usage of the function which is not ideal for fast inference of a large number of volumes. For this reason, it can be beneficial to use the inference pipeline directly.
from vireg.inference.pipeline import InferencePipeline, InferencePipelineConfig
config: dict | None ...
inference_cfg = InferencePipelineConfig(
transformation_type="affine",
registration_method="hyreg",
interpolation_mode="bilinear",
config=config,
)
inference_pipeline = InferencePipeline(cfg=inference_cfg, device=device)
for fixed_volume,moving_volume,fixed_mask in volumes:
registered_vol = inference_pipeline.register(
vol_fixed=fixed_volume,
vol_moving=moving_volume,
vol_mask_fixed=fixed_mask
)
A more granular configuration of the InferencePipeline is possible by passing a dictionary of named parameters to the InferencePipelineConfig. This dictionary can be nested and should contain only parameters specific to the registration method chosen.
from vireg.inference.pipeline import InferencePipeline, InferencePipelineConfig
cfg =
inference_cfg = InferencePipelineConfig(
transformation_type="affine",
registration_method="sitk",
interpolation_mode="bilinear",
config=cfg
)
inference_pipeline = InferencePipeline(cfg=inference_cfg, device=device)
for fixed_volume,moving_volume,fixed_mask in volumes:
registered_vol = inference_pipeline.register(
fixed_volume,
moving_volume,
fixed_mask
)
For a detailed explanation about all possible parameters for each registration framework, visit the affine registration and the joint registration sections, or refer to vireg/inference/configs/configs.py.
Note It is important that the named parameters passed in the dictionary correspond to the registration method specified.