# `viz`

## Module: `viz.gmem`

`GlobalHorizon`() |

## Module: `viz.horizon`

## Module: `viz.horizon.app`

`Horizon`(*[, tractograms, images, pams, ...]) |
`horizon`(*[, tractograms, images, pams, ...]) | Interactive medical visualization - Invert the Horizon!

## Module: `viz.horizon.tab`

## Module: `viz.horizon.tab.base`

`HorizonUIElement`(visibility, selected_value, obj) | Dataclass to define properties of horizon ui elements.
`HorizonTab`() | Base for different tabs available in horizon.
`TabManager`(tabs, win_size, on_tab_changed, ...) | A Manager for tabs of the table panel.
`build_label`(text, *[, font_size, bold]) | Simple utility function to build labels.
`build_slider`(initial_value, max_value, *[, ...]) | Create a horizon theme based disk-knob slider.
`build_checkbox`(*[, labels, checked_labels, ...]) | Create horizon theme checkboxes.
`build_radio_button`(*[, labels, ...]) | Create horizon theme radio buttons.
`build_switcher`(*[, items, label, ...]) | Create horizon theme switcher.

## Module: `viz.horizon.tab.cluster`

`ClustersTab`(clusters_visualizer, threshold) |

## Module: `viz.horizon.tab.peak`

`PeaksTab`(peak_actor) |

## Module: `viz.horizon.tab.roi`

`ROIsTab`(contour_actors) |

## Module: `viz.horizon.tab.slice`

`SlicesTab`(slices_visualizer, tab_name, ...) | Interaction tab for slice visualization.

## Module: `viz.horizon.tab.surface`

`SurfaceTab`(visualizer, tab_name, file_name) |

## Module: `viz.horizon.util`

`check_img_shapes`(images) | Check if the images have same shapes.
`check_img_dtype`(images) | Check supplied image dtype.
`show_ellipsis`(text, text_size, available_size) | Apply ellipsis to the text.
`unpack_image`(img) | Unpack provided image data.
`unpack_surface`(surface) | Unpack surface data.
`check_peak_size`(pams, *[, ref_img_shape, ...]) | Check shape of peaks.

## Module: `viz.horizon.visualizer`

## Module: `viz.horizon.visualizer.cluster`

`ClustersVisualizer`(show_manager, scene, ...) |

## Module: `viz.horizon.visualizer.peak`

`PeakActor`(directions, indices, *[, values, ...]) | FURY actor for visualizing DWI peaks.
`PeaksVisualizer`(pam, world_coords) |
`peak`(peaks_dirs, *[, peaks_values, mask, ...]) | Visualize peak directions as given from `peaks_from_model` function.

## Module: `viz.horizon.visualizer.slice`

`SlicesVisualizer`(interactor, scene, data, *) |

## Module: `viz.horizon.visualizer.surface`

`SurfaceVisualizer`(surface, scene, color) |

## Module: `viz.panel`

`build_label`(text, *[, font_size, bold]) | Simple utility function to build labels
`slicer_panel`(scene, iren, *[, data, affine, ...]) | Slicer panel with slicer included

## Module: `viz.plotting`

plotting functions

`compare_maps`(fits, maps, *[, transpose, ...]) | Compare one or more scalar maps for different fits or models.
`compare_qti_maps`(gt, fit1, fit2, mask, *[, ...]) | Compare one or more qti derived maps obtained with different fitting routines.
`bundle_shape_profile`(x, shape_profile, std) | Plot bundlewarp bundle shape profile.
`image_mosaic`(images, *[, ax_labels, ...]) | Draw a mosaic of 2D images using pyplot.imshow().

## Module: `viz.projections`

Visualization tools for 2D projections of 3D functions on the sphere, such as ODFs.

`sph_project`(vertices, val, *[, ax, vmin, ...]) | Draw a signal on a 2D projection of the sphere.

## Module: `viz.regtools`

`simple_plot`(file_name, title, x, y, xlabel, ...) | Saves the simple plot with given x and y values
`overlay_images`(img0, img1, *[, title0, ...]) | Plot two images one on top of the other using red and green channels.
`draw_lattice_2d`(nrows, ncols, delta) | Create a regular lattice of nrows x ncols squares.
`plot_2d_diffeomorphic_map`(mapping, *[, ...]) | Draw the effect of warping a regular lattice by a diffeomorphic map.
`plot_slices`(V, *[, slice_indices, fname]) | Plot 3 slices from the given volume: 1 sagittal, 1 coronal and 1 axial
`overlay_slices`(L, R, *[, slice_index, ...]) | Plot three overlaid slices from the given volumes.

## Module: `viz.streamline`

`show_bundles`(bundles, *[, interactive, ...]) | Render bundles to visualize them interactively or save them into a png.
`viz_two_bundles`(b1, b2, fname, *[, c1, c2, ...]) | Render and plot two bundles to visualize them.
`viz_vector_field`(points_aligned, directions, ...) | Render and plot vector field.
`viz_displacement_mag`(bundle, offsets, fname, *) | Render and plot displacement magnitude over the bundle.

### `GlobalHorizon`

class dipy.viz.gmem.GlobalHorizon

  Bases: `object`

