code: def test_horizon_events(rng):
      # using here MNI template affine 2009a
      affine = np.array(
          [
              [1.0, 0.0, 0.0, -98.0],
              [0.0, 1.0, 0.0, -134.0],
              [0.0, 0.0, 1.0, -72.0],
              [0.0, 0.0, 0.0, 1.0],
          ]
      )
  
      data = 255 * rng.random((197, 233, 189))
      vox_size = (1.0, 1.0, 1.0)
  
      images = [(data, affine)]
      # images = None
      from dipy.segment.tests.test_bundles import setup_module
  
      setup_module()
      from dipy.segment.tests.test_bundles import f1
  
      streamlines = f1.copy()
      streamlines._data += np.array([-98.0, -134.0, -72.0])
  
      header = create_nifti_header(affine, data.shape, vox_size)
      sft = StatefulTractogram(streamlines, header, Space.RASMM)
  
      tractograms = [sft]
  
      # select all centroids and expand and click everything else
      # do not press the key shortcuts as vtk generates warning that
      # blocks recording
      fname = os.path.join(DATA_DIR, "record_horizon.log.gz")
  
      horizon(
          tractograms=tractograms,
          images=images,
          pams=None,
          cluster=True,
          cluster_thr=5.0,
          random_colors=False,
          length_gt=0,
          length_lt=np.inf,
          clusters_gt=0,
          clusters_lt=np.inf,
          world_coords=True,
          interactive=True,
          out_png="tmp.png",
          recorded_events=fname,
      )
  
file_path: dipy/dipy/viz/tests/test_apps.py
imports: import os
  import warnings
  import numpy
  import numpy.testing
  import pytest
  from dipy.data import DATA_DIR
  from dipy.io.stateful_tractogram import Space, StatefulTractogram
  from dipy.io.utils import create_nifti_header
  from dipy.testing import check_for_warnings
  from dipy.testing.decorators import use_xvfb
  from dipy.tracking.streamline import Streamlines
  from dipy.utils.optpkg import optional_package
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 1 for calling a global function with example usage: test_horizon_events(rng) without return types