code: def test_cmc_stopping_criterion():
      """This tests that the cmc stopping criterion returns expected
      streamline statuses.
      """
  
      gm = np.array([[[1, 1], [0, 0], [0, 0]]])
      wm = np.array([[[0, 0], [1, 1], [0, 0]]])
      csf = np.array([[[0, 0], [0, 0], [1, 1]]])
      include_map = gm
      exclude_map = csf
  
      cmc_tc = CmcStoppingCriterion(
          include_map=include_map,
          exclude_map=exclude_map,
          step_size=1,
          average_voxel_size=1,
      )
      cmc_tc_from_pve = CmcStoppingCriterion.from_pve(
          wm_map=wm,
          gm_map=gm,
          csf_map=csf,
          step_size=1,
          average_voxel_size=1,
      )
  
      # Test constructors
      for idx in np.ndindex(wm.shape):
          idx = np.asarray(idx, dtype="float64")
          npt.assert_almost_equal(
              cmc_tc.get_include(idx), cmc_tc_from_pve.get_include(idx)
          )
          npt.assert_almost_equal(
              cmc_tc.get_exclude(idx), cmc_tc_from_pve.get_exclude(idx)
          )
  
      # Test voxel center
      for ind in ndindex(wm.shape):
          pts = np.array(ind, dtype="float64")
          state = cmc_tc.check_point(pts)
          if csf[ind] == 1:
              npt.assert_equal(
                  state, int(StreamlineStatus.INVALIDPOINT)
              )
          elif gm[ind] == 1:
              npt.assert_equal(state, int(StreamlineStatus.ENDPOINT))
          else:
              npt.assert_equal(state, int(StreamlineStatus.TRACKPOINT))
  
      # Test outside points
      outside_pts = [
          [100, 100, 100],
          [0, -1, 1],
          [0, 10, 2],
          [0, 0.5, -0.51],
          [0, -0.51, 0.1],
      ]
      for pts in outside_pts:
          pts = np.array(pts, dtype="float64")
          npt.assert_equal(
              cmc_tc.check_point(pts),
              int(StreamlineStatus.OUTSIDEIMAGE),
          )
          npt.assert_equal(cmc_tc.get_exclude(pts), 0)
          npt.assert_equal(cmc_tc.get_include(pts), 0)
  
file_path: dipy/dipy/tracking/tests/test_stopping_criterion.py
imports: import numpy
  import numpy.testing
  import scipy.ndimage
  from dipy.core.ndindex import ndindex
  from dipy.tracking.stopping_criterion import ActStoppingCriterion, BinaryStoppingCriterion, CmcStoppingCriterion, ThresholdStoppingCriterion, StreamlineStatus
  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_cmc_stopping_criterion() without return types