### `Horizon`

class dipy.viz.horizon.app.Horizon(*, tractograms=None, images=None, pams=None, surfaces=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), surface_colors=((1, 0, 0),))

  Bases: `object`

  Methods

  build_scene |
  build_show |

  build_scene()
  build_show(scene)

### horizon

dipy.viz.horizon.app.horizon(*, tractograms=None, images=None, pams=None, surfaces=None, cluster=False, rgb=False, cluster_thr=15.0, random_colors=None, bg_color=(0, 0, 0), order_transparent=True, length_gt=0, length_lt=1000, clusters_gt=0, clusters_lt=10000, world_coords=True, interactive=True, buan=False, buan_colors=None, roi_images=False, roi_colors=(1, 0, 0), out_png='tmp.png', recorded_events=None, return_showm=False)

  Interactive medical visualization - Invert the Horizon!

  See [1] for further details about 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

    surfaces sequence of tuples

      Each tuple contains vertices and faces

    cluster bool

      Enable QuickBundlesX clustering

    rgb: bool, optional

      Enable the color image.

    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

      Given multiple tractograms and/or ROIs then each tractogram and/or ROI will be shown with 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 objects, then use the options ‘tracts’ and ‘rois’ for the tractograms and the ROIs respectively.

    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.

    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.

    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 color of the roi images. Default is red (1, 0, 0)

    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 capabilities externally and for testing purposes.

  References

  [1]

  Eleftherios Garyfallidis, Marc-Alexandre Côté, Bramsh Qamar Chandio, Shreyas Fadnavis, Javier Guaje, Ranveer Aggarwal, Etienne St-Onge, Karandeep Singh Juneja, Serge Koudoro, and David Reagan. DIPY Horizon: fast, modular, unified and adaptive visualization. In ISMRM 27th Annual Meeting & Exhibition SMRT 28th Annual Meeting, volume. Montréal, Canada, 2019. International Society for Magnetic Resonance in Medicine (ISMRM).

### `HorizonUIElement`

class dipy.viz.horizon.tab.base.HorizonUIElement(visibility: bool, selected_value: Any, obj: Any)

  Bases: `object`

  Dataclass to define properties of horizon ui elements.

  obj: Any
  position = (0, 0)
  selected_value: Any
  size = ('auto', 'auto')
  visibility: bool

### `HorizonTab`

class dipy.viz.horizon.tab.base.HorizonTab

  Bases: `ABC`

  Base for different tabs available in horizon.

  Attributes:
    `actors`

      Name of the tab.

    `elements`

      list of underlying FURY ui elements in the tab.

    `name`

      Name of the tab.

    `tab_id`

      Id of the tab.

  Methods

  `build`(tab_id) | Build all the elements under the tab.
  `on_tab_selected`() | Implement if require to update something while the tab becomes active.

  abstract property actors

    Name of the tab.

  abstractmethod build(tab_id)

    Build all the elements under the tab.

    Parameters:
      tab_id int

        Id of the tab.

  property elements

    list of underlying FURY ui elements in the tab.

  abstract property name

    Name of the tab.

  on_tab_selected()

    Implement if require to update something while the tab becomes active.

  property tab_id

    Id of the tab. Reference for Tab Manager to identify the tab.

    Returns:
      int

### `TabManager`

class dipy.viz.horizon.tab.base.TabManager(tabs, win_size, on_tab_changed, add_to_scene, *, remove_from_scene, sync_slices=False, sync_volumes=False, sync_peaks=False)

  Bases: `object`

  A Manager for tabs of the table panel.

  Attributes:
    `tab_ui` TabUI

      FURY TabUI object.

  Methods

  `reposition`(win_size) | Reposition the tabs panel.
  `synchronize_slices`(active_tab_id, x_value, ...) | Synchronize slicers for all the images and peaks.
  `synchronize_volumes`(active_tab_id, value) | Synchronize volumes for all the images with volumes.

  handle_text_overflows |

  handle_text_overflows()
  reposition(win_size)

    Reposition the tabs panel.

    Parameters:
      win_size(float, float)

        size of the horizon window.

  synchronize_slices(active_tab_id, x_value, y_value, z_value)

    Synchronize slicers for all the images and peaks.

    Parameters:
      active_tab_id: int

        tab_id of the action performing tab

      x_value: float

        x-value of the active slicer

      y_value: float

        y-value of the active slicer

      z_value: float

        z-value of the active slicer

  synchronize_volumes(active_tab_id, value)

    Synchronize volumes for all the images with volumes.

    Parameters:
      active_tab_id int

        tab_id of the action performing tab

      value float

        volume value of the active volume slider

  property tab_ui

    FURY TabUI object.

### build_label

dipy.viz.horizon.tab.base.build_label(text, *, font_size=16, bold=False)

  Simple utility function to build labels.

  Parameters:
    text str
    font_size int, optional
    bold bool, optional
  Returns:
    label TextBlock2D

### build_slider

