code: def test_PTTDirectionGetter():
      # Test the constructors and errors of the PTTDirectionGetter
      class SillyModel(SphHarmModel):
          def fit(self, data, mask=None):
              coeff = np.zeros(data.shape[:-1] + (15,))
              return SphHarmFit(self, coeff, mask=None)
  
      silly_model = SillyModel(gtab=None)
      data = np.zeros((3, 3, 3, 7))
      fit = silly_model.fit(data)
      point = np.zeros(3)
      dir = unit_octahedron.vertices[0].copy()
  
      # Make ptt_dg from shm_coeffs
      with warnings.catch_warnings():
          warnings.filterwarnings(
              "ignore",
              message=descoteaux07_legacy_msg,
              category=PendingDeprecationWarning,
          )
          dg = PTTDirectionGetter.from_shcoeff(
              fit.shm_coeff, 90, unit_octahedron
          )
      npt.assert_equal(dg.get_direction(point, dir), 1)
  
      # Make ptt_dg from pmf
      pmf = np.zeros((3, 3, 3, unit_octahedron.theta.shape[0]))
      dg = PTTDirectionGetter.from_pmf(pmf, 90, unit_octahedron)
      npt.assert_equal(dg.get_direction(point, dir), 1)
  
      with warnings.catch_warnings():
          warnings.filterwarnings(
              "ignore",
              message=tournier07_legacy_msg,
              category=PendingDeprecationWarning,
          )
  
          # Check probe_length ValueError
          npt.assert_raises(
              ValueError,
              PTTDirectionGetter.from_shcoeff,
              fit.shm_coeff,
              90,
              unit_octahedron,
              basis_type="tournier07",
              probe_length=0,
          )
  
          # Check probe_radius ValueError
          npt.assert_raises(
              ValueError,
              PTTDirectionGetter.from_shcoeff,
              fit.shm_coeff,
              90,
              unit_octahedron,
              basis_type="tournier07",
              probe_radius=-1,
          )
  
          # Check probe_quality ValueError
          npt.assert_raises(
              ValueError,
              PTTDirectionGetter.from_shcoeff,
              fit.shm_coeff,
              90,
              unit_octahedron,
              basis_type="tournier07",
              probe_quality=1,
          )
  
          # Check probe_length ValueError
          npt.assert_raises(
              ValueError,
              PTTDirectionGetter.from_shcoeff,
              fit.shm_coeff,
              90,
              unit_octahedron,
              basis_type="tournier07",
              probe_count=0,
          )
  
file_path: dipy/dipy/direction/tests/test_ptt_direction_getter.py
imports: import warnings
  import numpy
  import numpy.testing
  from dipy.core.sphere import unit_octahedron
  from dipy.data import get_fnames, default_sphere
  from dipy.direction import PTTDirectionGetter
  from dipy.io.image import load_nifti
  from dipy.reconst.shm import SphHarmFit, SphHarmModel, sh_to_sf, descoteaux07_legacy_msg, tournier07_legacy_msg
  from dipy.tracking.local_tracking import LocalTracking
  from dipy.tracking.stopping_criterion import BinaryStoppingCriterion
  from dipy.tracking.streamline import Streamlines
label_desc: Use image node_id 2 for calling a global function with example usage: test_PTTDirectionGetter() and returns: SphHarmFit