# NiBabel

### Access a cacophony of neuro-imaging file formats

# `viewers`

Utilities for viewing images

Includes version of OrthoSlicer3D code originally written by our own Paul Ivanov.

`OrthoSlicer3D`(data[, affine, axes, title]) | Orthogonal-plane slice viewer

## `OrthoSlicer3D`

class nibabel.viewers.OrthoSlicer3D(data, affine=None, axes=None, title=None)

  Bases: `object`

  Orthogonal-plane slice viewer

  OrthoSlicer3d expects 3- or 4-dimensional array data. It treats 4D data as a sequence of 3D spatial volumes, where a slice over the final array axis gives a single 3D spatial volume.

  For 3D data, the default behavior is to create a figure with 3 axes, one for each slice orientation of the spatial volume.

  Clicking and dragging the mouse in any one axis will select out the corresponding slices in the other two. Scrolling up and down moves the slice up and down in the current axis.

  For 4D data, the fourth figure axis can be used to control which 3D volume is displayed. Alternatively, the `-` key can be used to decrement the displayed volume and the `+` or `=` keys can be used to increment it.

  Examples

      >>> import numpy as np
      >>> a = np.sin(np.linspace(0, np.pi, 20))
      >>> b = np.sin(np.linspace(0, np.pi*5, 20))
      >>> data = np.outer(a, b)[..., np.newaxis] * a
      >>> OrthoSlicer3D(data).show()

  Parameters:
    data array-like

      The data that will be displayed by the slicer. Should have 3+ dimensions.

    affine array-like or None, optional

      Affine transform for the data. This is used to determine how the data should be sliced for plotting into the sagittal, coronal, and axial view axes. If None, identity is assumed. The aspect ratio of the data are inferred from the affine transform.

    axes tuple of mpl.Axes or None, optional

      3 or 4 axes instances for the 3 slices plus volumes, or None (default).

    title str or None, optional

      The title to display. Can be None (default) to display no title.

  __init__(data, affine=None, axes=None, title=None)
    Parameters:
      data array-like

        The data that will be displayed by the slicer. Should have 3+ dimensions.

      affine array-like or None, optional

        Affine transform for the data. This is used to determine how the data should be sliced for plotting into the sagittal, coronal, and axial view axes. If None, identity is assumed. The aspect ratio of the data are inferred from the affine transform.

      axes tuple of mpl.Axes or None, optional

        3 or 4 axes instances for the 3 slices plus volumes, or None (default).

      title str or None, optional

        The title to display. Can be None (default) to display no title.

  property clim

    The current color limits

  close()

    Close the viewer figures

  property cmap

    The current colormap

  draw()

    Redraw the current image

  property figs

    A tuple of the figure(s) containing the axes

  link_to(other)

    Link positional changes between two canvases

    Parameters:
      other instance of OrthoSlicer3D

        Other viewer to use to link movements.

  property n_volumes

    Number of volumes in the data

  property position

    The current coordinates

  set_position(x=None, y=None, z=None)

    Set current displayed slice indices

    Parameters:
      x float | None

        X coordinate to use. If None, do not change.

      y float | None

        Y coordinate to use. If None, do not change.

      z float | None

        Z coordinate to use. If None, do not change.

  set_volume_idx(v)

    Set current displayed volume index

    Parameters:
      v int

        Volume index.

  show()

    Show the slicer in blocking mode; convenience for `plt.show()`