API Reference#

Registration functions#

hipct_reg.registration.run_registration(reg_input: RegistrationInput, *, find_rotation: bool = True, initial_rotation: float | None = None, sampling_percentage: float = 0.01) tuple[Similarity3DTransform, float]#

Run registration pipeline on pre-loaded/pre-processed images.

Parameters#

find_rotation: bool

If True, try and find the rotation first. If False, start rigid registration with no rotation.

initial_rotation: float

Force the initial rotation of the rigid registration to a specific value.

sampling_percentage :

Fraction of pixels sampled at each iteration. Must be between 0 and 1.

Returns#

transform :

Registered transform from zoom image to the overview image.

metric :

Registration metric at the final step. The registration metric is Mattes mutual information.

hipct_reg.registration.registration_rot(reg_input: RegistrationInput, *, zrot: float, angle_range: float, angle_step: float, sampling_percentage: float = 0.01, verbose: bool = False) tuple[Euler3DTransform, RotRegMetrics]#

Run a registration using a rotational transform about the z-axis. The angles of the transform which are sampled are set by manually by function arguments.

Parameters#

zrot :

Initial rotation for the registration. In units of degrees.

angle_range :

Range of angles to scan. In units of degrees.

angle_step :

Step to take when scanning range of angles. In units of degrees.

verbose :

If True, log every step of the optimisation at debug level.

sampling_percentage :

Fraction of pixels sampled at each iteration. Must be between 0 and 1.

Returns#

transform :

Final registered transform.

metrics :

Dict containing the registration metric as a function of angle.

hipct_reg.registration.registration_rigid(reg_input: RegistrationInput, *, zrot: float, sampling_percentage: float = 0.01) tuple[Similarity3DTransform, float]#

Run a registration using a full rigid transform.

The returned transform maps from the zoom image to the overview image.

Parameters#

zrot :

Initial rotation for the registration. In units of degrees.

sampling_percentage :

Fraction of pixels sampled at each iteration. Must be between 0 and 1.

Returns#

transform :

Registered transform from zoom image to the overview image.

metric :

Registration metric at the final step. The registration metric is Mattes mutual information.

hipct_reg.helpers.get_pixel_transform_params(reg_input: RegistrationInput, coord_transform: Similarity3DTransform) PixelTransformDict#

Convert the registered transform to a pixel-to-pixel transform mapping from a zoom to a overview image.

Data helpers#

hipct_reg.data.get_reg_input(*, zoom_name: str, overview_name: str, zoom_point: tuple[int, int, int], overview_point: tuple[int, int, int], zoom_level: int, overview_level: int, overview_size_z: int = 32) RegistrationInput#

Given the dataset of a zoom image, get: - along z: overview_size_z * 2 voxels from the overview - along x/y: a 1/sqrt(2) shaped square from the centre of the zoom image.

this is the max data that can be taken while not including empty data outside the topography circle

Data is cached on disk so it doesn’t need to be re-downloaded.

Parameters#

zoom_name: str

Name of zoom dataset.

overview_name: str

Name of overview dataset.

zoom_point: tuple[int, int, int]

Central point of zoom image.

overview_point: tuple[int, int, int]

Central point of overview image.

zoom_level: int

Downsample level of zoom image.

overview_level: int

Downsample level of overview image.

overview_size_z: int

Half the number of voxels along the z-axis to fetch in the overview image.

Notes#

The zoom and overview points must be in pixel coordinates at the downsample level requested.

class hipct_reg.data.Cuboid(ds: Dataset, centre_point: tuple[int, int, int], size_xy: int, size_z: int, downsample_level: int)#

Represents a small cuboid of data located within an image.

Attributes#

ds :

Dataset.

centre_point :

Index of the centre of the cube.

size_xy :

Half the size of an edge of cuboid in the x-y plane, in pixels.

size_z :

Half the thickness of the cuboid along the z-axis, in pixels.

downsample_level :

Downsample level to get data from.

download_cube() None#

Download the cube from GCS.

get_array() ndarray[tuple[Any, ...], dtype[uint16]]#

Get cube as a numpy array.

get_image() Image#

Get cube as a SimpleITK image.

get_remote_arr() Array#

Get remote GCS store for the cube.

property local_zarr_path: Path#

Path to cube saved to a local zarr store.

Misc#

class hipct_reg.types.RegistrationInput(zoom_name: str, overview_name: str, zoom_image: Image, overview_image: Image, zoom_level: int, overview_level: int, zoom_common_point: tuple[int, int, int], overview_common_point: tuple[int, int, int])#

A container for all the data needed to register a zoom to an overview image.

Contains both images, and pixel indices of a common point in both images.

class hipct_reg.registration.RotRegMetrics#
class hipct_reg.helpers.show_image(image: Image, ax: Axes, z: int, **imshow_kwargs: Any)#

Show a 2D SimpleITK image in a Matplotlib figure.

Parameters#

image :

Image to show.

ax :

Axes to show it on.

z :

z-index at which to slice the image. A 2D x-y plane is displayed at this index.

imshow_kwargs :

Any additional keyword arguments are handed to imshow.