dipy.viz.horizon.tab.base.build_slider(initial_value, max_value, *, min_value=0, length=450, line_width=3, radius=8, font_size=16, text_template='{value:.1f} ({ratio:.0%})', on_moving_slider=<function <lambda>>, on_value_changed=<function <lambda>>, on_change=<function <lambda>>, on_handle_released=<function <lambda>>, label='', label_font_size=16, label_style_bold=False, is_double_slider=False)

  Create a horizon theme based disk-knob slider.

  Parameters:
    initial_value float, (float, float)

      Initial value(s) of the slider.

    max_value float

      Maximum value of the slider.

    min_value float, optional

      Minimum value of the slider.

    length int, optional

      Length of the slider.

    line_width int, optional

      Width of the line on which the disk will slide.

    radius int, optional

      Radius of the disk handle.

    font_size int, optional

      Size of the text to display alongside the slider (pt).

    text_template str, callable, optional

      If str, text template can contain one or multiple of the replacement fields: {value:}, {ratio:}. If callable, this instance of :class:LineSlider2D will be passed as argument to the text template function.

    on_moving_slider callable, optional

      When the slider is interacted by the user.

    on_value_changed callable, optional

      When value of the slider changed programmatically.

    on_change callable, optional

      When value of the slider changed.

    on_handle_released: callable, optional

      When handle released.

    label str, optional

      Label to ui element for slider

    label_font_size int, optional

      Size of label text to display with slider

    label_style_bold bool, optional

      Is label should have bold style.

    is_double_slider bool, optional

      True if the slider allows to adjust two values.

  Returns:
    label HorizonUIElement

      Slider label.

    HorizonUIElement

      Slider.

### build_checkbox

dipy.viz.horizon.tab.base.build_checkbox(*, labels=None, checked_labels=None, padding=1, font_size=16, on_change=<function <lambda>>)

  Create horizon theme checkboxes.

  Parameters:
    labels list(str), optional

      List of labels of each option.

    checked_labels: list(str), optional

      List of labels that are checked on setting up.

    padding float, optional

      The distance between two adjacent options element

    font_size int, optional

      Size of the text font.

    on_change callback, optional

      When checkbox value changed

  Returns:
    checkbox HorizonUIElement

### build_radio_button

dipy.viz.horizon.tab.base.build_radio_button(*, labels=None, checked_labels=None, padding=1, font_size=16, on_change=<function <lambda>>)

  Create horizon theme radio buttons.

  Parameters:
    labels list(str), optional

      List of labels of each option.

    checked_labels: list(str), optional

      List of labels that are checked on setting up.

    padding float, optional

      The distance between two adjacent options element

    font_size int, optional

      Size of the text font.

    on_change callback, optional

      When radio button value changed

  Returns:
    radio HorizonUIElement

### build_switcher

dipy.viz.horizon.tab.base.build_switcher(*, items=None, label='', initial_selection=0, on_prev_clicked=<function <lambda>>, on_next_clicked=<function <lambda>>, on_value_changed=<function <lambda>>)

  Create horizon theme switcher.

  Parameters:
    items list, optional

      dictionaries with keys ‘label’ and ‘value’. Label will be used to show it to user and value will be used for selection.

    label str, optional

      label for the switcher.

    initial_selection int, optional

      index of the selected item initially.

    on_prev_clicked callback, optional

      method providing a callback when prev value is selected in switcher.

    on_next_clicked callback, optional

      method providing a callback when next value is selected in switcher.

    on_value_changed callback, optional

      method providing a callback when either prev or next value selected in switcher.

  Returns:
    HorizonCombineElement(

      label: HorizonUIElement, element(switcher): HorizonUIElement)

  Notes

  switcher: consists ‘obj’ which is an array providing FURY UI elements used.

### `ClustersTab`

class dipy.viz.horizon.tab.cluster.ClustersTab(clusters_visualizer, threshold)

  Bases: `HorizonTab`

  Attributes:
    `actors`

      All the actors in the visualizer.

    `centroid_actors`

      Centroid actors of the tractograms.

    `cluster_actors`

      Cluster actors of the tractograms.

    `elements`

      list of underlying FURY ui elements in the tab.

    `name`

      Title of the tab.

    `tab_id`

      Id of the tab.

  Methods

  `build`(tab_id) | Position the elements in the tab.
  `on_tab_selected`() | Implement if require to update something while the tab becomes active.

  property actors

    All the actors in the visualizer.

    Returns:
      list
  build(tab_id)

    Position the elements in the tab.

    Parameters:
      tab_id int

        Id of the tab.

  property centroid_actors

    Centroid actors of the tractograms.

    Returns:
      dict

        various properties of centroids.

  property cluster_actors

    Cluster actors of the tractograms.

    Returns:
      dict

        various properties of clusters.

  property name

    Title of the tab.

    Returns:
      str

### `PeaksTab`

