Simple ITK TransformVector Returning Error

Hi, I am trying to apply a 3D euler transform to a vector at a particular point:

basis = np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]])
origin = np.array([0.0, 0.0, 0.0]).reshape(-1, 3)
out = transform.TransformVector(basis, origin)

which returns the following error:
TypeError: in method 'Transform_TransformVector', argument 2 of type 'std::vector< double,std::allocator< double > > const &'

Clearly I am specifying the inputs wrongly but I haven’t found any example of apply this function in the documentation or forum. Please help!

Hello @natwille1,

Per the function documentation, for linear transforms such as Euler3D the point does not matter, so any arbitrary setting is fine:

import SimpleITK as sitk
import numpy as np

transform = sitk.Euler3DTransform()
transform.SetTranslation([10, 20, 30])
transform.SetRotation(0, 0, np.pi/2.0) #90 degree rotation around z, x axis should become y

v = [1, 0, 0] # x axis
arbitrary_p = [0, 0, 0]

print(transform.TransformVector(v, arbitrary_p))
                               
2 Likes

Thanks, that simplified it!

1 Like