docstr: Interactive medical visualization - Invert the Horizon!
  
  
  Parameters
  ----------
  tractograms : sequence of StatefulTractograms
      StatefulTractograms are used for making sure that the coordinate
      systems are correct
  images : sequence of tuples
      Each tuple contains data and affine
  pams : sequence of PeakAndMetrics
      Contains peak directions and spherical harmonic coefficients
  cluster : bool
      Enable QuickBundlesX clustering
  rgb : bool, optional
      Enable the color image (rgb only, alpha channel will be ignored).
  cluster_thr : float
      Distance threshold used for clustering. Default value 15.0 for
      small animal data you may need to use something smaller such
      as 2.0. The threshold is in mm. For this parameter to be active
      ``cluster`` should be enabled.
  random_colors : string, optional
      Given multiple tractograms and/or ROIs then each tractogram and/or
      ROI will be shown with a different color. If no value is provided,
      both the tractograms and the ROIs will have a different random
      color generated from a distinguishable colormap. If the effect
      should only be applied to one of the 2 types, then use the
      options 'tracts' and 'rois' for the tractograms and the ROIs
      respectively.
  length_gt : float
      Clusters with average length greater than ``length_gt`` amount
      in mm will be shown.
  length_lt : float
      Clusters with average length less than ``length_lt`` amount in mm
      will be shown.
  clusters_gt : int
      Clusters with size greater than ``clusters_gt`` will be shown.
  clusters_lt : int
      Clusters with size less than ``clusters_lt`` will be shown.
  world_coords : bool
      Show data in their world coordinates (not native voxel coordinates)
      Default True.
  interactive : bool
      Allow user interaction. If False then Horizon goes on stealth mode
      and just saves pictures.
  out_png : string
      Filename of saved picture.
  recorded_events : string
      File path to replay recorded events
  return_showm : bool
      Return ShowManager object. Used only at Python level. Can be used
      for extending Horizon's cababilities externally and for testing
      purposes.
  bg_color : ndarray or list or tuple
      Define the background color of the scene.
      Default is black (0, 0, 0)
  order_transparent : bool
      Default True. Use depth peeling to sort transparent objects.
      If True also enables anti-aliasing.
  buan : bool, optional
      Enables BUAN framework visualization. Default is False.
  buan_colors : list, optional
      List of colors for bundles.
  roi_images : bool, optional
      Displays binary images as contours. Default is False.
  roi_colors : ndarray or list or tuple, optional
      Define the colors of the roi images. Default is red (1, 0, 0)
  
  
  References
  ----------
  .. [Horizon_ISMRM19] Garyfallidis E., M-A. Cote, B.Q. Chandio,
      S. Fadnavis, J. Guaje, R. Aggarwal, E. St-Onge, K.S. Juneja,
      S. Koudoro, D. Reagan, DIPY Horizon: fast, modular, unified and
      adaptive visualization, Proceedings of: International Society of
      Magnetic Resonance in Medicine (ISMRM), Montreal, Canada, 2019.
