NaviNIBS.util.Transforms module

Return type:

ndarray

Extract translation and rotation components from transform. Assume the transform is rigid. :rtype: tuple[ndarray, ndarray] :return: (3x3 rotation matrix, 3-elem translation vector)

Apply 4x4 transform(s) to a set of points :type A2B: Union[ndarray, Iterable[ndarray]] :param A2B: single 4x4 transform, or iterable of 4x4 transforms. If multiple, will apply in reversed order, so that

applyTransform([space1ToSpace2Transf, space2TransfToSpace3Transf], pts) correctly transforms from space1 to space3 as might be expected with space2TransfToSpace3Transf @ space1ToSpace2Transf @ augmentedPts

Parameters:

pts (ndarray) – Nx3 points. Or can be in shape (3,) and will return transformed points with same shape.

Param:

doCheck: whether to check that transform is valid

Param:

doStrictCheck: whether raise error if transform is not valid

Return type:

ndarray

Returns:

transformed points

Return type:

ndarray

Combine transforms in reverse order, using same ordering convention as applyTransform, such that applyTransform(concatenateTransforms([space1ToSpace2Transf, space2TransfToSpace3Transf]), pts) correctly transforms from space1 to space3 as might be expected with space2TransfToSpace3Transf @ space1ToSpace2Transf @ augmentedPts

Return type:

ndarray

Return type:

ndarray

Return type:

str

Raises ValueError if unable to convert to valid transform :type inputStr: str :param inputStr: str representation of a transform, e.g. from

transformToString(np.asarray([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]))

Return type:

ndarray

Returns:

transform as 4x4 ndarray

Calculate rotation such that X-axis points in direction of vecA, Y-axis points in direction of (oproj_vecA vecB) adapted from https://rock-learning.github.io/pytransform3d/_apidoc/pytransform3d.rotations.matrix_from_two_vectors.html

Parameters:
  • vecA (ndarray)

  • vecB (ndarray)

Return type:

ndarray

Returns:

3x3 rotation matrix

Calculate rotation that would rotate vecA to vecB

Return type:

ndarray

Estimate a transform that aligns one set of points onto another.

Some methods assume row-wise matching of points between sets.

For details of the kabsch-svd method, see:
Parameters:
  • ptsA (ndarray) – Nx3 ndarray of points

  • ptsB (ndarray) – Mx3 ndarray of points

  • method (str) – method to use for estimating transform. Default is ‘kabsch-svd’’

  • weights (Optional[ndarray]) –

    default None, otherwise format depends on method: if method == ‘kabsch-svd’:

    Kabsch weighted algorithm will be used. Weights should be of length equal to number of points in ptsA and ptsB.

    elif method == ‘ICP’:

    Weights should be of length 6, with values as defined by simpleicp’s rbp_observation_weights argument.

Return type:

ndarray

Returns:

A2B, 4x4 transform aligning ptsA to ptsB