docstr: Creates streamlines by using local fiber-tracking.
  
  Parameters
  ----------
  direction_getter : instance of DirectionGetter
      Used to get directions for fiber tracking.
  stopping_criterion : instance of StoppingCriterion
      Identifies endpoints and invalid points to inform tracking.
  seeds : array (N, 3), optional
      Points to seed the tracking. Seed points should be given in point
      space of the track (see ``affine``).
  affine : array (4, 4), optional
      Coordinate space for the streamline point with respect to voxel
      indices of input data. This affine can contain scaling, rotational,
      and translational components but should not contain any shearing.
      An identity matrix can be used to generate streamlines in "voxel
      coordinates" as long as isotropic voxels were used to acquire the
      data.
  step_size : float, optional
      Step size used for tracking.
  max_cross : int or None, optional
      The maximum number of direction to track from each seed in crossing
      voxels. By default all initial directions are tracked.
  maxlen : int, optional
      Maximum length of generated streamlines. Longer streamlines will be
      discarted if `return_all=False`.
  minlen : int, optional
      Minimum length of generated streamlines. Shorter streamlines will
      be discarted if `return_all=False`.
  fixedstep : bool, optional
      If true, a fixed stepsize is used, otherwise a variable step size
      is used.
  return_all : bool, optional
      If true, return all generated streamlines, otherwise only
      streamlines reaching end points or exiting the image.
  random_seed : int, optional
      The seed for the random seed generator (numpy.random.seed and
      random.seed).
  save_seeds : bool, optional
      If True, return seeds alongside streamlines
  unidirectional : bool, optional
      If true, the tracking is performed only in the forward direction.
      The seed position will be the first point of all streamlines.
  randomize_forward_direction : bool, optional
      If true, the forward direction is randomized (multiplied by 1
      or -1). Otherwise, the provided forward direction is used.
  initial_directions: array (N, npeaks, 3), optional
      Initial direction to follow from the ``seed`` position. If
      ``max_cross`` is None, one streamline will be generated per peak
      per voxel. If None, `direction_getter.initial_direction` is used.
