kwneuro.reg

Classes

TransformResource

A wrapper for ANTs registration results that simplifies viewing and

Functions

register_volumes(...)

Registers a moving volume to a fixed reference volume using ANTs.

Module Contents

class kwneuro.reg.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.

property matrices: list[ants.ANTsTransform]

Returns the affine transform if it exists.

property warp_fields: list[kwneuro.resource.InMemoryVolumeResource]

Returns the non-linear displacement field if it exists.

static initialize_from_ants(ants_result: dict[str, list[str]]) TransformResource

Initializes a TransformResource from an ANTs registration result by wrapping references to the temporary transform files generated by ANTs.

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.

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

kwneuro.reg.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.

Parameters:
  • fixed – The reference volume.

  • moving – The volume to be warped.

  • type_of_transform – The transformation model (e.g., “SyN”, “Rigid”). The full list of supported transforms can be found in the ANTs documentation.

  • mask – Optional mask for the fixed image space.

  • moving_mask – Optional mask for the moving image space.

Returns:

A tuple containing the registered volume and the transform object.