code: def seeds_from_mask(mask, affine, density=(1, 1, 1)):
      """Create seeds for fiber tracking from a binary mask.
  
      Seeds points are placed evenly distributed in all voxels of ``mask`` which
      are ``True``.
  
      Parameters
      ----------
      mask : binary 3d array_like
          A binary array specifying where to place the seeds for fiber tracking.
      affine : array, (4, 4)
          The mapping between voxel indices and the point space for seeds.
          The voxel_to_rasmm matrix, typically from a NIFTI file.
          A seed point at the center the voxel ``[i, j, k]``
          will be represented as ``[x, y, z]`` where
          ``[x, y, z, 1] == np.dot(affine, [i, j, k , 1])``.
      density : int or array_like (3,)
          Specifies the number of seeds to place along each dimension. A
          ``density`` of `2` is the same as ``[2, 2, 2]`` and will result in a
          total of 8 seeds per voxel.
  
      See Also
      --------
      random_seeds_from_mask
  
      Raises
      ------
      ValueError
          When ``mask`` is not a three-dimensional array
  
      Examples
      --------
      >>> mask = np.zeros((3,3,3), 'bool')
      >>> mask[0,0,0] = 1
      >>> seeds_from_mask(mask, np.eye(4), [1,1,1])
      array([[ 0.,  0.,  0.]])
  
      """
      mask = np.array(mask, dtype=bool, copy=False, ndmin=3)
      if mask.ndim != 3:
          raise ValueError("mask cannot be more than 3d")
  
      density = np.asarray(density, int)
      if density.size == 1:
          d = density
          density = np.empty(3, dtype=int)
          density.fill(d)
      elif density.shape != (3,):
          raise ValueError(
              "density should be in integer array of shape (3,)"
          )
  
      # Grid of points between -.5 and .5, centered at 0, with given density
      grid = np.mgrid[0 : density[0], 0 : density[1], 0 : density[2]]
      grid = grid.T.reshape((-1, 3))
      grid = grid / density
      grid += 0.5 / density - 0.5
  
      where = np.argwhere(mask)
  
      # Add the grid of points to each voxel in mask
      seeds = where[:, np.newaxis, :] + grid[np.newaxis, :, :]
      seeds = seeds.reshape((-1, 3))
  
      # Apply the spatial transform
      if seeds.any():
          # Use affine to move seeds into real world coordinates
          seeds = np.dot(seeds, affine[:3, :3].T)
          seeds += affine[:3, 3]
  
      return seeds
  
imports: from collections import defaultdict, OrderedDict
  from functools import wraps
  from itertools import combinations, groupby
  from warnings import warn
  import numpy
  from nibabel.affines import apply_affine
  from scipy.spatial.distance import cdist
  from dipy.core.geometry import dist_to_corner
  from dipy.tracking import metrics
  from dipy.tracking.vox2track import _streamlines_in_mask
  from dipy.tracking._utils import _mapping_to_voxel, _to_voxel_coordinates
label_desc: Use image node_id 6 for calling a global function with example usage: seeds_from_mask(mask, affine, density) and returns: seeds