class dipy.viz.horizon.tab.peak.PeaksTab(peak_actor)

  Bases: `HorizonTab`

  Attributes:
    `actors`

      actors controlled by tab.

    `elements`

      list of underlying FURY ui elements in the tab.

    `name`

      Name of the tab.

    `tab_id`

      Id of the tab.

  Methods

  `build`(tab_id) | Build all the elements under the tab.
  `on_tab_selected`() | Trigger when tab becomes active.
  `update_slices`(x_slice, y_slice, z_slice) | Updates slicer positions.

  property actors

    actors controlled by tab.

    Returns:
      list

        List of actors.

  build(tab_id)

    Build all the elements under the tab.

    Parameters:
      tab_id int

        Id of the tab.

  property name

    Name of the tab.

    Returns:
      str
  on_tab_selected()

    Trigger when tab becomes active.

  update_slices(x_slice, y_slice, z_slice)

    Updates slicer positions.

    Parameters:
      x_slice: float

        x-value where the slicer should be placed

      y_slice: float

        y-value where the slicer should be placed

      z_slice: float

        z-value where the slicer should be placed

### `ROIsTab`

class dipy.viz.horizon.tab.roi.ROIsTab(contour_actors)

  Bases: `HorizonTab`

  Attributes:
    `actors`

      Actors controlled by tab.

    `elements`

      list of underlying FURY ui elements in the tab.

    `name`

      Title of the tab.

    `tab_id`

      Id of the tab.

  Methods

  `build`(tab_id) | Position the elements in the tab.
  `on_tab_selected`() | Implement if require to update something while the tab becomes active.

  property actors

    Actors controlled by tab.

    Returns:
      list
  build(tab_id)

    Position the elements in the tab.

    Parameters:
      tab_id int

        Identifier for the tab. Index of the tab in TabUI.

  property name

    Title of the tab.

    Returns:
      str

### `SlicesTab`

class dipy.viz.horizon.tab.slice.SlicesTab(slices_visualizer, tab_name, file_name, *, force_render=<function SlicesTab.<lambda>>)

  Bases: `HorizonTab`

  Interaction tab for slice visualization.

  Attributes:
    `name` str

      Name of the tab.

  Methods

  `build`(tab_id) | Build all the elements under the tab.
  `on_tab_selected`() | Trigger when tab becomes active.
  `update_slices`(x_slice, y_slice, z_slice) | Updates slicer positions.
  `update_volume`(volume) | Updates volume based on passed volume.

  property actors

    visualization actors controlled by tab.

  build(tab_id)

    Build all the elements under the tab.

    Parameters:
      tab_id int

        Id of the tab.

  property file_name

    Name of the file opened in the tab.

  property name

    Name of the tab.

  on_tab_selected()

    Trigger when tab becomes active.

  update_slices(x_slice, y_slice, z_slice)

    Updates slicer positions.

    Parameters:
      x_slice: float

        x-value where the slicer should be placed

      y_slice: float

        y-value where the slicer should be placed

      z_slice: float

        z-value where the slicer should be placed

  update_volume(volume)

    Updates volume based on passed volume.

    Parameters:
      volume float

        value of where the volume slider should be placed

### `SurfaceTab`

class dipy.viz.horizon.tab.surface.SurfaceTab(visualizer, tab_name, file_name)

  Bases: `HorizonTab`

  Attributes:
    `actors`

      Actors controlled by this tab.

    `elements`

      list of underlying FURY ui elements in the tab.

    `name`

      Name of the tab.

    `tab_id`

      Id of the tab.

  Methods

  `build`(tab_id) | Build all the elements under the tab.
  `on_tab_selected`() | Implement if require to update something while the tab becomes active.

  property actors

    Actors controlled by this tab.

  build(tab_id)

    Build all the elements under the tab.

    Parameters:
      tab_id int

        Id of the tab.

  property name

    Name of the tab.

    Returns:
      str

### check_img_shapes

dipy.viz.horizon.util.check_img_shapes(images)

  Check if the images have same shapes. It also provides details about the volumes are same or not. If the shapes are not equal it will return False for both shape and volume.

  Parameters:
    images list
  Returns:
    tuple

      tuple[0] = True, if shapes are equal. tuple[1] = True, if volumes are equal.

### check_img_dtype

dipy.viz.horizon.util.check_img_dtype(images)

  Check supplied image dtype.

  If not supported numerical type, fallback to supported numerical types (either int32 or float 32). If non-numerical type, skip the data.

  Parameters:
    images list

      Each image is tuple of (data, affine).

  Returns:
    list

      Valid images from the provided images.

### show_ellipsis

dipy.viz.horizon.util.show_ellipsis(text, text_size, available_size)

  Apply ellipsis to the text.

  Parameters:
    text string

      Text required to be check for ellipsis.

    text_size float

      Current size of the text in pixels.

    available_size float

      Size available to fit the text. This will be used to truncate the text and show ellipsis.

  Returns:
    string

      Text after processing for ellipsis.

### unpack_image

dipy.viz.horizon.util.unpack_image(img)

  Unpack provided image data.

  Standard way to handle different value images.

  Parameters:
    img tuple

      An image can contain either (data, affine) or (data, affine, fname).

  Returns:
    tuple

      If img with (data, affine) it will convert to (data, affine, None). Otherwise it will be passed as it is.

### unpack_surface

dipy.viz.horizon.util.unpack_surface(surface)

  Unpack surface data.

  Parameters:
    surface tuple

      It either contains (vertices, faces) or (vertices, faces, fname).

  Returns:
    tuple

      If surface with (vertices, faces) it will convert to (vertices, faces, None). Otherwise it will be passed as it is.