docstr_tok: ["Creates","streamlines","by","using","local","fiber-tracking",".","Parameters","--","--","--","--","--","direction_getter",":","instance","of","DirectionGetter","Used","to","get","directions","for","fiber","tracking",".","stopping_criterion",":","instance","of","StoppingCriterion","Identifies","endpoints","and","invalid","points","to","inform","tracking",".","seeds",":","array","(","N",",","3",")",",","optional","Points","to","seed","the","tracking",".","Seed","points","should","be","given","in","point","space","of","the","track","(","see","``","affine","``",")",".","affine",":","array","(","4",",","4",")",",","optional","Coordinate","space","for","the","streamline","point","with","respect","to","voxel","indices","of","input","data",".","This","affine","can","contain","scaling",",","rotational",",","and","translational","components","but","should","not","contain","any","shearing",".","An","identity","matrix","can","be","used","to","generate","streamlines","in","``","voxel","coordinates","''","as","long","as","isotropic","voxels","were","used","to","acquire","the","data",".","step_size",":","float",",","optional","Step","size","used","for","tracking",".","max_cross",":","int","or","None",",","optional","The","maximum","number","of","direction","to","track","from","each","seed","in","crossing","voxels",".","By","default","all","initial","directions","are","tracked",".","maxlen",":","int",",","optional","Maximum","length","of","generated","streamlines",".","Longer","streamlines","will","be","discarted","if","`","return_all=False","`",".","minlen",":","int",",","optional","Minimum","length","of","generated","streamlines",".","Shorter","streamlines","will","be","discarted","if","`","return_all=False","`",".","fixedstep",":","bool",",","optional","If","true",",","a","fixed","stepsize","is","used",",","otherwise","a","variable","step","size","is","used",".","return_all",":","bool",",","optional","If","true",",","return","all","generated","streamlines",",","otherwise","only","streamlines","reaching","end","points","or","exiting","the","image",".","random_seed",":","int",",","optional","The","seed","for","the","random","seed","generator","(","numpy.random.seed","and","random.seed",")",".","save_seeds",":","bool",",","optional","If","True",",","return","seeds","alongside","streamlines","unidirectional",":","bool",",","optional","If","true",",","the","tracking","is","performed","only","in","the","forward","direction",".","The","seed","position","will","be","the","first","point","of","all","streamlines",".","randomize_forward_direction",":","bool",",","optional","If","true",",","the","forward","direction","is","randomized","(","multiplied","by","1","or","-1",")",".","Otherwise",",","the","provided","forward","direction","is","used",".","initial_directions",":","array","(","N",",","npeaks",",","3",")",",","optional","Initial","direction","to","follow","from","the","``","seed","``","position",".","If","``","max_cross","``","is","None",",","one","streamline","will","be","generated","per","peak","per","voxel",".","If","None",",","`","direction_getter.initial_direction","`","is","used","."]
code: def __init__(
      self,
      direction_getter,
      stopping_criterion,
      seeds,
      affine,
      step_size,
      max_cross=None,
      maxlen=500,
      minlen=2,
      fixedstep=True,
      return_all=True,
      random_seed=None,
      save_seeds=False,
      unidirectional=False,
      randomize_forward_direction=False,
      initial_directions=None,
  ):
      """Creates streamlines by using local fiber-tracking.
  
      Parameters
      ----------
      direction_getter : instance of DirectionGetter
          Used to get directions for fiber tracking.
      stopping_criterion : instance of StoppingCriterion
          Identifies endpoints and invalid points to inform tracking.
      seeds : array (N, 3), optional
          Points to seed the tracking. Seed points should be given in point
          space of the track (see ``affine``).
      affine : array (4, 4), optional
          Coordinate space for the streamline point with respect to voxel
          indices of input data. This affine can contain scaling, rotational,
          and translational components but should not contain any shearing.
          An identity matrix can be used to generate streamlines in "voxel
          coordinates" as long as isotropic voxels were used to acquire the
          data.
      step_size : float, optional
          Step size used for tracking.
      max_cross : int or None, optional
          The maximum number of direction to track from each seed in crossing
          voxels. By default all initial directions are tracked.
      maxlen : int, optional
          Maximum length of generated streamlines. Longer streamlines will be
          discarted if `return_all=False`.
      minlen : int, optional
          Minimum length of generated streamlines. Shorter streamlines will
          be discarted if `return_all=False`.
      fixedstep : bool, optional
          If true, a fixed stepsize is used, otherwise a variable step size
          is used.
      return_all : bool, optional
          If true, return all generated streamlines, otherwise only
          streamlines reaching end points or exiting the image.
      random_seed : int, optional
          The seed for the random seed generator (numpy.random.seed and
          random.seed).
      save_seeds : bool, optional
          If True, return seeds alongside streamlines
      unidirectional : bool, optional
          If true, the tracking is performed only in the forward direction.
          The seed position will be the first point of all streamlines.
      randomize_forward_direction : bool, optional
          If true, the forward direction is randomized (multiplied by 1
          or -1). Otherwise, the provided forward direction is used.
      initial_directions: array (N, npeaks, 3), optional
          Initial direction to follow from the ``seed`` position. If
          ``max_cross`` is None, one streamline will be generated per peak
          per voxel. If None, `direction_getter.initial_direction` is used.
      """
  
      self.direction_getter = direction_getter
      self.stopping_criterion = stopping_criterion
      self.seeds = seeds
      self.unidirectional = unidirectional
      self.randomize_forward_direction = randomize_forward_direction
      self.initial_directions = initial_directions
  
      if affine.shape != (4, 4):
          raise ValueError("affine should be a (4, 4) array.")
      if step_size <= 0:
          raise ValueError("step_size must be greater than 0.")
      if maxlen < 1:
          raise ValueError("maxlen must be greater than 0.")
      if minlen > maxlen:
          raise ValueError(
              "maxlen must be greater than or equal to minlen"
          )
      if not isinstance(seeds, Iterable):
          raise ValueError("seeds should be (N,3) array.")
      if (
          initial_directions is not None
          and seeds.shape[0] != initial_directions.shape[0]
      ):
          raise ValueError(
              "initial_directions and seeds must have the "
              + "same shape[0]."
          )
      if (
          initial_directions is None
          and unidirectional
          and not self.randomize_forward_direction
      ):
          warn(
              "Unidirectional tractography will be performed "
              + "without providing initial directions nor "
              + "randomizing extracted initial forward "
              + "directions. This may introduce directional "
              + "biases in the reconstructed streamlines. "
              + "See ``initial_directions`` and "
              + "``randomize_forward_direction`` parameters."
          )
  
      self.affine = affine
      self._voxel_size = np.ascontiguousarray(
          self._get_voxel_size(affine), dtype=float
      )
      self.step_size = step_size
      self.fixed_stepsize = fixedstep
      self.max_cross = max_cross
      self.max_length = maxlen
      self.min_length = minlen
      self.return_all = return_all
      self.random_seed = random_seed
      self.save_seeds = save_seeds
  
file_path: dipy/dipy/tracking/local_tracking.py
imports: import random
  from collections.abc import Iterable
  from warnings import warn
  import numpy
  from dipy.tracking.localtrack import local_tracker, pft_tracker
  from dipy.tracking.stopping_criterion import AnatomicalStoppingCriterion, StreamlineStatus
  from dipy.tracking import utils
  from dipy.utils import fast_numpy
label_desc: Use image node_id 2 to create a new LocalTracking object  with example: obj = LocalTracking(direction_getter, stopping_criterion, seeds, affine, step_size, max_cross, maxlen, minlen, fixedstep, return_all, random_seed, save_seeds, unidirectional, randomize_forward_direction, initial_directions)