code: def test_binary_stopping_criterion(rng):
      """This tests that the binary stopping criterion returns expected
      streamline statuses.
      """
  
      mask = rng.random((4, 4, 4))
      mask[mask < 0.4] = 0.0
  
      btc_boolean = BinaryStoppingCriterion(mask > 0)
      btc_float64 = BinaryStoppingCriterion(mask)
  
      # Test voxel center
      for ind in ndindex(mask.shape):
          pts = np.array(ind, dtype="float64")
          state_boolean = btc_boolean.check_point(pts)
          state_float64 = btc_float64.check_point(pts)
          if mask[ind] > 0:
              npt.assert_equal(
                  state_boolean, int(StreamlineStatus.TRACKPOINT)
              )
              npt.assert_equal(
                  state_float64, int(StreamlineStatus.TRACKPOINT)
              )
          else:
              npt.assert_equal(
                  state_boolean, int(StreamlineStatus.ENDPOINT)
              )
              npt.assert_equal(
                  state_float64, int(StreamlineStatus.ENDPOINT)
              )
  
      # Test random points in voxel
      for ind in ndindex(mask.shape):
          for _ in range(50):
              pts = np.array(ind, dtype="float64") + rng.random(3) - 0.5
              state_boolean = btc_boolean.check_point(pts)
              state_float64 = btc_float64.check_point(pts)
              if mask[ind] > 0:
                  npt.assert_equal(
                      state_boolean, int(StreamlineStatus.TRACKPOINT)
                  )
                  npt.assert_equal(
                      state_float64, int(StreamlineStatus.TRACKPOINT)
                  )
              else:
                  npt.assert_equal(
                      state_boolean, int(StreamlineStatus.ENDPOINT)
                  )
                  npt.assert_equal(
                      state_float64, int(StreamlineStatus.ENDPOINT)
                  )
  
      # Test outside points
      outside_pts = [
          [100, 100, 100],
          [0, -1, 1],
          [0, 10, 2],
          [0, 0.5, -0.51],
          [0, -0.51, 0.1],
          [4, 0, 0],
      ]
      for pts in outside_pts:
          pts = np.array(pts, dtype="float64")
          state_boolean = btc_boolean.check_point(pts)
          state_float64 = btc_float64.check_point(pts)
          npt.assert_equal(
              state_boolean, int(StreamlineStatus.OUTSIDEIMAGE)
          )
          npt.assert_equal(
              state_float64, int(StreamlineStatus.OUTSIDEIMAGE)
          )
  
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 1 for calling a global function with example usage: test_binary_stopping_criterion(rng) without return types