docstr: Test the feature: centerdistance.
docstr_tok: ["Test","the","feature",":","centerdistance","."]
code: def test_centerdistance(self):
      """Test the feature: centerdistance."""
  
      i = numpy.asarray([[0, 0], [0, 0]])
      e = [
          math.sqrt(0.5),
          math.sqrt(0.5),
          math.sqrt(0.5),
          math.sqrt(0.5),
      ]
      r = centerdistance(i)
      numpy.testing.assert_allclose(
          r,
          e,
          err_msg="centerdistance: 2D, single-spectrum, 2x2, unmasked and not normalized",
      )
  
      r = centerdistance([i, i])
      numpy.testing.assert_allclose(
          r,
          e,
          err_msg="centerdistance: 2D, multi-spectrum, 2x2, unmasked and not normalized",
      )
  
      i = numpy.asarray([[1, 0.0], [2, 3.0]])
      r = centerdistance(i)
      numpy.testing.assert_allclose(
          r,
          e,
          err_msg="centerdistance: 2D, single-spectrum, 2x2, unmasked and not normalized: feature not independent of image content",
      )
  
      i = numpy.asarray([[0, 0, 0], [0, 0, 0], [0, 0, 0]])
      e = [
          math.sqrt(2),
          1,
          math.sqrt(2),
          1,
          0,
          1,
          math.sqrt(2),
          1,
          math.sqrt(2),
      ]
      r = centerdistance(i)
      numpy.testing.assert_allclose(
          r,
          e,
          err_msg="centerdistance: 2D, single-spectrum, 3x3, unmasked and not normalized",
      )
  
      m = [
          [True, False, False],
          [False, True, False],
          [False, False, True],
      ]
      e = [math.sqrt(2), 0, math.sqrt(2)]
      r = centerdistance(i, mask=m)
      numpy.testing.assert_allclose(
          r,
          e,
          err_msg="centerdistance: 2D, single-spectrum, 2x2, masked and not normalized",
      )
  
      e = [
          math.sqrt(1.25),
          1,
          math.sqrt(1.25),
          math.sqrt(0.25),
          0,
          math.sqrt(0.25),
          math.sqrt(1.25),
          1,
          math.sqrt(1.25),
      ]
      s = [1.0, 0.5]
      r = centerdistance(i, voxelspacing=s)
      numpy.testing.assert_allclose(
          r,
          e,
          err_msg="centerdistance: 2D, single-spectrum, 3x3, unmasked and not normalized: voxel spacing not taken into account",
      )
  
      i = numpy.asarray([i, i, i])
      e = [
          math.sqrt(2),
          1,
          math.sqrt(2),
          1,
          0,
          1,
          math.sqrt(2),
          1,
          math.sqrt(2),
      ]
      en1 = [
          math.sqrt(3),
          math.sqrt(2),
          math.sqrt(3),
          math.sqrt(2),
          1,
          math.sqrt(2),
          math.sqrt(3),
          math.sqrt(2),
          math.sqrt(3),
      ]
      e = numpy.asarray([en1, e, en1]).ravel()
      r = centerdistance(i)
      numpy.testing.assert_allclose(
          r,
          e,
          err_msg="centerdistance: 3D, single-spectrum, 3x3x3, unmasked and not normalized",
      )
  
      i = numpy.asarray([i, i, i])
      en2 = [
          math.sqrt(4),
          math.sqrt(3),
          math.sqrt(4),
          math.sqrt(3),
          math.sqrt(2),
          math.sqrt(3),
          math.sqrt(4),
          math.sqrt(3),
          math.sqrt(4),
      ]
      e = numpy.asarray(
          [
              numpy.asarray([en2, en1, en2]).ravel(),
              e,
              numpy.asarray([en2, en1, en2]).ravel(),
          ]
      ).ravel()
      r = centerdistance(i)
      numpy.testing.assert_allclose(
          r,
          e,
          err_msg="centerdistance: 4D, single-spectrum, 3x3x3x3, unmasked and not normalized",
      )
  
file_path: medpy/tests/features_/intensity.py
imports: import unittest
  import math
  import numpy
  from medpy.features.intensity import intensities, centerdistance, centerdistance_xdminus1, indices, local_mean_gauss, local_histogram
  from medpy.features.utilities import join, append
  from medpy.core.exceptions import ArgumentError
label_desc: Use image node_id 5 for calling the TestIntensityFeatures obj's underlying member method code with example usage: obj.test_centerdistance() without return types