### check_peak_size

dipy.viz.horizon.util.check_peak_size(pams, *, ref_img_shape=None, sync_imgs=False)

  Check shape of peaks.

  Parameters:
    pams PeaksAndMetrics

      Peaks and metrics.

    ref_img_shape tuple, optional

      3D shape of the image, by default None.

    sync_imgs bool, optional

      True if the images are synchronized, by default False.

  Returns:
    bool

      If the peaks are aligned with images and other peaks.

### `ClustersVisualizer`

class dipy.viz.horizon.visualizer.cluster.ClustersVisualizer(show_manager, scene, tractograms, *, enable_callbacks=True)

  Bases: `object`

  Attributes:
    centroid_actors
    cluster_actors
    lengths
    sizes
    tractogram_clusters

  Methods

  add_cluster_actors |
  recluster_tractograms |

  add_cluster_actors(tract_idx, streamlines, thr, colors)
  property centroid_actors
  property cluster_actors
  property lengths
  recluster_tractograms(thr)
  property sizes
  property tractogram_clusters

### `PeakActor`

class dipy.viz.horizon.visualizer.peak.PeakActor(directions, indices, *, values=None, affine=None, colors=None, lookup_colormap=None, linewidth=1, symmetric=True)

  Bases: `Actor`

  FURY actor for visualizing DWI peaks.

  Parameters:
    directions ndarray

      Peak directions. The shape of the array should be (X, Y, Z, D, 3).

    indices tuple

      Indices given in tuple(x_indices, y_indices, z_indices) format for mapping 2D ODF array to 3D voxel grid.

    values ndarray, optional

      Peak values. The shape of the array should be (X, Y, Z, D).

    affine array, optional

      4x4 transformation array from native coordinates to world coordinates.

    colors None or string (‘rgb_standard’) or tuple (3D or 4D) or array/ndarray (N, 3 or 4) or (K, 3 or 4) or (N, ) or (K, )

      If None a standard orientation colormap is used for every line. If one tuple of color is used. Then all streamlines will have the same color. If an array (N, 3 or 4) is given, where N is equal to the number of points. Then every point is colored with a different RGB(A) color. If an array (K, 3 or 4) is given, where K is equal to the number of lines. Then every line is colored with a different RGB(A) color. If an array (N, ) is given, where N is the number of points then these are considered as the values to be used by the colormap. If an array (K,) is given, where K is the number of lines then these are considered as the values to be used by the colormap.

    lookup_colormap vtkLookupTable, optional

      Add a default lookup table to the colormap. Look at `fury.actor.colormap_lookup_table()` for more information.

    linewidth float, optional

      Line thickness.

    symmetric: bool, optional

      If True, peaks are drawn for both peaks_dirs and -peaks_dirs. Else, peaks are only drawn for directions given by peaks_dirs.

  Attributes:
    cross_section
    global_opacity
    high_ranges
    is_range
    linewidth
    low_ranges
    max_centers
    min_centers

  Methods

  display_cross_section |
  display_extent |

  property cross_section
  display_cross_section(x, y, z)
  display_extent(x1, x2, y1, y2, z1, z2)
  property global_opacity
  property high_ranges
  property is_range
  property linewidth
  property low_ranges
  property max_centers
  property min_centers

### `PeaksVisualizer`

class dipy.viz.horizon.visualizer.peak.PeaksVisualizer(pam, world_coords)

  Bases: `object`

  Attributes:
    actors
  property actors

### peak

dipy.viz.horizon.visualizer.peak.peak(peaks_dirs, *, peaks_values=None, mask=None, affine=None, colors=None, linewidth=1, lookup_colormap=None, symmetric=True)

  Visualize peak directions as given from `peaks_from_model` function.

  Parameters:
    peaks_dirs ndarray

      Peak directions. The shape of the array should be (X, Y, Z, D, 3).

    peaks_values ndarray, optional

      Peak values. The shape of the array should be (X, Y, Z, D).

    affine array, optional

      4x4 transformation array from native coordinates to world coordinates.

    mask ndarray, optional

      3D mask

    colors tuple or None, optional

      Default None. If None then every peak gets an orientation color in similarity to a DEC map.

    lookup_colormap vtkLookupTable, optional

      Add a default lookup table to the colormap. Look at `fury.actor.colormap_lookup_table()` for more information.

    linewidth float, optional

      Line thickness. Default is 1.

    symmetric bool, optional

      If True, peaks are drawn for both peaks_dirs and -peaks_dirs. Else, peaks are only drawn for directions given by peaks_dirs. Default is True.

  Returns:
    peak_actor PeakActor

      Actor or LODActor representing the peaks directions and/or magnitudes.

### `SlicesVisualizer`

class dipy.viz.horizon.visualizer.slice.SlicesVisualizer(interactor, scene, data, *, affine=None, world_coords=False, percentiles=(0, 100), rgb=False, fname=None)

  Bases: `object`

  Attributes:
    data_shape
    intensities_range
    rgb
    selected_slices
    slice_actors
    volume_max
    volume_min

  Methods

  change_volume |
  register_picker_callback |

  change_volume(next_idx, intensity_ratios, visible_slices)
  property data_shape
  property intensities_range
  register_picker_callback(callback)
  property rgb
  property selected_slices
  property slice_actors
  property volume_max
  property volume_min

