code: def test_contour_from_roi():
      hardi_img, gtab, labels_img = read_stanford_labels()
      data = np.asanyarray(hardi_img.dataobj)
      labels = np.asanyarray(labels_img.dataobj)
      affine = hardi_img.affine
  
      white_matter = (labels == 1) | (labels == 2)
  
      with warnings.catch_warnings():
          warnings.filterwarnings(
              "ignore",
              message=descoteaux07_legacy_msg,
              category=PendingDeprecationWarning,
          )
          csa_model = CsaOdfModel(gtab, sh_order=6)
  
          csa_peaks = peaks_from_model(
              csa_model,
              data,
              default_sphere,
              relative_peak_threshold=0.8,
              min_separation_angle=45,
              mask=white_matter,
          )
  
      classifier = ThresholdStoppingCriterion(csa_peaks.gfa, 0.25)
  
      seed_mask = labels == 2
      seeds = utils.seeds_from_mask(
          seed_mask, density=[1, 1, 1], affine=affine
      )
  
      # Initialization of LocalTracking.
      # The computation happens in the next step.
      streamlines = LocalTracking(
          csa_peaks, classifier, seeds, affine, step_size=2
      )
  
      # Compute streamlines and store as a list.
      streamlines = list(streamlines)
  
      # Prepare the display objects.
      streamlines_actor = actor.line(
          streamlines, colormap.line_colors(streamlines)
      )
      seedroi_actor = actor.contour_from_roi(
          seed_mask, affine, [0, 1, 1], 0.5
      )
  
      # Create the 3d display.
      sc = window.Scene()
      sc2 = window.Scene()
      sc.add(streamlines_actor)
      arr3 = window.snapshot(sc, "test_surface3.png", offscreen=True)
      report3 = window.analyze_snapshot(arr3, find_objects=True)
      sc2.add(streamlines_actor)
      sc2.add(seedroi_actor)
      arr4 = window.snapshot(sc2, "test_surface4.png", offscreen=True)
      report4 = window.analyze_snapshot(arr4, find_objects=True)
  
      # assert that the seed ROI rendering is not far
      # away from the streamlines (affine error)
      npt.assert_equal(report3.objects, report4.objects)
  
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 2 for calling a global function with example usage: test_contour_from_roi() without return types