transform_data module

Enable transformation of data for comparison to ground truth.

If we know the infill pattern of a given phantom, we know a few things about the geometry of diffusion in that phantom. This module provides a way to compare scan data to that known information.

Specifically, we define a “ground truth space,” where the centre of the phantom is at the origin, and a fiducial visible from the image is on the negative y-axis. Then a translation and rotation can move each voxel’s coordinates from image space to ground truth space.

transform_data.find_centroid(mask)

Find the centroid of a phantom’s mask.

Parameters:mask (array_like) – A 2D binary array, where 1s indicate voxels containing a phantom.
Returns:A 1D array containing the coordinates of the mask’s centroid.
Return type:array_like
transform_data.gen_geometry_data(mask_data, geometry_generator, centroid, scaling, angle=None, fiducial=None)

Generate geometric ground truth data from a mask.

Parameters:
  • mask_data (array_like) – 3D mask of points to be analyzed.
  • geometry_generator (function(tuple of float)) – Function to get the quantity of interest given a point.
  • centroid (tuple of int) – Centroid of the phantom in image space.
  • scaling (float) – Isotropic scale factor from coords to image space.
  • angle (float, optional) – The angle by which the phantom would need to be rotated to have the fiducial at the bottom in the x-y plane. Exactly one of angle or fiducial must be included as an argument.
  • fiducial (tuple of float, optional) – The location of the fiducial in image space. Exactly one of fiducial or angle must be included as an argument.
Returns:

An image of the calculated geometry data

Return type:

array_like

transform_data.transform_image_point(point, centroid, angle=None, fiducial=None)

Perform a rigid transform of a given point.

The infill pattern definitions assume the origin is at the centroid of the phantom. This is never the case for scan data, so to compare scan data to a ground truth, we need to translate the image data to move the phantom’s centroid to the origin, and rotate it to align a fiducial to the known ground truth.

Parameters:
  • point (tuple of int) – The indices of the point to be transformed in image space
  • centroid (tuple of float) – The indices of the phantom’s centroid in image space
  • angle (float, optional) – The angle by which the phantom would need to be rotated to have the fiducial at the bottom in the x-y plane. Exactly one of angle or fiducial must be included as an argument.
  • fiducial (tuple of float, optional) – The location of the fiducial in image space. Exactly one of fiducial or angle must be included as an argument.
Returns:

The corresponding indices of the original point in ground truth space.

Return type:

tuple of float