### `SurfaceVisualizer`

class dipy.viz.horizon.visualizer.surface.SurfaceVisualizer(surface, scene, color)

  Bases: `object`

  Attributes:
    actors
  property actors

### build_label

dipy.viz.panel.build_label(text, *, font_size=18, bold=False)

  Simple utility function to build labels

  Parameters:
    text str
    font_size int
    bold bool
  Returns:
    label TextBlock2D

### slicer_panel

dipy.viz.panel.slicer_panel(scene, iren, *, data=None, affine=None, world_coords=False, pam=None, mask=None, mem=None)

  Slicer panel with slicer included

  Parameters:
    scene Scene

      Scene.

    iren Interactor

      Interactor.

    data 3d ndarray

      Data to be sliced.

    affine 4x4 ndarray

      Affine matrix.

    world_coords bool

      If True then the affine is applied.

    peaks PeaksAndMetrics

      Default None

    mem
  Returns:
    panel Panel

### compare_maps

dipy.viz.plotting.compare_maps(fits, maps, *, transpose=None, fit_labels=None, map_labels=None, fit_kwargs=None, map_kwargs=None, filename=None)

  Compare one or more scalar maps for different fits or models.

  Parameters:
    fits list

      List of fits to be compared.

    maps list

      Names of attributes to be compared. Default: ‘rtop’.

    transpose bool, optional

      If False, different fits are placed on different rows and different maps on different columns. If True, the order is transposed. If None, the figures are placed such that there are more columns than rows. Default: None.

    fit_labels list, optional

      Labels for the different fitting routines. If None the fits are labeled by number. Default: None.

    map_labels list, optional

      Labels for the different attributes. If None the attribute names are used. Default: None.

    fit_kwargs list or dict, optional

      A dict or list of dicts with imshow options for each fitting routine. The dicts are passed to imshow as keyword-argument pairs. Default: {}.

    map_kwargs list or dict, optional

      A dict or list of dicts with imshow options for each MAP-MRI scalar. The dicts are passed to imshow as keyword-argument pairs. Default: {}.

    filename string, optional

      Filename where the image will be saved. Default: None.

### compare_qti_maps

dipy.viz.plotting.compare_qti_maps(gt, fit1, fit2, mask, *, maps=('fa', 'ufa'), fitname=('QTI', 'QTI+'), xlimits=([0, 1], [0.4, 1.5]), disprange=([0, 1], [0, 1]), slice=13)

  Compare one or more qti derived maps obtained with different fitting routines.

  Parameters:
    gt qti fit object

      The qti fit to be considered as ground truth

    fit1 qti fit object

      First qti fit to be compared

    fit2 qti fit object

      Second qti fit to be compared

    mask np.ndarray

      Boolean array indicating which voxels to retain for comparing the values

    maps array-like, optional

      QTI invariants to be compared

    fitname array-like, optional

      Names of the used QTI fitting routines

    xlimits array-like, optional

      X-Axis limits for the histograms visualization

    disprange array-like, optional

      Display range for maps

    slice int, optional

      Axial brain slice to be visualized

### bundle_shape_profile

dipy.viz.plotting.bundle_shape_profile(x, shape_profile, std)

  Plot bundlewarp bundle shape profile.

  Parameters:
    x np.ndarray

      Integer array containing x-axis

    shape_profile np.ndarray

      Float array containing bundlewarp displacement magnitudes along the length of the bundle

    std np.ndarray

      Float array containing standard deviations

### image_mosaic

dipy.viz.plotting.image_mosaic(images, *, ax_labels=None, ax_kwargs=None, figsize=None, filename=None)

  Draw a mosaic of 2D images using pyplot.imshow(). A colorbar is drawn beside each image.

  Parameters:
    images: list of ndarray

      Images to render.

    ax_labels: list of str, optional

      Label for each image.

    ax_kwargs: list of dictionaries, optional

      keyword arguments passed to imshow for each image. One dictionary per image.

    figsize: tuple of ints, optional

      Figure size.

    filename: str, optional

      When given, figure is saved to disk under this name.

  Returns:
    fig: pyplot.Figure

      The figure.

    ax: pyplot.Axes or array of Axes

      The subplots for each image.

### sph_project

dipy.viz.projections.sph_project(vertices, val, *, ax=None, vmin=None, vmax=None, cmap=None, cbar=True, tri=False, boundary=False, **basemap_args)

  Draw a signal on a 2D projection of the sphere.

  Parameters:
    vertices(N,3) ndarray

      Unit vector points of the sphere

    val(N) ndarray

      Function values.

    ax mpl axis, optional

      If specified, draw onto this existing axis instead.

    vmin float, optional

      Minimum value to cut the z.

    vmax float, optional

      Minimum value to cut the z.

    cmap matplotlib.colors.Colormap, optional

      Colormap.

    cbar bool, optional

      Whether to add the color-bar to the figure.

    tri bool, optional

      Whether to display the plot triangulated as a pseudo-color plot.

    boundary bool, optional

      Whether to draw the boundary around the projection in a black line.

  Returns:
    ax axis

      Matplotlib figure axis

  Examples

      >>> from dipy.data import default_sphere
      >>> verts = default_sphere.vertices
      >>> _ax = sph_project(verts.T, np.random.rand(len(verts.T)))

