itk_dreg.reduce_dfield.transform_collection¶

Module Contents¶

Classes¶

TransformEntry

Wraps a single transform for inclusion in a TransformCollection with or without a transform domain.

TransformCollection

Represent a collection of (possibly bounded) itk.Transform(s).

Data¶

API¶

itk_dreg.reduce_dfield.transform_collection.logger¶

‘getLogger(…)’

class itk_dreg.reduce_dfield.transform_collection.TransformEntry¶

Wraps a single transform for inclusion in a TransformCollection with or without a transform domain.

transform: itk.Transform¶

None

Transform representing some spatial relationship.

domain: Optional[itk.Image]¶

None

The domain over which the transform is valid.

If a value is provided then the is considered to be bounded, meaning it is only valid to transform a point in real space by this transform if the transform falls within the physical bounds of the transform domain. As a convenience, a transform domain is constrained such that it must be representable with an oriented bounding box in physical space. An unbuffered itk.Image may be used to describe the oriented bounding box. The voxel grid subdivision of the itk.Image is ignored in TransformCollection processing. If None then the transform is considered to be unbounded, meaning it is valid to transform any point in real space by this transform to obtain another point in R^3.

class itk_dreg.reduce_dfield.transform_collection.TransformCollection(transform_and_domain_list: List[itk_dreg.reduce_dfield.transform_collection.TransformEntry] = None, blend_method: Callable[[itk.Point, List[itk_dreg.reduce_dfield.transform_collection.TransformEntry]], itk.Point] = None)¶

Represent a collection of (possibly bounded) itk.Transform(s).

A single point to transform may fall within multiple transform domains. In that case a simple average is taken of point output candidates.

A domain of None indicates that a transform is valid over an unbounded, global input domain.

TODO: Re-implement in ITK C++ to inherit from itk.Transform for use in filters and for improved performance.

Initialization

Initialize a new TransformCollection.

Parameters:
  • transform_and_domain_list – The list of transforms and associated transform domains to inform TransformCollection behavior.

  • blend_method – The method to use to blend among output candidates in the case of overlapping transform domains.

property transforms: List[itk.Transform]¶

The itk.Transforms in this collection.

property domains: List[Optional[itk.Image]]¶

The transform domains in this collection.

static _bounds_contains(bounds: numpy.typing.ArrayLike, pt: numpy.typing.ArrayLike) bool¶

Determines whether a point (X,Y,Z) falls within an axis-aligned physical bounding box.

Parameters:
  • bounds – A 2x3 voxel array representing axis-aligned inclusive upper and lower bounds in (X,Y,Z) physical space.

  • pt – A physical point (X,Y,Z).

Returns:

True if the point is contained inside the inclusive physical region, else False.

static blend_simple_mean(input_pt: itk.Point, region_contributors: List[itk_dreg.reduce_dfield.transform_collection.TransformEntry]) numpy.typing.ArrayLike¶

Method to blend among multiple possible transform outputs by performing unweighted averaging of all point candidates.

If the input point falls within the domain overlap of three transforms, each transform will be applied independently to produce three point candidates and the output will be the linear sum of each candidate weighted by (1/3).

This is a simple approach that may result in significant discontinuities at transform domain edges.

Parameters:
  • input_pt – The point to transform.

  • region_contributors – The transforms whose domains include the given point.

Returns:

The average transformed point.

classmethod blend_distance_weighted_mean(input_pt: itk.Point, region_contributors: List[itk_dreg.reduce_dfield.transform_collection.TransformEntry]) numpy.typing.ArrayLike¶

Blending method to weight transform results by their proximity to the edge of the corresponding transform domain.

This blending approach avoids discontinuities at transform domain bounds. Transforms that have no bounds on the domain over which they apply are weighted minimally.

#TODO Investigate alternatives to consider unbounded/background transform information.

Parameters:
  • input_pt – The point to transform.

  • region_contributors – The transforms whose domains include the given point.

Returns:

The average transformed point.

classmethod _physical_distance_from_edge(input_pt: itk.Point, domain: itk.Image) Tuple[float, int]¶

Estimate unsigned minimum physical distance to closest domain side.

Handles domain with isotropic or anisotropic spacing over non-axis-aligned image domain representation.

Parameters:
  • input_pt – The point to transform.

  • domain – The transform domain to consider.

Returns:

Tuple with elements: 0. The physical linear distance to the nearest image edge, and

  1. The zero-indexed axis to travel to reach the nearest edge.

static _pixel_distance_from_edge(input_pt: itk.Point, domain: itk.Image) numpy.typing.ArrayLike¶

Estimate signed voxel distance to each image side.

Inspired by https://github.com/InsightSoftwareConsortium/ITKMontage/blob/master/include/itkTileMergeImageFilter.hxx#L217

Parameters:
  • input_pt – The point to transform.

  • domain – The transform domain to consider.

Returns:

The shortest pixel distance to an edge along each axis in ITK access order (I,J,K)

static _validate_entry(entry: itk_dreg.reduce_dfield.transform_collection.TransformEntry) None¶

Validate that an input transform entry is valid.

Parameters:

entry – The bounded or unbounded transform entry.

Raises:

TypeError – If either the transform or transform domain type is invalid.

push(entry: itk_dreg.reduce_dfield.transform_collection.TransformEntry) None¶

Add a new bounded or unbounded transform to the underlying collection.

Parameters:

entry – The transform and domain to add.

Raises:

TypeError – If the entry is invalid.

transform_point(pt: itk.Point[itk.F, 3]) itk.Point[itk.F, 3]¶

Transforms an input physical point (X,Y,Z) by the piecewise transform relationship developed by underlying bounded transforms and the selected blending method.

Parameters:

pt – The physical point (X,Y,Z) to transform.

Returns:

The transformed point (X,Y,Z) obtained after blending among point outputs from each viable transform candidate.

Raises:

ValueError – If the input point does not fall within any of the transform domains contained within the TransformCollection.

TransformPoint(pt: itk.Point[itk.F, 3]) numpy.typing.ArrayLike¶

itk.Transform-like interface to transform a point by the transform relationship developed by this TransformCollection instance.

See transform_point documentation.