code: def test_ad_get_affine_matrix():
      matrix = ra._get_affine_matrix(np.array([0]), "SPM")
      npt.assert_equal(matrix, np.eye(4))
      # test translation
      params = [1, 2, 3]
      matrix = ra._get_affine_matrix(params, "SPM")
      out = np.eye(4)
      out[0:3, 3] = params
      npt.assert_equal(matrix, out)
      # test rotation
      params = np.array([0, 0, 0, np.pi / 2, np.pi / 2, np.pi / 2])
      matrix = ra._get_affine_matrix(params, "SPM")
      out = np.array(
          [0, 0, 1, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1]
      ).reshape((4, 4))
      npt.assert_almost_equal(matrix, out)
      # test scaling
      params = np.array([0, 0, 0, 0, 0, 0, 1, 2, 3])
      matrix = ra._get_affine_matrix(params, "SPM")
      out = np.array(
          [1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1]
      ).reshape((4, 4))
      npt.assert_equal(matrix, out)
      # test shear
      params = np.array([0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 3])
      matrix = ra._get_affine_matrix(params, "SPM")
      out = np.array(
          [1, 1, 2, 0, 0, 1, 3, 0, 0, 0, 1, 0, 0, 0, 0, 1]
      ).reshape((4, 4))
      npt.assert_equal(matrix, out)
  
file_path: nipype/nipype/algorithms/tests/test_rapidart.py
imports: import numpy
  import numpy.testing
  from ..None import rapidart
  from ...interfaces.base import Bunch
label_desc: Use image node_id 3 for calling a global function with example usage: test_ad_get_affine_matrix() without return types