code: def test_select_by_rois():
      streamlines = [
          np.array([[0, 0.0, 0.9], [1.9, 0.0, 0.0]]),
          np.array([[0.1, 0.0, 0], [0, 1.0, 1.0], [0, 2.0, 2.0]]),
          np.array([[2, 2, 2], [3, 3, 3]]),
      ]
  
      # Make two ROIs:
      mask1 = np.zeros((4, 4, 4), dtype=bool)
      mask2 = np.zeros_like(mask1)
      mask1[0, 0, 0] = True
      mask2[1, 0, 0] = True
  
      selection = select_by_rois(
          streamlines, np.eye(4), [mask1], [True], tol=1
      )
  
      assert_arrays_equal(
          list(selection), [streamlines[0], streamlines[1]]
      )
  
      selection = select_by_rois(
          streamlines, np.eye(4), [mask1, mask2], [True, True], tol=1
      )
  
      assert_arrays_equal(
          list(selection), [streamlines[0], streamlines[1]]
      )
  
      selection = select_by_rois(
          streamlines, np.eye(4), [mask1, mask2], [True, False]
      )
  
      assert_arrays_equal(list(selection), [streamlines[1]])
  
      # Setting tolerance too low gets overridden:
      with warnings.catch_warnings():
          warnings.simplefilter("ignore")
          selection = select_by_rois(
              streamlines,
              np.eye(4),
              [mask1, mask2],
              [True, False],
              tol=0.1,
          )
  
          assert_arrays_equal(list(selection), [streamlines[1]])
  
      selection = select_by_rois(
          streamlines, np.eye(4), [mask1, mask2], [True, True], tol=0.87
      )
  
      assert_arrays_equal(list(selection), [streamlines[1]])
  
      mask3 = np.zeros_like(mask1)
      mask3[0, 2, 2] = 1
      selection = select_by_rois(
          streamlines,
          np.eye(4),
          [mask1, mask2, mask3],
          [True, True, False],
          tol=1.0,
      )
  
      assert_arrays_equal(list(selection), [streamlines[0]])
  
      # Select using only one ROI
      selection = select_by_rois(
          streamlines, np.eye(4), [mask1], [True], tol=0.87
      )
      assert_arrays_equal(list(selection), [streamlines[1]])
  
      selection = select_by_rois(
          streamlines, np.eye(4), [mask1], [True], tol=1.0
      )
      assert_arrays_equal(
          list(selection), [streamlines[0], streamlines[1]]
      )
  
      # Use different modes:
      selection = select_by_rois(
          streamlines,
          np.eye(4),
          [mask1, mask2, mask3],
          [True, True, False],
          mode="all",
          tol=1.0,
      )
      assert_arrays_equal(list(selection), [streamlines[0]])
  
      selection = select_by_rois(
          streamlines,
          np.eye(4),
          [mask1, mask2, mask3],
          [True, True, False],
          mode="either_end",
          tol=1.0,
      )
      assert_arrays_equal(list(selection), [streamlines[0]])
  
      selection = select_by_rois(
          streamlines,
          np.eye(4),
          [mask1, mask2, mask3],
          [True, True, False],
          mode="both_end",
          tol=1.0,
      )
      assert_arrays_equal(list(selection), [streamlines[0]])
  
      mask2[0, 2, 2] = True
      selection = select_by_rois(
          streamlines,
          np.eye(4),
          [mask1, mask2, mask3],
          [True, True, False],
          mode="both_end",
          tol=1.0,
      )
  
      assert_arrays_equal(
          list(selection), [streamlines[0], streamlines[1]]
      )
  
      # Test with generator input:
      selection = select_by_rois(
          generate_sl(streamlines), np.eye(4), [mask1], [True], tol=1.0
      )
      assert_arrays_equal(
          list(selection), [streamlines[0], streamlines[1]]
      )
  
imports: import warnings
  import types
  import numpy
  from numpy.linalg import norm
  import numpy.testing
  from dipy.testing.memory import get_type_refcount
  from dipy.testing import assert_arrays_equal
  from dipy.testing.decorators import set_random_number_generator
  from dipy.testing import assert_true
  from numpy.testing import assert_array_equal, assert_array_almost_equal, assert_raises, assert_allclose, assert_almost_equal, assert_equal
  from dipy.tracking.streamlinespeed import compress_streamlines, length, set_number_of_points
  from dipy.tracking.streamline import Streamlines
  from dipy.tracking.streamline import relist_streamlines, unlist_streamlines, center_streamlines, transform_streamlines, select_random_set_of_streamlines, select_by_rois, orient_by_rois, orient_by_streamline, values_from_volume, deform_streamlines, cluster_confidence
label_desc: Use image node_id 19 for calling a global function with example usage: test_select_by_rois() without return types