code: def test_harmonic_fields_3d():
      nslices = 25
      nrows = 34
      ncols = 37
      mid_slice = nslices // 2
      mid_row = nrows // 2
      mid_col = ncols // 2
      expected_d = np.empty(shape=(nslices, nrows, ncols, 3))
      expected_d_inv = np.empty(shape=(nslices, nrows, ncols, 3))
      for b in [0.3, 0.7]:
          for m in [2, 5]:
              for k in range(nslices):
                  for i in range(nrows):
                      for j in range(ncols):
                          kk = k - mid_slice
                          ii = i - mid_row
                          jj = j - mid_col
                          theta = np.arctan2(ii, jj)
                          expected_d[k, i, j, 0] = kk * (
                              1.0 / (1 + b * np.cos(m * theta)) - 1.0
                          )
                          expected_d[k, i, j, 1] = ii * (
                              1.0 / (1 + b * np.cos(m * theta)) - 1.0
                          )
                          expected_d[k, i, j, 2] = jj * (
                              1.0 / (1 + b * np.cos(m * theta)) - 1.0
                          )
                          expected_d_inv[k, i, j, 0] = (
                              b * np.cos(m * theta) * kk
                          )
                          expected_d_inv[k, i, j, 1] = (
                              b * np.cos(m * theta) * ii
                          )
                          expected_d_inv[k, i, j, 2] = (
                              b * np.cos(m * theta) * jj
                          )
  
              actual_d, actual_d_inv = vfu.create_harmonic_fields_3d(
                  nslices, nrows, ncols, b, m
              )
              assert_array_almost_equal(expected_d, actual_d)
              assert_array_almost_equal(expected_d_inv, expected_d_inv)
  
imports: import numpy
  from numpy.testing import assert_array_equal, assert_array_almost_equal, assert_almost_equal, assert_equal, assert_raises
  from scipy.ndimage import map_coordinates
  from nibabel.affines import apply_affine, from_matvec
  from dipy.core import geometry
  from dipy.align import floating
  from dipy.align import imwarp
  from dipy.align import vector_fields
  from dipy.align.transforms import regtransforms
  from dipy.align.parzenhist import sample_domain_regular
  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_harmonic_fields_3d() without return types