kwneuro.reg =========== .. py:module:: kwneuro.reg Classes ------- .. autoapisummary:: kwneuro.reg.TransformResource Functions --------- .. autoapisummary:: kwneuro.reg.register_volumes Module Contents --------------- .. py:class:: TransformResource A wrapper for ANTs registration results that simplifies viewing and applying transforms. While the underlying transform files are always stored on-disk, they remain in a temporary directory until explicitly persisted via the save() method. .. py:property:: matrices :type: list[ants.ANTsTransform] Returns the affine transform if it exists. .. py:property:: warp_fields :type: list[kwneuro.resource.InMemoryVolumeResource] Returns the non-linear displacement field if it exists. .. py:method:: initialize_from_ants(ants_result: dict[str, list[str]]) -> TransformResource :staticmethod: Initializes a TransformResource from an ANTs registration result by wrapping references to the temporary transform files generated by ANTs. .. py:method:: apply(fixed: kwneuro.resource.VolumeResource, moving: kwneuro.resource.VolumeResource, invert: bool = False, interpolation: str = 'linear') -> kwneuro.resource.InMemoryVolumeResource Wrapper around ants.apply_transforms using this result. .. py:method:: save(output_dir: kwneuro.util.PathLike) -> TransformResource Copies the underlying ANTs transformation files to a permanent directory and returns a new TransformResource pointing to the saved locations .. py:function:: register_volumes(fixed: kwneuro.resource.VolumeResource, moving: kwneuro.resource.VolumeResource, type_of_transform: str = 'SyN', mask: kwneuro.resource.VolumeResource | None = None, moving_mask: kwneuro.resource.VolumeResource | None = None) -> tuple[kwneuro.resource.InMemoryVolumeResource, TransformResource] Registers a moving volume to a fixed reference volume using ANTs. :param fixed: The reference volume. :param moving: The volume to be warped. :param type_of_transform: The transformation model (e.g., "SyN", "Rigid"). The full list of supported transforms can be found in the ANTs documentation. :param mask: Optional mask for the fixed image space. :param moving_mask: Optional mask for the moving image space. :returns: A tuple containing the registered volume and the transform object.