code: def test_probabilistic_odf_weighted_tracker():
      """This tests that the Probabilistic Direction Getter plays nice
      LocalTracking and produces reasonable streamlines in a simple example.
      """
      sphere = HemiSphere.from_sphere(unit_octahedron)
  
      # A simple image with three possible configurations, a vertical tract,
      # a horizontal tract and a crossing
      pmf_lookup = np.array(
          [
              [0.0, 0.0, 1.0],
              [1.0, 0.0, 0.0],
              [0.0, 1.0, 0.0],
              [0.6, 0.4, 0.0],
          ]
      )
      simple_image = np.array(
          [
              [0, 1, 0, 0, 0, 0],
              [0, 1, 0, 0, 0, 0],
              [0, 3, 2, 2, 2, 0],
              [0, 1, 0, 0, 0, 0],
              [0, 1, 0, 0, 0, 0],
          ]
      )
  
      simple_image = simple_image[..., None]
      pmf = pmf_lookup[simple_image]
  
      seeds = [np.array([1.0, 1.0, 0.0])] * 30
  
      mask = (simple_image > 0).astype(float)
      sc = ThresholdStoppingCriterion(mask, 0.5)
  
      dg = ProbabilisticDirectionGetter.from_pmf(
          pmf, 90, sphere, pmf_threshold=0.1
      )
      streamlines = LocalTracking(dg, sc, seeds, np.eye(4), 1.0)
  
      expected = [
          np.array(
              [
                  [0.0, 1.0, 0.0],
                  [1.0, 1.0, 0.0],
                  [2.0, 1.0, 0.0],
                  [2.0, 2.0, 0.0],
                  [2.0, 3.0, 0.0],
                  [2.0, 4.0, 0.0],
              ]
          ),
          np.array(
              [
                  [0.0, 1.0, 0.0],
                  [1.0, 1.0, 0.0],
                  [2.0, 1.0, 0.0],
                  [3.0, 1.0, 0.0],
                  [4.0, 1.0, 0.0],
              ]
          ),
      ]
  
      path = [False, False]
      for sl in streamlines:
          if allclose(sl, expected[0]):
              path[0] = True
          elif allclose(sl, expected[1]):
              path[1] = True
          else:
              raise AssertionError()
      npt.assert_(all(path))
  
      # The first path is not possible if 90 degree turns are excluded
      dg = ProbabilisticDirectionGetter.from_pmf(
          pmf, 80, sphere, pmf_threshold=0.1
      )
      streamlines = LocalTracking(dg, sc, seeds, np.eye(4), 1.0)
  
      for sl in streamlines:
          npt.assert_(np.allclose(sl, expected[1]))
  
      # The first path is not possible if pmf_threshold > 0.67
      # 0.4/0.6 < 2/3, multiplying the pmf should not change the ratio
      dg = ProbabilisticDirectionGetter.from_pmf(
          10 * pmf, 90, sphere, pmf_threshold=0.67
      )
      streamlines = LocalTracking(dg, sc, seeds, np.eye(4), 1.0)
  
      for sl in streamlines:
          npt.assert_(np.allclose(sl, expected[1]))
  
      # Test non WM seed position
      seeds = [[0, 0, 0], [5, 5, 5]]
      streamlines = LocalTracking(
          dg, sc, seeds, np.eye(4), 0.2, max_cross=1, return_all=True
      )
      streamlines = Streamlines(streamlines)
      npt.assert_(len(streamlines[0]) == 1)  # INVALIDPOINT
      npt.assert_(len(streamlines[1]) == 1)  # OUTSIDEIMAGE
  
      # Test that all points are within the image volume
      seeds = seeds_from_mask(np.ones(mask.shape), np.eye(4), density=2)
      streamline_generator = LocalTracking(
          dg, sc, seeds, np.eye(4), 0.5, return_all=True
      )
      streamlines = Streamlines(streamline_generator)
      for s in streamlines:
          npt.assert_(np.all((s + 0.5).astype(int) >= 0))
          npt.assert_(np.all((s + 0.5).astype(int) < mask.shape))
      # Test that the number of streamline return with return_all=True equal the
      # number of seeds places
  
      npt.assert_(np.array([len(streamlines) == len(seeds)]))
  
      # Test reproducibility
      tracking_1 = Streamlines(
          LocalTracking(dg, sc, seeds, np.eye(4), 0.5, random_seed=0)
      )._data
      tracking_2 = Streamlines(
          LocalTracking(dg, sc, seeds, np.eye(4), 0.5, random_seed=0)
      )._data
      npt.assert_equal(tracking_1, tracking_2)
  
imports: from logging import warn
  import warnings
  import nibabel
  import numpy
  import numpy.testing
  from dipy.core.gradients import gradient_table
  from dipy.core.sphere import HemiSphere, unit_octahedron
  from dipy.data import get_fnames, get_sphere
  from dipy.direction import BootDirectionGetter, ClosestPeakDirectionGetter, DeterministicMaximumDirectionGetter, PeaksAndMetrics, ProbabilisticDirectionGetter, PTTDirectionGetter
  from dipy.reconst.csdeconv import ConstrainedSphericalDeconvModel
  from dipy.reconst.shm import descoteaux07_legacy_msg
  from dipy.tracking.local_tracking import LocalTracking, ParticleFilteringTracking
  from dipy.tracking.streamline import Streamlines
  from dipy.tracking.stopping_criterion import ActStoppingCriterion, BinaryStoppingCriterion, ThresholdStoppingCriterion, StreamlineStatus
  from dipy.tracking.utils import random_seeds_from_mask, seeds_from_mask
  from dipy.sims.voxel import single_tensor, multi_tensor
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 5 for calling a global function with example usage: test_probabilistic_odf_weighted_tracker() without return types