code: def test_transform_origins_3d():
      # Create arbitrary image-to-space transforms
      axis = np.array([0.5, 2.0, 1.5])
      t = 0.15  # translation factor
  
      for theta in [
          -1 * np.pi / 6.0,
          0.0,
          np.pi / 5.0,
      ]:  # rotation angle
          for s in [0.83, 1.3, 2.07]:  # scale
              m_shapes = [
                  (256, 256, 128),
                  (255, 255, 127),
                  (64, 127, 142),
              ]
              for shape_moving in m_shapes:
                  s_shapes = [
                      (256, 256, 128),
                      (255, 255, 127),
                      (64, 127, 142),
                  ]
                  for shape_static in s_shapes:
                      moving = np.ndarray(shape=shape_moving)
                      static = np.ndarray(shape=shape_static)
                      trans = np.array(
                          [
                              [1, 0, 0, -t * shape_static[0]],
                              [0, 1, 0, -t * shape_static[1]],
                              [0, 0, 1, -t * shape_static[2]],
                              [0, 0, 0, 1],
                          ]
                      )
                      trans_inv = npl.inv(trans)
                      rot = np.zeros(shape=(4, 4))
                      rot[:3, :3] = geometry.rodrigues_axis_rotation(
                          axis, theta
                      )
                      rot[3, 3] = 1.0
                      scale = np.array(
                          [
                              [1 * s, 0, 0, 0],
                              [0, 1 * s, 0, 0],
                              [0, 0, 1 * s, 0],
                              [0, 0, 0, 1],
                          ]
                      )
  
                      static_grid2world = trans_inv.dot(
                          scale.dot(rot.dot(trans))
                      )
                      moving_grid2world = npl.inv(static_grid2world)
  
                      # Expected translation
                      c_static = static_grid2world[:3, 3]
                      c_moving = moving_grid2world[:3, 3]
                      expected = np.eye(4)
                      expected[:3, 3] = c_moving - c_static
  
                      # Implementation under test
                      actual = imaffine.transform_origins(
                          static,
                          static_grid2world,
                          moving,
                          moving_grid2world,
                      )
                      assert_array_almost_equal(actual.affine, expected)
  
file_path: dipy/dipy/align/tests/test_imaffine.py
imports: import numpy
  import numpy.linalg
  from numpy.testing import assert_array_equal, assert_array_almost_equal, assert_equal, assert_raises, assert_warns
  from dipy.core import geometry
  from dipy.align import vector_fields
  from dipy.align import imaffine
  from dipy.align.imaffine import AffineInversionError, AffineInvalidValuesError, AffineMap, _number_dim_affine_matrix
  from dipy.align.transforms import regtransforms
  from dipy.align.tests.test_parzenhist import setup_random_transform
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 3 for calling a global function with example usage: test_transform_origins_3d() without return types