code: def voxel2streamline(streamline, affine, unique_idx=None):
      """
      Maps voxels to streamlines and streamlines to voxels, for setting up
      the LiFE equations matrix
  
      Parameters
      ----------
      streamline : list
          A collection of streamlines, each n by 3, with n being the number of
          nodes in the fiber.
      affine : array_like (4, 4)
          The mapping from voxel coordinates to streamline points.
          The voxel_to_rasmm matrix, typically from a NIFTI file.
      unique_idx : array (optional).
         The unique indices in the streamlines
  
      Returns
      -------
      v2f, v2fn : tuple of dicts
  
      The first dict in the tuple answers the question: Given a voxel (from
      the unique indices in this model), which fibers pass through it?
  
      The second answers the question: Given a streamline, for each voxel that
      this streamline passes through, which nodes of that streamline are in that
      voxel?
      """
      transformed_streamline = transform_streamlines(streamline, affine)
  
      if unique_idx is None:
          all_coords = np.concatenate(transformed_streamline)
          unique_idx = unique_rows(np.round(all_coords))
  
      return _voxel2streamline(
          transformed_streamline, unique_idx.astype(np.intp)
      )
  
imports: import numpy
  import scipy.sparse
  import scipy.linalg
  from dipy.reconst.base import ReconstModel, ReconstFit
  from dipy.tracking.utils import unique_rows
  from dipy.tracking.streamline import transform_streamlines
  from dipy.tracking.vox2track import _voxel2streamline
  import dipy.data
  import dipy.core.optimize
label_desc: Use image node_id 6 for calling a global function with example usage: voxel2streamline(streamline, affine, unique_idx) and returns: _voxel2streamline