code: def test_tensor_slicer(interactive=False):
      evals = np.array([1.4, 0.35, 0.35]) * 10 ** (-3)
      evecs = np.eye(3)
  
      mevals = np.zeros((3, 2, 4, 3))
      mevecs = np.zeros((3, 2, 4, 3, 3))
  
      mevals[..., :] = evals
      mevecs[..., :, :] = evecs
  
      sphere = get_sphere("symmetric724")
  
      affine = np.eye(4)
      scene = window.Scene()
  
      tensor_actor = actor.tensor_slicer(
          mevals,
          mevecs,
          affine=affine,
          sphere=sphere,
          scale=0.3,
          opacity=0.4,
      )
      _, J, K = mevals.shape[:3]
      scene.add(tensor_actor)
      scene.reset_camera()
      scene.reset_clipping_range()
  
      tensor_actor.display_extent(0, 1, 0, J, 0, K)
      if interactive:
          window.show(scene, reset_camera=False)
  
      tensor_actor.GetProperty().SetOpacity(1.0)
      if interactive:
          window.show(scene, reset_camera=False)
  
      npt.assert_equal(scene.GetActors().GetNumberOfItems(), 1)
  
      # Test extent
      big_extent = scene.GetActors().GetLastActor().GetBounds()
      big_extent_x = abs(big_extent[1] - big_extent[0])
      tensor_actor.display(x=2)
  
      if interactive:
          window.show(scene, reset_camera=False)
  
      small_extent = scene.GetActors().GetLastActor().GetBounds()
      small_extent_x = abs(small_extent[1] - small_extent[0])
      npt.assert_equal(big_extent_x > small_extent_x, True)
  
      # Test empty mask
      empty_actor = actor.tensor_slicer(
          mevals,
          mevecs,
          affine=affine,
          mask=np.zeros(mevals.shape[:3]),
          sphere=sphere,
          scale=0.3,
      )
      npt.assert_equal(empty_actor.GetMapper(), None)
  
      # Test mask
      mask = np.ones(mevals.shape[:3])
      mask[:2, :3, :3] = 0
      cfa = color_fa(fractional_anisotropy(mevals), mevecs)
      tensor_actor = actor.tensor_slicer(
          mevals,
          mevecs,
          affine=affine,
          mask=mask,
          scalar_colors=cfa,
          sphere=sphere,
          scale=0.3,
      )
      scene.clear()
      scene.add(tensor_actor)
      scene.reset_camera()
      scene.reset_clipping_range()
  
      if interactive:
          window.show(scene, reset_camera=False)
  
      mask_extent = scene.GetActors().GetLastActor().GetBounds()
      mask_extent_x = abs(mask_extent[1] - mask_extent[0])
      npt.assert_equal(big_extent_x > mask_extent_x, True)
  
      # test display
      tensor_actor.display()
      current_extent = scene.GetActors().GetLastActor().GetBounds()
      current_extent_x = abs(current_extent[1] - current_extent[0])
      npt.assert_equal(big_extent_x > current_extent_x, True)
      if interactive:
          window.show(scene, reset_camera=False)
  
      tensor_actor.display(y=1)
      current_extent = scene.GetActors().GetLastActor().GetBounds()
      current_extent_y = abs(current_extent[3] - current_extent[2])
      big_extent_y = abs(big_extent[3] - big_extent[2])
      npt.assert_equal(big_extent_y > current_extent_y, True)
      if interactive:
          window.show(scene, reset_camera=False)
  
      tensor_actor.display(z=1)
      current_extent = scene.GetActors().GetLastActor().GetBounds()
      current_extent_z = abs(current_extent[5] - current_extent[4])
      big_extent_z = abs(big_extent[5] - big_extent[4])
      npt.assert_equal(big_extent_z > current_extent_z, True)
      if interactive:
          window.show(scene, reset_camera=False)
  
      # Test error handling of the method when
      # incompatible dimension of mevals and evecs are passed.
      mevals = np.zeros((3, 2, 3))
      mevecs = np.zeros((3, 2, 4, 3, 3))
  
      with npt.assert_raises(RuntimeError):
          tensor_actor = actor.tensor_slicer(
              mevals,
              mevecs,
              affine=affine,
              mask=mask,
              scalar_colors=cfa,
              sphere=sphere,
              scale=0.3,
          )
  
imports: import warnings
  import pytest
  import numpy
  import numpy.testing
  from dipy.testing.decorators import use_xvfb, set_random_number_generator
  from dipy.utils.optpkg import optional_package
  from dipy.data import get_sphere
  from dipy.align.reslice import reslice
  from dipy.data import read_stanford_labels
  from dipy.reconst.shm import CsaOdfModel
  from dipy.data import default_sphere
  from dipy.direction import peaks_from_model
  from dipy.tracking import utils
  from dipy.tracking.stopping_criterion import ThresholdStoppingCriterion
  from dipy.tracking.local_tracking import LocalTracking
  from dipy.reconst.shm import descoteaux07_legacy_msg, sh_to_sf_matrix
  from dipy.align.tests.test_streamlinear import fornix_streamlines
  from dipy.tracking.streamline import center_streamlines, transform_streamlines
  from dipy.reconst.dti import color_fa, fractional_anisotropy
label_desc: Use image node_id 5 for calling a global function with example usage: test_tensor_slicer(interactive) without return types