code: def test_parzen_joint_histogram():
      # Test the simple functionality of ParzenJointHistogram,
      # the gradients and computation of the joint intensity distribution
      # will be tested independently
      for nbins in [15, 30, 50]:
          for min_int in [-10.0, 0.0, 10.0]:
              for intensity_range in [0.1, 1.0, 10.0]:
                  fact = 1
                  max_int = min_int + intensity_range
                  P = ParzenJointHistogram(nbins)
                  # Make a pair of 4-pixel images, introduce +/- 1 values
                  # that will be excluded using a mask
                  static = np.array(
                      [min_int - 1.0, min_int, max_int, max_int + 1.0]
                  )
                  # Multiply by an arbitrary value (make the ranges different)
                  moving = fact * np.array(
                      [min_int, min_int - 1.0, max_int + 1.0, max_int]
                  )
                  # Create a mask to exclude the invalid values (beyond min and
                  # max computed above)
                  static_mask = np.array([0, 1, 1, 0])
                  moving_mask = np.array([1, 0, 0, 1])
  
                  P.setup(static, moving, static_mask, moving_mask)
  
                  # Test bin_normalize_static at the boundary
                  normalized = P.bin_normalize_static(min_int)
                  assert_almost_equal(normalized, P.padding)
                  index = P.bin_index(normalized)
                  assert_equal(index, P.padding)
                  normalized = P.bin_normalize_static(max_int)
                  assert_almost_equal(normalized, nbins - P.padding)
                  index = P.bin_index(normalized)
                  assert_equal(index, nbins - 1 - P.padding)
  
                  # Test bin_normalize_moving at the boundary
                  normalized = P.bin_normalize_moving(fact * min_int)
                  assert_almost_equal(normalized, P.padding)
                  index = P.bin_index(normalized)
                  assert_equal(index, P.padding)
                  normalized = P.bin_normalize_moving(fact * max_int)
                  assert_almost_equal(normalized, nbins - P.padding)
                  index = P.bin_index(normalized)
                  assert_equal(index, nbins - 1 - P.padding)
  
                  # Test bin_index not at the boundary
                  delta_s = (max_int - min_int) / (
                      nbins - 2 * P.padding
                  )
                  delta_m = (
                      fact
                      * (max_int - min_int)
                      / (nbins - 2 * P.padding)
                  )
                  for i in range(nbins - 2 * P.padding):
                      normalized = P.bin_normalize_static(
                          min_int + (i + 0.5) * delta_s
                      )
                      index = P.bin_index(normalized)
                      assert_equal(index, P.padding + i)
  
                      normalized = P.bin_normalize_moving(
                          fact * min_int + (i + 0.5) * delta_m
                      )
                      index = P.bin_index(normalized)
                      assert_equal(index, P.padding + i)
  
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 4 for calling a global function with example usage: test_parzen_joint_histogram() without return types