class_docstr: Interaction tab for slice visualization.
  
  Attributes
  ----------
  name : str
      Name of the tab.
class_docstr_tok: ["Interaction","tab","for","slice","visualization",".","Attributes","--","--","--","--","--","name",":","str","Name","of","the","tab","."]
code: def __init__(
      self,
      slices_visualizer,
      slice_id=0,
      force_render=lambda _element: None,
  ):
      super().__init__()
      self._visualizer = slices_visualizer
  
      if slice_id == 0:
          self._name = "Image"
      else:
          self._name = f"Image {slice_id}"
  
      self._force_render = force_render
      self._tab_id = 0
  
      self.on_slice_change = lambda _tab_id, _x, _y, _z: None
  
      self._opacity_toggle = build_checkbox(
          labels=[""],
          checked_labels=[""],
          on_change=self._toggle_opacity,
      )
  
      self._slice_opacity_label, self._slice_opacity = build_slider(
          initial_value=1.0,
          max_value=1.0,
          text_template="{ratio:.0%}",
          on_change=self._change_opacity,
          label="Opacity",
      )
  
      self._slice_x_label, self._slice_x = build_slider(
          initial_value=self._visualizer.selected_slices[0],
          max_value=self._visualizer.data_shape[0] - 1,
          text_template="{value:.0f}",
          label="X Slice",
      )
  
      self._change_slice_x = partial(
          self._change_slice_value, selected_slice=self._slice_x
      )
      self._adjust_slice_x = partial(
          self._change_slice_value,
          selected_slice=self._slice_x,
          sync_slice=True,
      )
      self._visualize_slice_x = partial(
          self._visualizer.slice_actors[0].display_extent,
          y1=0,
          y2=self._visualizer.data_shape[1] - 1,
          z1=0,
          z2=self._visualizer.data_shape[2] - 1,
      )
  
      self._slice_x.obj.on_value_changed = self._adjust_slice_x
      self._slice_x.obj.on_moving_slider = self._change_slice_x
  
      self._change_slice_visibility_x = partial(
          self._update_slice_visibility,
          selected_slice=self._slice_x,
          actor=self._visualizer.slice_actors[0],
      )
  
      self._slice_x_toggle = build_checkbox(
          labels=[""],
          checked_labels=[""],
          on_change=self._change_slice_visibility_x,
      )
  
      self._slice_y_label, self._slice_y = build_slider(
          initial_value=self._visualizer.selected_slices[1],
          max_value=self._visualizer.data_shape[1] - 1,
          text_template="{value:.0f}",
          label="Y Slice",
      )
  
      self._change_slice_y = partial(
          self._change_slice_value, selected_slice=self._slice_y
      )
      self._adjust_slice_y = partial(
          self._change_slice_value,
          selected_slice=self._slice_y,
          sync_slice=True,
      )
      self._visualize_slice_y = partial(
          self._visualizer.slice_actors[1].display_extent,
          x1=0,
          x2=self._visualizer.data_shape[0] - 1,
          z1=0,
          z2=self._visualizer.data_shape[2] - 1,
      )
  
      self._slice_y.obj.on_value_changed = self._adjust_slice_y
      self._slice_y.obj.on_moving_slider = self._change_slice_y
  
      self._change_slice_visibility_y = partial(
          self._update_slice_visibility,
          selected_slice=self._slice_y,
          actor=self._visualizer.slice_actors[1],
      )
  
      self._slice_y_toggle = build_checkbox(
          labels=[""],
          checked_labels=[""],
          on_change=self._change_slice_visibility_y,
      )
  
      self._slice_z_label, self._slice_z = build_slider(
          initial_value=self._visualizer.selected_slices[2],
          max_value=self._visualizer.data_shape[2] - 1,
          text_template="{value:.0f}",
          label="Z Slice",
      )
  
      self._change_slice_z = partial(
          self._change_slice_value, selected_slice=self._slice_z
      )
      self._adjust_slice_z = partial(
          self._change_slice_value,
          selected_slice=self._slice_z,
          sync_slice=True,
      )
      self._visualize_slice_z = partial(
          self._visualizer.slice_actors[2].display_extent,
          x1=0,
          x2=self._visualizer.data_shape[0] - 1,
          y1=0,
          y2=self._visualizer.data_shape[1] - 1,
      )
  
      self._slice_z.obj.on_value_changed = self._adjust_slice_z
      self._slice_z.obj.on_moving_slider = self._change_slice_z
  
      self._change_slice_visibility_z = partial(
          self._update_slice_visibility,
          selected_slice=self._slice_z,
          actor=self._visualizer.slice_actors[2],
      )
  
      self._slice_z_toggle = build_checkbox(
          labels=[""],
          checked_labels=[""],
          on_change=self._change_slice_visibility_z,
      )
  
      self._voxel_label = build_label(
          text="Voxel", is_horizon_label=True
      )
      self._voxel_data = build_label(text="", is_horizon_label=True)
  
      self._visualizer.register_picker_callback(
          self._change_picked_voxel
      )
  
      self.register_elements(
          self._opacity_toggle,
          self._slice_opacity_label,
          self._slice_opacity,
          self._slice_x_toggle,
          self._slice_x_label,
          self._slice_x,
          self._slice_y_toggle,
          self._slice_y_label,
          self._slice_y,
          self._slice_z_toggle,
          self._slice_z_label,
          self._slice_z,
          self._voxel_label,
          self._voxel_data,
      )
  
      if not self._visualizer.rgb:
          self._intensities_label, self._intensities = build_slider(
              initial_value=self._visualizer.intensities_range,
              min_value=self._visualizer.volume_min,
              max_value=self._visualizer.volume_max,
              text_template="{value:.0f}",
              on_change=self._change_intensity,
              label="Intensities",
              is_double_slider=True,
          )
  
          self._supported_colormap = [
              {"label": "Gray", "value": "gray"},
              {"label": "Bone", "value": "bone"},
              {"label": "Cividis", "value": "cividis"},
              {"label": "Inferno", "value": "inferno"},
              {"label": "Magma", "value": "magma"},
              {"label": "Viridis", "value": "viridis"},
              {"label": "Jet", "value": "jet"},
              {"label": "Pastel 1", "value": "Pastel1"},
              {"label": "Distinct", "value": "dist"},
          ]
  
          (
              self._colormap_switcher_label,
              self._colormap_switcher,
          ) = build_switcher(
              items=self._supported_colormap,
              label="Colormap",
              on_value_changed=self._change_color_map,
          )
  
          self.register_elements(
              self._intensities_label,
              self._intensities,
              self._colormap_switcher_label,
              self._colormap_switcher,
          )
  
          if len(self._visualizer.data_shape) == 4:
              self._volume_label, self._volume = build_slider(
                  initial_value=0,
                  max_value=self._visualizer.data_shape[-1] - 1,
                  on_moving_slider=self._change_volume,
                  text_template="{value:.0f}",
                  label="Volume",
              )
              self.register_elements(self._volume_label, self._volume)
  
imports: import warnings
  from functools import partial
  import numpy
  from dipy.utils.optpkg import optional_package
  from dipy.viz.horizon.tab import HorizonTab, build_label, build_slider, build_switcher, build_checkbox
label_desc: Use image node_id 1 to create a new SlicesTab object from inherited base classes: HorizonTab with example: obj = SlicesTab(slices_visualizer, slice_id, force_render)