code: def test_streamline_mapping():
      streamlines = [
          np.array([[0, 0, 0], [0, 0, 0], [0, 2, 2]], "float"),
          np.array([[0, 0, 0], [0, 1, 1], [0, 2, 2]], "float"),
          np.array([[0, 2, 2], [0, 1, 1], [0, 0, 0]], "float"),
      ]
      mapping = streamline_mapping(streamlines, affine=np.eye(4))
      expected = {
          (0, 0, 0): [0, 1, 2],
          (0, 2, 2): [0, 1, 2],
          (0, 1, 1): [1, 2],
      }
      npt.assert_equal(mapping, expected)
  
      mapping = streamline_mapping(
          streamlines, affine=np.eye(4), mapping_as_streamlines=True
      )
      expected = dict(
          (k, [streamlines[i] for i in indices])
          for k, indices in expected.items()
      )
      npt.assert_equal(mapping, expected)
  
      # Test passing affine
      affine = np.eye(4)
      affine[:3, 3] = 0.5
      mapping = streamline_mapping(
          streamlines, affine=affine, mapping_as_streamlines=True
      )
      npt.assert_equal(mapping, expected)
  
      # Make the voxel size smaller
      affine = np.diag([0.5, 0.5, 0.5, 1.0])
      affine[:3, 3] = 0.25
      expected = dict(
          (tuple(i * 2 for i in key), value)
          for key, value in expected.items()
      )
      mapping = streamline_mapping(
          streamlines, affine=affine, mapping_as_streamlines=True
      )
      npt.assert_equal(mapping, expected)
  
imports: import warnings
  import numpy
  import pytest
  from dipy.tracking import metrics
  from dipy.tracking.streamline import transform_streamlines
  from dipy.tracking.utils import connectivity_matrix, density_map, length, ndbincount, reduce_labels, seeds_from_mask, random_seeds_from_mask, target, target_line_based, unique_rows, near_roi, reduce_rois, path_length, _min_at, max_angle_from_curvature, min_radius_curvature_from_angle
  from dipy.tracking._utils import _to_voxel_coordinates
  from dipy.tracking.vox2track import streamline_mapping
  import numpy.testing
  from dipy.testing import assert_true
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 12 for calling a global function with example usage: test_streamline_mapping() without return types