code: def test_cubic_spline_derivative():
      # Test derivative of the cubic spline, as defined in [Mattes03] eq. (3) by
      # comparing the analytical and numerical derivatives
      #
      # [Mattes03] Mattes, D., Haynor, D. R., Vesselle, H., Lewellen, T. K.,
      #            & Eubank, W. PET-CT image registration in the chest using
      #            free-form deformations. IEEE Transactions on Medical Imaging,
      #            22(1), 120-8, 2003.
      in_list = []
      for epsilon in [-1e-9, 0.0, 1e-9]:
          for t in [-2.0, -1.0, 0.0, 1.0, 2.0]:
              x = t + epsilon
              in_list.append(x)
      h = 1e-6
      in_list = np.array(in_list)
      input_h = in_list + h
      s = np.array(cubic_spline(in_list))
      s_h = np.array(cubic_spline(input_h))
      expected = (s_h - s) / h
      actual = cubic_spline_derivative(in_list)
      assert_array_almost_equal(actual, expected)
  
imports: import numpy
  import scipy
  from functools import reduce
  from operator import mul
  from dipy.core.ndindex import ndindex
  from dipy.core.interpolation import interpolate_scalar_2d, interpolate_scalar_3d
  from dipy.data import get_fnames
  from dipy.align import vector_fields
  from dipy.align.transforms import regtransforms
  from dipy.align.parzenhist import ParzenJointHistogram, cubic_spline, cubic_spline_derivative, sample_domain_regular
  from numpy.testing import assert_array_equal, assert_array_almost_equal, assert_almost_equal, assert_equal, assert_raises
  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_cubic_spline_derivative() without return types