napari.utils.transforms.CompositeAffine#

class napari.utils.transforms.CompositeAffine(scale=(1, 1), translate=(0, 0), *, rotate=None, shear=None, ndim=None, name=None)[source]#

Bases: Affine

n-dimensional affine transformation composed from more basic components.

Composition is in the following order

rotate * shear * scale + translate

Parameters:
  • rotate (float, 3-tuple of float, or n-D array.) – If a float convert into a 2D rotation matrix using that value as an angle. If 3-tuple convert into a 3D rotation matrix, using a yaw, pitch, roll convention. Otherwise assume an nD rotation. Angles are assumed to be in degrees. They can be converted from radians with np.degrees if needed.

  • scale (1-D array) – A 1-D array of factors to scale each axis by. Scale is broadcast to 1 in leading dimensions, so that, for example, a scale of [4, 18, 34] in 3D can be used as a scale of [1, 4, 18, 34] in 4D without modification. An empty translation vector implies no scaling.

  • shear (1-D array or n-D array) – Either a vector of upper triangular values, or an nD shear matrix with ones along the main diagonal.

  • translate (1-D array) – A 1-D array of factors to shift each axis by. Translation is broadcast to 0 in leading dimensions, so that, for example, a translation of [4, 18, 34] in 3D can be used as a translation of [0, 4, 18, 34] in 4D without modification. An empty translation vector implies no translation.

  • ndim (int) – The dimensionality of the transform. If None, this is inferred from the other parameters.

  • name (string) – A string name for the transform.

Methods

compose(transform)

Return the composite of this transform and the provided one.

expand_dims(axes)

Return a transform with added axes for non-visible dimensions.

replace_slice(axes, transform)

Returns a transform where the transform at the indicated n dimensions is replaced with another n-dimensional transform

set_slice(axes)

Return a transform subset to the visible dimensions.

Attributes

affine_matrix

Return the affine matrix for the transform.

changed

inverse

Return the inverse transform.

linear_matrix

Return the linear matrix of the transform.

ndim

Dimensionality of the transform.

rotate

Return the rotation of the transform.

scale

Return the scale of the transform.

shear

Return the shear of the transform.

translate

Return the translation of the transform.

Details

property affine_matrix#

Return the affine matrix for the transform.

compose(transform)#

Return the composite of this transform and the provided one.

expand_dims(axes: Sequence[int]) CompositeAffine[source]#

Return a transform with added axes for non-visible dimensions.

Parameters:

axes (Sequence[int]) – Location of axes to expand the current transform with. Passing a list allows expansion to occur at specific locations and for expand_dims to be like an inverse to the set_slice method.

Returns:

Resulting transform.

Return type:

Transform

property inverse: Affine#

Return the inverse transform.

property linear_matrix#

Return the linear matrix of the transform.

property ndim: int#

Dimensionality of the transform.

replace_slice(axes: Sequence[int], transform: Affine) Affine#

Returns a transform where the transform at the indicated n dimensions is replaced with another n-dimensional transform

Parameters:
  • axes (Sequence[int]) – Axes where the transform will be replaced

  • transform (Affine) – The transform that will be inserted. Must have as many dimension as len(axes)

Returns:

Resulting transform.

Return type:

Affine

property rotate: ndarray[Any, dtype[ScalarType]]#

Return the rotation of the transform.

property scale: ndarray[Any, dtype[ScalarType]]#

Return the scale of the transform.

set_slice(axes: Sequence[int]) CompositeAffine[source]#

Return a transform subset to the visible dimensions.

Parameters:

axes (Sequence[int]) – Axes to subset the current transform with.

Returns:

Resulting transform.

Return type:

Affine

property shear: ndarray[Any, dtype[ScalarType]]#

Return the shear of the transform.

property translate: ndarray[Any, dtype[ScalarType]]#

Return the translation of the transform.