code: def _target(
      target_f,
      streamlines,
      voxel_both_true,
      voxel_one_true,
      test_bad_points,
  ):
      affine = np.eye(4)
      mask = np.zeros((4, 4, 4), dtype=bool)
  
      # Both pass though
      mask[voxel_both_true] = True
      new = list(target_f(streamlines, affine, mask))
      npt.assert_equal(len(new), 2)
      new = list(target_f(streamlines, affine, mask, include=False))
      npt.assert_equal(len(new), 0)
  
      # only first
      mask[:] = False
      mask[voxel_one_true] = True
      new = list(target_f(streamlines, affine, mask))
      npt.assert_equal(len(new), 1)
      assert_true(new[0] is streamlines[0])
      new = list(target_f(streamlines, affine, mask, include=False))
      npt.assert_equal(len(new), 1)
      assert_true(new[0] is streamlines[1])
  
      # Test that bad points raise a value error
      if test_bad_points:
          bad_sl = streamlines + [np.array([[10.0, 10.0, 10.0]])]
          new = target_f(bad_sl, affine, mask)
          npt.assert_raises(ValueError, list, new)
          bad_sl = streamlines + [-np.array([[10.0, 10.0, 10.0]])]
          new = target_f(bad_sl, affine, mask)
          npt.assert_raises(ValueError, list, new)
  
      # Test smaller voxels
      affine = np.array(
          [[0.3, 0, 0, 0], [0, 0.2, 0, 0], [0, 0, 0.4, 0], [0, 0, 0, 1]]
      )
      streamlines = transform_streamlines(streamlines, affine)
      new = list(target_f(streamlines, affine, mask))
      npt.assert_equal(len(new), 1)
      assert_true(new[0] is streamlines[0])
      new = list(target_f(streamlines, affine, mask, include=False))
      npt.assert_equal(len(new), 1)
      assert_true(new[0] is streamlines[1])
  
      # Test that changing mask or affine does not break target/target_line_based
      include = target_f(streamlines, affine, mask)
      exclude = target_f(streamlines, affine, mask, include=False)
      affine[:] = np.eye(4)
      mask[:] = False
      include = list(include)
      exclude = list(exclude)
      npt.assert_equal(len(include), 1)
      assert_true(include[0] is streamlines[0])
      npt.assert_equal(len(exclude), 1)
      assert_true(exclude[0] is streamlines[1])
  
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 9 for calling a global function with example usage: _target(target_f, streamlines, voxel_both_true, voxel_one_true, test_bad_points) without return types