code: def intersect_sphere(xyz, center, radius):
      """If any segment of the track is intersecting with a sphere of
      specific center and radius return True otherwise False
  
      Parameters
      ----------
      xyz : array, shape (N,3)
         representing x,y,z of the N points of the track
      center : array, shape (3,)
         center of the sphere
      radius : float
         radius of the sphere
  
      Returns
      -------
      tf : {True, False}
         True if track `xyz` intersects sphere
  
      >>> from dipy.tracking.metrics import intersect_sphere
      >>> line=np.array(([0,0,0],[1,1,1],[2,2,2]))
      >>> sph_cent=np.array([1,1,1])
      >>> sph_radius = 1
      >>> intersect_sphere(line,sph_cent,sph_radius)
      True
  
      Notes
      -----
      The ray to sphere intersection method used here is similar with
      https://paulbourke.net/geometry/circlesphere/
      https://paulbourke.net/geometry/circlesphere/source.cpp
      we just applied it for every segment neglecting the intersections where
      the intersecting points are not inside the segment
      """
      center = np.array(center)
      # print center
  
      lt = xyz.shape[0]
  
      for i in range(lt - 1):
          # first point
          x1 = xyz[i]
          # second point
          x2 = xyz[i + 1]
          # do the calculations as given in the Notes
          x = x2 - x1
          a = np.inner(x, x)
          x1c = x1 - center
          b = 2 * np.inner(x, x1c)
          c = (
              np.inner(center, center)
              + np.inner(x1, x1)
              - 2 * np.inner(center, x1)
              - radius**2
          )
          bb4ac = b * b - 4 * a * c
          # print 'bb4ac',bb4ac
          if (
              abs(a) < np.finfo(float).eps or bb4ac < 0
          ):  # too small segment or
              # no intersection
              continue
          if bb4ac == 0:  # one intersection point p
              mu = -b / 2 * a
              p = x1 + mu * x
              # check if point is inside the segment
              # print 'p',p
              if np.inner(p - x1, p - x1) <= a:
                  return True
          if bb4ac > 0:  # two intersection points p1 and p2
              mu = (-b + np.sqrt(bb4ac)) / (2 * a)
              p1 = x1 + mu * x
              mu = (-b - np.sqrt(bb4ac)) / (2 * a)
              p2 = x1 + mu * x
              # check if points are inside the line segment
              # print 'p1,p2',p1,p2
              if (
                  np.inner(p1 - x1, p1 - x1) <= a
                  or np.inner(p2 - x1, p2 - x1) <= a
              ):
                  return True
      return False
  
imports: from dipy.utils.deprecator import deprecate_with_version
  from dipy.tracking.streamline import set_number_of_points
  import numpy
  from scipy.interpolate import splprep, splev
label_desc: Use image node_id 13 for calling a global function with example usage: intersect_sphere(xyz, center, radius) and returns: False, True, True