docstr_tok: ["Interactive","medical","visualization","-","Invert","the","Horizon","!","Parameters","--","--","--","--","--","tractograms",":","sequence","of","StatefulTractograms","StatefulTractograms","are","used","for","making","sure","that","the","coordinate","systems","are","correct","images",":","sequence","of","tuples","Each","tuple","contains","data","and","affine","pams",":","sequence","of","PeakAndMetrics","Contains","peak","directions","and","spherical","harmonic","coefficients","cluster",":","bool","Enable","QuickBundlesX","clustering","rgb",":","bool",",","optional","Enable","the","color","image","(","rgb","only",",","alpha","channel","will","be","ignored",")",".","cluster_thr",":","float","Distance","threshold","used","for","clustering",".","Default","value","15.0","for","small","animal","data","you","may","need","to","use","something","smaller","such","as","2.0",".","The","threshold","is","in","mm",".","For","this","parameter","to","be","active","``","cluster","``","should","be","enabled",".","random_colors",":","string",",","optional","Given","multiple","tractograms","and\/or","ROIs","then","each","tractogram","and\/or","ROI","will","be","shown","with","a","different","color",".","If","no","value","is","provided",",","both","the","tractograms","and","the","ROIs","will","have","a","different","random","color","generated","from","a","distinguishable","colormap",".","If","the","effect","should","only","be","applied","to","one","of","the","2","types",",","then","use","the","options","'tracts","'","and","'rois","'","for","the","tractograms","and","the","ROIs","respectively",".","length_gt",":","float","Clusters","with","average","length","greater","than","``","length_gt","``","amount","in","mm","will","be","shown",".","length_lt",":","float","Clusters","with","average","length","less","than","``","length_lt","``","amount","in","mm","will","be","shown",".","clusters_gt",":","int","Clusters","with","size","greater","than","``","clusters_gt","``","will","be","shown",".","clusters_lt",":","int","Clusters","with","size","less","than","``","clusters_lt","``","will","be","shown",".","world_coords",":","bool","Show","data","in","their","world","coordinates","(","not","native","voxel","coordinates",")","Default","True",".","interactive",":","bool","Allow","user","interaction",".","If","False","then","Horizon","goes","on","stealth","mode","and","just","saves","pictures",".","out_png",":","string","Filename","of","saved","picture",".","recorded_events",":","string","File","path","to","replay","recorded","events","return_showm",":","bool","Return","ShowManager","object",".","Used","only","at","Python","level",".","Can","be","used","for","extending","Horizon","'s","cababilities","externally","and","for","testing","purposes",".","bg_color",":","ndarray","or","list","or","tuple","Define","the","background","color","of","the","scene",".","Default","is","black","(","0",",","0",",","0",")","order_transparent",":","bool","Default","True",".","Use","depth","peeling","to","sort","transparent","objects",".","If","True","also","enables","anti-aliasing",".","buan",":","bool",",","optional","Enables","BUAN","framework","visualization",".","Default","is","False",".","buan_colors",":","list",",","optional","List","of","colors","for","bundles",".","roi_images",":","bool",",","optional","Displays","binary","images","as","contours",".","Default","is","False",".","roi_colors",":","ndarray","or","list","or","tuple",",","optional","Define","the","colors","of","the","roi","images",".","Default","is","red","(","1",",","0",",","0",")","References","--","--","--","--","--","..","[","Horizon_ISMRM19","]","Garyfallidis","E.",",","M-A",".","Cote",",","B.Q",".","Chandio",",","S.","Fadnavis",",","J.","Guaje",",","R.","Aggarwal",",","E.","St-Onge",",","K.S",".","Juneja",",","S.","Koudoro",",","D.","Reagan",",","DIPY","Horizon",":","fast",",","modular",",","unified","and","adaptive","visualization",",","Proceedings","of",":","International","Society","of","Magnetic","Resonance","in","Medicine","(","ISMRM",")",",","Montreal",",","Canada",",","2019","."]
code: def __init__(
      self,
      tractograms=None,
      images=None,
      pams=None,
      cluster=False,
      rgb=False,
      cluster_thr=15.0,
      random_colors=None,
      length_gt=0,
      length_lt=1000,
      clusters_gt=0,
      clusters_lt=10000,
      world_coords=True,
      interactive=True,
      out_png="tmp.png",
      recorded_events=None,
      return_showm=False,
      bg_color=(0, 0, 0),
      order_transparent=True,
      buan=False,
      buan_colors=None,
      roi_images=False,
      roi_colors=(1, 0, 0),
  ):
      """Interactive medical visualization - Invert the Horizon!
  
  
      Parameters
      ----------
      tractograms : sequence of StatefulTractograms
          StatefulTractograms are used for making sure that the coordinate
          systems are correct
      images : sequence of tuples
          Each tuple contains data and affine
      pams : sequence of PeakAndMetrics
          Contains peak directions and spherical harmonic coefficients
      cluster : bool
          Enable QuickBundlesX clustering
      rgb : bool, optional
          Enable the color image (rgb only, alpha channel will be ignored).
      cluster_thr : float
          Distance threshold used for clustering. Default value 15.0 for
          small animal data you may need to use something smaller such
          as 2.0. The threshold is in mm. For this parameter to be active
          ``cluster`` should be enabled.
      random_colors : string, optional
          Given multiple tractograms and/or ROIs then each tractogram and/or
          ROI will be shown with a different color. If no value is provided,
          both the tractograms and the ROIs will have a different random
          color generated from a distinguishable colormap. If the effect
          should only be applied to one of the 2 types, then use the
          options 'tracts' and 'rois' for the tractograms and the ROIs
          respectively.
      length_gt : float
          Clusters with average length greater than ``length_gt`` amount
          in mm will be shown.
      length_lt : float
          Clusters with average length less than ``length_lt`` amount in mm
          will be shown.
      clusters_gt : int
          Clusters with size greater than ``clusters_gt`` will be shown.
      clusters_lt : int
          Clusters with size less than ``clusters_lt`` will be shown.
      world_coords : bool
          Show data in their world coordinates (not native voxel coordinates)
          Default True.
      interactive : bool
          Allow user interaction. If False then Horizon goes on stealth mode
          and just saves pictures.
      out_png : string
          Filename of saved picture.
      recorded_events : string
          File path to replay recorded events
      return_showm : bool
          Return ShowManager object. Used only at Python level. Can be used
          for extending Horizon's cababilities externally and for testing
          purposes.
      bg_color : ndarray or list or tuple
          Define the background color of the scene.
          Default is black (0, 0, 0)
      order_transparent : bool
          Default True. Use depth peeling to sort transparent objects.
          If True also enables anti-aliasing.
      buan : bool, optional
          Enables BUAN framework visualization. Default is False.
      buan_colors : list, optional
          List of colors for bundles.
      roi_images : bool, optional
          Displays binary images as contours. Default is False.
      roi_colors : ndarray or list or tuple, optional
          Define the colors of the roi images. Default is red (1, 0, 0)
  
  
      References
      ----------
      .. [Horizon_ISMRM19] Garyfallidis E., M-A. Cote, B.Q. Chandio,
          S. Fadnavis, J. Guaje, R. Aggarwal, E. St-Onge, K.S. Juneja,
          S. Koudoro, D. Reagan, DIPY Horizon: fast, modular, unified and
          adaptive visualization, Proceedings of: International Society of
          Magnetic Resonance in Medicine (ISMRM), Montreal, Canada, 2019.
      """
      if not has_fury:
          raise ImportError(
              "Horizon requires FURY. Please install it "
              "with pip install fury"
          )
      if Version(fury_version) < Version("0.9.0"):
          ValueError(
              "Horizon requires FURY version 0.9.0 or higher."
              " Please upgrade FURY with pip install -U fury."
          )
  
      self.cluster = cluster
      self.rgb = rgb
      self.cluster_thr = cluster_thr
      self.random_colors = random_colors
      self.length_lt = length_lt
      self.length_gt = length_gt
      self.clusters_lt = clusters_lt
      self.clusters_gt = clusters_gt
      self.world_coords = world_coords
      self.interactive = interactive
      self.prng = np.random.RandomState(27)
      self.tractograms = tractograms or []
      self.out_png = out_png
      self.images = images or []
      self.pams = pams or []
  
      self.cea = {}  # holds centroid actors
      self.cla = {}  # holds cluster actors
      self.recorded_events = recorded_events
      self.show_m = None
      self.return_showm = return_showm
      self.bg_color = bg_color
      self.order_transparent = order_transparent
      self.buan = buan
      self.buan_colors = buan_colors
      self.__roi_images = roi_images
      self.__roi_colors = roi_colors
  
      if self.random_colors is not None:
          self.color_gen = distinguishable_colormap()
          if not self.random_colors:
              self.random_colors = ["tracts", "rois"]
      else:
          self.random_colors = []
  
      self.__clusters_visualizer = None
      self.__tabs = []
      self.__tab_mgr = None
  
      self.__help_visible = True
  
      # TODO: Move to another class/module
      self.__hide_centroids = True
      self.__select_all = False
  
      self.__win_size = (0, 0)
  
imports: from packaging.version import Version
  import warnings
  import numpy
  from dipy import __version__
  from dipy.io.stateful_tractogram import Space, StatefulTractogram
  from dipy.io.streamline import save_tractogram
  from dipy.tracking.streamline import Streamlines
  from dipy.utils.optpkg import optional_package
  from dipy.viz.gmem import GlobalHorizon
  from dipy.viz.horizon.tab import ClustersTab, PeaksTab, ROIsTab, SlicesTab, TabManager, build_label
  from dipy.viz.horizon.visualizer import ClustersVisualizer, SlicesVisualizer
  from dipy.viz.horizon.util import check_img_dtype, check_img_shapes
label_desc: Use image node_id 1 to create a new Horizon object  with example: obj = Horizon(tractograms, images, pams, cluster, rgb, cluster_thr, random_colors, length_gt, length_lt, clusters_gt, clusters_lt, world_coords, interactive, out_png, recorded_events, return_showm, bg_color, order_transparent, buan, buan_colors, roi_images, roi_colors)