liom_toolkit.registration.register module
- liom_toolkit.registration.register.align_annotations_to_volume(target_volume: ANTsImage, mask: ANTsImage, template: ANTsImage, data_dir: str, resolution: int = 25, rigid_type: str = 'Similarity', deformable_type: str = 'SyN', keep_intermediary: bool = False, syn_image: dict | None = None, syn_allen: dict | None = None) ANTsImage
Align an annotation to a target image.
- Parameters:
target_volume (ants.ANTsImage) – The target image to align to.
mask (ants.ANTsImage) – The mask to use in registration.
template (ants.ANTsImage) – The template to use for registration.
resolution (int) – The resolution of the atlas in micron. Must be 10, 25, 50 or 100 microns
data_dir (str) – The directory to use for saving temporary files.
rigid_type (str) – The type of rigid registration to use.
deformable_type (str) – The type of deformable registration to use.
keep_intermediary (bool) – Whether to keep intermediary files or not.
syn_image (dict) – The syn transform for the image. If None, it will be calculated.
syn_allen (dict) – The syn transform for the Allen template. If None, it will be calculated.
- Returns:
The aligned annotation.
- Return type:
ants.ANTsImage
- liom_toolkit.registration.register.align_brain_region_to_atlas(target_volume: ANTsImage, mask: ANTsImage, template: ANTsImage, region: str, data_dir: str, resolution: int = 25, registration_volume: ANTsImage | None = None, rigid_type: str = 'Similarity', deformable_type: str = 'SyN', keep_intermediary: bool = False, syn_image: dict | None = None, syn_allen: dict | None = None) ANTsImage
Mask an image with a brain region. Assumes all images are in RAS+ orientation.
- Parameters:
target_volume (ants.ANTsImage) – The image to mask.
mask (ants.ANTsImage) – The mask to use.
template (ants.ANTsImage) – The template to use for registration.
region (str) – The brain region to use. Will do a lookup in the Allen ontology.
data_dir (str) – The directory to use for saving temporary files.
resolution (int) – The resolution of the atlas in micron. Must be 10, 25, 50 or 100 microns
registration_volume (ants.ANTsImage) – The volume to use for registration. If None, the target_volume will be used.
rigid_type (str) – The type of rigid registration to use.
deformable_type (str) – The type of deformable registration to use.
keep_intermediary (bool) – Whether to write intermediary files or not. Will also save the final masked image.
syn_image (dict) – The syn transform for the image. If None, it will be calculated.
syn_allen (dict) – The syn transform for the Allen template. If None, it will be calculated.
- Returns:
The brain region mask aligned to the target volume.
- Return type:
ants.ANTsImage
- liom_toolkit.registration.register.align_volume_to_allen(image: ANTsImage, mask: ANTsImage | None, resolution: int = 25) ANTsImage
Align a volume to the Allen template using the Allen template as a reference.
- Parameters:
image (ants.ANTsImage) – The image to align
mask (ants.ANTsImage | None) – The mask to use in registration
resolution (int) – The resolution of the atlas in micron. Must be 10, 25, 50 or 100 microns
- Returns:
The aligned image
- Return type:
ants.ANTsImage
- liom_toolkit.registration.register.deformably_register_volume(image: ~ants.core.ants_image.ANTsImage, mask: ~ants.core.ants_image.ANTsImage | None, template: ~ants.core.ants_image.ANTsImage, rigid_type: str = 'Similarity', deformable_type: str = 'SyN', interpolator: str = 'linear', rigid_interpolator: str = 'linear', use_composite: bool = True) -> (<class 'ants.core.ants_image.ANTsImage'>, <class 'dict'>, <class 'dict'>)
Register an image to a template using a rigid registration followed by a deformable registration.
- Parameters:
image (ants.ANTsImage) – The image to register
mask (ants.ANTsImage) – The mask to use in registration
template (ants.ANTsImage) – The template to register to
rigid_type (str) – The type of rigid registration to use
deformable_type (str) – The type of deformable registration to use
interpolator (str) – The interpolator to use to apply the transform.
rigid_interpolator (str) – The interpolator to use for applying the rigid transform.
use_composite (bool) – Whether to create a composite transform or not
- Returns:
The registered image, the transform from the rigid registration, and the transform from the deformable registration
- Return type:
tuple[ants.ANTsImage, dict, dict]
- liom_toolkit.registration.register.get_transformations_for_atlas(image: ~ants.core.ants_image.ANTsImage, mask: ~ants.core.ants_image.ANTsImage, template: ~ants.core.ants_image.ANTsImage, template_allen: ~ants.core.ants_image.ANTsImage, data_dir: str, rigid_type: str = 'Similarity', deformable_type: str = 'SyN', keep_intermediary: bool = False) -> (<class 'dict'>, <class 'dict'>)
Get the transformations for an image to be aligned to the Allen template.
- Parameters:
image (ants.ANTsImage) – The image to align.
mask (ants.ANTsImage) – The mask of the image to use in registration.
template (ants.ANTsImage) – The custom template to use for registration.
template_allen (ants.ANTsImage) – The Allen template to use for registration.
data_dir (str) – The directory to use for saving temporary files.
rigid_type (str) – The type of rigid registration to use.
deformable_type (str) – The type of deformable registration to use.
keep_intermediary (bool) – Whether to keep intermediary files or not.
- Returns:
The transformations for the image to be aligned to the Allen template.
- Return type:
tuple[dict, dict]
- liom_toolkit.registration.register.rigidly_register_volume(image: ~ants.core.ants_image.ANTsImage, mask: ~ants.core.ants_image.ANTsImage, template: ~ants.core.ants_image.ANTsImage, rigid_type: str = 'Similarity', interpolator: str = 'linear', use_composite: bool = True) -> (<class 'ants.core.ants_image.ANTsImage'>, <class 'dict'>)
Register an image to a template using a rigid registration.
- Parameters:
image (ants.ANTsImage) – The image to register
mask (ants.ANTsImage) – The mask to use in registration
template (ants.ANTsImage) – The template to register to
rigid_type (str) – The type of rigid registration to use
interpolator (str) – The interpolator to use to apply the transform.
use_composite (bool) – Whether to create a composite transform or not
- Returns:
The registered image and the transform from the rigid registration
- Return type:
tuple[ants.ANTsImage, dict]