### simple_plot

dipy.viz.regtools.simple_plot(file_name, title, x, y, xlabel, ylabel)

  Saves the simple plot with given x and y values

  Parameters:
    file_name string

      file name for saving the plot

    title string

      title of the plot

    x integer list

      x-axis values to be plotted

    y integer list

      y-axis values to be plotted

    xlabel string

      label for x-axis

    ylable string

      label for y-axis

### overlay_images

dipy.viz.regtools.overlay_images(img0, img1, *, title0='', title_mid='', title1='', fname=None, **fig_kwargs)

  Plot two images one on top of the other using red and green channels.

  Creates a figure containing three images: the first image to the left plotted on the red channel of a color image, the second to the right plotted on the green channel of a color image and the two given images on top of each other using the red channel for the first image and the green channel for the second one. It is assumed that both images have the same shape. The intended use of this function is to visually assess the quality of a registration result.

  Parameters:
    img0 array, shape(R, C)

      the image to be plotted on the red channel, to the left of the figure

    img1 array, shape(R, C)

      the image to be plotted on the green channel, to the right of the figure

    title0 string, optional

      the title to be written on top of the image to the left. By default, no title is displayed.

    title_mid string, optional

      the title to be written on top of the middle image. By default, no title is displayed.

    title1 string, optional

      the title to be written on top of the image to the right. By default, no title is displayed.

    fname string, optional

      the file name to write the resulting figure. If None (default), the image is not saved.

    fig_kwargs dict

      Extra parameters for saving figure, e.g. dpi=300.

### draw_lattice_2d

dipy.viz.regtools.draw_lattice_2d(nrows, ncols, delta)

  Create a regular lattice of nrows x ncols squares.

  Creates an image (2D array) of a regular lattice of nrows x ncols squares. The size of each square is delta x delta pixels (not counting the separation lines). The lines are one pixel width.

  Parameters:
    nrows int

      the number of squares to be drawn vertically

    ncols int

      the number of squares to be drawn horizontally

    delta int

      the size of each square of the grid. Each square is delta x delta pixels

  Returns:
    lattice array, shape (R, C)

      the image (2D array) of the segular lattice. The shape (R, C) of the array is given by R = 1 + (delta + 1) * nrows C = 1 + (delta + 1) * ncols

### plot_2d_diffeomorphic_map

dipy.viz.regtools.plot_2d_diffeomorphic_map(mapping, *, delta=10, fname=None, direct_grid_shape=None, direct_grid2world=-1, inverse_grid_shape=None, inverse_grid2world=-1, show_figure=True, **fig_kwargs)

  Draw the effect of warping a regular lattice by a diffeomorphic map.

  Draws a diffeomorphic map by showing the effect of the deformation on a regular grid. The resulting figure contains two images: the direct transformation is plotted to the left, and the inverse transformation is plotted to the right.

  Parameters:
    mapping DiffeomorphicMap object

      the diffeomorphic map to be drawn

    delta int, optional

      the size (in pixels) of the squares of the regular lattice to be used to plot the warping effects. Each square will be delta x delta pixels. By default, the size will be 10 pixels.

    fname string, optional

      the name of the file the figure will be written to. If None (default), the figure will not be saved to disk.

    direct_grid_shape tuple, shape (2,), optional

      the shape of the grid image after being deformed by the direct transformation. By default, the shape of the deformed grid is the same as the grid of the displacement field, which is by default equal to the shape of the fixed image. In other words, the resulting deformed grid (deformed by the direct transformation) will normally have the same shape as the fixed image.

    direct_grid2world array, shape (3, 3), optional

      the affine transformation mapping the direct grid’s coordinates to physical space. By default, this transformation will correspond to the image-to-world transformation corresponding to the default direct_grid_shape (in general, if users specify a direct_grid_shape, they should also specify direct_grid2world).

    inverse_grid_shape tuple, shape (2,), optional

      the shape of the grid image after being deformed by the inverse transformation. By default, the shape of the deformed grid under the inverse transform is the same as the image used as “moving” when the diffeomorphic map was generated by a registration algorithm (so it corresponds to the effect of warping the static image towards the moving).

    inverse_grid2world array, shape (3, 3), optional

      the affine transformation mapping inverse grid’s coordinates to physical space. By default, this transformation will correspond to the image-to-world transformation corresponding to the default inverse_grid_shape (in general, if users specify an inverse_grid_shape, they should also specify inverse_grid2world).

    show_figure bool, optional

      if True (default), the deformed grids will be plotted using matplotlib, else the grids are just returned

    fig_kwargs dict

      Extra parameters for saving figure, e.g. dpi=300.

  Returns:
    warped_forward array

      Image with the grid showing the effect of transforming the moving image to the static image. The shape will be direct_grid_shape if specified, otherwise the shape of the static image.

    warped_backward array

      Image with the grid showing the effect of transforming the static image to the moving image. Shape will be inverse_grid_shape if specified, otherwise the shape of the moving image.

  Notes

  The default value for the affine transformation is “-1” to handle the case in which the user provides “None” as input meaning “identity”. If we used None as default, we wouldn’t know if the user specifically wants to use the identity (specifically passing None) or if it was left unspecified, meaning to use the appropriate default matrix.

