ai_ct_scans.non_rigid_alignment module
Module to provide functions to perform non-rigid alignment of images.
- ai_ct_scans.non_rigid_alignment.align_2D_using_CPD(image, reference, point_threshold=None, filter_distance=1.0)
Align an 2D image to a reference image using a non-rigid transform.
- Parameters
image (np.ndarray) – A 2D greyscale image to be aligned.
reference (np.ndarray) – A 2D greyscale image that to be used as the reference.
point_threshold (np.ndarray) – Threshold value used for point extraction as an absolute intensity value.
filter_distance (float) – Distance threshold used to filter matched points.
- Returns
A 2D greyscale image that is the result of the alignment.
- Return type
(np.ndarray)
- ai_ct_scans.non_rigid_alignment.align_3D_using_CPD(image, reference, match_filter_distance=1.0, maximum_source_points=5000, maximum_target_points=30000)
Align a full 3d scan to a reference using a non-rigid transform.
- Parameters
image (np.ndarray) – A 3D scan to be aligned.
reference (np.ndarray) – A 3D scan to be used as the reference.
match_filter_distance (float) – Distance threshold used to filter points following matching after coherent point drift.
maximum_source_points (int) – Maximum number of points to use from scan during alignment.
maximum_target_points (int) – Maximum number of points to use from reference scan during alignment.
- Returns
A 3D greyscale image that is the result of the alignment.
- Return type
(np.ndarray)
- ai_ct_scans.non_rigid_alignment.estimate_3D_alignment_transform(image, reference, match_filter_distance=1.0, maximum_source_points=5000, maximum_target_points=30000)
Estimate the transform required to align a full 3d scan to a reference using a non-rigid transform.
- Parameters
image (np.ndarray) – A 3D scan to be aligned.
reference (np.ndarray) – A 3D scan to be used as the reference.
match_filter_distance (float) – Distance threshold used to filter points.
maximum_source_points (int) – Maximum number of points to use from scan during alignment.
maximum_target_points (int) – Maximum number of points to use from reference scan during alignment.
- Returns
A 3D greyscale image that is the result of the alignment.
- Return type
(np.ndarray)
- ai_ct_scans.non_rigid_alignment.get_warp_overlay(shape, transform_function, chunk_thickness=10)
Generate a heatmap showing the the magnitude of the warp used to align a scan at each voxel.
The warp is defined as the fractional volumetric change at each voxel.
- Parameters
shape (tuple of int) – The shape of the scan that has been aligned
transform_function (callable) – The transform function used to align the scan.
chunk_thickness (int) – Thickness of the chunks used to build up the warp overlay.
- Returns
3D heatmap representing the warp magnitude.
- Return type
(np.ndarray)
- ai_ct_scans.non_rigid_alignment.main()
CLI tool to calculate or apply a transform to align 3D scans.
- ai_ct_scans.non_rigid_alignment.read_transform(path)
Read and load a serialised transform from disk.
- Parameters
path (str or Path) – Path to write serialised transform to.
- Returns
A transform that maps points in the source image onto the reference image.
- Return type
(inst of sklearn.pipeline.Pipeline)
- ai_ct_scans.non_rigid_alignment.transform_3d_volume(image, transform_function)
Transform a 3d volume by a generic geometric transform.
- Parameters
image (np.ndarray) – A 3D greyscale image to transform.
transform_function (callable) – Function used to map coordinates in input image to transformed image. Takes
shape (and returns points as an np.ndarray of) –
- Returns
A 3D greyscale image that is the result of the transform.
- Return type
(np.ndarray)
- ai_ct_scans.non_rigid_alignment.transform_3d_volume_in_chunks(image, transform_function, chunk_thickness)
Transform a 3d volume by a generic geometric transform, chunk-by-chunk in order to reduce required memory.
Chunks are taken in the axial direction.
- Parameters
image (np.ndarray) – A 3D greyscale image to transform.
transform_function (callable) – Function used to map coordinates in input image to transformed image. Takes
shape (and returns points as an np.ndarray of) –
chunk_thickness (int) – Thickness of the chunks to align
- Returns
A 3D greyscale image that is the result of the transform.
- Return type
(np.ndarray)
- ai_ct_scans.non_rigid_alignment.write_transform(transform, path)
Serialise a transform and write to disk.
- Parameters
transform (inst of sklearn.pipeline.Pipeline) – A transform that maps points in the source image onto the reference image.
path (str) – Path to write serialised transform to.