Skip to main content

Getting started

Installation for inference

Because the package has conda dependencies, it's dependencies will currently not be correctly installed when installing it as a pip package directly from Github. The dependencies therefore have to be manually installed from the environment.yaml. This can be cloned or simply copied from the repository.

pixi install --all

Alternatively, to install vireg in an existing environment::

pixi add vireg

Pixi tasks

Rather than having a makefile, some preconfigured commands are now provides as pixi tasks. Tasks exist for running testing, running mypy and running ruff. These can be run as follows:

pixi run -e dev run-main-tests
pixi run -e dev run-mypy
pixi run -e dev run-ruff

Basic usage

For details about training, evaluation, and inference, visit the corresponding training, evaluation, and inference sections.

In essence, for the registration of two Vicom volume the register_vols function can be used. This function supports a variety of frameworks (SimpleITK, Deep Learning, Test Time Optimization, HyReg, and any custom combination of these) and has input flags for the registration mode (rigid/affine/elastic/joint) and interpolation mode (nearest/bilinear/bspline).

To apply the return transform to another image the function apply_transform. can be used. This will work for any type of transform returned by register_vols.

from vicom import Volume
from vireg.inference import register_vols, apply_transform

# Define vicom volumes to register
fixed_volume: Volume = ...
moving_volume: Volume = ...
fixed_mask: Volume | None = ...

config: dict | None = ...
# perform affine registration with torch
# the returned transform goes from moving to fixed
registered_vol, transform = register_vols(
fixed_volume,
moving_volume,
fixed_mask,
registration_method="hyreg" # or "sitk", "dl", "tto", "hyreg", "custom"
transformation_type="affine" # or "rigid", "affine", "elastic", "joint"
interpolation_mode = 'bilinear', # or "bilinear", "nearest", "bspline"
return_transform = True,
config=config
)

# apply the transform to another image (i.e. a mask)
registered_mask = apply_transform(moving_mask, transform_params=transform, interpolation_mode = 'nearest')

More advanced usage examples can be found in the inference section.