### plot_slices

dipy.viz.regtools.plot_slices(V, *, slice_indices=None, fname=None, **fig_kwargs)

  Plot 3 slices from the given volume: 1 sagittal, 1 coronal and 1 axial

  Creates a figure showing the axial, coronal and sagittal slices at the requested positions of the given volume. The requested slices are specified by slice_indices.

  Parameters:
    V array, shape (S, R, C)

      the 3D volume to extract the slices from

    slice_indices array, shape (3,), optional

      the indices of the sagittal (slice_indices[0]), coronal (slice_indices[1]) and axial (slice_indices[2]) slices to be displayed. If None, the middle slices along each direction are displayed.

    fname string, optional

      the name of the file to save the figure to. If None (default), the figure is not saved to disk.

    fig_kwargs dict

      Extra parameters for saving figure, e.g. dpi=300.

### overlay_slices

dipy.viz.regtools.overlay_slices(L, R, *, slice_index=None, slice_type=1, ltitle='Left', rtitle='Right', fname=None, **fig_kwargs)

  Plot three overlaid slices from the given volumes.

  Creates a figure containing three images: the gray scale k-th slice of the first volume (L) to the left, where k=slice_index, the k-th slice of the second volume (R) to the right and the k-th slices of the two given images on top of each other using the red channel for the first volume and the green channel for the second one. It is assumed that both volumes have the same shape. The intended use of this function is to visually assess the quality of a registration result.

  Parameters:
    L array, shape (S, R, C)

      the first volume to extract the slice from plotted to the left

    R array, shape (S, R, C)

      the second volume to extract the slice from, plotted to the right

    slice_index int, optional

      the index of the slices (along the axis given by slice_type) to be overlaid. If None, the slice along the specified axis is used

    slice_type int, optional

      the type of slice to be extracted: 0=sagittal, 1=coronal (default), 2=axial.

    ltitle string, optional

      the string to be written as the title of the left image. By default, no title is displayed.

    rtitle string, optional

      the string to be written as the title of the right image. By default, no title is displayed.

    fname string, optional

      the name of the file to write the image to. If None (default), the figure is not saved to disk.

    fig_kwargs: extra parameters for saving figure, e.g. `dpi=300`.

### show_bundles

dipy.viz.streamline.show_bundles(bundles, *, interactive=True, view='sagittal', colors=None, linewidth=0.3, save_as=None)

  Render bundles to visualize them interactively or save them into a png.

  The function allows to just render the bundles in an interactive plot or to export them into a png file.

  Parameters:
    bundles list

      Bundles to be rendered.

    interactive boolean, optional

      If True a 3D interactive rendering is created. Default is True.

    view str, optional

      Viewing angle. Supported options: ‘sagittal’, ‘axial’ and ‘coronal’.

    colors list, optional

      Colors to be used for each bundle. If None default colors are used.

    linewidth float, optional

      Width of each rendered streamline. Default is 0.3.

    save_as str, optional

      If not None rendered scene is stored in a png file with that name. Default is None.

### viz_two_bundles

dipy.viz.streamline.viz_two_bundles(b1, b2, fname, *, c1=(1, 0, 0), c2=(0, 1, 0), interactive=False)

  Render and plot two bundles to visualize them.

  Parameters:
    b1 Streamlines

      Bundle one to be rendered.

    b2 Streamlines

      Bundle two to be rendered.

    fname: str

      Rendered scene is stored in a png file with that name.

    C1 tuple, optional

      Color to be used for first bundle. Default red.

    C2 tuple, optional

      Color to be used for second bundle. Default green.

    interactive boolean, optional

      If True a 3D interactive rendering is created. Default is True.

### viz_vector_field

dipy.viz.streamline.viz_vector_field(points_aligned, directions, colors, offsets, fname, *, bundle=None, interactive=False)

  Render and plot vector field.

  Parameters:
    points_aligned List

      List containing starting positions of vectors.

    directions List

      List containing unitary directions of vectors.

    colors List

      List containing colors for each vector.

    offsets List

      List containing vector field modules.

    fname: str

      Rendered scene is stored in a png file with that name.

    bundle Streamlines, optional

      Bundle to be rendered with vector field (Default None).

    interactive boolean, optional

      If True a 3D interactive rendering is created. Default is True.

### viz_displacement_mag

dipy.viz.streamline.viz_displacement_mag(bundle, offsets, fname, *, interactive=False)

  Render and plot displacement magnitude over the bundle.

  Parameters:
    bundle Streamlines,

      Bundle to be rendered.

    offsets List

      List containing displacement magnitdues per point on the bundle.

    fname: str

      Rendered scene is stored in a png file with that name.

    interactive boolean, optional

      If True a 3D interactive rendering is created. Default is True.