viz

Module: viz.actor

apply_affine(aff, pts) Apply affine matrix aff to points pts
axes([scale, colorx, colory, colorz, opacity]) Create an actor with the coordinate’s system axes where red = x, green = y, blue = z.
colormap_lookup_table([scale_range, ...]) Lookup table for the colormap
contour_from_roi(data[, affine, color, opacity]) Generates surface actor from a binary ROI.
create_colormap(v[, name, auto]) Create colors from a specific colormap and return it as an array of shape (N,3) where every row gives the corresponding r,g,b value.
dots(points[, color, opacity, dot_size]) Create one or more 3d points
label([text, pos, scale, color]) Create a label actor.
line(lines[, colors, opacity, linewidth, ...]) Create an actor for one or more lines.
lines_to_vtk_polydata(lines[, colors]) Create a vtkPolyData with lines and colors
odf_slicer(odfs[, affine, mask, sphere, ...]) Slice spherical fields in native or world coordinates
optional_package(name[, trip_msg]) Return package-like thing and module setup for package name
peak_slicer(peaks_dirs[, peaks_values, ...]) Visualize peak directions as given from peaks_from_model
point(points, colors[, opacity, ...]) Visualize points as sphere glyphs
scalar_bar([lookup_table, title]) Default scalar bar actor for a given colormap (colorbar)
set_input(vtk_object, inp) Generic input function which takes into account VTK 5 or 6
setup_module()
slicer(data[, affine, value_range, opacity, ...]) Cuts 3D scalar or rgb volumes into 2D images
streamtube(lines[, colors, opacity, ...]) Uses streamtubes to visualize polylines
tensor_slicer(evals, evecs[, affine, mask, ...]) Slice many tensors as ellipsoids in native or world coordinates

Module: viz.colormap

boys2rgb(v) boys 2 rgb cool colormap
cc(na, nd)
colormap_lookup_table([scale_range, ...]) Lookup table for the colormap
create_colormap(v[, name, auto]) Create colors from a specific colormap and return it as an array of shape (N,3) where every row gives the corresponding r,g,b value.
get_cmap([name, lut]) Get a colormap instance, defaulting to rc values if name is None.
line_colors(streamlines[, cmap]) Create colors for streamlines to be used in actor.line
optional_package(name[, trip_msg]) Return package-like thing and module setup for package name
orient2rgb(v) standard orientation 2 rgb colormap
setup_module()
ss(na, nd)
warn Issue a warning, or maybe ignore it or raise an exception.

Module: viz.fvtk

Fvtk module implements simple visualization functions using VTK.

The main idea is the following: A window can have one or more renderers. A renderer can have none, one or more actors. Examples of actors are a sphere, line, point etc. You basically add actors in a renderer and in that way you can visualize the forementioned objects e.g. sphere, line ...

Examples

>>> from dipy.viz import fvtk
>>> r=fvtk.ren()
>>> a=fvtk.axes()
>>> fvtk.add(r,a)
>>> #fvtk.show(r)

For more information on VTK there many neat examples in http://www.vtk.org/Wiki/VTK/Tutorials/External_Tutorials

VolumeMapper alias of vtkSmartVolumeMapper
xrange alias of range
add(ren, a) Add a specific actor
axes([scale, colorx, colory, colorz, opacity]) Create an actor with the coordinate’s system axes where red = x, green = y, blue = z.
camera(ren[, pos, focal, viewup, verbose]) Change the active camera
clear(ren) Remove all actors from the renderer
contour(vol[, voxsz, affine, levels, ...]) Take a volume and draw surface contours for any any number of
create_colormap(v[, name, auto]) Create colors from a specific colormap and return it as an array of shape (N,3) where every row gives the corresponding r,g,b value.
dots(points[, color, opacity, dot_size]) Create one or more 3d points
get_cmap([name, lut]) Get a colormap instance, defaulting to rc values if name is None.
label(ren[, text, pos, scale, color]) Create a label actor.
line(lines[, colors, opacity, linewidth, ...]) Create an actor for one or more lines.
ndindex(shape) An N-dimensional iterator object to index arrays.
optional_package(name[, trip_msg]) Return package-like thing and module setup for package name
peaks(peaks_dirs[, peaks_values, scale, colors]) Visualize peak directions as given from peaks_from_model
point(points, colors[, opacity, ...]) Visualize points as sphere glyphs
record([ren, cam_pos, cam_focal, cam_view, ...]) This will record a video of your scene
ren([background]) Create a renderer.
renderer([background]) Create a renderer.
rm(ren, a) Remove a specific actor
rm_all(ren) Remove all actors from the renderer
setup_module()
show(ren[, title, size, png_magnify, ...]) Show window with current renderer
slicer(data[, affine, value_range, opacity, ...]) Cuts 3D scalar or rgb volumes into 2D images
snapshot(ren[, fname, size, offscreen, ...]) Saves a snapshot of the renderer in a file or in memory
sphere_funcs(sphere_values, sphere[, image, ...]) Plot many morphed spherical functions simultaneously.
streamtube(lines[, colors, opacity, ...]) Uses streamtubes to visualize polylines
tensor(evals, evecs[, scalar_colors, ...]) Plot many tensors as ellipsoids simultaneously.
volume(vol[, voxsz, affine, center_origin, ...]) Create a volume and return a volumetric actor using volumetric rendering.
warn Issue a warning, or maybe ignore it or raise an exception.

Module: viz.interactor

CustomInteractorStyle() Manipulate the camera and interact with objects in the scene.
Event()

Attributes

vtkInteractorStyleUser vtkInteractorStyleUser - provides customizable interaction routines
optional_package(name[, trip_msg]) Return package-like thing and module setup for package name
setup_module()

Module: viz.projections

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

doctest_skip_parser(func) Decorator replaces custom skip test markup in doctests.
optional_package(name[, trip_msg]) Return package-like thing and module setup for package name
setup_module()
sph_project(vertices, val[, ax, vmin, vmax, ...]) Draw a signal on a 2D projection of the sphere.

Module: viz.regtools

draw_lattice_2d(nrows, ncols, delta) Create a regular lattice of nrows x ncols squares.
optional_package(name[, trip_msg]) Return package-like thing and module setup for package name
overlay_images(img0, img1[, title0, ...]) Plot two images one on top of the other using red and green channels.
overlay_slices(L, R[, slice_index, ...]) Plot three overlaid slices from the given volumes.
plot_2d_diffeomorphic_map(mapping[, delta, ...]) 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 sagital, 1 coronal and 1 axial
setup_module()

Module: viz.ui

Button2D(icon_fnames[, size]) A 2D overlay button and is of type vtkTexturedActor2D.
CustomInteractorStyle() Manipulate the camera and interact with objects in the scene.
DiskSlider2D([position, initial_value, ...]) A disk slider.
FileSelectMenu2D(size, font_size, position, ...) A menu to select files in the current folder.
FileSelectMenuText2D(font_size, position, ...) The text to select folder in a file select menu.
LineSlider2D([line_width, inner_radius, ...]) A 2D Line Slider.
Panel2D(center, size[, color, opacity, align]) A 2D UI Panel.
Rectangle2D(size[, center, color, opacity]) A 2D rectangle sub-classed from UI.
TextBlock2D([text, font_size, font_family, ...]) Wraps over the default vtkTextActor and helps setting the text.
TextBox2D(width, height[, text, position, ...]) An editable 2D text box that behaves as a UI component.
UI() An umbrella class for all UI elements.
optional_package(name[, trip_msg]) Return package-like thing and module setup for package name
read_viz_icons([style, fname]) Read specific icon from specific style
setup_module()
warn Issue a warning, or maybe ignore it or raise an exception.

Module: viz.utils

get_actor_from_polydata(polydata) get vtkActor from a vtkPolyData
get_actor_from_polymapper(poly_mapper) get vtkActor from a vtkPolyDataMapper
get_polydata_colors(polydata) get points color (ndarrays Nx3 int) from a vtk polydata
get_polydata_lines(line_polydata) vtk polydata to a list of lines ndarrays
get_polydata_normals(polydata) get vertices normal (ndarrays Nx3 int) from a vtk polydata
get_polydata_triangles(polydata) get triangles (ndarrays Nx3 int) from a vtk polydata
get_polydata_vertices(polydata) get vertices (ndarrays Nx3 int) from a vtk polydata
get_polymapper_from_polydata(polydata) get vtkPolyDataMapper from a vtkPolyData
line_colors(streamlines[, cmap]) Create colors for streamlines to be used in actor.line
lines_to_vtk_polydata(lines[, colors]) Create a vtkPolyData with lines and colors
map_coordinates(input, coordinates[, ...]) Map the input array to new coordinates by interpolation.
map_coordinates_3d_4d(input_array, indices) Evaluate the input_array data at the given indices
numpy_to_vtk_colors(colors) Numpy color array to a vtk color array
numpy_to_vtk_points(points) Numpy points array to a vtk points array
optional_package(name[, trip_msg]) Return package-like thing and module setup for package name
set_input(vtk_object, inp) Generic input function which takes into account VTK 5 or 6
set_polydata_colors(polydata, colors) set polydata colors with a numpy array (ndarrays Nx3 int)
set_polydata_normals(polydata, normals) set polydata normals with a numpy array (ndarrays Nx3 int)
set_polydata_triangles(polydata, triangles) set polydata triangles with a numpy array (ndarrays Nx3 int)
set_polydata_vertices(polydata, vertices) set polydata vertices with a numpy array (ndarrays Nx3 int)
setup_module()
update_polydata_normals(polydata) generate and update polydata normals

Module: viz.widget

button(iren, ren, callback, fname[, ...]) A textured two state button widget
button_display_coordinates(renderer, ...)
optional_package(name[, trip_msg]) Return package-like thing and module setup for package name
setup_module()
slider(iren, ren, callback[, min_value, ...]) A 2D slider widget
text(iren, ren, callback[, message, ...]) 2D text that can be clicked and process events

Module: viz.window

CustomInteractorStyle() Manipulate the camera and interact with objects in the scene.
InTemporaryDirectory([suffix, prefix, dir]) Create, return, and change directory to a temporary directory
Renderer Your scene class
ShowManager([ren, title, size, png_magnify, ...]) This class is the interface between the renderer, the window and the interactor.
vtkRenderer vtkRenderer - abstract specification for renderers
add(ren, a) Add a specific actor
analyze_renderer(ren)
analyze_snapshot(im[, bg_color, colors, ...]) Analyze snapshot from memory or file
asbytes(s)
clear(ren) Remove all actors from the renderer
copy(x) Shallow copy operation on arbitrary Python objects.
open_file_dialog([file_types]) Simple Tk file dialog for opening files
optional_package(name[, trip_msg]) Return package-like thing and module setup for package name
record([ren, cam_pos, cam_focal, cam_view, ...]) This will record a video of your scene
ren([background]) Create a renderer.
renderer([background]) Create a renderer.
rm(ren, a) Remove a specific actor
rm_all(ren) Remove all actors from the renderer
save_file_dialog([initial_file, ...]) Simple Tk file dialog for saving a file
setup_module()
show(ren[, title, size, png_magnify, ...]) Show window with current renderer
snapshot(ren[, fname, size, offscreen, ...]) Saves a snapshot of the renderer in a file or in memory
vtk_to_numpy(vtk_array) Converts a VTK data array to a numpy array.
warn Issue a warning, or maybe ignore it or raise an exception.

apply_affine

dipy.viz.actor.apply_affine(aff, pts)

Apply affine matrix aff to points pts

Returns result of application of aff to the right of pts. The coordinate dimension of pts should be the last.

For the 3D case, aff will be shape (4,4) and pts will have final axis length 3 - maybe it will just be N by 3. The return value is the transformed points, in this case:

res = np.dot(aff[:3,:3], pts.T) + aff[:3,3:4]
transformed_pts = res.T

This routine is more general than 3D, in that aff can have any shape (N,N), and pts can have any shape, as long as the last dimension is for the coordinates, and is therefore length N-1.

Parameters:

aff : (N, N) array-like

Homogenous affine, for 3D points, will be 4 by 4. Contrary to first appearance, the affine will be applied on the left of pts.

pts : (..., N-1) array-like

Points, where the last dimension contains the coordinates of each point. For 3D, the last dimension will be length 3.

Returns:

transformed_pts : (..., N-1) array

transformed points

Examples

>>> aff = np.array([[0,2,0,10],[3,0,0,11],[0,0,4,12],[0,0,0,1]])
>>> pts = np.array([[1,2,3],[2,3,4],[4,5,6],[6,7,8]])
>>> apply_affine(aff, pts) 
array([[14, 14, 24],
       [16, 17, 28],
       [20, 23, 36],
       [24, 29, 44]]...)

Just to show that in the simple 3D case, it is equivalent to:

>>> (np.dot(aff[:3,:3], pts.T) + aff[:3,3:4]).T 
array([[14, 14, 24],
       [16, 17, 28],
       [20, 23, 36],
       [24, 29, 44]]...)

But pts can be a more complicated shape:

>>> pts = pts.reshape((2,2,3))
>>> apply_affine(aff, pts) 
array([[[14, 14, 24],
        [16, 17, 28]],

       [[20, 23, 36],
        [24, 29, 44]]]...)

axes

dipy.viz.actor.axes(scale=(1, 1, 1), colorx=(1, 0, 0), colory=(0, 1, 0), colorz=(0, 0, 1), opacity=1)

Create an actor with the coordinate’s system axes where red = x, green = y, blue = z.

Parameters:

scale : tuple (3,)

Axes size e.g. (100, 100, 100). Default is (1, 1, 1).

colorx : tuple (3,)

x-axis color. Default red (1, 0, 0).

colory : tuple (3,)

y-axis color. Default green (0, 1, 0).

colorz : tuple (3,)

z-axis color. Default blue (0, 0, 1).

opacity : float, optional

Takes values from 0 (fully transparent) to 1 (opaque). Default is 1.

Returns:

vtkAssembly

colormap_lookup_table

dipy.viz.actor.colormap_lookup_table(scale_range=(0, 1), hue_range=(0.8, 0), saturation_range=(1, 1), value_range=(0.8, 0.8))

Lookup table for the colormap

Parameters:

scale_range : tuple

It can be anything e.g. (0, 1) or (0, 255). Usually it is the mininum and maximum value of your data. Default is (0, 1).

hue_range : tuple of floats

HSV values (min 0 and max 1). Default is (0.8, 0).

saturation_range : tuple of floats

HSV values (min 0 and max 1). Default is (1, 1).

value_range : tuple of floats

HSV value (min 0 and max 1). Default is (0.8, 0.8).

Returns:

lookup_table : vtkLookupTable

contour_from_roi

dipy.viz.actor.contour_from_roi(data, affine=None, color=array([1, 0, 0]), opacity=1)

Generates surface actor from a binary ROI.

The color and opacity of the surface can be customized.

Parameters:

data : array, shape (X, Y, Z)

An ROI file that will be binarized and displayed.

affine : array, shape (4, 4)

Grid to space (usually RAS 1mm) transformation matrix. Default is None. If None then the identity matrix is used.

color : (1, 3) ndarray

RGB values in [0,1].

opacity : float

Opacity of surface between 0 and 1.

Returns:

contour_assembly : vtkAssembly

ROI surface object displayed in space coordinates as calculated by the affine parameter.

create_colormap

dipy.viz.actor.create_colormap(v, name='plasma', auto=True)

Create colors from a specific colormap and return it as an array of shape (N,3) where every row gives the corresponding r,g,b value. The colormaps we use are similar with those of matplotlib.

Parameters:

v : (N,) array

vector of values to be mapped in RGB colors according to colormap

name : str.

Name of the colormap. Currently implemented: ‘jet’, ‘blues’, ‘accent’, ‘bone’ and matplotlib colormaps if you have matplotlib installed. For example, we suggest using ‘plasma’, ‘viridis’ or ‘inferno’. ‘jet’ is popular but can be often misleading and we will deprecate it the future.

auto : bool,

if auto is True then v is interpolated to [0, 10] from v.min() to v.max()

Notes

Dipy supports a few colormaps for those who do not use Matplotlib, for more colormaps consider downloading Matplotlib (see matplotlib.org).

dots

dipy.viz.actor.dots(points, color=(1, 0, 0), opacity=1, dot_size=5)

Create one or more 3d points

Parameters:

points : ndarray, (N, 3)

color : tuple (3,)

opacity : float, optional

Takes values from 0 (fully transparent) to 1 (opaque)

dot_size : int

Returns:

vtkActor

label

dipy.viz.actor.label(text='Origin', pos=(0, 0, 0), scale=(0.2, 0.2, 0.2), color=(1, 1, 1))

Create a label actor.

This actor will always face the camera

Parameters:

text : str

Text for the label.

pos : (3,) array_like, optional

Left down position of the label.

scale : (3,) array_like

Changes the size of the label.

color : (3,) array_like

Label color as (r,g,b) tuple.

Returns:

l : vtkActor object

Label.

Examples

>>> from dipy.viz import window, actor
>>> ren = window.Renderer()
>>> l = actor.label(text='Hello')
>>> ren.add(l)
>>> #window.show(ren)

line

dipy.viz.actor.line(lines, colors=None, opacity=1, linewidth=1, spline_subdiv=None, lod=True, lod_points=10000, lod_points_size=3, lookup_colormap=None)

Create an actor for one or more lines.

Parameters:

lines : list of arrays

colors : array (N, 3), list of arrays, tuple (3,), array (K,), None

If None then a standard orientation colormap is used for every line. If one tuple of color is used. Then all streamlines will have the same colour. If an array (N, 3) is given, where N is equal to the number of lines. Then every line is coloured with a different RGB color. If a list of RGB arrays is given then every point of every line takes a different color. If an array (K, ) is given, where K is the number of points of all lines then these are considered as the values to be used by the colormap. If an array (L, ) is given, where L is the number of streamlines then these are considered as the values to be used by the colormap per streamline. If an array (X, Y, Z) or (X, Y, Z, 3) is given then the values for the colormap are interpolated automatically using trilinear interpolation.

opacity : float, optional

Takes values from 0 (fully transparent) to 1 (opaque). Default is 1.

linewidth : float, optional

Line thickness. Default is 1.

spline_subdiv : int, optional

Number of splines subdivision to smooth streamtubes. Default is None which means no subdivision.

lod : bool

Use vtkLODActor(level of detail) rather than vtkActor. Default is True. Level of detail actors do not render the full geometry when the frame rate is low.

lod_points : int

Number of points to be used when LOD is in effect. Default is 10000.

lod_points_size : int

Size of points when lod is in effect. Default is 3.

lookup_colormap : bool, optional

Add a default lookup table to the colormap. Default is None which calls dipy.viz.actor.colormap_lookup_table().

Returns:

v : vtkActor or vtkLODActor object

Line.

Examples

>>> from dipy.viz import actor, window
>>> ren = window.Renderer()
>>> lines = [np.random.rand(10, 3), np.random.rand(20, 3)]
>>> colors = np.random.rand(2, 3)
>>> c = actor.line(lines, colors)
>>> ren.add(c)
>>> #window.show(ren)

lines_to_vtk_polydata

dipy.viz.actor.lines_to_vtk_polydata(lines, colors=None)

Create a vtkPolyData with lines and colors

Parameters:

lines : list

list of N curves represented as 2D ndarrays

colors : array (N, 3), list of arrays, tuple (3,), array (K,), None

If None then a standard orientation colormap is used for every line. If one tuple of color is used. Then all streamlines will have the same colour. If an array (N, 3) is given, where N is equal to the number of lines. Then every line is coloured with a different RGB color. If a list of RGB arrays is given then every point of every line takes a different color. If an array (K, 3) is given, where K is the number of points of all lines then every point is colored with a different RGB color. If an array (K,) is given, where K is the number of points of all lines then these are considered as the values to be used by the colormap. If an array (L,) is given, where L is the number of streamlines then these are considered as the values to be used by the colormap per streamline. If an array (X, Y, Z) or (X, Y, Z, 3) is given then the values for the colormap are interpolated automatically using trilinear interpolation.

Returns:

poly_data : vtkPolyData

is_colormap : bool, true if the input color array was a colormap

odf_slicer

dipy.viz.actor.odf_slicer(odfs, affine=None, mask=None, sphere=None, scale=2.2, norm=True, radial_scale=True, opacity=1.0, colormap='plasma', global_cm=False)

Slice spherical fields in native or world coordinates

Parameters:

odfs : ndarray

4D array of spherical functions

affine : array

4x4 transformation array from native coordinates to world coordinates

mask : ndarray

3D mask

sphere : Sphere

a sphere

scale : float

Distance between spheres.

norm : bool

Normalize sphere_values.

radial_scale : bool

Scale sphere points according to odf values.

opacity : float

Takes values from 0 (fully transparent) to 1 (opaque). Default is 1.

colormap : None or str

If None then white color is used. Otherwise the name of colormap is given. Matplotlib colormaps are supported (e.g., ‘inferno’).

global_cm : bool

If True the colormap will be applied in all ODFs. If False it will be applied individually at each voxel (default False).

Returns:

actor : vtkActor

Spheres

optional_package

dipy.viz.actor.optional_package(name, trip_msg=None)

Return package-like thing and module setup for package name

Parameters:

name : str

package name

trip_msg : None or str

message to give when someone tries to use the return package, but we could not import it, and have returned a TripWire object instead. Default message if None.

Returns:

pkg_like : module or TripWire instance

If we can import the package, return it. Otherwise return an object raising an error when accessed

have_pkg : bool

True if import for package was successful, false otherwise

module_setup : function

callable usually set as setup_module in calling namespace, to allow skipping tests.

peak_slicer

dipy.viz.actor.peak_slicer(peaks_dirs, peaks_values=None, mask=None, affine=None, colors=(1, 0, 0), opacity=1.0, linewidth=1, lod=False, lod_points=10000, lod_points_size=3)

Visualize peak directions as given from peaks_from_model

Parameters:

peaks_dirs : ndarray

Peak directions. The shape of the array can be (M, 3) or (X, M, 3) or (X, Y, M, 3) or (X, Y, Z, M, 3)

peaks_values : ndarray

Peak values. The shape of the array can be (M, ) or (X, M) or (X, Y, M) or (X, Y, Z, M)

affine : array

4x4 transformation array from native coordinates to world coordinates

mask : ndarray

3D mask

colors : tuple or None

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

opacity : float, optional

Takes values from 0 (fully transparent) to 1 (opaque)

linewidth : float, optional

Line thickness. Default is 1.

lod : bool

Use vtkLODActor(level of detail) rather than vtkActor. Default is False. Level of detail actors do not render the full geometry when the frame rate is low.

lod_points : int

Number of points to be used when LOD is in effect. Default is 10000.

lod_points_size : int

Size of points when lod is in effect. Default is 3.

Returns:

vtkActor

point

dipy.viz.actor.point(points, colors, opacity=1.0, point_radius=0.1, theta=8, phi=8)

Visualize points as sphere glyphs

Parameters:

points : ndarray, shape (N, 3)

colors : ndarray (N,3) or tuple (3,)

point_radius : float

theta : int

phi : int

opacity : float, optional

Takes values from 0 (fully transparent) to 1 (opaque)

Returns:

vtkActor

Examples

>>> from dipy.viz import window, actor
>>> ren = window.Renderer()
>>> pts = np.random.rand(5, 3)
>>> point_actor = actor.point(pts, window.colors.coral)
>>> ren.add(point_actor)
>>> #window.show(ren)

scalar_bar

dipy.viz.actor.scalar_bar(lookup_table=None, title=' ')

Default scalar bar actor for a given colormap (colorbar)

Parameters:

lookup_table : vtkLookupTable or None

If None then colormap_lookup_table is called with default options.

title : str

Returns:

scalar_bar : vtkScalarBarActor

set_input

dipy.viz.actor.set_input(vtk_object, inp)

Generic input function which takes into account VTK 5 or 6

Parameters:

vtk_object: vtk object

inp: vtkPolyData or vtkImageData or vtkAlgorithmOutput

Returns:

vtk_object

Notes

This can be used in the following way::
from dipy.viz.utils import set_input poly_mapper = set_input(vtk.vtkPolyDataMapper(), poly_data)

setup_module

dipy.viz.actor.setup_module()

slicer

dipy.viz.actor.slicer(data, affine=None, value_range=None, opacity=1.0, lookup_colormap=None, interpolation='linear', picking_tol=0.025)

Cuts 3D scalar or rgb volumes into 2D images

Parameters:

data : array, shape (X, Y, Z) or (X, Y, Z, 3)

A grayscale or rgb 4D volume as a numpy array.

affine : array, shape (4, 4)

Grid to space (usually RAS 1mm) transformation matrix. Default is None. If None then the identity matrix is used.

value_range : None or tuple (2,)

If None then the values will be interpolated from (data.min(), data.max()) to (0, 255). Otherwise from (value_range[0], value_range[1]) to (0, 255).

opacity : float, optional

Opacity of 0 means completely transparent and 1 completely visible.

lookup_colormap : vtkLookupTable

If None (default) then a grayscale map is created.

interpolation : string

If ‘linear’ (default) then linear interpolation is used on the final texture mapping. If ‘nearest’ then nearest neighbor interpolation is used on the final texture mapping.

picking_tol : float

The tolerance for the vtkCellPicker, specified as a fraction of rendering window size.

Returns:

image_actor : ImageActor

An object that is capable of displaying different parts of the volume as slices. The key method of this object is display_extent where one can input grid coordinates and display the slice in space (or grid) coordinates as calculated by the affine parameter.

streamtube

dipy.viz.actor.streamtube(lines, colors=None, opacity=1, linewidth=0.1, tube_sides=9, lod=True, lod_points=10000, lod_points_size=3, spline_subdiv=None, lookup_colormap=None)

Uses streamtubes to visualize polylines

Parameters:

lines : list

list of N curves represented as 2D ndarrays

colors : array (N, 3), list of arrays, tuple (3,), array (K,), None

If None then a standard orientation colormap is used for every line. If one tuple of color is used. Then all streamlines will have the same colour. If an array (N, 3) is given, where N is equal to the number of lines. Then every line is coloured with a different RGB color. If a list of RGB arrays is given then every point of every line takes a different color. If an array (K, ) is given, where K is the number of points of all lines then these are considered as the values to be used by the colormap. If an array (L, ) is given, where L is the number of streamlines then these are considered as the values to be used by the colormap per streamline. If an array (X, Y, Z) or (X, Y, Z, 3) is given then the values for the colormap are interpolated automatically using trilinear interpolation.

opacity : float

Takes values from 0 (fully transparent) to 1 (opaque). Default is 1.

linewidth : float

Default is 0.01.

tube_sides : int

Default is 9.

lod : bool

Use vtkLODActor(level of detail) rather than vtkActor. Default is True. Level of detail actors do not render the full geometry when the frame rate is low.

lod_points : int

Number of points to be used when LOD is in effect. Default is 10000.

lod_points_size : int

Size of points when lod is in effect. Default is 3.

spline_subdiv : int

Number of splines subdivision to smooth streamtubes. Default is None.

lookup_colormap : vtkLookupTable

Add a default lookup table to the colormap. Default is None which calls dipy.viz.actor.colormap_lookup_table().

Notes

Streamtubes can be heavy on GPU when loading many streamlines and therefore, you may experience slow rendering time depending on system GPU. A solution to this problem is to reduce the number of points in each streamline. In Dipy we provide an algorithm that will reduce the number of points on the straighter parts of the streamline but keep more points on the curvier parts. This can be used in the following way:

from dipy.tracking.distances import approx_polygon_track
lines = [approx_polygon_track(line, 0.2) for line in lines]

Alternatively we suggest using the line actor which is much more efficient.

Examples

>>> import numpy as np
>>> from dipy.viz import actor, window
>>> ren = window.Renderer()
>>> lines = [np.random.rand(10, 3), np.random.rand(20, 3)]
>>> colors = np.random.rand(2, 3)
>>> c = actor.streamtube(lines, colors)
>>> ren.add(c)
>>> #window.show(ren)

tensor_slicer

dipy.viz.actor.tensor_slicer(evals, evecs, affine=None, mask=None, sphere=None, scale=2.2, norm=True, opacity=1.0, scalar_colors=None)

Slice many tensors as ellipsoids in native or world coordinates

Parameters:

evals : (3,) or (X, 3) or (X, Y, 3) or (X, Y, Z, 3) ndarray

eigenvalues

evecs : (3, 3) or (X, 3, 3) or (X, Y, 3, 3) or (X, Y, Z, 3, 3) ndarray

eigenvectors

affine : array

4x4 transformation array from native coordinates to world coordinates*

mask : ndarray

3D mask

sphere : Sphere

a sphere

scale : float

Distance between spheres.

norm : bool

Normalize sphere_values.

opacity : float

Takes values from 0 (fully transparent) to 1 (opaque). Default is 1.

scalar_colors : (3,) or (X, 3) or (X, Y, 3) or (X, Y, Z, 3) ndarray

RGB colors used to show the tensors Default None, color the ellipsoids using color_fa

Returns:

actor : vtkActor

Ellipsoid

boys2rgb

dipy.viz.colormap.boys2rgb(v)

boys 2 rgb cool colormap

Maps a given field of undirected lines (line field) to rgb colors using Boy’s Surface immersion of the real projective plane. Boy’s Surface is one of the three possible surfaces obtained by gluing a Mobius strip to the edge of a disk. The other two are the crosscap and Roman surface, Steiner surfaces that are homeomorphic to the real projective plane (Pinkall 1986). The Boy’s surface is the only 3D immersion of the projective plane without singularities. Visit http://www.cs.brown.edu/~cad/rp2coloring for further details. Cagatay Demiralp, 9/7/2008.

Code was initially in matlab and was rewritten in Python for dipy by the Dipy Team. Thank you Cagatay for putting this online.

Parameters:

v : array, shape (N, 3) of unit vectors (e.g., principal eigenvectors of

tensor data) representing one of the two directions of the undirected lines in a line field.

Returns:

c : array, shape (N, 3) matrix of rgb colors corresponding to the vectors

given in V.

Examples

>>> from dipy.viz import colormap
>>> v = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
>>> c = colormap.boys2rgb(v)

cc

dipy.viz.colormap.cc(na, nd)

colormap_lookup_table

dipy.viz.colormap.colormap_lookup_table(scale_range=(0, 1), hue_range=(0.8, 0), saturation_range=(1, 1), value_range=(0.8, 0.8))

Lookup table for the colormap

Parameters:

scale_range : tuple

It can be anything e.g. (0, 1) or (0, 255). Usually it is the mininum and maximum value of your data. Default is (0, 1).

hue_range : tuple of floats

HSV values (min 0 and max 1). Default is (0.8, 0).

saturation_range : tuple of floats

HSV values (min 0 and max 1). Default is (1, 1).

value_range : tuple of floats

HSV value (min 0 and max 1). Default is (0.8, 0.8).

Returns:

lookup_table : vtkLookupTable

create_colormap

dipy.viz.colormap.create_colormap(v, name='plasma', auto=True)

Create colors from a specific colormap and return it as an array of shape (N,3) where every row gives the corresponding r,g,b value. The colormaps we use are similar with those of matplotlib.

Parameters:

v : (N,) array

vector of values to be mapped in RGB colors according to colormap

name : str.

Name of the colormap. Currently implemented: ‘jet’, ‘blues’, ‘accent’, ‘bone’ and matplotlib colormaps if you have matplotlib installed. For example, we suggest using ‘plasma’, ‘viridis’ or ‘inferno’. ‘jet’ is popular but can be often misleading and we will deprecate it the future.

auto : bool,

if auto is True then v is interpolated to [0, 10] from v.min() to v.max()

Notes

Dipy supports a few colormaps for those who do not use Matplotlib, for more colormaps consider downloading Matplotlib (see matplotlib.org).

get_cmap

dipy.viz.colormap.get_cmap(name=None, lut=None)

Get a colormap instance, defaulting to rc values if name is None.

Colormaps added with register_cmap() take precedence over built-in colormaps.

If name is a matplotlib.colors.Colormap instance, it will be returned.

If lut is not None it must be an integer giving the number of entries desired in the lookup table, and name must be a standard mpl colormap name.

line_colors

dipy.viz.colormap.line_colors(streamlines, cmap='rgb_standard')

Create colors for streamlines to be used in actor.line

Parameters:

streamlines : sequence of ndarrays

cmap : (‘rgb_standard’, ‘boys_standard’)

Returns:

colors : ndarray

optional_package

dipy.viz.colormap.optional_package(name, trip_msg=None)

Return package-like thing and module setup for package name

Parameters:

name : str

package name

trip_msg : None or str

message to give when someone tries to use the return package, but we could not import it, and have returned a TripWire object instead. Default message if None.

Returns:

pkg_like : module or TripWire instance

If we can import the package, return it. Otherwise return an object raising an error when accessed

have_pkg : bool

True if import for package was successful, false otherwise

module_setup : function

callable usually set as setup_module in calling namespace, to allow skipping tests.

orient2rgb

dipy.viz.colormap.orient2rgb(v)

standard orientation 2 rgb colormap

v : array, shape (N, 3) of vectors not necessarily normalized

Returns:

c : array, shape (N, 3) matrix of rgb colors corresponding to the vectors

given in V.

Examples

>>> from dipy.viz import colormap
>>> v = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
>>> c = colormap.orient2rgb(v)

setup_module

dipy.viz.colormap.setup_module()

ss

dipy.viz.colormap.ss(na, nd)

warn

dipy.viz.colormap.warn()

Issue a warning, or maybe ignore it or raise an exception.

VolumeMapper

dipy.viz.fvtk.VolumeMapper

alias of vtkSmartVolumeMapper

xrange

dipy.viz.fvtk.xrange

alias of range

add

dipy.viz.fvtk.add(ren, a)

Add a specific actor

axes

dipy.viz.fvtk.axes(scale=(1, 1, 1), colorx=(1, 0, 0), colory=(0, 1, 0), colorz=(0, 0, 1), opacity=1)

Create an actor with the coordinate’s system axes where red = x, green = y, blue = z.

Parameters:

scale : tuple (3,)

Axes size e.g. (100, 100, 100). Default is (1, 1, 1).

colorx : tuple (3,)

x-axis color. Default red (1, 0, 0).

colory : tuple (3,)

y-axis color. Default green (0, 1, 0).

colorz : tuple (3,)

z-axis color. Default blue (0, 0, 1).

opacity : float, optional

Takes values from 0 (fully transparent) to 1 (opaque). Default is 1.

Returns:

vtkAssembly

camera

dipy.viz.fvtk.camera(ren, pos=None, focal=None, viewup=None, verbose=True)

Change the active camera

Parameters:

ren : vtkRenderer

pos : tuple

(x, y, z) position of the camera

focal : tuple

(x, y, z) focal point

viewup : tuple

(x, y, z) viewup vector

verbose : bool

show information about the camera

Returns:

vtkCamera

clear

dipy.viz.fvtk.clear(ren)

Remove all actors from the renderer

contour

dipy.viz.fvtk.contour(vol, voxsz=(1.0, 1.0, 1.0), affine=None, levels=[50], colors=[array([ 1., 0., 0.])], opacities=[0.5])

Take a volume and draw surface contours for any any number of thresholds (levels) where every contour has its own color and opacity

Parameters:

vol : (N, M, K) ndarray

An array representing the volumetric dataset for which we will draw some beautiful contours .

voxsz : (3,) array_like

Voxel size.

affine : None

Not used.

levels : array_like

Sequence of thresholds for the contours taken from image values needs to be same datatype as vol.

colors : (N, 3) ndarray

RGB values in [0,1].

opacities : array_like

Opacities of contours.

Returns:

vtkAssembly

Examples

>>> import numpy as np
>>> from dipy.viz import fvtk
>>> A=np.zeros((10,10,10))
>>> A[3:-3,3:-3,3:-3]=1
>>> r=fvtk.ren()
>>> fvtk.add(r,fvtk.contour(A,levels=[1]))
>>> #fvtk.show(r)

create_colormap

dipy.viz.fvtk.create_colormap(v, name='plasma', auto=True)

Create colors from a specific colormap and return it as an array of shape (N,3) where every row gives the corresponding r,g,b value. The colormaps we use are similar with those of matplotlib.

Parameters:

v : (N,) array

vector of values to be mapped in RGB colors according to colormap

name : str.

Name of the colormap. Currently implemented: ‘jet’, ‘blues’, ‘accent’, ‘bone’ and matplotlib colormaps if you have matplotlib installed. For example, we suggest using ‘plasma’, ‘viridis’ or ‘inferno’. ‘jet’ is popular but can be often misleading and we will deprecate it the future.

auto : bool,

if auto is True then v is interpolated to [0, 10] from v.min() to v.max()

Notes

Dipy supports a few colormaps for those who do not use Matplotlib, for more colormaps consider downloading Matplotlib (see matplotlib.org).

dots

dipy.viz.fvtk.dots(points, color=(1, 0, 0), opacity=1, dot_size=5)

Create one or more 3d points

Parameters:

points : ndarray, (N, 3)

color : tuple (3,)

opacity : float, optional

Takes values from 0 (fully transparent) to 1 (opaque)

dot_size : int

Returns:

vtkActor

get_cmap

dipy.viz.fvtk.get_cmap(name=None, lut=None)

Get a colormap instance, defaulting to rc values if name is None.

Colormaps added with register_cmap() take precedence over built-in colormaps.

If name is a matplotlib.colors.Colormap instance, it will be returned.

If lut is not None it must be an integer giving the number of entries desired in the lookup table, and name must be a standard mpl colormap name.

label

dipy.viz.fvtk.label(ren, text='Origin', pos=(0, 0, 0), scale=(0.2, 0.2, 0.2), color=(1, 1, 1))

Create a label actor. This actor will always face the camera Parameters ———- ren : vtkRenderer() object

Renderer as returned by ren().
text : str
Text for the label.
pos : (3,) array_like, optional
Left down position of the label.
scale : (3,) array_like
Changes the size of the label.
color : (3,) array_like
Label color as (r,g,b) tuple.
l : vtkActor object
Label.
>>> from dipy.viz import fvtk
>>> r=fvtk.ren()
>>> l=fvtk.label(r)
>>> fvtk.add(r,l)
>>> #fvtk.show(r)

line

dipy.viz.fvtk.line(lines, colors=None, opacity=1, linewidth=1, spline_subdiv=None, lod=True, lod_points=10000, lod_points_size=3, lookup_colormap=None)

Create an actor for one or more lines.

Parameters:

lines : list of arrays

colors : array (N, 3), list of arrays, tuple (3,), array (K,), None

If None then a standard orientation colormap is used for every line. If one tuple of color is used. Then all streamlines will have the same colour. If an array (N, 3) is given, where N is equal to the number of lines. Then every line is coloured with a different RGB color. If a list of RGB arrays is given then every point of every line takes a different color. If an array (K, ) is given, where K is the number of points of all lines then these are considered as the values to be used by the colormap. If an array (L, ) is given, where L is the number of streamlines then these are considered as the values to be used by the colormap per streamline. If an array (X, Y, Z) or (X, Y, Z, 3) is given then the values for the colormap are interpolated automatically using trilinear interpolation.

opacity : float, optional

Takes values from 0 (fully transparent) to 1 (opaque). Default is 1.

linewidth : float, optional

Line thickness. Default is 1.

spline_subdiv : int, optional

Number of splines subdivision to smooth streamtubes. Default is None which means no subdivision.

lod : bool

Use vtkLODActor(level of detail) rather than vtkActor. Default is True. Level of detail actors do not render the full geometry when the frame rate is low.

lod_points : int

Number of points to be used when LOD is in effect. Default is 10000.

lod_points_size : int

Size of points when lod is in effect. Default is 3.

lookup_colormap : bool, optional

Add a default lookup table to the colormap. Default is None which calls dipy.viz.actor.colormap_lookup_table().

Returns:

v : vtkActor or vtkLODActor object

Line.

Examples

>>> from dipy.viz import actor, window
>>> ren = window.Renderer()
>>> lines = [np.random.rand(10, 3), np.random.rand(20, 3)]
>>> colors = np.random.rand(2, 3)
>>> c = actor.line(lines, colors)
>>> ren.add(c)
>>> #window.show(ren)

ndindex

dipy.viz.fvtk.ndindex(shape)

An N-dimensional iterator object to index arrays.

Given the shape of an array, an ndindex instance iterates over the N-dimensional index of the array. At each iteration a tuple of indices is returned; the last dimension is iterated over first.

Parameters:

shape : tuple of ints

The dimensions of the array.

Examples

>>> from dipy.core.ndindex import ndindex
>>> shape = (3, 2, 1)
>>> for index in ndindex(shape):
...     print(index)
(0, 0, 0)
(0, 1, 0)
(1, 0, 0)
(1, 1, 0)
(2, 0, 0)
(2, 1, 0)

optional_package

dipy.viz.fvtk.optional_package(name, trip_msg=None)

Return package-like thing and module setup for package name

Parameters:

name : str

package name

trip_msg : None or str

message to give when someone tries to use the return package, but we could not import it, and have returned a TripWire object instead. Default message if None.

Returns:

pkg_like : module or TripWire instance

If we can import the package, return it. Otherwise return an object raising an error when accessed

have_pkg : bool

True if import for package was successful, false otherwise

module_setup : function

callable usually set as setup_module in calling namespace, to allow skipping tests.

peaks

dipy.viz.fvtk.peaks(peaks_dirs, peaks_values=None, scale=2.2, colors=(1, 0, 0))

Visualize peak directions as given from peaks_from_model

Parameters:

peaks_dirs : ndarray

Peak directions. The shape of the array can be (M, 3) or (X, M, 3) or (X, Y, M, 3) or (X, Y, Z, M, 3)

peaks_values : ndarray

Peak values. The shape of the array can be (M, ) or (X, M) or (X, Y, M) or (X, Y, Z, M)

scale : float

Distance between spheres

colors : ndarray or tuple

Peak colors

Returns:

vtkActor

point

dipy.viz.fvtk.point(points, colors, opacity=1.0, point_radius=0.1, theta=8, phi=8)

Visualize points as sphere glyphs

Parameters:

points : ndarray, shape (N, 3)

colors : ndarray (N,3) or tuple (3,)

point_radius : float

theta : int

phi : int

opacity : float, optional

Takes values from 0 (fully transparent) to 1 (opaque)

Returns:

vtkActor

Examples

>>> from dipy.viz import window, actor
>>> ren = window.Renderer()
>>> pts = np.random.rand(5, 3)
>>> point_actor = actor.point(pts, window.colors.coral)
>>> ren.add(point_actor)
>>> #window.show(ren)

record

dipy.viz.fvtk.record(ren=None, cam_pos=None, cam_focal=None, cam_view=None, out_path=None, path_numbering=False, n_frames=1, az_ang=10, magnification=1, size=(300, 300), reset_camera=True, verbose=False)

This will record a video of your scene

Records a video as a series of .png files of your scene by rotating the azimuth angle az_angle in every frame.

Parameters:

ren : vtkRenderer() object

as returned from function ren()

cam_pos : None or sequence (3,), optional

Camera’s position. If None then default camera’s position is used.

cam_focal : None or sequence (3,), optional

Camera’s focal point. If None then default camera’s focal point is used.

cam_view : None or sequence (3,), optional

Camera’s view up direction. If None then default camera’s view up vector is used.

out_path : str, optional

Output path for the frames. If None a default dipy.png is created.

path_numbering : bool

When recording it changes out_path to out_path + str(frame number)

n_frames : int, optional

Number of frames to save, default 1

az_ang : float, optional

Azimuthal angle of camera rotation.

magnification : int, optional

How much to magnify the saved frame. Default is 1.

size : (int, int)

(width, height) of the window. Default is (300, 300).

reset_camera : bool

If True Call ren.reset_camera(). Otherwise you need to set the

camera before calling this function.

verbose : bool

print information about the camera. Default is False.

Examples

>>> from dipy.viz import window, actor
>>> ren = window.Renderer()
>>> a = actor.axes()
>>> ren.add(a)
>>> # uncomment below to record
>>> # window.record(ren)
>>> #check for new images in current directory

ren

dipy.viz.fvtk.ren(background=None)

Create a renderer.

Parameters:

background : tuple

Initial background color of renderer

Returns:

v : Renderer

Examples

>>> from dipy.viz import window, actor
>>> import numpy as np
>>> r = window.Renderer()
>>> lines=[np.random.rand(10,3)]
>>> c=actor.line(lines, window.colors.red)
>>> r.add(c)
>>> #window.show(r)

renderer

dipy.viz.fvtk.renderer(background=None)

Create a renderer.

Parameters:

background : tuple

Initial background color of renderer

Returns:

v : Renderer

Examples

>>> from dipy.viz import window, actor
>>> import numpy as np
>>> r = window.Renderer()
>>> lines=[np.random.rand(10,3)]
>>> c=actor.line(lines, window.colors.red)
>>> r.add(c)
>>> #window.show(r)

rm

dipy.viz.fvtk.rm(ren, a)

Remove a specific actor

rm_all

dipy.viz.fvtk.rm_all(ren)

Remove all actors from the renderer

setup_module

dipy.viz.fvtk.setup_module()

show

dipy.viz.fvtk.show(ren, title='DIPY', size=(300, 300), png_magnify=1, reset_camera=True, order_transparent=False)

Show window with current renderer

Parameters:

ren : Renderer() or vtkRenderer()

The scene that holds all the actors.

title : string

A string for the window title bar. Default is DIPY and current version.

size : (int, int)

(width, height) of the window. Default is (300, 300).

png_magnify : int

Number of times to magnify the screenshot. Default is 1. This can be used to save high resolution screenshots when pressing ‘s’ inside the window.

reset_camera : bool

Default is True. You can change this option to False if you want to keep the camera as set before calling this function.

order_transparent : bool

True is useful when you want to order transparent actors according to their relative position to the camera. The default option which is False will order the actors according to the order of their addition to the Renderer().

Notes

Default interaction keys for

  • 3d navigation are with left, middle and right mouse dragging
  • resetting the camera press ‘r’
  • saving a screenshot press ‘s’
  • for quiting press ‘q’

Examples

>>> import numpy as np
>>> from dipy.viz import window, actor
>>> r = window.Renderer()
>>> lines=[np.random.rand(10,3),np.random.rand(20,3)]
>>> colors=np.array([[0.2,0.2,0.2],[0.8,0.8,0.8]])
>>> c=actor.line(lines,colors)
>>> r.add(c)
>>> l=actor.label(text="Hello")
>>> r.add(l)
>>> #window.show(r)

slicer

dipy.viz.fvtk.slicer(data, affine=None, value_range=None, opacity=1.0, lookup_colormap=None, interpolation='linear', picking_tol=0.025)

Cuts 3D scalar or rgb volumes into 2D images

Parameters:

data : array, shape (X, Y, Z) or (X, Y, Z, 3)

A grayscale or rgb 4D volume as a numpy array.

affine : array, shape (4, 4)

Grid to space (usually RAS 1mm) transformation matrix. Default is None. If None then the identity matrix is used.

value_range : None or tuple (2,)

If None then the values will be interpolated from (data.min(), data.max()) to (0, 255). Otherwise from (value_range[0], value_range[1]) to (0, 255).

opacity : float, optional

Opacity of 0 means completely transparent and 1 completely visible.

lookup_colormap : vtkLookupTable

If None (default) then a grayscale map is created.

interpolation : string

If ‘linear’ (default) then linear interpolation is used on the final texture mapping. If ‘nearest’ then nearest neighbor interpolation is used on the final texture mapping.

picking_tol : float

The tolerance for the vtkCellPicker, specified as a fraction of rendering window size.

Returns:

image_actor : ImageActor

An object that is capable of displaying different parts of the volume as slices. The key method of this object is display_extent where one can input grid coordinates and display the slice in space (or grid) coordinates as calculated by the affine parameter.

snapshot

dipy.viz.fvtk.snapshot(ren, fname=None, size=(300, 300), offscreen=True, order_transparent=False)

Saves a snapshot of the renderer in a file or in memory

Parameters:

ren : vtkRenderer

as returned from function renderer()

fname : str or None

Save PNG file. If None return only an array without saving PNG.

size : (int, int)

(width, height) of the window. Default is (300, 300).

offscreen : bool

Default True. Go stealthmode no window should appear.

order_transparent : bool

Default False. Use depth peeling to sort transparent objects.

Returns:

arr : ndarray

Color array of size (width, height, 3) where the last dimension holds the RGB values.

sphere_funcs

dipy.viz.fvtk.sphere_funcs(sphere_values, sphere, image=None, colormap='jet', scale=2.2, norm=True, radial_scale=True)

Plot many morphed spherical functions simultaneously.

Parameters:

sphere_values : (M,) or (X, M) or (X, Y, M) or (X, Y, Z, M) ndarray

Values on the sphere.

sphere : Sphere

image : None,

Not yet supported.

colormap : None or ‘jet’

If None then no color is used.

scale : float,

Distance between spheres.

norm : bool,

Normalize sphere_values.

radial_scale : bool,

Scale sphere points according to odf values.

Returns:

actor : vtkActor

Spheres.

Examples

>>> from dipy.viz import fvtk
>>> r = fvtk.ren()
>>> odfs = np.ones((5, 5, 724))
>>> odfs[..., 0] = 2.
>>> from dipy.data import get_sphere
>>> sphere = get_sphere('symmetric724')
>>> fvtk.add(r, fvtk.sphere_funcs(odfs, sphere))
>>> #fvtk.show(r)

streamtube

dipy.viz.fvtk.streamtube(lines, colors=None, opacity=1, linewidth=0.1, tube_sides=9, lod=True, lod_points=10000, lod_points_size=3, spline_subdiv=None, lookup_colormap=None)

Uses streamtubes to visualize polylines

Parameters:

lines : list

list of N curves represented as 2D ndarrays

colors : array (N, 3), list of arrays, tuple (3,), array (K,), None

If None then a standard orientation colormap is used for every line. If one tuple of color is used. Then all streamlines will have the same colour. If an array (N, 3) is given, where N is equal to the number of lines. Then every line is coloured with a different RGB color. If a list of RGB arrays is given then every point of every line takes a different color. If an array (K, ) is given, where K is the number of points of all lines then these are considered as the values to be used by the colormap. If an array (L, ) is given, where L is the number of streamlines then these are considered as the values to be used by the colormap per streamline. If an array (X, Y, Z) or (X, Y, Z, 3) is given then the values for the colormap are interpolated automatically using trilinear interpolation.

opacity : float

Takes values from 0 (fully transparent) to 1 (opaque). Default is 1.

linewidth : float

Default is 0.01.

tube_sides : int

Default is 9.

lod : bool

Use vtkLODActor(level of detail) rather than vtkActor. Default is True. Level of detail actors do not render the full geometry when the frame rate is low.

lod_points : int

Number of points to be used when LOD is in effect. Default is 10000.

lod_points_size : int

Size of points when lod is in effect. Default is 3.

spline_subdiv : int

Number of splines subdivision to smooth streamtubes. Default is None.

lookup_colormap : vtkLookupTable

Add a default lookup table to the colormap. Default is None which calls dipy.viz.actor.colormap_lookup_table().

Notes

Streamtubes can be heavy on GPU when loading many streamlines and therefore, you may experience slow rendering time depending on system GPU. A solution to this problem is to reduce the number of points in each streamline. In Dipy we provide an algorithm that will reduce the number of points on the straighter parts of the streamline but keep more points on the curvier parts. This can be used in the following way:

from dipy.tracking.distances import approx_polygon_track
lines = [approx_polygon_track(line, 0.2) for line in lines]

Alternatively we suggest using the line actor which is much more efficient.

Examples

>>> import numpy as np
>>> from dipy.viz import actor, window
>>> ren = window.Renderer()
>>> lines = [np.random.rand(10, 3), np.random.rand(20, 3)]
>>> colors = np.random.rand(2, 3)
>>> c = actor.streamtube(lines, colors)
>>> ren.add(c)
>>> #window.show(ren)

tensor

dipy.viz.fvtk.tensor(evals, evecs, scalar_colors=None, sphere=None, scale=2.2, norm=True)

Plot many tensors as ellipsoids simultaneously.

Parameters:

evals : (3,) or (X, 3) or (X, Y, 3) or (X, Y, Z, 3) ndarray

eigenvalues

evecs : (3, 3) or (X, 3, 3) or (X, Y, 3, 3) or (X, Y, Z, 3, 3) ndarray

eigenvectors

scalar_colors : (3,) or (X, 3) or (X, Y, 3) or (X, Y, Z, 3) ndarray

RGB colors used to show the tensors Default None, color the ellipsoids using color_fa

sphere : Sphere,

this sphere will be transformed to the tensor ellipsoid Default is None which uses a symmetric sphere with 724 points.

scale : float,

distance between ellipsoids.

norm : boolean,

Normalize evals.

Returns:

actor : vtkActor

Ellipsoids

Examples

>>> from dipy.viz import fvtk
>>> r = fvtk.ren()
>>> evals = np.array([1.4, .35, .35]) * 10 ** (-3)
>>> evecs = np.eye(3)
>>> from dipy.data import get_sphere
>>> sphere = get_sphere('symmetric724')
>>> fvtk.add(r, fvtk.tensor(evals, evecs, sphere=sphere))
>>> #fvtk.show(r)

volume

dipy.viz.fvtk.volume(vol, voxsz=(1.0, 1.0, 1.0), affine=None, center_origin=1, info=0, maptype=0, trilinear=1, iso=0, iso_thr=100, opacitymap=None, colormap=None)

Create a volume and return a volumetric actor using volumetric rendering.

This function has many different interesting capabilities. The maptype, opacitymap and colormap are the most crucial parameters here.

Parameters:

vol : array, shape (N, M, K), dtype uint8

An array representing the volumetric dataset that we want to visualize using volumetric rendering.

voxsz : (3,) array_like

Voxel size.

affine : (4, 4) ndarray

As given by volumeimages.

center_origin : int {0,1}

It considers that the center of the volume is the point ``(-vol.shape[0]/2.0+0.5,-vol.shape[1]/2.0+0.5,

-vol.shape[2]/2.0+0.5)``.

info : int {0,1}

If 1 it prints out some info about the volume, the method and the dataset.

trilinear : int {0,1}

Use trilinear interpolation, default 1, gives smoother rendering. If you want faster interpolation use 0 (Nearest).

maptype : int {0,1}

The maptype is a very important parameter which affects the raycasting algorithm in use for the rendering. The options are: If 0 then vtkVolumeTextureMapper2D is used. If 1 then vtkVolumeRayCastFunction is used.

iso : int {0,1}

If iso is 1 and maptype is 1 then we use vtkVolumeRayCastIsosurfaceFunction which generates an isosurface at the predefined iso_thr value. If iso is 0 and maptype is 1 vtkVolumeRayCastCompositeFunction is used.

iso_thr : int

If iso is 1 then then this threshold in the volume defines the value which will be used to create the isosurface.

opacitymap : (2, 2) ndarray

The opacity map assigns a transparency coefficient to every point in the volume. The default value uses the histogram of the volume to calculate the opacitymap.

colormap : (4, 4) ndarray

The color map assigns a color value to every point in the volume. When None from the histogram it uses a red-blue colormap.

Returns:

v : vtkVolume

Volume.

Notes

What is the difference between TextureMapper2D and RayCastFunction? Coming soon... See VTK user’s guide [book] & The Visualization Toolkit [book] and VTK’s online documentation & online docs.

What is the difference between RayCastIsosurfaceFunction and RayCastCompositeFunction? Coming soon... See VTK user’s guide [book] & The Visualization Toolkit [book] and VTK’s online documentation & online docs.

What about trilinear interpolation? Coming soon... well when time permits really ... :-)

Examples

First example random points.

>>> from dipy.viz import fvtk
>>> import numpy as np
>>> vol=100*np.random.rand(100,100,100)
>>> vol=vol.astype('uint8')
>>> vol.min(), vol.max()
(0, 99)
>>> r = fvtk.ren()
>>> v = fvtk.volume(vol)
>>> fvtk.add(r,v)
>>> #fvtk.show(r)

Second example with a more complicated function

>>> from dipy.viz import fvtk
>>> import numpy as np
>>> x, y, z = np.ogrid[-10:10:20j, -10:10:20j, -10:10:20j]
>>> s = np.sin(x*y*z)/(x*y*z)
>>> r = fvtk.ren()
>>> v = fvtk.volume(s)
>>> fvtk.add(r,v)
>>> #fvtk.show(r)

If you find this function too complicated you can always use mayavi. Please do not forget to use the -wthread switch in ipython if you are running mayavi.

from enthought.mayavi import mlab import numpy as np x, y, z = np.ogrid[-10:10:20j, -10:10:20j, -10:10:20j] s = np.sin(x*y*z)/(x*y*z) mlab.pipeline.volume(mlab.pipeline.scalar_field(s)) mlab.show()

More mayavi demos are available here:

http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/mlab.html

warn

dipy.viz.fvtk.warn()

Issue a warning, or maybe ignore it or raise an exception.

CustomInteractorStyle

class dipy.viz.interactor.CustomInteractorStyle

Bases: vtkInteractionStylePython.vtkInteractorStyleUser

Manipulate the camera and interact with objects in the scene.

This interactor style allows the user to interactively manipulate (pan, rotate and zoom) the camera. It also allows the user to interact (click, scroll, etc.) with objects in the scene.

Several events handling methods from vtkInteractorStyleUser have been overloaded to allow the propagation of the events to the objects the user is interacting with.

In summary, while interacting with the scene, the mouse events are as follows: - Left mouse button: rotates the camera - Right mouse button: dollys the camera - Mouse wheel: dollys the camera - Middle mouse button: pans the camera

Methods

AddObserver(int, ...) C++: unsigned long AddObserver(const char *event,
AutoAdjustCameraClippingRangeOff(...) C++: void AutoAdjustCameraClippingRangeOff()
AutoAdjustCameraClippingRangeOn(...) C++: void AutoAdjustCameraClippingRangeOn()
BreakOnError() C++: static void BreakOnError() C++: static void BreakOnError()
ComputeDisplayToWorld(vtkRenderer, float, ...) Convenience methods for outside classes.
ComputeWorldToDisplay(vtkRenderer, float, ...) Convenience methods for outside classes.
DebugOff() C++: virtual void DebugOff() C++: virtual void DebugOff()
DebugOn() C++: virtual void DebugOn() C++: virtual void DebugOn()
DelegateTDxEvent(int, ...) C++: void DelegateTDxEvent(unsigned long event, void *calldata)
Dolly() C++: virtual void Dolly() C++: virtual void Dolly()
EnabledOff() C++: void EnabledOff() C++: void EnabledOff()
EnabledOn() C++: void EnabledOn() C++: void EnabledOn()
EndDolly() C++: virtual void EndDolly() C++: virtual void EndDolly()
EndPan() C++: virtual void EndPan() C++: virtual void EndPan()
EndRotate() C++: virtual void EndRotate() C++: virtual void EndRotate()
EndSpin() C++: virtual void EndSpin() C++: virtual void EndSpin()
EndTimer() C++: virtual void EndTimer() C++: virtual void EndTimer()
EndTwoPointer() C++: virtual void EndTwoPointer() C++: virtual void EndTwoPointer()
EndUniformScale(...) C++: virtual void EndUniformScale()
EndZoom() C++: virtual void EndZoom() C++: virtual void EndZoom()
FastDelete() C++: virtual void FastDelete() C++: virtual void FastDelete()
FindPokedRenderer(int, ...) C++: void FindPokedRenderer(int, int)
GetAddressAsString(...) C++: const char *GetAddressAsString()
GetAutoAdjustCameraClippingRange(...) C++: int GetAutoAdjustCameraClippingRange()
GetAutoAdjustCameraClippingRangeMaxValue(...) C++: int GetAutoAdjustCameraClippingRangeMaxValue()
GetAutoAdjustCameraClippingRangeMinValue(...) C++: int GetAutoAdjustCameraClippingRangeMinValue()
GetButton() -> int C++: int GetButton() C++: int GetButton()
GetChar() -> int C++: int GetChar() C++: int GetChar()
GetClassName(...) C++: const char *GetClassName()
GetCommand(...) C++: vtkCommand *GetCommand(unsigned long tag)
GetCtrlKey() -> int C++: int GetCtrlKey() C++: int GetCtrlKey()
GetCurrentRenderer(...) C++: vtkRenderer *GetCurrentRenderer()
GetDebug() -> bool C++: bool GetDebug() C++: bool GetDebug()
GetDefaultRenderer(...) C++: vtkRenderer *GetDefaultRenderer()
GetEnabled() -> int C++: int GetEnabled() C++: int GetEnabled()
GetGlobalWarningDisplay(...) C++: static int GetGlobalWarningDisplay()
GetHandleObservers(...) C++: int GetHandleObservers()
GetInteractor(...) C++: vtkRenderWindowInteractor *GetInteractor()
GetKeyPressActivation(...) C++: int GetKeyPressActivation()
GetKeyPressActivationValue(...) C++: char GetKeyPressActivationValue()
GetKeySym() -> string C++: char *GetKeySym() C++: char *GetKeySym()
GetLastPos() -> (int, int) C++: int *GetLastPos() C++: int *GetLastPos()
GetMTime(...) C++: virtual vtkMTimeType GetMTime()
GetMouseWheelMotionFactor(...) C++: double GetMouseWheelMotionFactor()
GetOldPos() -> (int, int) C++: int *GetOldPos() C++: int *GetOldPos()
GetPickColor() -> (float, float, ...) C++: double *GetPickColor()
GetPickingManaged(...) C++: bool GetPickingManaged()
GetPriority() -> float C++: float GetPriority() C++: float GetPriority()
GetPriorityMaxValue(...) C++: float GetPriorityMaxValue()
GetPriorityMinValue(...) C++: float GetPriorityMinValue()
GetReferenceCount(...) C++: int GetReferenceCount()
GetShiftKey() -> int C++: int GetShiftKey() C++: int GetShiftKey()
GetState() -> int C++: int GetState() C++: int GetState()
GetTDxStyle(...) C++: vtkTDxInteractorStyle *GetTDxStyle()
GetTimerDuration(...) C++: unsigned long GetTimerDuration()
GetTimerDurationMaxValue(...) C++: unsigned long GetTimerDurationMaxValue()
GetTimerDurationMinValue(...) C++: unsigned long GetTimerDurationMinValue()
GetUseTimers() -> int C++: int GetUseTimers() C++: int GetUseTimers()
GlobalWarningDisplayOff(...) C++: static void GlobalWarningDisplayOff()
GlobalWarningDisplayOn(...) C++: static void GlobalWarningDisplayOn()
GrabFocus(vtkCommand, ...) C++: void GrabFocus(vtkCommand *mouseEvents,
HandleObserversOff(...) C++: void HandleObserversOff()
HandleObserversOn() C++: void HandleObserversOn() C++: void HandleObserversOn()
HasObserver(int, ...) C++: int HasObserver(unsigned long event, vtkCommand *)
HighlightActor2D(...) C++: virtual void HighlightActor2D(vtkActor2D *actor2D)
HighlightProp(...) C++: virtual void HighlightProp(vtkProp *prop)
HighlightProp3D(...) C++: virtual void HighlightProp3D(vtkProp3D *prop3D)
InitializeObjectBase(...) C++: void InitializeObjectBase()
InvokeEvent(int, ...) C++: int InvokeEvent(unsigned long event, void *callData)
IsA(string) -> int C++: int IsA(const char *name) C++: int IsA(const char *name)
IsTypeOf(...) C++: static vtkTypeBool IsTypeOf(const char *type)
KeyPressActivationOff(...) C++: void KeyPressActivationOff()
KeyPressActivationOn(...) C++: void KeyPressActivationOn()
Modified() C++: virtual void Modified() C++: virtual void Modified()
NewInstance(...) C++: vtkInteractorStyleUser *NewInstance()
Off() C++: void Off() C++: void Off()
On() C++: void On() C++: void On()
OnChar() C++: virtual void OnChar() C++: virtual void OnChar()
OnConfigure() C++: virtual void OnConfigure() C++: virtual void OnConfigure()
OnEnter() C++: virtual void OnEnter() C++: virtual void OnEnter()
OnExpose() C++: virtual void OnExpose() C++: virtual void OnExpose()
OnKeyDown() C++: virtual void OnKeyDown() C++: virtual void OnKeyDown()
OnKeyPress() C++: virtual void OnKeyPress() C++: virtual void OnKeyPress()
OnKeyRelease() C++: virtual void OnKeyRelease() C++: virtual void OnKeyRelease()
OnKeyUp() C++: virtual void OnKeyUp() C++: virtual void OnKeyUp()
OnLeave() C++: virtual void OnLeave() C++: virtual void OnLeave()
OnLeftButtonDown(...) C++: virtual void OnLeftButtonDown()
OnLeftButtonUp(...) C++: virtual void OnLeftButtonUp()
OnLongTap() C++: virtual void OnLongTap() C++: virtual void OnLongTap()
OnMiddleButtonDown(...) C++: virtual void OnMiddleButtonDown()
OnMiddleButtonUp(...) C++: virtual void OnMiddleButtonUp()
OnMouseMove() C++: virtual void OnMouseMove() C++: virtual void OnMouseMove()
OnMouseWheelBackward(...) C++: virtual void OnMouseWheelBackward()
OnMouseWheelForward(...) C++: virtual void OnMouseWheelForward()
OnPan() C++: virtual void OnPan() C++: virtual void OnPan()
OnPinch() C++: virtual void OnPinch() C++: virtual void OnPinch()
OnRightButtonDown(...) C++: virtual void OnRightButtonDown()
OnRightButtonUp(...) C++: virtual void OnRightButtonUp()
OnRotate() C++: virtual void OnRotate() C++: virtual void OnRotate()
OnSwipe() C++: virtual void OnSwipe() C++: virtual void OnSwipe()
OnTap() C++: virtual void OnTap() C++: virtual void OnTap()
OnTimer() C++: virtual void OnTimer() C++: virtual void OnTimer()
Pan() C++: virtual void Pan() C++: virtual void Pan()
PickingManagedOff() C++: void PickingManagedOff() C++: void PickingManagedOff()
PickingManagedOn() C++: void PickingManagedOn() C++: void PickingManagedOn()
Register(...) C++: virtual void Register(vtkObjectBase *o)
ReleaseFocus() C++: void ReleaseFocus() C++: void ReleaseFocus()
RemoveAllObservers(...) C++: void RemoveAllObservers()
RemoveObserver(...) C++: void RemoveObserver(vtkCommand *)
RemoveObservers(int, ...) C++: void RemoveObservers(unsigned long event, vtkCommand *)
Rotate() C++: virtual void Rotate() C++: virtual void Rotate()
SafeDownCast(...) C++: vtkInteractorStyleUser SafeDownCast(vtkObject o)
SetAutoAdjustCameraClippingRange(...) C++: void SetAutoAdjustCameraClippingRange(int)
SetCurrentRenderer(...) C++: virtual void SetCurrentRenderer(vtkRenderer *)
SetDebug(bool) C++: void SetDebug(bool debugFlag) C++: void SetDebug(bool debugFlag)
SetDefaultRenderer(...) C++: virtual void SetDefaultRenderer(vtkRenderer *)
SetEnabled(int) C++: virtual void SetEnabled(int) C++: virtual void SetEnabled(int)
SetGlobalWarningDisplay(...) C++: static void SetGlobalWarningDisplay(int val)
SetHandleObservers(...) C++: void SetHandleObservers(int a)
SetInteractor(...)
SetKeyPressActivation(...) C++: void SetKeyPressActivation(int a)
SetKeyPressActivationValue(...) C++: void SetKeyPressActivationValue(char a)
SetMouseWheelMotionFactor(...) C++: void SetMouseWheelMotionFactor(double a)
SetPickColor(float, float, ...) C++: void SetPickColor(double, double, double)
SetPickingManaged(...) C++: void SetPickingManaged(bool a)
SetPriority(float) C++: void SetPriority(float) C++: void SetPriority(float)
SetReferenceCount(...) C++: void SetReferenceCount(int)
SetTDxStyle(...) C++: virtual void SetTDxStyle(vtkTDxInteractorStyle *tdxStyle)
SetTimerDuration(...) C++: void SetTimerDuration(unsigned long)
SetUseTimers(int) C++: void SetUseTimers(int a) C++: void SetUseTimers(int a)
Spin() C++: virtual void Spin() C++: virtual void Spin()
StartAnimate() C++: virtual void StartAnimate() C++: virtual void StartAnimate()
StartDolly() C++: virtual void StartDolly() C++: virtual void StartDolly()
StartPan() C++: virtual void StartPan() C++: virtual void StartPan()
StartRotate() C++: virtual void StartRotate() C++: virtual void StartRotate()
StartSpin() C++: virtual void StartSpin() C++: virtual void StartSpin()
StartState(...) C++: virtual void StartState(int newstate)
StartTimer() C++: virtual void StartTimer() C++: virtual void StartTimer()
StartTwoPointer(...) C++: virtual void StartTwoPointer()
StartUniformScale(...) C++: virtual void StartUniformScale()
StartZoom() C++: virtual void StartZoom() C++: virtual void StartZoom()
StopAnimate() C++: virtual void StopAnimate() C++: virtual void StopAnimate()
StopState() C++: virtual void StopState() C++: virtual void StopState()
UnRegister(...) C++: virtual void UnRegister(vtkObjectBase *o)
UniformScale() C++: virtual void UniformScale() C++: virtual void UniformScale()
UseTimersOff() C++: void UseTimersOff() C++: void UseTimersOff()
UseTimersOn() C++: void UseTimersOn() C++: void UseTimersOn()
Zoom() C++: virtual void Zoom() C++: virtual void Zoom()
add_active_prop(prop)
add_callback(prop, event_type, callback[, ...]) Adds a callback associated to a specific event for a VTK prop.
force_render() Causes the renderer to refresh.
get_prop_at_event_position() Returns the prop that lays at the event position.
on_char(obj, evt)
on_key_press(obj, evt)
on_key_release(obj, evt)
on_left_button_down(obj, evt)
on_left_button_up(obj, evt)
on_middle_button_down(obj, evt)
on_middle_button_up(obj, evt)
on_mouse_move(obj, evt)
on_mouse_wheel_backward(obj, evt)
on_mouse_wheel_forward(obj, evt)
on_right_button_down(obj, evt)
on_right_button_up(obj, evt)
propagate_event(evt, *props)
remove_active_prop(prop)
__init__()
SetInteractor(vtkRenderWindowInteractor) C++: virtual void SetInteractor( vtkRenderWindowInteractor *interactor)
add_active_prop(prop)
add_callback(prop, event_type, callback, priority=0, args=[])

Adds a callback associated to a specific event for a VTK prop.

Parameters:

prop : vtkProp

event_type : event code

callback : function

priority : int

force_render()

Causes the renderer to refresh.

get_prop_at_event_position()

Returns the prop that lays at the event position.

on_char(obj, evt)
on_key_press(obj, evt)
on_key_release(obj, evt)
on_left_button_down(obj, evt)
on_left_button_up(obj, evt)
on_middle_button_down(obj, evt)
on_middle_button_up(obj, evt)
on_mouse_move(obj, evt)
on_mouse_wheel_backward(obj, evt)
on_mouse_wheel_forward(obj, evt)
on_right_button_down(obj, evt)
on_right_button_up(obj, evt)
propagate_event(evt, *props)
remove_active_prop(prop)

Event

class dipy.viz.interactor.Event

Bases: object

Attributes

abort_flag

Methods

abort() Aborts the event i.e.
reset() Done with the current event.
update(event_name, interactor) Updates current event information.
__init__()
abort()

Aborts the event i.e. do not propagate it any further.

abort_flag
reset()

Done with the current event. Reset the attributes.

update(event_name, interactor)

Updates current event information.

vtkInteractorStyleUser

class dipy.viz.interactor.vtkInteractorStyleUser

Bases: vtkRenderingCorePython.vtkInteractorStyle

vtkInteractorStyleUser - provides customizable interaction routines

Superclass: vtkInteractorStyle

The most common way to customize user interaction is to write a subclass of vtkInteractorStyle: vtkInteractorStyleUser allows you to customize the interaction to without subclassing vtkInteractorStyle. This is particularly useful for setting up custom interaction modes in scripting languages such as Tcl and Python. This class allows you to hook into the MouseMove, ButtonPress/Release, KeyPress/Release, etc. events. If you want to hook into just a single mouse button, but leave the interaction modes for the others unchanged, you must use e.g. SetMiddleButtonPressMethod() instead of the more general SetButtonPressMethod().

Methods

AddObserver(int, ...) C++: unsigned long AddObserver(const char *event,
AutoAdjustCameraClippingRangeOff(...) C++: void AutoAdjustCameraClippingRangeOff()
AutoAdjustCameraClippingRangeOn(...) C++: void AutoAdjustCameraClippingRangeOn()
BreakOnError() C++: static void BreakOnError() C++: static void BreakOnError()
ComputeDisplayToWorld(vtkRenderer, float, ...) Convenience methods for outside classes.
ComputeWorldToDisplay(vtkRenderer, float, ...) Convenience methods for outside classes.
DebugOff() C++: virtual void DebugOff() C++: virtual void DebugOff()
DebugOn() C++: virtual void DebugOn() C++: virtual void DebugOn()
DelegateTDxEvent(int, ...) C++: void DelegateTDxEvent(unsigned long event, void *calldata)
Dolly() C++: virtual void Dolly() C++: virtual void Dolly()
EnabledOff() C++: void EnabledOff() C++: void EnabledOff()
EnabledOn() C++: void EnabledOn() C++: void EnabledOn()
EndDolly() C++: virtual void EndDolly() C++: virtual void EndDolly()
EndPan() C++: virtual void EndPan() C++: virtual void EndPan()
EndRotate() C++: virtual void EndRotate() C++: virtual void EndRotate()
EndSpin() C++: virtual void EndSpin() C++: virtual void EndSpin()
EndTimer() C++: virtual void EndTimer() C++: virtual void EndTimer()
EndTwoPointer() C++: virtual void EndTwoPointer() C++: virtual void EndTwoPointer()
EndUniformScale(...) C++: virtual void EndUniformScale()
EndZoom() C++: virtual void EndZoom() C++: virtual void EndZoom()
FastDelete() C++: virtual void FastDelete() C++: virtual void FastDelete()
FindPokedRenderer(int, ...) C++: void FindPokedRenderer(int, int)
GetAddressAsString(...) C++: const char *GetAddressAsString()
GetAutoAdjustCameraClippingRange(...) C++: int GetAutoAdjustCameraClippingRange()
GetAutoAdjustCameraClippingRangeMaxValue(...) C++: int GetAutoAdjustCameraClippingRangeMaxValue()
GetAutoAdjustCameraClippingRangeMinValue(...) C++: int GetAutoAdjustCameraClippingRangeMinValue()
GetButton() -> int C++: int GetButton() C++: int GetButton()
GetChar() -> int C++: int GetChar() C++: int GetChar()
GetClassName(...) C++: const char *GetClassName()
GetCommand(...) C++: vtkCommand *GetCommand(unsigned long tag)
GetCtrlKey() -> int C++: int GetCtrlKey() C++: int GetCtrlKey()
GetCurrentRenderer(...) C++: vtkRenderer *GetCurrentRenderer()
GetDebug() -> bool C++: bool GetDebug() C++: bool GetDebug()
GetDefaultRenderer(...) C++: vtkRenderer *GetDefaultRenderer()
GetEnabled() -> int C++: int GetEnabled() C++: int GetEnabled()
GetGlobalWarningDisplay(...) C++: static int GetGlobalWarningDisplay()
GetHandleObservers(...) C++: int GetHandleObservers()
GetInteractor(...) C++: vtkRenderWindowInteractor *GetInteractor()
GetKeyPressActivation(...) C++: int GetKeyPressActivation()
GetKeyPressActivationValue(...) C++: char GetKeyPressActivationValue()
GetKeySym() -> string C++: char *GetKeySym() C++: char *GetKeySym()
GetLastPos() -> (int, int) C++: int *GetLastPos() C++: int *GetLastPos()
GetMTime(...) C++: virtual vtkMTimeType GetMTime()
GetMouseWheelMotionFactor(...) C++: double GetMouseWheelMotionFactor()
GetOldPos() -> (int, int) C++: int *GetOldPos() C++: int *GetOldPos()
GetPickColor() -> (float, float, ...) C++: double *GetPickColor()
GetPickingManaged(...) C++: bool GetPickingManaged()
GetPriority() -> float C++: float GetPriority() C++: float GetPriority()
GetPriorityMaxValue(...) C++: float GetPriorityMaxValue()
GetPriorityMinValue(...) C++: float GetPriorityMinValue()
GetReferenceCount(...) C++: int GetReferenceCount()
GetShiftKey() -> int C++: int GetShiftKey() C++: int GetShiftKey()
GetState() -> int C++: int GetState() C++: int GetState()
GetTDxStyle(...) C++: vtkTDxInteractorStyle *GetTDxStyle()
GetTimerDuration(...) C++: unsigned long GetTimerDuration()
GetTimerDurationMaxValue(...) C++: unsigned long GetTimerDurationMaxValue()
GetTimerDurationMinValue(...) C++: unsigned long GetTimerDurationMinValue()
GetUseTimers() -> int C++: int GetUseTimers() C++: int GetUseTimers()
GlobalWarningDisplayOff(...) C++: static void GlobalWarningDisplayOff()
GlobalWarningDisplayOn(...) C++: static void GlobalWarningDisplayOn()
GrabFocus(vtkCommand, ...) C++: void GrabFocus(vtkCommand *mouseEvents,
HandleObserversOff(...) C++: void HandleObserversOff()
HandleObserversOn() C++: void HandleObserversOn() C++: void HandleObserversOn()
HasObserver(int, ...) C++: int HasObserver(unsigned long event, vtkCommand *)
HighlightActor2D(...) C++: virtual void HighlightActor2D(vtkActor2D *actor2D)
HighlightProp(...) C++: virtual void HighlightProp(vtkProp *prop)
HighlightProp3D(...) C++: virtual void HighlightProp3D(vtkProp3D *prop3D)
InitializeObjectBase(...) C++: void InitializeObjectBase()
InvokeEvent(int, ...) C++: int InvokeEvent(unsigned long event, void *callData)
IsA(string) -> int C++: int IsA(const char *name) C++: int IsA(const char *name)
IsTypeOf(...) C++: static vtkTypeBool IsTypeOf(const char *type)
KeyPressActivationOff(...) C++: void KeyPressActivationOff()
KeyPressActivationOn(...) C++: void KeyPressActivationOn()
Modified() C++: virtual void Modified() C++: virtual void Modified()
NewInstance(...) C++: vtkInteractorStyleUser *NewInstance()
Off() C++: void Off() C++: void Off()
On() C++: void On() C++: void On()
OnChar() C++: virtual void OnChar() C++: virtual void OnChar()
OnConfigure() C++: virtual void OnConfigure() C++: virtual void OnConfigure()
OnEnter() C++: virtual void OnEnter() C++: virtual void OnEnter()
OnExpose() C++: virtual void OnExpose() C++: virtual void OnExpose()
OnKeyDown() C++: virtual void OnKeyDown() C++: virtual void OnKeyDown()
OnKeyPress() C++: virtual void OnKeyPress() C++: virtual void OnKeyPress()
OnKeyRelease() C++: virtual void OnKeyRelease() C++: virtual void OnKeyRelease()
OnKeyUp() C++: virtual void OnKeyUp() C++: virtual void OnKeyUp()
OnLeave() C++: virtual void OnLeave() C++: virtual void OnLeave()
OnLeftButtonDown(...) C++: virtual void OnLeftButtonDown()
OnLeftButtonUp(...) C++: virtual void OnLeftButtonUp()
OnLongTap() C++: virtual void OnLongTap() C++: virtual void OnLongTap()
OnMiddleButtonDown(...) C++: virtual void OnMiddleButtonDown()
OnMiddleButtonUp(...) C++: virtual void OnMiddleButtonUp()
OnMouseMove() C++: virtual void OnMouseMove() C++: virtual void OnMouseMove()
OnMouseWheelBackward(...) C++: virtual void OnMouseWheelBackward()
OnMouseWheelForward(...) C++: virtual void OnMouseWheelForward()
OnPan() C++: virtual void OnPan() C++: virtual void OnPan()
OnPinch() C++: virtual void OnPinch() C++: virtual void OnPinch()
OnRightButtonDown(...) C++: virtual void OnRightButtonDown()
OnRightButtonUp(...) C++: virtual void OnRightButtonUp()
OnRotate() C++: virtual void OnRotate() C++: virtual void OnRotate()
OnSwipe() C++: virtual void OnSwipe() C++: virtual void OnSwipe()
OnTap() C++: virtual void OnTap() C++: virtual void OnTap()
OnTimer() C++: virtual void OnTimer() C++: virtual void OnTimer()
Pan() C++: virtual void Pan() C++: virtual void Pan()
PickingManagedOff() C++: void PickingManagedOff() C++: void PickingManagedOff()
PickingManagedOn() C++: void PickingManagedOn() C++: void PickingManagedOn()
Register(...) C++: virtual void Register(vtkObjectBase *o)
ReleaseFocus() C++: void ReleaseFocus() C++: void ReleaseFocus()
RemoveAllObservers(...) C++: void RemoveAllObservers()
RemoveObserver(...) C++: void RemoveObserver(vtkCommand *)
RemoveObservers(int, ...) C++: void RemoveObservers(unsigned long event, vtkCommand *)
Rotate() C++: virtual void Rotate() C++: virtual void Rotate()
SafeDownCast(...) C++: vtkInteractorStyleUser SafeDownCast(vtkObject o)
SetAutoAdjustCameraClippingRange(...) C++: void SetAutoAdjustCameraClippingRange(int)
SetCurrentRenderer(...) C++: virtual void SetCurrentRenderer(vtkRenderer *)
SetDebug(bool) C++: void SetDebug(bool debugFlag) C++: void SetDebug(bool debugFlag)
SetDefaultRenderer(...) C++: virtual void SetDefaultRenderer(vtkRenderer *)
SetEnabled(int) C++: virtual void SetEnabled(int) C++: virtual void SetEnabled(int)
SetGlobalWarningDisplay(...) C++: static void SetGlobalWarningDisplay(int val)
SetHandleObservers(...) C++: void SetHandleObservers(int a)
SetInteractor(...) C++: virtual void SetInteractor(
SetKeyPressActivation(...) C++: void SetKeyPressActivation(int a)
SetKeyPressActivationValue(...) C++: void SetKeyPressActivationValue(char a)
SetMouseWheelMotionFactor(...) C++: void SetMouseWheelMotionFactor(double a)
SetPickColor(float, float, ...) C++: void SetPickColor(double, double, double)
SetPickingManaged(...) C++: void SetPickingManaged(bool a)
SetPriority(float) C++: void SetPriority(float) C++: void SetPriority(float)
SetReferenceCount(...) C++: void SetReferenceCount(int)
SetTDxStyle(...) C++: virtual void SetTDxStyle(vtkTDxInteractorStyle *tdxStyle)
SetTimerDuration(...) C++: void SetTimerDuration(unsigned long)
SetUseTimers(int) C++: void SetUseTimers(int a) C++: void SetUseTimers(int a)
Spin() C++: virtual void Spin() C++: virtual void Spin()
StartAnimate() C++: virtual void StartAnimate() C++: virtual void StartAnimate()
StartDolly() C++: virtual void StartDolly() C++: virtual void StartDolly()
StartPan() C++: virtual void StartPan() C++: virtual void StartPan()
StartRotate() C++: virtual void StartRotate() C++: virtual void StartRotate()
StartSpin() C++: virtual void StartSpin() C++: virtual void StartSpin()
StartState(...) C++: virtual void StartState(int newstate)
StartTimer() C++: virtual void StartTimer() C++: virtual void StartTimer()
StartTwoPointer(...) C++: virtual void StartTwoPointer()
StartUniformScale(...) C++: virtual void StartUniformScale()
StartZoom() C++: virtual void StartZoom() C++: virtual void StartZoom()
StopAnimate() C++: virtual void StopAnimate() C++: virtual void StopAnimate()
StopState() C++: virtual void StopState() C++: virtual void StopState()
UnRegister(...) C++: virtual void UnRegister(vtkObjectBase *o)
UniformScale() C++: virtual void UniformScale() C++: virtual void UniformScale()
UseTimersOff() C++: void UseTimersOff() C++: void UseTimersOff()
UseTimersOn() C++: void UseTimersOn() C++: void UseTimersOn()
Zoom() C++: virtual void Zoom() C++: virtual void Zoom()
__init__()

Initialize self. See help(type(self)) for accurate signature.

GetButton() -> int C++: int GetButton()

C++: int GetButton()

Get the mouse button that was last pressed inside the window (returns zero when the button is released).

GetChar() -> int C++: int GetChar()

C++: int GetChar()

Get the character for a Char event.

GetClassName() -> string C++: const char *GetClassName()

C++: const char *GetClassName()

GetCtrlKey() -> int C++: int GetCtrlKey()

C++: int GetCtrlKey()

Test whether modifiers were held down when mouse button or key was pressed

GetKeySym() -> string C++: char *GetKeySym()

C++: char *GetKeySym()

Get the KeySym (in the same format as Tk KeySyms) for a KeyPress or KeyRelease method.

GetLastPos() -> (int, int) C++: int *GetLastPos()

C++: int *GetLastPos()

GetOldPos() -> (int, int) C++: int *GetOldPos()

C++: int *GetOldPos()

GetShiftKey() -> int C++: int GetShiftKey()

C++: int GetShiftKey()

Test whether modifiers were held down when mouse button or key was pressed

IsA(string) -> int C++: int IsA(const char *name)

C++: int IsA(const char *name)

NewInstance() -> vtkInteractorStyleUser C++: vtkInteractorStyleUser *NewInstance()

C++: vtkInteractorStyleUser *NewInstance()

OnChar() C++: virtual void OnChar()

C++: virtual void OnChar()

Keyboard functions

OnConfigure() C++: virtual void OnConfigure()

C++: virtual void OnConfigure()

These are more esoteric events, but are useful in some cases.

OnEnter() C++: virtual void OnEnter()

C++: virtual void OnEnter()

These are more esoteric events, but are useful in some cases.

OnExpose() C++: virtual void OnExpose()

C++: virtual void OnExpose()

These are more esoteric events, but are useful in some cases.

OnKeyPress() C++: virtual void OnKeyPress()

C++: virtual void OnKeyPress()

Keyboard functions

OnKeyRelease() C++: virtual void OnKeyRelease()

C++: virtual void OnKeyRelease()

Keyboard functions

OnLeave() C++: virtual void OnLeave()

C++: virtual void OnLeave()

These are more esoteric events, but are useful in some cases.

OnLeftButtonDown() C++: virtual void OnLeftButtonDown()

C++: virtual void OnLeftButtonDown()

Generic event bindings

OnLeftButtonUp() C++: virtual void OnLeftButtonUp()

C++: virtual void OnLeftButtonUp()

Generic event bindings

OnMiddleButtonDown() C++: virtual void OnMiddleButtonDown()

C++: virtual void OnMiddleButtonDown()

Generic event bindings

OnMiddleButtonUp() C++: virtual void OnMiddleButtonUp()

C++: virtual void OnMiddleButtonUp()

Generic event bindings

OnMouseMove() C++: virtual void OnMouseMove()

C++: virtual void OnMouseMove()

Generic event bindings

OnMouseWheelBackward() C++: virtual void OnMouseWheelBackward()

C++: virtual void OnMouseWheelBackward()

Generic event bindings

OnMouseWheelForward() C++: virtual void OnMouseWheelForward()

C++: virtual void OnMouseWheelForward()

Generic event bindings

OnRightButtonDown() C++: virtual void OnRightButtonDown()

C++: virtual void OnRightButtonDown()

Generic event bindings

OnRightButtonUp() C++: virtual void OnRightButtonUp()

C++: virtual void OnRightButtonUp()

Generic event bindings

OnTimer() C++: virtual void OnTimer()

C++: virtual void OnTimer()

SafeDownCast(vtkObject) -> vtkInteractorStyleUser C++: vtkInteractorStyleUser *SafeDownCast(vtkObject* o)

C++: vtkInteractorStyleUser SafeDownCast(vtkObject o)

optional_package

dipy.viz.interactor.optional_package(name, trip_msg=None)

Return package-like thing and module setup for package name

Parameters:

name : str

package name

trip_msg : None or str

message to give when someone tries to use the return package, but we could not import it, and have returned a TripWire object instead. Default message if None.

Returns:

pkg_like : module or TripWire instance

If we can import the package, return it. Otherwise return an object raising an error when accessed

have_pkg : bool

True if import for package was successful, false otherwise

module_setup : function

callable usually set as setup_module in calling namespace, to allow skipping tests.

setup_module

dipy.viz.interactor.setup_module()

doctest_skip_parser

dipy.viz.projections.doctest_skip_parser(func)

Decorator replaces custom skip test markup in doctests.

Say a function has a docstring:

>>> something # skip if not HAVE_AMODULE
>>> something + else
>>> something # skip if HAVE_BMODULE

This decorator will evaluate the expresssion after skip if. If this evaluates to True, then the comment is replaced by # doctest: +SKIP. If False, then the comment is just removed. The expression is evaluated in the globals scope of func.

For example, if the module global HAVE_AMODULE is False, and module global HAVE_BMODULE is False, the returned function will have docstring:

>>> something 
>>> something + else
>>> something

optional_package

dipy.viz.projections.optional_package(name, trip_msg=None)

Return package-like thing and module setup for package name

Parameters:

name : str

package name

trip_msg : None or str

message to give when someone tries to use the return package, but we could not import it, and have returned a TripWire object instead. Default message if None.

Returns:

pkg_like : module or TripWire instance

If we can import the package, return it. Otherwise return an object raising an error when accessed

have_pkg : bool

True if import for package was successful, false otherwise

module_setup : function

callable usually set as setup_module in calling namespace, to allow skipping tests.

setup_module

dipy.viz.projections.setup_module()

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, vmax : floats

Values to cut the z

cmap : mpl colormap

cbar: Whether to add the color-bar to the figure

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

boundary : Whether to draw the boundary around the projection

in a black line

Returns:

ax : axis

Matplotlib figure axis

Examples

>>> from dipy.data import get_sphere
>>> verts = get_sphere('symmetric724').vertices
>>> ax = sph_project(verts.T, np.random.rand(len(verts.T))) 

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

optional_package

dipy.viz.regtools.optional_package(name, trip_msg=None)

Return package-like thing and module setup for package name

Parameters:

name : str

package name

trip_msg : None or str

message to give when someone tries to use the return package, but we could not import it, and have returned a TripWire object instead. Default message if None.

Returns:

pkg_like : module or TripWire instance

If we can import the package, return it. Otherwise return an object raising an error when accessed

have_pkg : bool

True if import for package was successful, false otherwise

module_setup : function

callable usually set as setup_module in calling namespace, to allow skipping tests.

overlay_images

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

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.

overlay_slices

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

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, plottet 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=sagital, 1=coronal (default), 2=axial.

ltitle : string (optional)

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

rtitle : string (optional)

the string to be written as 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.

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)

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 ploted using matplotlib, else the grids are just returned

Returns:

warped_forward : array

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

warped_backward : array

Image with 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.

plot_slices

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

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

Creates a figure showing the axial, coronal and sagital 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 sagital (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.

setup_module

dipy.viz.regtools.setup_module()

Button2D

class dipy.viz.ui.Button2D(icon_fnames, size=(30, 30))

Bases: dipy.viz.ui.UI

A 2D overlay button and is of type vtkTexturedActor2D. Currently supports: - Multiple icons. - Switching between icons.

Attributes

size: (float, float) Button size (width, height) in pixels.

Methods

add_callback(prop, event_type, callback[, ...]) Adds a callback to a specific event for this UI component.
add_to_renderer(ren) Allows UI objects to add their own props to the renderer.
build_actor(icon) Return an image as a 2D actor with a specific position.
get_actors() Returns the actors that compose this UI component.
handle_events(actor)
key_press_callback(i_ren, obj, self)
left_button_click_callback(i_ren, obj, self)
left_button_release_callback(i_ren, obj, self)
mouse_move_callback(i_ren, obj, self)
next_icon() Increments the state of the Button.
next_icon_name() Returns the next icon name while cycling through icons.
right_button_click_callback(i_ren, obj, self)
right_button_release_callback(i_ren, obj, self)
scale(size) Scales the button.
set_center(position) Sets the icon center to position.
set_icon(icon) Modifies the icon used by the vtkTexturedActor2D.
set_visibility(visibility) Sets visibility of this UI component and all its sub-components.
__init__(icon_fnames, size=(30, 30))
Parameters:

size : 2-tuple of int, optional

Button size.

icon_fnames : dict

{iconname : filename, iconname : filename, ...}

build_actor(icon)

Return an image as a 2D actor with a specific position.

Parameters:icon : vtkImageData
Returns:vtkTexturedActor2D
color

Gets the button’s color.

get_actors()

Returns the actors that compose this UI component.

next_icon()

Increments the state of the Button.

Also changes the icon.

next_icon_name()

Returns the next icon name while cycling through icons.

scale(size)

Scales the button.

Parameters:

size : (float, float)

Scaling factor (width, height) in pixels.

set_center(position)

Sets the icon center to position.

Parameters:

position : (float, float)

The new center of the button (x, y).

set_icon(icon)

Modifies the icon used by the vtkTexturedActor2D.

Parameters:icon : imageDataGeometryFilter
size

Gets the button size.

CustomInteractorStyle

class dipy.viz.ui.CustomInteractorStyle

Bases: vtkInteractionStylePython.vtkInteractorStyleUser

Manipulate the camera and interact with objects in the scene.

This interactor style allows the user to interactively manipulate (pan, rotate and zoom) the camera. It also allows the user to interact (click, scroll, etc.) with objects in the scene.

Several events handling methods from vtkInteractorStyleUser have been overloaded to allow the propagation of the events to the objects the user is interacting with.

In summary, while interacting with the scene, the mouse events are as follows: - Left mouse button: rotates the camera - Right mouse button: dollys the camera - Mouse wheel: dollys the camera - Middle mouse button: pans the camera

Methods

AddObserver(int, ...) C++: unsigned long AddObserver(const char *event,
AutoAdjustCameraClippingRangeOff(...) C++: void AutoAdjustCameraClippingRangeOff()
AutoAdjustCameraClippingRangeOn(...) C++: void AutoAdjustCameraClippingRangeOn()
BreakOnError() C++: static void BreakOnError() C++: static void BreakOnError()
ComputeDisplayToWorld(vtkRenderer, float, ...) Convenience methods for outside classes.
ComputeWorldToDisplay(vtkRenderer, float, ...) Convenience methods for outside classes.
DebugOff() C++: virtual void DebugOff() C++: virtual void DebugOff()
DebugOn() C++: virtual void DebugOn() C++: virtual void DebugOn()
DelegateTDxEvent(int, ...) C++: void DelegateTDxEvent(unsigned long event, void *calldata)
Dolly() C++: virtual void Dolly() C++: virtual void Dolly()
EnabledOff() C++: void EnabledOff() C++: void EnabledOff()
EnabledOn() C++: void EnabledOn() C++: void EnabledOn()
EndDolly() C++: virtual void EndDolly() C++: virtual void EndDolly()
EndPan() C++: virtual void EndPan() C++: virtual void EndPan()
EndRotate() C++: virtual void EndRotate() C++: virtual void EndRotate()
EndSpin() C++: virtual void EndSpin() C++: virtual void EndSpin()
EndTimer() C++: virtual void EndTimer() C++: virtual void EndTimer()
EndTwoPointer() C++: virtual void EndTwoPointer() C++: virtual void EndTwoPointer()
EndUniformScale(...) C++: virtual void EndUniformScale()
EndZoom() C++: virtual void EndZoom() C++: virtual void EndZoom()
FastDelete() C++: virtual void FastDelete() C++: virtual void FastDelete()
FindPokedRenderer(int, ...) C++: void FindPokedRenderer(int, int)
GetAddressAsString(...) C++: const char *GetAddressAsString()
GetAutoAdjustCameraClippingRange(...) C++: int GetAutoAdjustCameraClippingRange()
GetAutoAdjustCameraClippingRangeMaxValue(...) C++: int GetAutoAdjustCameraClippingRangeMaxValue()
GetAutoAdjustCameraClippingRangeMinValue(...) C++: int GetAutoAdjustCameraClippingRangeMinValue()
GetButton() -> int C++: int GetButton() C++: int GetButton()
GetChar() -> int C++: int GetChar() C++: int GetChar()
GetClassName(...) C++: const char *GetClassName()
GetCommand(...) C++: vtkCommand *GetCommand(unsigned long tag)
GetCtrlKey() -> int C++: int GetCtrlKey() C++: int GetCtrlKey()
GetCurrentRenderer(...) C++: vtkRenderer *GetCurrentRenderer()
GetDebug() -> bool C++: bool GetDebug() C++: bool GetDebug()
GetDefaultRenderer(...) C++: vtkRenderer *GetDefaultRenderer()
GetEnabled() -> int C++: int GetEnabled() C++: int GetEnabled()
GetGlobalWarningDisplay(...) C++: static int GetGlobalWarningDisplay()
GetHandleObservers(...) C++: int GetHandleObservers()
GetInteractor(...) C++: vtkRenderWindowInteractor *GetInteractor()
GetKeyPressActivation(...) C++: int GetKeyPressActivation()
GetKeyPressActivationValue(...) C++: char GetKeyPressActivationValue()
GetKeySym() -> string C++: char *GetKeySym() C++: char *GetKeySym()
GetLastPos() -> (int, int) C++: int *GetLastPos() C++: int *GetLastPos()
GetMTime(...) C++: virtual vtkMTimeType GetMTime()
GetMouseWheelMotionFactor(...) C++: double GetMouseWheelMotionFactor()
GetOldPos() -> (int, int) C++: int *GetOldPos() C++: int *GetOldPos()
GetPickColor() -> (float, float, ...) C++: double *GetPickColor()
GetPickingManaged(...) C++: bool GetPickingManaged()
GetPriority() -> float C++: float GetPriority() C++: float GetPriority()
GetPriorityMaxValue(...) C++: float GetPriorityMaxValue()
GetPriorityMinValue(...) C++: float GetPriorityMinValue()
GetReferenceCount(...) C++: int GetReferenceCount()
GetShiftKey() -> int C++: int GetShiftKey() C++: int GetShiftKey()
GetState() -> int C++: int GetState() C++: int GetState()
GetTDxStyle(...) C++: vtkTDxInteractorStyle *GetTDxStyle()
GetTimerDuration(...) C++: unsigned long GetTimerDuration()
GetTimerDurationMaxValue(...) C++: unsigned long GetTimerDurationMaxValue()
GetTimerDurationMinValue(...) C++: unsigned long GetTimerDurationMinValue()
GetUseTimers() -> int C++: int GetUseTimers() C++: int GetUseTimers()
GlobalWarningDisplayOff(...) C++: static void GlobalWarningDisplayOff()
GlobalWarningDisplayOn(...) C++: static void GlobalWarningDisplayOn()
GrabFocus(vtkCommand, ...) C++: void GrabFocus(vtkCommand *mouseEvents,
HandleObserversOff(...) C++: void HandleObserversOff()
HandleObserversOn() C++: void HandleObserversOn() C++: void HandleObserversOn()
HasObserver(int, ...) C++: int HasObserver(unsigned long event, vtkCommand *)
HighlightActor2D(...) C++: virtual void HighlightActor2D(vtkActor2D *actor2D)
HighlightProp(...) C++: virtual void HighlightProp(vtkProp *prop)
HighlightProp3D(...) C++: virtual void HighlightProp3D(vtkProp3D *prop3D)
InitializeObjectBase(...) C++: void InitializeObjectBase()
InvokeEvent(int, ...) C++: int InvokeEvent(unsigned long event, void *callData)
IsA(string) -> int C++: int IsA(const char *name) C++: int IsA(const char *name)
IsTypeOf(...) C++: static vtkTypeBool IsTypeOf(const char *type)
KeyPressActivationOff(...) C++: void KeyPressActivationOff()
KeyPressActivationOn(...) C++: void KeyPressActivationOn()
Modified() C++: virtual void Modified() C++: virtual void Modified()
NewInstance(...) C++: vtkInteractorStyleUser *NewInstance()
Off() C++: void Off() C++: void Off()
On() C++: void On() C++: void On()
OnChar() C++: virtual void OnChar() C++: virtual void OnChar()
OnConfigure() C++: virtual void OnConfigure() C++: virtual void OnConfigure()
OnEnter() C++: virtual void OnEnter() C++: virtual void OnEnter()
OnExpose() C++: virtual void OnExpose() C++: virtual void OnExpose()
OnKeyDown() C++: virtual void OnKeyDown() C++: virtual void OnKeyDown()
OnKeyPress() C++: virtual void OnKeyPress() C++: virtual void OnKeyPress()
OnKeyRelease() C++: virtual void OnKeyRelease() C++: virtual void OnKeyRelease()
OnKeyUp() C++: virtual void OnKeyUp() C++: virtual void OnKeyUp()
OnLeave() C++: virtual void OnLeave() C++: virtual void OnLeave()
OnLeftButtonDown(...) C++: virtual void OnLeftButtonDown()
OnLeftButtonUp(...) C++: virtual void OnLeftButtonUp()
OnLongTap() C++: virtual void OnLongTap() C++: virtual void OnLongTap()
OnMiddleButtonDown(...) C++: virtual void OnMiddleButtonDown()
OnMiddleButtonUp(...) C++: virtual void OnMiddleButtonUp()
OnMouseMove() C++: virtual void OnMouseMove() C++: virtual void OnMouseMove()
OnMouseWheelBackward(...) C++: virtual void OnMouseWheelBackward()
OnMouseWheelForward(...) C++: virtual void OnMouseWheelForward()
OnPan() C++: virtual void OnPan() C++: virtual void OnPan()
OnPinch() C++: virtual void OnPinch() C++: virtual void OnPinch()
OnRightButtonDown(...) C++: virtual void OnRightButtonDown()
OnRightButtonUp(...) C++: virtual void OnRightButtonUp()
OnRotate() C++: virtual void OnRotate() C++: virtual void OnRotate()
OnSwipe() C++: virtual void OnSwipe() C++: virtual void OnSwipe()
OnTap() C++: virtual void OnTap() C++: virtual void OnTap()
OnTimer() C++: virtual void OnTimer() C++: virtual void OnTimer()
Pan() C++: virtual void Pan() C++: virtual void Pan()
PickingManagedOff() C++: void PickingManagedOff() C++: void PickingManagedOff()
PickingManagedOn() C++: void PickingManagedOn() C++: void PickingManagedOn()
Register(...) C++: virtual void Register(vtkObjectBase *o)
ReleaseFocus() C++: void ReleaseFocus() C++: void ReleaseFocus()
RemoveAllObservers(...) C++: void RemoveAllObservers()
RemoveObserver(...) C++: void RemoveObserver(vtkCommand *)
RemoveObservers(int, ...) C++: void RemoveObservers(unsigned long event, vtkCommand *)
Rotate() C++: virtual void Rotate() C++: virtual void Rotate()
SafeDownCast(...) C++: vtkInteractorStyleUser SafeDownCast(vtkObject o)
SetAutoAdjustCameraClippingRange(...) C++: void SetAutoAdjustCameraClippingRange(int)
SetCurrentRenderer(...) C++: virtual void SetCurrentRenderer(vtkRenderer *)
SetDebug(bool) C++: void SetDebug(bool debugFlag) C++: void SetDebug(bool debugFlag)
SetDefaultRenderer(...) C++: virtual void SetDefaultRenderer(vtkRenderer *)
SetEnabled(int) C++: virtual void SetEnabled(int) C++: virtual void SetEnabled(int)
SetGlobalWarningDisplay(...) C++: static void SetGlobalWarningDisplay(int val)
SetHandleObservers(...) C++: void SetHandleObservers(int a)
SetInteractor(...)
SetKeyPressActivation(...) C++: void SetKeyPressActivation(int a)
SetKeyPressActivationValue(...) C++: void SetKeyPressActivationValue(char a)
SetMouseWheelMotionFactor(...) C++: void SetMouseWheelMotionFactor(double a)
SetPickColor(float, float, ...) C++: void SetPickColor(double, double, double)
SetPickingManaged(...) C++: void SetPickingManaged(bool a)
SetPriority(float) C++: void SetPriority(float) C++: void SetPriority(float)
SetReferenceCount(...) C++: void SetReferenceCount(int)
SetTDxStyle(...) C++: virtual void SetTDxStyle(vtkTDxInteractorStyle *tdxStyle)
SetTimerDuration(...) C++: void SetTimerDuration(unsigned long)
SetUseTimers(int) C++: void SetUseTimers(int a) C++: void SetUseTimers(int a)
Spin() C++: virtual void Spin() C++: virtual void Spin()
StartAnimate() C++: virtual void StartAnimate() C++: virtual void StartAnimate()
StartDolly() C++: virtual void StartDolly() C++: virtual void StartDolly()
StartPan() C++: virtual void StartPan() C++: virtual void StartPan()
StartRotate() C++: virtual void StartRotate() C++: virtual void StartRotate()
StartSpin() C++: virtual void StartSpin() C++: virtual void StartSpin()
StartState(...) C++: virtual void StartState(int newstate)
StartTimer() C++: virtual void StartTimer() C++: virtual void StartTimer()
StartTwoPointer(...) C++: virtual void StartTwoPointer()
StartUniformScale(...) C++: virtual void StartUniformScale()
StartZoom() C++: virtual void StartZoom() C++: virtual void StartZoom()
StopAnimate() C++: virtual void StopAnimate() C++: virtual void StopAnimate()
StopState() C++: virtual void StopState() C++: virtual void StopState()
UnRegister(...) C++: virtual void UnRegister(vtkObjectBase *o)
UniformScale() C++: virtual void UniformScale() C++: virtual void UniformScale()
UseTimersOff() C++: void UseTimersOff() C++: void UseTimersOff()
UseTimersOn() C++: void UseTimersOn() C++: void UseTimersOn()
Zoom() C++: virtual void Zoom() C++: virtual void Zoom()
add_active_prop(prop)
add_callback(prop, event_type, callback[, ...]) Adds a callback associated to a specific event for a VTK prop.
force_render() Causes the renderer to refresh.
get_prop_at_event_position() Returns the prop that lays at the event position.
on_char(obj, evt)
on_key_press(obj, evt)
on_key_release(obj, evt)
on_left_button_down(obj, evt)
on_left_button_up(obj, evt)
on_middle_button_down(obj, evt)
on_middle_button_up(obj, evt)
on_mouse_move(obj, evt)
on_mouse_wheel_backward(obj, evt)
on_mouse_wheel_forward(obj, evt)
on_right_button_down(obj, evt)
on_right_button_up(obj, evt)
propagate_event(evt, *props)
remove_active_prop(prop)
__init__()
SetInteractor(vtkRenderWindowInteractor) C++: virtual void SetInteractor( vtkRenderWindowInteractor *interactor)
add_active_prop(prop)
add_callback(prop, event_type, callback, priority=0, args=[])

Adds a callback associated to a specific event for a VTK prop.

Parameters:

prop : vtkProp

event_type : event code

callback : function

priority : int

force_render()

Causes the renderer to refresh.

get_prop_at_event_position()

Returns the prop that lays at the event position.

on_char(obj, evt)
on_key_press(obj, evt)
on_key_release(obj, evt)
on_left_button_down(obj, evt)
on_left_button_up(obj, evt)
on_middle_button_down(obj, evt)
on_middle_button_up(obj, evt)
on_mouse_move(obj, evt)
on_mouse_wheel_backward(obj, evt)
on_mouse_wheel_forward(obj, evt)
on_right_button_down(obj, evt)
on_right_button_up(obj, evt)
propagate_event(evt, *props)
remove_active_prop(prop)

DiskSlider2D

class dipy.viz.ui.DiskSlider2D(position=(0, 0), initial_value=180, min_value=0, max_value=360, slider_inner_radius=40, slider_outer_radius=44, handle_inner_radius=10, handle_outer_radius=0, text_size=16, text_template='{ratio:.0%}')

Bases: dipy.viz.ui.UI

A disk slider.

A disk moves along the boundary of a ring. Goes from 0-360 degrees.

Attributes

base_disk_center: (float, float) Position of the system.
slider_inner_radius: int Inner radius of the base disk.
slider_outer_radius: int Outer radius of the base disk.
slider_radius: float Average radius of the base disk.
handle_outer_radius: int Outer radius of the slider’s handle.
handle_inner_radius: int Inner radius of the slider’s handle.
previous_value: float Value of Rotation of the actor before the current value.
initial_value: float Initial Value of Rotation of the actor assigned on creation of object.

Methods

add_callback(prop, event_type, callback[, ...]) Adds a callback to a specific event for this UI component.
add_to_renderer(ren) Allows UI objects to add their own props to the renderer.
base_disk_click_callback(i_ren, obj, slider) Update disk position and grab the focus.
build_actors() Builds actors for the system.
format_text() Returns formatted text to display along the slider.
get_actors() Returns the actors that compose this UI component.
handle_events(actor) Handle all default slider events.
handle_move_callback(i_ren, obj, slider) Move the slider’s handle.
handle_press_callback(i_ren, obj, slider) This is only needed to grab the focus.
key_press_callback(i_ren, obj, self)
left_button_click_callback(i_ren, obj, self)
left_button_release_callback(i_ren, obj, self)
mouse_move_callback(i_ren, obj, self)
move_handle(click_position) Moves the slider’s handle.
right_button_click_callback(i_ren, obj, self)
right_button_release_callback(i_ren, obj, self)
set_center(position) Changes the slider’s center position.
set_visibility(visibility) Sets visibility of this UI component and all its sub-components.
update() Updates the slider.
__init__(position=(0, 0), initial_value=180, min_value=0, max_value=360, slider_inner_radius=40, slider_outer_radius=44, handle_inner_radius=10, handle_outer_radius=0, text_size=16, text_template='{ratio:.0%}')
Parameters:

position : (float, float)

Position (x, y) of the slider’s center.

initial_value : float

Initial value of the slider.

min_value : float

Minimum value of the slider.

max_value : float

Maximum value of the slider.

slider_inner_radius : int

Inner radius of the base disk.

slider_outer_radius : int

Outer radius of the base disk.

handle_outer_radius : int

Outer radius of the slider’s handle.

handle_inner_radius : int

Inner radius of the slider’s handle.

text_size : int

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

text_template : str, callable

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

angle

Angle (in rad) the handle makes with x-axis

static base_disk_click_callback(i_ren, obj, slider)

Update disk position and grab the focus.

Parameters:

i_ren : CustomInteractorStyle

obj : vtkActor

The picked actor

slider : DiskSlider2D

build_actors()

Builds actors for the system.

format_text()

Returns formatted text to display along the slider.

get_actors()

Returns the actors that compose this UI component.

handle_events(actor)

Handle all default slider events.

static handle_move_callback(i_ren, obj, slider)

Move the slider’s handle.

Parameters:

i_ren : CustomInteractorStyle

obj : vtkActor

The picked actor

slider : DiskSlider2D

static handle_press_callback(i_ren, obj, slider)

This is only needed to grab the focus.

Parameters:

i_ren : CustomInteractorStyle

obj : vtkActor

The picked actor

slider : DiskSlider2D

move_handle(click_position)

Moves the slider’s handle.

Parameters:

click_position: (float, float)

Position of the mouse click.

previous_value
ratio
set_center(position)

Changes the slider’s center position.

Parameters:

position : (float, float)

New position (x, y).

update()

Updates the slider.

value

FileSelectMenu2D

class dipy.viz.ui.FileSelectMenu2D(size, font_size, position, parent, extensions, directory_path, reverse_scrolling=False, line_spacing=1.4)

Bases: dipy.viz.ui.UI

A menu to select files in the current folder.

Can go to new folder, previous folder and select a file and keep it in a variable.

Attributes

n_text_actors: int The number of text actors. Calculated dynamically.
selected_file: string Current selected file.
text_item_list: list(FileSelectMenuText2D) List of FileSelectMenuText2Ds - both visible and invisible.
window_offset: int Used for scrolling. Tells you the index of the first visible FileSelectMenuText2D object.
size: (float, float) The size of the system (x, y) in pixels.
font_size: int The font size in pixels.
line_spacing: float Distance between menu text items in pixels.
parent_ui: UI The UI component this object belongs to.
extensions: list(string) List of extensions to be shown as files.

Methods

add_callback(prop, event_type, callback[, ...]) Adds a callback to a specific event for this UI component.
add_to_renderer(ren)
build_actors(position) Builds the number of text actors that will fit in the given size.
down_button_callback(i_ren, obj, ...) Pressing down button scrolls down in the menu.
fill_text_actors() Fills file/folder names to text actors.
get_actors() Returns the actors that compose this UI component.
get_all_file_names() Gets file and directory names.
get_directory_names() Re-allots file names to the text actors.
get_file_names() Re-allots file names to the text actors.
handle_events(actor)
key_press_callback(i_ren, obj, self)
left_button_click_callback(i_ren, obj, self)
left_button_release_callback(i_ren, obj, self)
mouse_move_callback(i_ren, obj, self)
right_button_click_callback(i_ren, obj, self)
right_button_release_callback(i_ren, obj, self)
select_file(file_name) Changes the selected file name.
set_center(position) Sets the elements center.
set_visibility(visibility) Sets visibility of this UI component and all its sub-components.
up_button_callback(i_ren, obj, file_select_menu) Pressing up button scrolls up in the menu.
__init__(size, font_size, position, parent, extensions, directory_path, reverse_scrolling=False, line_spacing=1.4)
Parameters:

size: (float, float)

The size of the system (x, y) in pixels.

font_size: int

The font size in pixels.

parent: :class:`UI`

The UI component this object belongs to. This will be useful when this UI element is used as a part of other UI elements, like a file save dialog.

position: (float, float)

The initial position (x, y) in pixels.

reverse_scrolling: {True, False}

If True, scrolling up will move the list of files down.

line_spacing: float

Distance between menu text items in pixels.

extensions: list(string)

List of extensions to be shown as files.

directory_path: string

Path of the directory where this dialog should open. Example: os.getcwd()

add_to_renderer(ren)
build_actors(position)

Builds the number of text actors that will fit in the given size.

Allots them positions in the panel, which is only there to allot positions, otherwise the panel itself is invisible.

Parameters:

position: (float, float)

Position of the panel (x, y) in pixels.

static down_button_callback(i_ren, obj, file_select_menu)

Pressing down button scrolls down in the menu.

Parameters:

i_ren: :class:`CustomInteractorStyle`

obj: :class:`vtkActor`

The picked actor

file_select_menu: :class:`FileSelectMenu2D`

fill_text_actors()

Fills file/folder names to text actors.

The list is truncated if the number of file/folder names is greater than the available number of text actors.

get_actors()

Returns the actors that compose this UI component.

get_all_file_names()

Gets file and directory names.

Returns:

all_file_names: list(string)

List of all file and directory names as string.

get_directory_names()

Re-allots file names to the text actors.

Uses FileSelectMenuText2D for selecting files and folders.

Returns:

directory_names: list(string)

List of all directory names as string.

get_file_names()

Re-allots file names to the text actors.

Uses FileSelectMenuText2D for selecting files and folders.

Returns:

file_names: list(string)

List of all file names as string.

handle_events(actor)
select_file(file_name)

Changes the selected file name.

Parameters:

file_name: string

Name of the file.

set_center(position)

Sets the elements center.

Parameters:

position: (float, float)

New position (x, y) in pixels.

static up_button_callback(i_ren, obj, file_select_menu)

Pressing up button scrolls up in the menu.

Parameters:

i_ren: :class:`CustomInteractorStyle`

obj: :class:`vtkActor`

The picked actor

file_select_menu: :class:`FileSelectMenu2D`

FileSelectMenuText2D

class dipy.viz.ui.FileSelectMenuText2D(font_size, position, file_select)

Bases: dipy.viz.ui.UI

The text to select folder in a file select menu.

Provides a callback to change the directory.

Attributes

file_name: string The name of the file the text is displaying.
file_type: string Whether the file is a file or directory.
file_select: FileSelect2D The FileSelectMenu2D reference this text belongs to.

Methods

add_callback(prop, event_type, callback[, ...]) Adds a callback to a specific event for this UI component.
add_to_renderer(ren) Allows UI objects to add their own props to the renderer.
build_actor(position[, text, color, ...]) Builds a text actor.
get_actors() Returns the actors that compose this UI component.
handle_events(actor)
key_press_callback(i_ren, obj, self)
left_button_click_callback(i_ren, obj, self)
left_button_clicked(i_ren, obj, file_select_text) A callback to handle left click for this UI element.
left_button_release_callback(i_ren, obj, self)
mark_selected() Changes the background color of the actor.
mouse_move_callback(i_ren, obj, self)
right_button_click_callback(i_ren, obj, self)
right_button_release_callback(i_ren, obj, self)
set_attributes(file_name, file_type) Set attributes (file name and type) of this component.
set_center(position) Sets the text center to position.
set_visibility(visibility) Sets visibility of this UI component and all its sub-components.
__init__(font_size, position, file_select)
Parameters:

font_size: int

The font size of the text in pixels.

position: (float, float)

Absolute text position (x, y) in pixels.

file_select: :class:`FileSelect2D`

The FileSelectMenu2D reference this text belongs to.

build_actor(position, text='Text', color=(1, 1, 1), font_family='Arial', justification='left', bold=False, italic=False, shadow=False, font_size='14')

Builds a text actor.

Parameters:

text: string

The initial text while building the actor.

position: (float, float)

The text position (x, y) in pixels.

color: (float, float, float)

Values must be between 0-1 (RGB).

font_family: string

Currently only supports Arial.

justification: string

Text justification - left, right or center.

bold: bool

Whether or not the text is bold.

italic: bool

Whether or not the text is italicized.

shadow: bool

Whether or not the text has shadow.

font_size: int

The font size of the text in pixels.

Returns:

text_actor: TextBlock2D

The base text actor.

get_actors()

Returns the actors that compose this UI component.

static left_button_clicked(i_ren, obj, file_select_text)

A callback to handle left click for this UI element.

Parameters:

i_ren: :class:`CustomInteractorStyle`

obj: :class:`vtkActor`

The picked actor

file_select_text: :class:`FileSelectMenuText2D`

mark_selected()

Changes the background color of the actor.

set_attributes(file_name, file_type)

Set attributes (file name and type) of this component.

This function is for use by a FileSelectMenu2D to set the current file_name and file_type for this FileSelectMenuText2D component.

Parameters:

file_name: string

The name of the file.

file_type: string

File type = directory or file.

set_center(position)

Sets the text center to position.

Parameters:

position: (float, float)

The new position (x, y) in pixels.

LineSlider2D

class dipy.viz.ui.LineSlider2D(line_width=5, inner_radius=0, outer_radius=10, center=(450, 300), length=200, initial_value=50, min_value=0, max_value=100, text_size=16, text_template='{value:.1f} ({ratio:.0%})')

Bases: dipy.viz.ui.UI

A 2D Line Slider.

A sliding ring on a line with a percentage indicator.

Currently supports: - A disk on a line (a thin rectangle). - Setting disk position.

Attributes

line_width (int) Width of the line on which the disk will slide.
inner_radius (int) Inner radius of the disk (ring).
outer_radius (int) Outer radius of the disk.
center ((float, float)) Center of the slider.
length (int) Length of the slider.
slider_line (vtkActor) The line on which the slider disk moves.
slider_disk (vtkActor) The moving slider disk.
text (TextBlock2D) The text that shows percentage.

Methods

add_callback(prop, event_type, callback[, ...]) Adds a callback to a specific event for this UI component.
add_to_renderer(ren) Allows UI objects to add their own props to the renderer.
build_actors(inner_radius, outer_radius, ...) Builds required actors.
disk_move_callback(i_ren, obj, slider) Actual disk movement.
disk_press_callback(i_ren, obj, slider) Only need to grab the focus.
format_text() Returns formatted text to display along the slider.
get_actors() Returns the actors that compose this UI component.
handle_events(actor) Handle all events for the LineSlider.
key_press_callback(i_ren, obj, self)
left_button_click_callback(i_ren, obj, self)
left_button_release_callback(i_ren, obj, self)
line_click_callback(i_ren, obj, slider) Update disk position and grab the focus.
mouse_move_callback(i_ren, obj, self)
right_button_click_callback(i_ren, obj, self)
right_button_release_callback(i_ren, obj, self)
set_center(position) Sets the center of the slider to position.
set_position(position) Sets the disk’s position.
set_visibility(visibility) Sets visibility of this UI component and all its sub-components.
update() Updates the slider.
__init__(line_width=5, inner_radius=0, outer_radius=10, center=(450, 300), length=200, initial_value=50, min_value=0, max_value=100, text_size=16, text_template='{value:.1f} ({ratio:.0%})')
Parameters:

line_width : int

Width of the line on which the disk will slide.

inner_radius : int

Inner radius of the disk (ring).

outer_radius : int

Outer radius of the disk.

center : (float, float)

Center of the slider.

length : int

Length of the slider.

initial_value : float

Initial value of the slider.

min_value : float

Minimum value of the slider.

max_value : float

Maximum value of the slider.

text_size : int

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

text_template : str, callable

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.

build_actors(inner_radius, outer_radius, text_size)

Builds required actors.

Parameters:

inner_radius: int

The inner radius of the sliding disk.

outer_radius: int

The outer radius of the sliding disk.

text_size: int

Size of the text that displays percentage.

static disk_move_callback(i_ren, obj, slider)

Actual disk movement.

Parameters:

i_ren : CustomInteractorStyle

obj : vtkActor

The picked actor

slider : LineSlider2D

static disk_press_callback(i_ren, obj, slider)

Only need to grab the focus.

Parameters:

i_ren : CustomInteractorStyle

obj : vtkActor

The picked actor

slider : LineSlider2D

format_text()

Returns formatted text to display along the slider.

get_actors()

Returns the actors that compose this UI component.

handle_events(actor)

Handle all events for the LineSlider. Base method needs to be overridden due to multiple actors.

static line_click_callback(i_ren, obj, slider)

Update disk position and grab the focus.

Parameters:

i_ren : CustomInteractorStyle

obj : vtkActor

The picked actor

slider : LineSlider2D

ratio
set_center(position)

Sets the center of the slider to position.

Parameters:

position : (float, float)

The new center of the whole slider (x, y).

set_position(position)

Sets the disk’s position.

Parameters:

position : (float, float)

The absolute position of the disk (x, y).

update()

Updates the slider.

value

Panel2D

class dipy.viz.ui.Panel2D(center, size, color=(0.1, 0.1, 0.1), opacity=0.7, align='left')

Bases: dipy.viz.ui.UI

A 2D UI Panel.

Can contain one or more UI elements.

Attributes

center ((float, float)) The center of the panel (x, y).
size ((float, float)) The size of the panel (width, height) in pixels.
alignment ([left, right]) Alignment of the panel with respect to the overall screen.

Methods

add_callback(prop, event_type, callback[, ...]) Adds a callback to a specific event for this UI component.
add_element(element, position_type, position) Adds an element to the panel.
add_to_renderer(ren) Allows UI objects to add their own props to the renderer.
get_actors() Returns the panel actor.
handle_events(actor)
key_press_callback(i_ren, obj, self)
left_button_click_callback(i_ren, obj, self)
left_button_dragged(i_ren, obj, panel2d_object)
left_button_pressed(i_ren, obj, panel2d_object)
left_button_release_callback(i_ren, obj, self)
mouse_move_callback(i_ren, obj, self)
re_align(window_size_change) Re-organises the elements in case the window size is changed.
right_button_click_callback(i_ren, obj, self)
right_button_release_callback(i_ren, obj, self)
set_center(position) Sets the panel center to position.
set_visibility(visibility) Sets visibility of this UI component and all its sub-components.
__init__(center, size, color=(0.1, 0.1, 0.1), opacity=0.7, align='left')
Parameters:

center : (float, float)

The center of the panel (x, y).

size : (float, float)

The size of the panel (width, height) in pixels.

color : (float, float, float)

Must take values in [0, 1].

opacity : float

Must take values in [0, 1].

align : [left, right]

Alignment of the panel with respect to the overall screen.

add_element(element, position_type, position)

Adds an element to the panel.

The center of the rectangular panel is its bottom lower position.

Parameters:

element : UI

The UI item to be added.

position_type: string

‘absolute’ or ‘relative’

position : (float, float)

Absolute for absolute and relative for relative

add_to_renderer(ren)

Allows UI objects to add their own props to the renderer.

Here, we add only call add_to_renderer for the additional components.

Parameters:ren : renderer
get_actors()

Returns the panel actor.

static left_button_dragged(i_ren, obj, panel2d_object)
static left_button_pressed(i_ren, obj, panel2d_object)
re_align(window_size_change)

Re-organises the elements in case the window size is changed.

Parameters:

window_size_change : (int, int)

New window size (width, height) in pixels.

set_center(position)

Sets the panel center to position.

The center of the rectangular panel is its bottom lower position.

Parameters:

position : (float, float)

The new center of the panel (x, y).

Rectangle2D

class dipy.viz.ui.Rectangle2D(size, center=(0, 0), color=(1, 1, 1), opacity=1.0)

Bases: dipy.viz.ui.UI

A 2D rectangle sub-classed from UI. Uses vtkPolygon.

Attributes

size ((float, float)) The size of the rectangle (height, width) in pixels.

Methods

add_callback(prop, event_type, callback[, ...]) Adds a callback to a specific event for this UI component.
add_to_renderer(ren) Allows UI objects to add their own props to the renderer.
build_actor(size) Builds the text actor.
get_actors() Returns the actors that compose this UI component.
handle_events(actor)
key_press_callback(i_ren, obj, self)
left_button_click_callback(i_ren, obj, self)
left_button_release_callback(i_ren, obj, self)
mouse_move_callback(i_ren, obj, self)
right_button_click_callback(i_ren, obj, self)
right_button_release_callback(i_ren, obj, self)
set_center(position) Sets the center to position.
set_position(position)
set_visibility(visibility) Sets visibility of this UI component and all its sub-components.
__init__(size, center=(0, 0), color=(1, 1, 1), opacity=1.0)

Initializes a rectangle.

Parameters:

size : (float, float)

The size of the rectangle (height, width) in pixels.

center : (float, float)

The center of the rectangle (x, y).

color : (float, float, float)

Must take values in [0, 1].

opacity : float

Must take values in [0, 1].

build_actor(size)

Builds the text actor.

Parameters:

size : (float, float)

The size of the rectangle (height, width) in pixels.

Returns:

vtkActor2D

color

Gets the rectangle’s color.

get_actors()

Returns the actors that compose this UI component.

opacity

Gets the rectangle’s opacity.

position

Gets text actor position.

Returns:

(float, float)

The current actor position. (x, y) in pixels.

set_center(position)

Sets the center to position.

Parameters:

position : (float, float)

The new center of the rectangle (x, y).

set_position(position)

TextBlock2D

class dipy.viz.ui.TextBlock2D(text='Text Block', font_size=18, font_family='Arial', justification='left', vertical_justification='bottom', bold=False, italic=False, shadow=False, color=(1, 1, 1), bg_color=None, position=(0, 0))

Bases: dipy.viz.ui.UI

Wraps over the default vtkTextActor and helps setting the text.

Contains member functions for text formatting.

Attributes

message Gets message from the text.
position Gets text actor position.
color Gets text color.
font_size Gets text font size.
font_family Gets font family.
justification Gets text justification.
vertical_justification Gets text vertical justification.
bold Returns whether the text is bold.
italic Returns whether the text is italicised.
shadow Returns whether the text has shadow.
actor (vtkTextActor) The text actor.
bg_color ((float, float, float)) RGB: Values must be between 0-1.

Methods

add_callback(prop, event_type, callback[, ...]) Adds a callback to a specific event for this UI component.
add_to_renderer(ren) Allows UI objects to add their own props to the renderer.
get_actor() Returns the actor composing this element.
get_actors() Returns the actors that compose this UI component.
handle_events(actor)
key_press_callback(i_ren, obj, self)
left_button_click_callback(i_ren, obj, self)
left_button_release_callback(i_ren, obj, self)
mouse_move_callback(i_ren, obj, self)
right_button_click_callback(i_ren, obj, self)
right_button_release_callback(i_ren, obj, self)
set_center(position) Sets the text center to position.
set_visibility(visibility) Sets visibility of this UI component and all its sub-components.
__init__(text='Text Block', font_size=18, font_family='Arial', justification='left', vertical_justification='bottom', bold=False, italic=False, shadow=False, color=(1, 1, 1), bg_color=None, position=(0, 0))
Parameters:

text : str

The initial text while building the actor.

position : (float, float)

(x, y) in pixels.

color : (float, float, float)

RGB: Values must be between 0-1.

bg_color : (float, float, float)

RGB: Values must be between 0-1.

font_size : int

Size of the text font.

font_family : str

Currently only supports Arial.

justification : str

left, right or center.

vertical_justification : str

bottom, middle or top.

bold : bool

Makes text bold.

italic : bool

Makes text italicised.

shadow : bool

Adds text shadow.

background_color

Gets background color.

Returns:

(float, float, float) or None

If None, there no background color. Otherwise, background color in RGB.

bold

Returns whether the text is bold.

Returns:

bool

Text is bold if True.

color

Gets text color.

Returns:

(float, float, float)

Returns text color in RGB.

font_family

Gets font family.

Returns:

str

Text font family.

font_size

Gets text font size.

Returns:

int

Text font size.

get_actor()

Returns the actor composing this element.

Returns:

vtkTextActor

The actor composing this class.

get_actors()

Returns the actors that compose this UI component.

italic

Returns whether the text is italicised.

Returns:

bool

Text is italicised if True.

justification

Gets text justification.

Returns:

str

Text justification.

message

Gets message from the text.

Returns:

str

The current text message.

position

Gets text actor position.

Returns:

(float, float)

The current actor position. (x, y) in pixels.

set_center(position)

Sets the text center to position.

Parameters:position : (float, float)
shadow

Returns whether the text has shadow.

Returns:

bool

Text is shadowed if True.

vertical_justification

Gets text vertical justification.

Returns:

str

Text vertical justification.

TextBox2D

class dipy.viz.ui.TextBox2D(width, height, text='Enter Text', position=(100, 10), color=(0, 0, 0), font_size=18, font_family='Arial', justification='left', bold=False, italic=False, shadow=False)

Bases: dipy.viz.ui.UI

An editable 2D text box that behaves as a UI component.

Currently supports: - Basic text editing. - Cursor movements. - Single and multi-line text boxes. - Pre text formatting (text needs to be formatted beforehand).

Attributes

text (str) The current text state.
actor (vtkActor2d) The text actor.
width (int) The number of characters in a single line of text.
height (int) The number of lines in the textbox.
window_left (int) Left limit of visible text in the textbox.
window_right (int) Right limit of visible text in the textbox.
caret_pos (int) Position of the caret in the text.
init (bool) Flag which says whether the textbox has just been initialized.

Methods

add_callback(prop, event_type, callback[, ...]) Adds a callback to a specific event for this UI component.
add_character(character) Inserts a character into the text and moves window and caret accordingly.
add_to_renderer(ren) Allows UI objects to add their own props to the renderer.
build_actor(text, position, color, ...) Builds a text actor.
edit_mode() Turns on edit mode.
get_actors() Returns the actors that compose this UI component.
handle_character(character) Main driving function that handles button events.
handle_events(actor)
key_press(i_ren, obj, textbox_object) Key press handler for textbox
key_press_callback(i_ren, obj, self)
left_button_click_callback(i_ren, obj, self)
left_button_press(i_ren, obj, textbox_object) Left button press handler for textbox
left_button_release_callback(i_ren, obj, self)
left_move_left() Moves left boundary of the text window left-wards.
left_move_right() Moves left boundary of the text window right-wards.
mouse_move_callback(i_ren, obj, self)
move_caret_left() Moves the caret towards left.
move_caret_right() Moves the caret towards right.
move_left() Handles left button press.
move_right() Handles right button press.
remove_character() Removes a character from the text and moves window and caret accordingly.
render_text([show_caret]) Renders text after processing.
right_button_click_callback(i_ren, obj, self)
right_button_release_callback(i_ren, obj, self)
right_move_left() Moves right boundary of the text window left-wards.
right_move_right() Moves right boundary of the text window right-wards.
set_center(position) Sets the text center to position.
set_message(message) Set custom text to textbox.
set_visibility(visibility) Sets visibility of this UI component and all its sub-components.
showable_text(show_caret) Chops out text to be shown on the screen.
width_set_text(text) Adds newlines to text where necessary.
__init__(width, height, text='Enter Text', position=(100, 10), color=(0, 0, 0), font_size=18, font_family='Arial', justification='left', bold=False, italic=False, shadow=False)
Parameters:

width : int

The number of characters in a single line of text.

height : int

The number of lines in the textbox.

text : str

The initial text while building the actor.

position : (float, float)

(x, y) in pixels.

color : (float, float, float)

RGB: Values must be between 0-1.

font_size : int

Size of the text font.

font_family : str

Currently only supports Arial.

justification : str

left, right or center.

bold : bool

Makes text bold.

italic : bool

Makes text italicised.

shadow : bool

Adds text shadow.

add_character(character)

Inserts a character into the text and moves window and caret accordingly.

Parameters:character : str
build_actor(text, position, color, font_size, font_family, justification, bold, italic, shadow)

Builds a text actor.

Parameters:

text : str

The initial text while building the actor.

position : (float, float)

(x, y) in pixels.

color : (float, float, float)

RGB: Values must be between 0-1.

font_size : int

Size of the text font.

font_family : str

Currently only supports Arial.

justification : str

left, right or center.

bold : bool

Makes text bold.

italic : bool

Makes text italicised.

shadow : bool

Adds text shadow.

Returns:

TextBlock2D

edit_mode()

Turns on edit mode.

get_actors()

Returns the actors that compose this UI component.

handle_character(character)

Main driving function that handles button events.

# TODO: Need to handle all kinds of characters like !, +, etc.

Parameters:character : str
static key_press(i_ren, obj, textbox_object)

Key press handler for textbox

Parameters:

i_ren: :class:`CustomInteractorStyle`

obj: :class:`vtkActor`

The picked actor

textbox_object: :class:`TextBox2D`

static left_button_press(i_ren, obj, textbox_object)

Left button press handler for textbox

Parameters:

i_ren: :class:`CustomInteractorStyle`

obj: :class:`vtkActor`

The picked actor

textbox_object: :class:`TextBox2D`

left_move_left()

Moves left boundary of the text window left-wards.

left_move_right()

Moves left boundary of the text window right-wards.

move_caret_left()

Moves the caret towards left.

move_caret_right()

Moves the caret towards right.

move_left()

Handles left button press.

move_right()

Handles right button press.

remove_character()

Removes a character from the text and moves window and caret accordingly.

render_text(show_caret=True)

Renders text after processing.

Parameters:

show_caret : bool

Whether or not to show the caret.

right_move_left()

Moves right boundary of the text window left-wards.

right_move_right()

Moves right boundary of the text window right-wards.

set_center(position)

Sets the text center to position.

Parameters:position : (float, float)
set_message(message)

Set custom text to textbox.

Parameters:

message: str

The custom message to be set.

showable_text(show_caret)

Chops out text to be shown on the screen.

Parameters:

show_caret : bool

Whether or not to show the caret.

width_set_text(text)

Adds newlines to text where necessary.

This is needed for multi-line text boxes.

Parameters:

text : str

The final text to be formatted.

Returns:

str

A multi line formatted text.

UI

class dipy.viz.ui.UI

Bases: object

An umbrella class for all UI elements.

While adding UI elements to the renderer, we go over all the sub-elements that come with it and add those to the renderer automatically.

Attributes

ui_param (object) This is an attribute that can be passed to the UI object by the interactor.
ui_list (list of UI) This is used when there are more than one UI elements inside a UI element. They’re all automatically added to the renderer at the same time as this one.
parent_ui: UI Reference to the parent UI element. This is useful of there is a parent UI element and its reference needs to be passed down to the child.
on_left_mouse_button_pressed: function Callback function for when the left mouse button is pressed.
on_left_mouse_button_released: function Callback function for when the left mouse button is released.
on_left_mouse_button_clicked: function Callback function for when clicked using the left mouse button (i.e. pressed -> released).
on_left_mouse_button_dragged: function Callback function for when dragging using the left mouse button.
on_right_mouse_button_pressed: function Callback function for when the right mouse button is pressed.
on_right_mouse_button_released: function Callback function for when the right mouse button is released.
on_right_mouse_button_clicked: function Callback function for when clicking using the right mouse button (i.e. pressed -> released).
on_right_mouse_button_dragged: function Callback function for when dragging using the right mouse button.

Methods

add_callback(prop, event_type, callback[, ...]) Adds a callback to a specific event for this UI component.
add_to_renderer(ren) Allows UI objects to add their own props to the renderer.
get_actors() Returns the actors that compose this UI component.
handle_events(actor)
key_press_callback(i_ren, obj, self)
left_button_click_callback(i_ren, obj, self)
left_button_release_callback(i_ren, obj, self)
mouse_move_callback(i_ren, obj, self)
right_button_click_callback(i_ren, obj, self)
right_button_release_callback(i_ren, obj, self)
set_center(position) Sets the center of the UI component
set_visibility(visibility) Sets visibility of this UI component and all its sub-components.
__init__()
add_callback(prop, event_type, callback, priority=0)

Adds a callback to a specific event for this UI component.

Parameters:

prop : vtkProp

The prop on which is callback is to be added.

event_type : string

The event code.

callback : function

The callback function.

priority : int

Higher number is higher priority.

add_to_renderer(ren)

Allows UI objects to add their own props to the renderer.

Parameters:ren : renderer
get_actors()

Returns the actors that compose this UI component.

handle_events(actor)
static key_press_callback(i_ren, obj, self)
static left_button_click_callback(i_ren, obj, self)
static left_button_release_callback(i_ren, obj, self)
static mouse_move_callback(i_ren, obj, self)
static right_button_click_callback(i_ren, obj, self)
static right_button_release_callback(i_ren, obj, self)
set_center(position)

Sets the center of the UI component

Parameters:

position : (float, float)

These are the x and y coordinates respectively, with the origin at the bottom left.

set_visibility(visibility)

Sets visibility of this UI component and all its sub-components.

optional_package

dipy.viz.ui.optional_package(name, trip_msg=None)

Return package-like thing and module setup for package name

Parameters:

name : str

package name

trip_msg : None or str

message to give when someone tries to use the return package, but we could not import it, and have returned a TripWire object instead. Default message if None.

Returns:

pkg_like : module or TripWire instance

If we can import the package, return it. Otherwise return an object raising an error when accessed

have_pkg : bool

True if import for package was successful, false otherwise

module_setup : function

callable usually set as setup_module in calling namespace, to allow skipping tests.

read_viz_icons

dipy.viz.ui.read_viz_icons(style='icomoon', fname='infinity.png')

Read specific icon from specific style

Parameters:

style : str

Current icon style. Default is icomoon.

fname : str

Filename of icon. This should be found in folder HOME/.dipy/style/. Default is infinity.png.

Returns:

path : str

Complete path of icon.

setup_module

dipy.viz.ui.setup_module()

warn

dipy.viz.ui.warn()

Issue a warning, or maybe ignore it or raise an exception.

get_actor_from_polydata

dipy.viz.utils.get_actor_from_polydata(polydata)

get vtkActor from a vtkPolyData

Parameters:polydata : vtkPolyData
Returns:actor : vtkActor

get_actor_from_polymapper

dipy.viz.utils.get_actor_from_polymapper(poly_mapper)

get vtkActor from a vtkPolyDataMapper

Parameters:poly_mapper : vtkPolyDataMapper
Returns:actor : vtkActor

get_polydata_colors

dipy.viz.utils.get_polydata_colors(polydata)

get points color (ndarrays Nx3 int) from a vtk polydata

Parameters:

polydata : vtkPolyData

Returns:

output : array (N, 3)

Colors. None if no normals in the vtk polydata.

get_polydata_lines

dipy.viz.utils.get_polydata_lines(line_polydata)

vtk polydata to a list of lines ndarrays

Parameters:

line_polydata : vtkPolyData

Returns:

lines : list

List of N curves represented as 2D ndarrays

get_polydata_normals

dipy.viz.utils.get_polydata_normals(polydata)

get vertices normal (ndarrays Nx3 int) from a vtk polydata

Parameters:

polydata : vtkPolyData

Returns:

output : array (N, 3)

Normals, represented as 2D ndarrays (Nx3). None if there are no normals in the vtk polydata.

get_polydata_triangles

dipy.viz.utils.get_polydata_triangles(polydata)

get triangles (ndarrays Nx3 int) from a vtk polydata

Parameters:

polydata : vtkPolyData

Returns:

output : array (N, 3)

triangles

get_polydata_vertices

dipy.viz.utils.get_polydata_vertices(polydata)

get vertices (ndarrays Nx3 int) from a vtk polydata

Parameters:

polydata : vtkPolyData

Returns:

output : array (N, 3)

points, represented as 2D ndarrays

get_polymapper_from_polydata

dipy.viz.utils.get_polymapper_from_polydata(polydata)

get vtkPolyDataMapper from a vtkPolyData

Parameters:polydata : vtkPolyData
Returns:poly_mapper : vtkPolyDataMapper

line_colors

dipy.viz.utils.line_colors(streamlines, cmap='rgb_standard')

Create colors for streamlines to be used in actor.line

Parameters:

streamlines : sequence of ndarrays

cmap : (‘rgb_standard’, ‘boys_standard’)

Returns:

colors : ndarray

lines_to_vtk_polydata

dipy.viz.utils.lines_to_vtk_polydata(lines, colors=None)

Create a vtkPolyData with lines and colors

Parameters:

lines : list

list of N curves represented as 2D ndarrays

colors : array (N, 3), list of arrays, tuple (3,), array (K,), None

If None then a standard orientation colormap is used for every line. If one tuple of color is used. Then all streamlines will have the same colour. If an array (N, 3) is given, where N is equal to the number of lines. Then every line is coloured with a different RGB color. If a list of RGB arrays is given then every point of every line takes a different color. If an array (K, 3) is given, where K is the number of points of all lines then every point is colored with a different RGB color. If an array (K,) is given, where K is the number of points of all lines then these are considered as the values to be used by the colormap. If an array (L,) is given, where L is the number of streamlines then these are considered as the values to be used by the colormap per streamline. If an array (X, Y, Z) or (X, Y, Z, 3) is given then the values for the colormap are interpolated automatically using trilinear interpolation.

Returns:

poly_data : vtkPolyData

is_colormap : bool, true if the input color array was a colormap

map_coordinates

dipy.viz.utils.map_coordinates(input, coordinates, output=None, order=3, mode='constant', cval=0.0, prefilter=True)

Map the input array to new coordinates by interpolation.

The array of coordinates is used to find, for each point in the output, the corresponding coordinates in the input. The value of the input at those coordinates is determined by spline interpolation of the requested order.

The shape of the output is derived from that of the coordinate array by dropping the first axis. The values of the array along the first axis are the coordinates in the input array at which the output value is found.

Parameters:

input : ndarray

The input array.

coordinates : array_like

The coordinates at which input is evaluated.

output : ndarray or dtype, optional

The array in which to place the output, or the dtype of the returned array.

order : int, optional

The order of the spline interpolation, default is 3. The order has to be in the range 0-5.

mode : str, optional

Points outside the boundaries of the input are filled according to the given mode (‘constant’, ‘nearest’, ‘reflect’, ‘mirror’ or ‘wrap’). Default is ‘constant’.

cval : scalar, optional

Value used for points outside the boundaries of the input if mode='constant'. Default is 0.0

prefilter : bool, optional

The parameter prefilter determines if the input is pre-filtered with spline_filter before interpolation (necessary for spline interpolation of order > 1). If False, it is assumed that the input is already filtered. Default is True.

Returns:

map_coordinates : ndarray

The result of transforming the input. The shape of the output is derived from that of coordinates by dropping the first axis.

See also

spline_filter, geometric_transform, scipy.interpolate

Examples

>>> from scipy import ndimage
>>> a = np.arange(12.).reshape((4, 3))
>>> a
array([[  0.,   1.,   2.],
       [  3.,   4.,   5.],
       [  6.,   7.,   8.],
       [  9.,  10.,  11.]])
>>> ndimage.map_coordinates(a, [[0.5, 2], [0.5, 1]], order=1)
array([ 2.,  7.])

Above, the interpolated value of a[0.5, 0.5] gives output[0], while a[2, 1] is output[1].

>>> inds = np.array([[0.5, 2], [0.5, 4]])
>>> ndimage.map_coordinates(a, inds, order=1, cval=-33.3)
array([  2. , -33.3])
>>> ndimage.map_coordinates(a, inds, order=1, mode='nearest')
array([ 2.,  8.])
>>> ndimage.map_coordinates(a, inds, order=1, cval=0, output=bool)
array([ True, False], dtype=bool)

map_coordinates_3d_4d

dipy.viz.utils.map_coordinates_3d_4d(input_array, indices)

Evaluate the input_array data at the given indices using trilinear interpolation

Parameters:

input_array : ndarray,

3D or 4D array

indices : ndarray

Returns:

output : ndarray

1D or 2D array

numpy_to_vtk_colors

dipy.viz.utils.numpy_to_vtk_colors(colors)

Numpy color array to a vtk color array

Parameters:colors: ndarray
Returns:vtk_colors : vtkDataArray

Notes

If colors are not already in UNSIGNED_CHAR you may need to multiply by 255.

Examples

>>> import numpy as np
>>> from dipy.viz.utils import numpy_to_vtk_colors
>>> rgb_array = np.random.rand(100, 3)
>>> vtk_colors = numpy_to_vtk_colors(255 * rgb_array)

numpy_to_vtk_points

dipy.viz.utils.numpy_to_vtk_points(points)

Numpy points array to a vtk points array

Parameters:points : ndarray
Returns:vtk_points : vtkPoints()

optional_package

dipy.viz.utils.optional_package(name, trip_msg=None)

Return package-like thing and module setup for package name

Parameters:

name : str

package name

trip_msg : None or str

message to give when someone tries to use the return package, but we could not import it, and have returned a TripWire object instead. Default message if None.

Returns:

pkg_like : module or TripWire instance

If we can import the package, return it. Otherwise return an object raising an error when accessed

have_pkg : bool

True if import for package was successful, false otherwise

module_setup : function

callable usually set as setup_module in calling namespace, to allow skipping tests.

set_input

dipy.viz.utils.set_input(vtk_object, inp)

Generic input function which takes into account VTK 5 or 6

Parameters:

vtk_object: vtk object

inp: vtkPolyData or vtkImageData or vtkAlgorithmOutput

Returns:

vtk_object

Notes

This can be used in the following way::
from dipy.viz.utils import set_input poly_mapper = set_input(vtk.vtkPolyDataMapper(), poly_data)

set_polydata_colors

dipy.viz.utils.set_polydata_colors(polydata, colors)

set polydata colors with a numpy array (ndarrays Nx3 int)

Parameters:

polydata : vtkPolyData

colors : colors, represented as 2D ndarrays (Nx3)

colors are uint8 [0,255] RGB for each points

set_polydata_normals

dipy.viz.utils.set_polydata_normals(polydata, normals)

set polydata normals with a numpy array (ndarrays Nx3 int)

Parameters:

polydata : vtkPolyData

normals : normals, represented as 2D ndarrays (Nx3) (one per vertex)

set_polydata_triangles

dipy.viz.utils.set_polydata_triangles(polydata, triangles)

set polydata triangles with a numpy array (ndarrays Nx3 int)

Parameters:

polydata : vtkPolyData

triangles : array (N, 3)

triangles, represented as 2D ndarrays (Nx3)

set_polydata_vertices

dipy.viz.utils.set_polydata_vertices(polydata, vertices)

set polydata vertices with a numpy array (ndarrays Nx3 int)

Parameters:

polydata : vtkPolyData

vertices : vertices, represented as 2D ndarrays (Nx3)

setup_module

dipy.viz.utils.setup_module()

update_polydata_normals

dipy.viz.utils.update_polydata_normals(polydata)

generate and update polydata normals

Parameters:polydata : vtkPolyData

button

dipy.viz.widget.button(iren, ren, callback, fname, right_normalized_pos=(0.98, 0.9), size=(50, 50))

A textured two state button widget

Parameters:

iren : vtkRenderWindowInteractor

Used to process events and handle them to the button. Can also be given by the attribute ShowManager.iren.

ren : vtkRenderer or Renderer

Used to update the slider’s position when the window changes. Can also be given by the ShowManager.ren attribute.

callback : function

Function that has at least obj and event as parameters. It will be called when the button is pressed.

fname : str

PNG file path of the icon used for the button.

right_normalized_pos : tuple

2d tuple holding the normalized right (X, Y) position of the slider.

size: tuple

2d tuple holding the size of the slider in pixels.

Returns:

button : ButtonWidget

This object inherits from vtkButtonWidget and has an additional method called place which allows to update the position of the slider if necessary. For example when the renderer size changes.

Notes

The button and slider widgets have similar positioning system. This enables the developers to create a HUD-like collections of buttons and sliders on the right side of the window that always stays in place when the dimensions of the window change.

button_display_coordinates

dipy.viz.widget.button_display_coordinates(renderer, normalized_display_position, size)

optional_package

dipy.viz.widget.optional_package(name, trip_msg=None)

Return package-like thing and module setup for package name

Parameters:

name : str

package name

trip_msg : None or str

message to give when someone tries to use the return package, but we could not import it, and have returned a TripWire object instead. Default message if None.

Returns:

pkg_like : module or TripWire instance

If we can import the package, return it. Otherwise return an object raising an error when accessed

have_pkg : bool

True if import for package was successful, false otherwise

module_setup : function

callable usually set as setup_module in calling namespace, to allow skipping tests.

setup_module

dipy.viz.widget.setup_module()

slider

dipy.viz.widget.slider(iren, ren, callback, min_value=0, max_value=255, value=125, label='Slider', right_normalized_pos=(0.9, 0.5), size=(50, 0), label_format='%0.0lf', color=(0.5, 0.5, 0.5), selected_color=(0.9, 0.2, 0.1))

A 2D slider widget

Parameters:

iren : vtkRenderWindowInteractor

Used to process events and handle them to the slider. Can also be given by the attribute ShowManager.iren.

ren : vtkRenderer or Renderer

Used to update the slider’s position when the window changes. Can also be given by the ShowManager.ren attribute.

callback : function

Function that has at least obj and event as parameters. It will be called when the slider’s bar has changed.

min_value : float

Minimum value of slider.

max_value : float

Maximum value of slider.

value :

Default value of slider.

label : str

Slider’s caption.

right_normalized_pos : tuple

2d tuple holding the normalized right (X, Y) position of the slider.

size: tuple

2d tuple holding the size of the slider in pixels.

label_format: str

Formating in which the slider’s value will appear for example “%0.2lf” allows for 2 decimal values.

Returns:

slider : SliderObject

This object inherits from vtkSliderWidget and has additional method called place which allows to update the position of the slider when for example the window is resized.

text

dipy.viz.widget.text(iren, ren, callback, message='DIPY', left_down_pos=(0.8, 0.5), right_top_pos=(0.9, 0.5), color=(1.0, 0.5, 0.0), opacity=1.0, border=False)

2D text that can be clicked and process events

Parameters:

iren : vtkRenderWindowInteractor

Used to process events and handle them to the button. Can also be given by the attribute ShowManager.iren.

ren : vtkRenderer or Renderer

Used to update the slider’s position when the window changes. Can also be given by the ShowManager.ren attribute.

callback : function

Function that has at least obj and event as parameters. It will be called when the button is pressed.

message : str

Message to be shown in the text widget

left_down_pos : tuple

Coordinates for left down corner of text. If float are provided, the normalized coordinate system is used, otherwise the coordinates represent pixel positions. Default is (0.8, 0.5).

right_top_pos : tuple

Coordinates for right top corner of text. If float are provided, the normalized coordinate system is used, otherwise the coordinates represent pixel positions. Default is (0.9, 0.5).

color : tuple

Foreground RGB color of text. Default is (1., .5, .0).

opacity : float

Takes values from 0 to 1. Default is 1.

border : bool

Show text border. Default is False.

Returns:

text : TextWidget

This object inherits from vtkTextWidget has an additional method called place which allows to update the position of the text if necessary.

CustomInteractorStyle

class dipy.viz.window.CustomInteractorStyle

Bases: vtkInteractionStylePython.vtkInteractorStyleUser

Manipulate the camera and interact with objects in the scene.

This interactor style allows the user to interactively manipulate (pan, rotate and zoom) the camera. It also allows the user to interact (click, scroll, etc.) with objects in the scene.

Several events handling methods from vtkInteractorStyleUser have been overloaded to allow the propagation of the events to the objects the user is interacting with.

In summary, while interacting with the scene, the mouse events are as follows: - Left mouse button: rotates the camera - Right mouse button: dollys the camera - Mouse wheel: dollys the camera - Middle mouse button: pans the camera

Methods

AddObserver(int, ...) C++: unsigned long AddObserver(const char *event,
AutoAdjustCameraClippingRangeOff(...) C++: void AutoAdjustCameraClippingRangeOff()
AutoAdjustCameraClippingRangeOn(...) C++: void AutoAdjustCameraClippingRangeOn()
BreakOnError() C++: static void BreakOnError() C++: static void BreakOnError()
ComputeDisplayToWorld(vtkRenderer, float, ...) Convenience methods for outside classes.
ComputeWorldToDisplay(vtkRenderer, float, ...) Convenience methods for outside classes.
DebugOff() C++: virtual void DebugOff() C++: virtual void DebugOff()
DebugOn() C++: virtual void DebugOn() C++: virtual void DebugOn()
DelegateTDxEvent(int, ...) C++: void DelegateTDxEvent(unsigned long event, void *calldata)
Dolly() C++: virtual void Dolly() C++: virtual void Dolly()
EnabledOff() C++: void EnabledOff() C++: void EnabledOff()
EnabledOn() C++: void EnabledOn() C++: void EnabledOn()
EndDolly() C++: virtual void EndDolly() C++: virtual void EndDolly()
EndPan() C++: virtual void EndPan() C++: virtual void EndPan()
EndRotate() C++: virtual void EndRotate() C++: virtual void EndRotate()
EndSpin() C++: virtual void EndSpin() C++: virtual void EndSpin()
EndTimer() C++: virtual void EndTimer() C++: virtual void EndTimer()
EndTwoPointer() C++: virtual void EndTwoPointer() C++: virtual void EndTwoPointer()
EndUniformScale(...) C++: virtual void EndUniformScale()
EndZoom() C++: virtual void EndZoom() C++: virtual void EndZoom()
FastDelete() C++: virtual void FastDelete() C++: virtual void FastDelete()
FindPokedRenderer(int, ...) C++: void FindPokedRenderer(int, int)
GetAddressAsString(...) C++: const char *GetAddressAsString()
GetAutoAdjustCameraClippingRange(...) C++: int GetAutoAdjustCameraClippingRange()
GetAutoAdjustCameraClippingRangeMaxValue(...) C++: int GetAutoAdjustCameraClippingRangeMaxValue()
GetAutoAdjustCameraClippingRangeMinValue(...) C++: int GetAutoAdjustCameraClippingRangeMinValue()
GetButton() -> int C++: int GetButton() C++: int GetButton()
GetChar() -> int C++: int GetChar() C++: int GetChar()
GetClassName(...) C++: const char *GetClassName()
GetCommand(...) C++: vtkCommand *GetCommand(unsigned long tag)
GetCtrlKey() -> int C++: int GetCtrlKey() C++: int GetCtrlKey()
GetCurrentRenderer(...) C++: vtkRenderer *GetCurrentRenderer()
GetDebug() -> bool C++: bool GetDebug() C++: bool GetDebug()
GetDefaultRenderer(...) C++: vtkRenderer *GetDefaultRenderer()
GetEnabled() -> int C++: int GetEnabled() C++: int GetEnabled()
GetGlobalWarningDisplay(...) C++: static int GetGlobalWarningDisplay()
GetHandleObservers(...) C++: int GetHandleObservers()
GetInteractor(...) C++: vtkRenderWindowInteractor *GetInteractor()
GetKeyPressActivation(...) C++: int GetKeyPressActivation()
GetKeyPressActivationValue(...) C++: char GetKeyPressActivationValue()
GetKeySym() -> string C++: char *GetKeySym() C++: char *GetKeySym()
GetLastPos() -> (int, int) C++: int *GetLastPos() C++: int *GetLastPos()
GetMTime(...) C++: virtual vtkMTimeType GetMTime()
GetMouseWheelMotionFactor(...) C++: double GetMouseWheelMotionFactor()
GetOldPos() -> (int, int) C++: int *GetOldPos() C++: int *GetOldPos()
GetPickColor() -> (float, float, ...) C++: double *GetPickColor()
GetPickingManaged(...) C++: bool GetPickingManaged()
GetPriority() -> float C++: float GetPriority() C++: float GetPriority()
GetPriorityMaxValue(...) C++: float GetPriorityMaxValue()
GetPriorityMinValue(...) C++: float GetPriorityMinValue()
GetReferenceCount(...) C++: int GetReferenceCount()
GetShiftKey() -> int C++: int GetShiftKey() C++: int GetShiftKey()
GetState() -> int C++: int GetState() C++: int GetState()
GetTDxStyle(...) C++: vtkTDxInteractorStyle *GetTDxStyle()
GetTimerDuration(...) C++: unsigned long GetTimerDuration()
GetTimerDurationMaxValue(...) C++: unsigned long GetTimerDurationMaxValue()
GetTimerDurationMinValue(...) C++: unsigned long GetTimerDurationMinValue()
GetUseTimers() -> int C++: int GetUseTimers() C++: int GetUseTimers()
GlobalWarningDisplayOff(...) C++: static void GlobalWarningDisplayOff()
GlobalWarningDisplayOn(...) C++: static void GlobalWarningDisplayOn()
GrabFocus(vtkCommand, ...) C++: void GrabFocus(vtkCommand *mouseEvents,
HandleObserversOff(...) C++: void HandleObserversOff()
HandleObserversOn() C++: void HandleObserversOn() C++: void HandleObserversOn()
HasObserver(int, ...) C++: int HasObserver(unsigned long event, vtkCommand *)
HighlightActor2D(...) C++: virtual void HighlightActor2D(vtkActor2D *actor2D)
HighlightProp(...) C++: virtual void HighlightProp(vtkProp *prop)
HighlightProp3D(...) C++: virtual void HighlightProp3D(vtkProp3D *prop3D)
InitializeObjectBase(...) C++: void InitializeObjectBase()
InvokeEvent(int, ...) C++: int InvokeEvent(unsigned long event, void *callData)
IsA(string) -> int C++: int IsA(const char *name) C++: int IsA(const char *name)
IsTypeOf(...) C++: static vtkTypeBool IsTypeOf(const char *type)
KeyPressActivationOff(...) C++: void KeyPressActivationOff()
KeyPressActivationOn(...) C++: void KeyPressActivationOn()
Modified() C++: virtual void Modified() C++: virtual void Modified()
NewInstance(...) C++: vtkInteractorStyleUser *NewInstance()
Off() C++: void Off() C++: void Off()
On() C++: void On() C++: void On()
OnChar() C++: virtual void OnChar() C++: virtual void OnChar()
OnConfigure() C++: virtual void OnConfigure() C++: virtual void OnConfigure()
OnEnter() C++: virtual void OnEnter() C++: virtual void OnEnter()
OnExpose() C++: virtual void OnExpose() C++: virtual void OnExpose()
OnKeyDown() C++: virtual void OnKeyDown() C++: virtual void OnKeyDown()
OnKeyPress() C++: virtual void OnKeyPress() C++: virtual void OnKeyPress()
OnKeyRelease() C++: virtual void OnKeyRelease() C++: virtual void OnKeyRelease()
OnKeyUp() C++: virtual void OnKeyUp() C++: virtual void OnKeyUp()
OnLeave() C++: virtual void OnLeave() C++: virtual void OnLeave()
OnLeftButtonDown(...) C++: virtual void OnLeftButtonDown()
OnLeftButtonUp(...) C++: virtual void OnLeftButtonUp()
OnLongTap() C++: virtual void OnLongTap() C++: virtual void OnLongTap()
OnMiddleButtonDown(...) C++: virtual void OnMiddleButtonDown()
OnMiddleButtonUp(...) C++: virtual void OnMiddleButtonUp()
OnMouseMove() C++: virtual void OnMouseMove() C++: virtual void OnMouseMove()
OnMouseWheelBackward(...) C++: virtual void OnMouseWheelBackward()
OnMouseWheelForward(...) C++: virtual void OnMouseWheelForward()
OnPan() C++: virtual void OnPan() C++: virtual void OnPan()
OnPinch() C++: virtual void OnPinch() C++: virtual void OnPinch()
OnRightButtonDown(...) C++: virtual void OnRightButtonDown()
OnRightButtonUp(...) C++: virtual void OnRightButtonUp()
OnRotate() C++: virtual void OnRotate() C++: virtual void OnRotate()
OnSwipe() C++: virtual void OnSwipe() C++: virtual void OnSwipe()
OnTap() C++: virtual void OnTap() C++: virtual void OnTap()
OnTimer() C++: virtual void OnTimer() C++: virtual void OnTimer()
Pan() C++: virtual void Pan() C++: virtual void Pan()
PickingManagedOff() C++: void PickingManagedOff() C++: void PickingManagedOff()
PickingManagedOn() C++: void PickingManagedOn() C++: void PickingManagedOn()
Register(...) C++: virtual void Register(vtkObjectBase *o)
ReleaseFocus() C++: void ReleaseFocus() C++: void ReleaseFocus()
RemoveAllObservers(...) C++: void RemoveAllObservers()
RemoveObserver(...) C++: void RemoveObserver(vtkCommand *)
RemoveObservers(int, ...) C++: void RemoveObservers(unsigned long event, vtkCommand *)
Rotate() C++: virtual void Rotate() C++: virtual void Rotate()
SafeDownCast(...) C++: vtkInteractorStyleUser SafeDownCast(vtkObject o)
SetAutoAdjustCameraClippingRange(...) C++: void SetAutoAdjustCameraClippingRange(int)
SetCurrentRenderer(...) C++: virtual void SetCurrentRenderer(vtkRenderer *)
SetDebug(bool) C++: void SetDebug(bool debugFlag) C++: void SetDebug(bool debugFlag)
SetDefaultRenderer(...) C++: virtual void SetDefaultRenderer(vtkRenderer *)
SetEnabled(int) C++: virtual void SetEnabled(int) C++: virtual void SetEnabled(int)
SetGlobalWarningDisplay(...) C++: static void SetGlobalWarningDisplay(int val)
SetHandleObservers(...) C++: void SetHandleObservers(int a)
SetInteractor(...)
SetKeyPressActivation(...) C++: void SetKeyPressActivation(int a)
SetKeyPressActivationValue(...) C++: void SetKeyPressActivationValue(char a)
SetMouseWheelMotionFactor(...) C++: void SetMouseWheelMotionFactor(double a)
SetPickColor(float, float, ...) C++: void SetPickColor(double, double, double)
SetPickingManaged(...) C++: void SetPickingManaged(bool a)
SetPriority(float) C++: void SetPriority(float) C++: void SetPriority(float)
SetReferenceCount(...) C++: void SetReferenceCount(int)
SetTDxStyle(...) C++: virtual void SetTDxStyle(vtkTDxInteractorStyle *tdxStyle)
SetTimerDuration(...) C++: void SetTimerDuration(unsigned long)
SetUseTimers(int) C++: void SetUseTimers(int a) C++: void SetUseTimers(int a)
Spin() C++: virtual void Spin() C++: virtual void Spin()
StartAnimate() C++: virtual void StartAnimate() C++: virtual void StartAnimate()
StartDolly() C++: virtual void StartDolly() C++: virtual void StartDolly()
StartPan() C++: virtual void StartPan() C++: virtual void StartPan()
StartRotate() C++: virtual void StartRotate() C++: virtual void StartRotate()
StartSpin() C++: virtual void StartSpin() C++: virtual void StartSpin()
StartState(...) C++: virtual void StartState(int newstate)
StartTimer() C++: virtual void StartTimer() C++: virtual void StartTimer()
StartTwoPointer(...) C++: virtual void StartTwoPointer()
StartUniformScale(...) C++: virtual void StartUniformScale()
StartZoom() C++: virtual void StartZoom() C++: virtual void StartZoom()
StopAnimate() C++: virtual void StopAnimate() C++: virtual void StopAnimate()
StopState() C++: virtual void StopState() C++: virtual void StopState()
UnRegister(...) C++: virtual void UnRegister(vtkObjectBase *o)
UniformScale() C++: virtual void UniformScale() C++: virtual void UniformScale()
UseTimersOff() C++: void UseTimersOff() C++: void UseTimersOff()
UseTimersOn() C++: void UseTimersOn() C++: void UseTimersOn()
Zoom() C++: virtual void Zoom() C++: virtual void Zoom()
add_active_prop(prop)
add_callback(prop, event_type, callback[, ...]) Adds a callback associated to a specific event for a VTK prop.
force_render() Causes the renderer to refresh.
get_prop_at_event_position() Returns the prop that lays at the event position.
on_char(obj, evt)
on_key_press(obj, evt)
on_key_release(obj, evt)
on_left_button_down(obj, evt)
on_left_button_up(obj, evt)
on_middle_button_down(obj, evt)
on_middle_button_up(obj, evt)
on_mouse_move(obj, evt)
on_mouse_wheel_backward(obj, evt)
on_mouse_wheel_forward(obj, evt)
on_right_button_down(obj, evt)
on_right_button_up(obj, evt)
propagate_event(evt, *props)
remove_active_prop(prop)
__init__()
SetInteractor(vtkRenderWindowInteractor) C++: virtual void SetInteractor( vtkRenderWindowInteractor *interactor)
add_active_prop(prop)
add_callback(prop, event_type, callback, priority=0, args=[])

Adds a callback associated to a specific event for a VTK prop.

Parameters:

prop : vtkProp

event_type : event code

callback : function

priority : int

force_render()

Causes the renderer to refresh.

get_prop_at_event_position()

Returns the prop that lays at the event position.

on_char(obj, evt)
on_key_press(obj, evt)
on_key_release(obj, evt)
on_left_button_down(obj, evt)
on_left_button_up(obj, evt)
on_middle_button_down(obj, evt)
on_middle_button_up(obj, evt)
on_mouse_move(obj, evt)
on_mouse_wheel_backward(obj, evt)
on_mouse_wheel_forward(obj, evt)
on_right_button_down(obj, evt)
on_right_button_up(obj, evt)
propagate_event(evt, *props)
remove_active_prop(prop)

InTemporaryDirectory

class dipy.viz.window.InTemporaryDirectory(suffix='', prefix='tmp', dir=None)

Bases: nibabel.tmpdirs.TemporaryDirectory

Create, return, and change directory to a temporary directory

Examples

>>> import os
>>> my_cwd = os.getcwd()
>>> with InTemporaryDirectory() as tmpdir:
...     _ = open('test.txt', 'wt').write('some text')
...     assert os.path.isfile('test.txt')
...     assert os.path.isfile(os.path.join(tmpdir, 'test.txt'))
>>> os.path.exists(tmpdir)
False
>>> os.getcwd() == my_cwd
True

Methods

cleanup()
__init__(suffix='', prefix='tmp', dir=None)

Renderer

class dipy.viz.window.Renderer

Bases: vtkRenderingCorePython.vtkRenderer

Your scene class

This is an important object that is responsible for preparing objects e.g. actors and volumes for rendering. This is a more pythonic version of vtkRenderer proving simple methods for adding and removing actors but also it provides access to all the functionality available in vtkRenderer if necessary.

Methods

AddActor(vtkProp) C++: void AddActor(vtkProp *p) C++: void AddActor(vtkProp *p)
AddActor2D(...) C++: void AddActor2D(vtkProp *p)
AddCuller(...) C++: void AddCuller(vtkCuller *)
AddLight(vtkLight) C++: void AddLight(vtkLight *) C++: void AddLight(vtkLight *)
AddObserver(int, ...) C++: unsigned long AddObserver(const char *event,
AddViewProp(...) C++: void AddViewProp(vtkProp *)
AddVolume(...) C++: void AddVolume(vtkProp *p)
AutomaticLightCreationOff(...) C++: void AutomaticLightCreationOff()
AutomaticLightCreationOn(...) C++: void AutomaticLightCreationOn()
BackingStoreOff() C++: void BackingStoreOff() C++: void BackingStoreOff()
BackingStoreOn() C++: void BackingStoreOn() C++: void BackingStoreOn()
BreakOnError() C++: static void BreakOnError() C++: static void BreakOnError()
CaptureGL2PSSpecialProp(...) C++: int CaptureGL2PSSpecialProp(vtkProp *)
Clear() C++: virtual void Clear() C++: virtual void Clear()
ClearLights() C++: virtual void ClearLights(void) C++: virtual void ClearLights(void)
ComputeAspect() C++: virtual void ComputeAspect() C++: virtual void ComputeAspect()
ComputeVisiblePropBounds([float, float, ...) Compute the bounding box of all the visible props Used in
CreateLight() C++: void CreateLight(void) C++: void CreateLight(void)
DebugOff() C++: virtual void DebugOff() C++: virtual void DebugOff()
DebugOn() C++: virtual void DebugOn() C++: virtual void DebugOn()
DeviceRender() C++: virtual void DeviceRender() C++: virtual void DeviceRender()
DeviceRenderOpaqueGeometry(...) C++: virtual void DeviceRenderOpaqueGeometry()
DeviceRenderTranslucentPolygonalGeometry(...) C++: virtual void DeviceRenderTranslucentPolygonalGeometry()
DisplayToLocalDisplay(float, ...) C++: virtual void DisplayToLocalDisplay(double &x, double &y)
DisplayToNormalizedDisplay(float, ...) C++: virtual void DisplayToNormalizedDisplay(double &u, double &v)
DisplayToView() C++: virtual void DisplayToView() C++: virtual void DisplayToView()
DisplayToWorld() C++: void DisplayToWorld() C++: void DisplayToWorld()
DrawOff() C++: void DrawOff() C++: void DrawOff()
DrawOn() C++: void DrawOn() C++: void DrawOn()
EraseOff() C++: void EraseOff() C++: void EraseOff()
EraseOn() C++: void EraseOn() C++: void EraseOn()
FastDelete() C++: virtual void FastDelete() C++: virtual void FastDelete()
GetActiveCamera(...) C++: vtkCamera *GetActiveCamera()
GetActors(...) C++: vtkActorCollection *GetActors()
GetActors2D(...) C++: vtkActor2DCollection *GetActors2D()
GetAddressAsString(...) C++: const char *GetAddressAsString()
GetAllocatedRenderTime(...) C++: virtual double GetAllocatedRenderTime()
GetAmbient() -> (float, float, ...) C++: double *GetAmbient()
GetAspect() -> (float, ...) C++: double *GetAspect()
GetAutomaticLightCreation(...) C++: int GetAutomaticLightCreation()
GetBackground() -> (float, float, ...) C++: double *GetBackground()
GetBackground2() -> (float, float, ...) C++: double *GetBackground2()
GetBackgroundTexture(...) C++: vtkTexture *GetBackgroundTexture()
GetBackingStore(...) C++: int GetBackingStore()
GetCenter() -> (float, ...) C++: virtual double *GetCenter()
GetClassName(...) C++: const char *GetClassName()
GetClippingRangeExpansion(...) C++: double GetClippingRangeExpansion()
GetClippingRangeExpansionMaxValue(...) C++: double GetClippingRangeExpansionMaxValue()
GetClippingRangeExpansionMinValue(...) C++: double GetClippingRangeExpansionMinValue()
GetCommand(...) C++: vtkCommand *GetCommand(unsigned long tag)
GetCullers(...) C++: vtkCullerCollection *GetCullers()
GetCurrentPickId(...) C++: unsigned int GetCurrentPickId()
GetDebug() -> bool C++: bool GetDebug() C++: bool GetDebug()
GetDelegate(...) C++: vtkRendererDelegate *GetDelegate()
GetDisplayPoint() -> (float, float, ...) C++: double *GetDisplayPoint()
GetDraw() -> int C++: int GetDraw() C++: int GetDraw()
GetErase() -> int C++: int GetErase() C++: int GetErase()
GetFXAAOptions(...) C++: vtkFXAAOptions *GetFXAAOptions()
GetGlobalWarningDisplay(...) C++: static int GetGlobalWarningDisplay()
GetGradientBackground(...) C++: bool GetGradientBackground()
GetInformation(...) C++: vtkInformation *GetInformation()
GetInteractive() -> int C++: int GetInteractive() C++: int GetInteractive()
GetIsPicking() -> int C++: int GetIsPicking() C++: int GetIsPicking()
GetLastRenderTimeInSeconds(...) C++: double GetLastRenderTimeInSeconds()
GetLastRenderingUsedDepthPeeling(...) C++: int GetLastRenderingUsedDepthPeeling()
GetLayer() -> int C++: int GetLayer() C++: int GetLayer()
GetLightFollowCamera(...) C++: int GetLightFollowCamera()
GetLights(...) C++: vtkLightCollection *GetLights()
GetMTime() -> int C++: vtkMTimeType GetMTime() C++: vtkMTimeType GetMTime()
GetMaximumNumberOfPeels(...) C++: int GetMaximumNumberOfPeels()
GetNearClippingPlaneTolerance(...) C++: double GetNearClippingPlaneTolerance()
GetNearClippingPlaneToleranceMaxValue(...) C++: double GetNearClippingPlaneToleranceMaxValue()
GetNearClippingPlaneToleranceMinValue(...) C++: double GetNearClippingPlaneToleranceMinValue()
GetNumberOfPropsRendered(...) C++: int GetNumberOfPropsRendered()
GetOcclusionRatio(...) C++: double GetOcclusionRatio()
GetOcclusionRatioMaxValue(...) C++: double GetOcclusionRatioMaxValue()
GetOcclusionRatioMinValue(...) C++: double GetOcclusionRatioMinValue()
GetOrigin() -> (int, ...) C++: virtual int *GetOrigin()
GetPass(...) C++: vtkRenderPass *GetPass()
GetPickHeight(...) C++: double GetPickHeight()
GetPickResultProps(...) C++: vtkPropCollection *GetPickResultProps()
GetPickWidth(...) C++: double GetPickWidth()
GetPickX() -> float C++: double GetPickX() C++: double GetPickX()
GetPickX1() -> float C++: double GetPickX1() C++: double GetPickX1()
GetPickX2() -> float C++: double GetPickX2() C++: double GetPickX2()
GetPickY() -> float C++: double GetPickY() C++: double GetPickY()
GetPickY1() -> float C++: double GetPickY1() C++: double GetPickY1()
GetPickY2() -> float C++: double GetPickY2() C++: double GetPickY2()
GetPickedZ(...) C++: virtual double GetPickedZ()
GetPixelAspect() -> (float, ...) C++: double *GetPixelAspect()
GetPreserveColorBuffer(...) C++: int GetPreserveColorBuffer()
GetPreserveDepthBuffer(...) C++: int GetPreserveDepthBuffer()
GetReferenceCount(...) C++: int GetReferenceCount()
GetRenderWindow(...) C++: vtkRenderWindow *GetRenderWindow()
GetSelector(...) C++: vtkHardwareSelector *GetSelector()
GetSize() -> (int, ...) C++: virtual int *GetSize()
GetTexturedBackground(...) C++: bool GetTexturedBackground()
GetTiledAspectRatio(...) C++: double GetTiledAspectRatio()
GetTiledSize([int, ...], [int, ...) C++: void GetTiledSize(int *width, int *height)
GetTiledSizeAndOrigin([int, ...], [int, ...) Get the size and origin of the viewport in display coordinates.
GetTimeFactor(...) C++: virtual double GetTimeFactor()
GetTwoSidedLighting(...) C++: int GetTwoSidedLighting()
GetUseDepthPeeling(...) C++: int GetUseDepthPeeling()
GetUseFXAA() -> bool C++: bool GetUseFXAA() C++: bool GetUseFXAA()
GetUseHiddenLineRemoval(...) C++: int GetUseHiddenLineRemoval()
GetUseShadows() -> int C++: int GetUseShadows() C++: int GetUseShadows()
GetVTKWindow(...) C++: virtual vtkWindow *GetVTKWindow()
GetViewPoint() -> (float, float, ...) C++: double *GetViewPoint()
GetViewProps(...) C++: vtkPropCollection *GetViewProps()
GetViewport() -> (float, float, float, ...) C++: double *GetViewport()
GetVolumes(...) C++: vtkVolumeCollection *GetVolumes()
GetWorldPoint() -> (float, float, float, ...) C++: double *GetWorldPoint()
GetZ(int, ...) C++: double GetZ(int x, int y)
GlobalWarningDisplayOff(...) C++: static void GlobalWarningDisplayOff()
GlobalWarningDisplayOn(...) C++: static void GlobalWarningDisplayOn()
GradientBackgroundOff(...) C++: void GradientBackgroundOff()
GradientBackgroundOn(...) C++: void GradientBackgroundOn()
HasObserver(int, ...) C++: int HasObserver(unsigned long event, vtkCommand *)
HasViewProp(...) C++: int HasViewProp(vtkProp *)
InitializeObjectBase(...) C++: void InitializeObjectBase()
InteractiveOff() C++: void InteractiveOff() C++: void InteractiveOff()
InteractiveOn() C++: void InteractiveOn() C++: void InteractiveOn()
InvokeEvent(int, ...) C++: int InvokeEvent(unsigned long event, void *callData)
IsA(string) -> int C++: int IsA(const char *name) C++: int IsA(const char *name)
IsActiveCameraCreated(...) C++: int IsActiveCameraCreated()
IsInViewport(int, ...) C++: virtual int IsInViewport(int x, int y)
IsTypeOf(...) C++: static vtkTypeBool IsTypeOf(const char *type)
LightFollowCameraOff(...) C++: void LightFollowCameraOff()
LightFollowCameraOn(...) C++: void LightFollowCameraOn()
LocalDisplayToDisplay(float, ...) C++: virtual void LocalDisplayToDisplay(double &x, double &y)
MakeCamera(...) C++: virtual vtkCamera *MakeCamera()
MakeLight(...) C++: virtual vtkLight *MakeLight()
Modified() C++: virtual void Modified() C++: virtual void Modified()
NewInstance(...) C++: vtkRenderer *NewInstance()
NormalizedDisplayToDisplay(float, ...) C++: virtual void NormalizedDisplayToDisplay(double &u, double &v)
NormalizedDisplayToViewport(float, ...) C++: virtual void NormalizedDisplayToViewport(double &x,
NormalizedViewportToView(float, float, ...) C++: virtual void NormalizedViewportToView(double &x, double &y,
NormalizedViewportToViewport(float, ...) C++: virtual void NormalizedViewportToViewport(double &u,
PickProp(float, ...) C++: vtkAssemblyPath *PickProp(double selectionX,
PickPropFrom(float, float, ...) C++: vtkAssemblyPath *PickPropFrom(double selectionX,
PreserveColorBufferOff(...) C++: void PreserveColorBufferOff()
PreserveColorBufferOn(...) C++: void PreserveColorBufferOn()
PreserveDepthBufferOff(...) C++: void PreserveDepthBufferOff()
PreserveDepthBufferOn(...) C++: void PreserveDepthBufferOn()
Register(...) C++: virtual void Register(vtkObjectBase *o)
ReleaseGraphicsResources(...) C++: virtual void ReleaseGraphicsResources(vtkWindow *)
RemoveActor(...) C++: void RemoveActor(vtkProp *p)
RemoveActor2D(...) C++: void RemoveActor2D(vtkProp *p)
RemoveAllLights() C++: void RemoveAllLights() C++: void RemoveAllLights()
RemoveAllObservers(...) C++: void RemoveAllObservers()
RemoveAllViewProps(...) C++: void RemoveAllViewProps(void)
RemoveCuller(...) C++: void RemoveCuller(vtkCuller *)
RemoveLight(...) C++: void RemoveLight(vtkLight *)
RemoveObserver(...) C++: void RemoveObserver(vtkCommand *)
RemoveObservers(int, ...) C++: void RemoveObservers(unsigned long event, vtkCommand *)
RemoveViewProp(...) C++: void RemoveViewProp(vtkProp *)
RemoveVolume(...) C++: void RemoveVolume(vtkProp *p)
Render() C++: virtual void Render() C++: virtual void Render()
ResetCamera(...) C++: virtual void ResetCamera()
ResetCameraClippingRange(...) C++: void ResetCameraClippingRange()
SafeDownCast(...) C++: vtkRenderer SafeDownCast(vtkObject o)
SetActiveCamera(...) C++: void SetActiveCamera(vtkCamera *)
SetAllocatedRenderTime(...) C++: void SetAllocatedRenderTime(double a)
SetAmbient(float, float, ...) C++: void SetAmbient(double, double, double)
SetAspect(float, ...) C++: void SetAspect(double, double)
SetAutomaticLightCreation(...) C++: void SetAutomaticLightCreation(int a)
SetBackground(float, float, ...) C++: void SetBackground(double, double, double)
SetBackground2(float, float, ...) C++: void SetBackground2(double, double, double)
SetBackgroundTexture(...) C++: virtual void SetBackgroundTexture(vtkTexture *)
SetBackingStore(...) C++: void SetBackingStore(int a)
SetClippingRangeExpansion(...) C++: void SetClippingRangeExpansion(double)
SetCurrentPickId(...) C++: void SetCurrentPickId(unsigned int a)
SetDebug(bool) C++: void SetDebug(bool debugFlag) C++: void SetDebug(bool debugFlag)
SetDelegate(...) C++: void SetDelegate(vtkRendererDelegate *d)
SetDisplayPoint(float, float, ...) C++: void SetDisplayPoint(double, double, double)
SetDraw(int) C++: void SetDraw(int a) C++: void SetDraw(int a)
SetErase(int) C++: void SetErase(int a) C++: void SetErase(int a)
SetFXAAOptions(...) C++: virtual void SetFXAAOptions(vtkFXAAOptions *)
SetGL2PSSpecialPropCollection(...) C++: void SetGL2PSSpecialPropCollection(vtkPropCollection *)
SetGlobalWarningDisplay(...) C++: static void SetGlobalWarningDisplay(int val)
SetGradientBackground(...) C++: void SetGradientBackground(bool a)
SetInformation(...) C++: virtual void SetInformation(vtkInformation *)
SetInteractive(...) C++: void SetInteractive(int a)
SetLayer(...) C++: virtual void SetLayer(int layer)
SetLightCollection(...) C++: void SetLightCollection(vtkLightCollection *lights)
SetLightFollowCamera(...) C++: void SetLightFollowCamera(int a)
SetMaximumNumberOfPeels(...) C++: void SetMaximumNumberOfPeels(int a)
SetNearClippingPlaneTolerance(...) C++: void SetNearClippingPlaneTolerance(double)
SetOcclusionRatio(...) C++: void SetOcclusionRatio(double)
SetPass(...) C++: void SetPass(vtkRenderPass *p)
SetPixelAspect(float, ...) C++: void SetPixelAspect(double, double)
SetPreserveColorBuffer(...) C++: void SetPreserveColorBuffer(int a)
SetPreserveDepthBuffer(...) C++: void SetPreserveDepthBuffer(int a)
SetReferenceCount(...) C++: void SetReferenceCount(int)
SetRenderWindow(...) C++: void SetRenderWindow(vtkRenderWindow *)
SetTexturedBackground(...) C++: void SetTexturedBackground(bool a)
SetTwoSidedLighting(...) C++: void SetTwoSidedLighting(int a)
SetUseDepthPeeling(...) C++: void SetUseDepthPeeling(int a)
SetUseFXAA(bool) C++: void SetUseFXAA(bool a) C++: void SetUseFXAA(bool a)
SetUseHiddenLineRemoval(...) C++: void SetUseHiddenLineRemoval(int a)
SetUseShadows(int) C++: void SetUseShadows(int a) C++: void SetUseShadows(int a)
SetViewPoint(float, float, ...) C++: void SetViewPoint(double, double, double)
SetViewport(float, float, float, ...) C++: void SetViewport(double, double, double, double)
SetWorldPoint(float, float, float, ...) C++: void SetWorldPoint(double, double, double, double)
StereoMidpoint(...) C++: virtual void StereoMidpoint()
TexturedBackgroundOff(...) C++: void TexturedBackgroundOff()
TexturedBackgroundOn(...) C++: void TexturedBackgroundOn()
Transparent() -> int C++: int Transparent() C++: int Transparent()
TwoSidedLightingOff(...) C++: void TwoSidedLightingOff()
TwoSidedLightingOn(...) C++: void TwoSidedLightingOn()
UnRegister(...) C++: virtual void UnRegister(vtkObjectBase *o)
UpdateLightsGeometryToFollowCamera(...) C++: virtual int UpdateLightsGeometryToFollowCamera(void)
UseDepthPeelingOff(...) C++: void UseDepthPeelingOff()
UseDepthPeelingOn() C++: void UseDepthPeelingOn() C++: void UseDepthPeelingOn()
UseFXAAOff() C++: void UseFXAAOff() C++: void UseFXAAOff()
UseFXAAOn() C++: void UseFXAAOn() C++: void UseFXAAOn()
UseHiddenLineRemovalOff(...) C++: void UseHiddenLineRemovalOff()
UseHiddenLineRemovalOn(...) C++: void UseHiddenLineRemovalOn()
UseShadowsOff() C++: void UseShadowsOff() C++: void UseShadowsOff()
UseShadowsOn() C++: void UseShadowsOn() C++: void UseShadowsOn()
ViewToDisplay() C++: virtual void ViewToDisplay() C++: virtual void ViewToDisplay()
ViewToNormalizedViewport(float, float, ...) C++: virtual void ViewToNormalizedViewport(double &x, double &y,
ViewToWorld(...) C++: void ViewToWorld()
ViewportToNormalizedDisplay(float, ...) C++: virtual void ViewportToNormalizedDisplay(double &x,
ViewportToNormalizedViewport(float, ...) C++: virtual void ViewportToNormalizedViewport(double &u,
VisibleActorCount(...) C++: int VisibleActorCount()
VisibleVolumeCount(...) C++: int VisibleVolumeCount()
WorldToDisplay() C++: void WorldToDisplay() C++: void WorldToDisplay()
WorldToView(...) C++: void WorldToView()
add(*actors) Add an actor to the renderer
azimuth(angle) Rotate the camera about the view up vector centered at the focal point.
background(color) Set a background color
camera()
camera_direction() Get the vector in the direction from the camera position to the focal point.
camera_info()
clear() Remove all actors from the renderer
dolly(value) Divide the camera’s distance from the focal point by the given dolly value.
elevation(angle) Rotate the camera about the cross product of the negative of the direction of projection and the view up vector, using the focal point as the center of rotation.
get_camera()
pitch(angle) Rotate the focal point about the cross product of the view up vector and the direction of projection, using the camera’s position as the center of rotation.
projection([proj_type]) Deside between parallel or perspective projection
reset_camera() Reset the camera to an automatic position given by the engine.
reset_clipping_range()
rm(actor) Remove a specific actor
rm_all() Remove all actors from the renderer
roll(angle) Rotate the camera about the direction of projection.
set_camera([position, focal_point, view_up])
size() Renderer size
yaw(angle) Rotate the focal point about the view up vector, using the camera’s position as the center of rotation.
zoom(value) In perspective mode, decrease the view angle by the specified factor.
__init__()

Initialize self. See help(type(self)) for accurate signature.

add(*actors)

Add an actor to the renderer

azimuth(angle)

Rotate the camera about the view up vector centered at the focal point. Note that the view up vector is whatever was set via SetViewUp, and is not necessarily perpendicular to the direction of projection. The result is a horizontal rotation of the camera.

background(color)

Set a background color

camera()
camera_direction()

Get the vector in the direction from the camera position to the focal point. This is usually the opposite of the ViewPlaneNormal, the vector perpendicular to the screen, unless the view is oblique.

camera_info()
clear()

Remove all actors from the renderer

dolly(value)

Divide the camera’s distance from the focal point by the given dolly value. Use a value greater than one to dolly-in toward the focal point, and use a value less than one to dolly-out away from the focal point.

elevation(angle)

Rotate the camera about the cross product of the negative of the direction of projection and the view up vector, using the focal point as the center of rotation. The result is a vertical rotation of the scene.

get_camera()
pitch(angle)

Rotate the focal point about the cross product of the view up vector and the direction of projection, using the camera’s position as the center of rotation. The result is a vertical rotation of the camera.

projection(proj_type='perspective')

Deside between parallel or perspective projection

Parameters:

proj_type : str

Can be ‘parallel’ or ‘perspective’ (default).

reset_camera()

Reset the camera to an automatic position given by the engine.

reset_clipping_range()
rm(actor)

Remove a specific actor

rm_all()

Remove all actors from the renderer

roll(angle)

Rotate the camera about the direction of projection. This will spin the camera about its axis.

set_camera(position=None, focal_point=None, view_up=None)
size()

Renderer size

yaw(angle)

Rotate the focal point about the view up vector, using the camera’s position as the center of rotation. Note that the view up vector is whatever was set via SetViewUp, and is not necessarily perpendicular to the direction of projection. The result is a horizontal rotation of the scene.

zoom(value)

In perspective mode, decrease the view angle by the specified factor. In parallel mode, decrease the parallel scale by the specified factor. A value greater than 1 is a zoom-in, a value less than 1 is a zoom-out.

ShowManager

class dipy.viz.window.ShowManager(ren=None, title='DIPY', size=(300, 300), png_magnify=1, reset_camera=True, order_transparent=False, interactor_style='custom')

Bases: object

This class is the interface between the renderer, the window and the interactor.

Methods

add_window_callback(win_callback) Add window callbacks
initialize() Initialize interaction
play_events(events) Plays recorded events of a past interaction.
play_events_from_file(filename) Plays recorded events of a past interaction.
record_events() Records events during the interaction.
record_events_to_file([filename]) Records events during the interaction.
render() Renders only once
start() Starts interaction
__init__(ren=None, title='DIPY', size=(300, 300), png_magnify=1, reset_camera=True, order_transparent=False, interactor_style='custom')

Manages the visualization pipeline

Parameters:

ren : Renderer() or vtkRenderer()

The scene that holds all the actors.

title : string

A string for the window title bar.

size : (int, int)

(width, height) of the window. Default is (300, 300).

png_magnify : int

Number of times to magnify the screenshot. This can be used to save high resolution screenshots when pressing ‘s’ inside the window.

reset_camera : bool

Default is True. You can change this option to False if you want to keep the camera as set before calling this function.

order_transparent : bool

True is useful when you want to order transparent actors according to their relative position to the camera. The default option which is False will order the actors according to the order of their addition to the Renderer().

interactor_style : str or vtkInteractorStyle

If str then if ‘trackball’ then vtkInteractorStyleTrackballCamera() is used, if ‘image’ then vtkInteractorStyleImage() is used (no rotation) or if ‘custom’ then CustomInteractorStyle is used. Otherwise you can input your own interactor style.

Notes

Default interaction keys for

  • 3d navigation are with left, middle and right mouse dragging
  • resetting the camera press ‘r’
  • saving a screenshot press ‘s’
  • for quiting press ‘q’

Examples

>>> from dipy.viz import actor, window
>>> renderer = window.Renderer()
>>> renderer.add(actor.axes())
>>> showm = window.ShowManager(renderer)
>>> # showm.initialize()
>>> # showm.render()
>>> # showm.start()

Attributes

ren (vtkRenderer())
iren (vtkRenderWindowInteractor())
style (vtkInteractorStyle())
window (vtkRenderWindow())

Methods

initialize()  
render()  
start()  
add_window_callback()  
add_window_callback(win_callback)

Add window callbacks

initialize()

Initialize interaction

play_events(events)

Plays recorded events of a past interaction.

The VTK events that happened during the recorded interaction will be played back.

Parameters:

events : str

Recorded events (one per line).

play_events_from_file(filename)

Plays recorded events of a past interaction.

The VTK events that happened during the recorded interaction will be played back from filename.

Parameters:

filename : str

Name of the file containing the recorded events (.log|.log.gz).

record_events()

Records events during the interaction.

The recording is represented as a list of VTK events that happened during the interaction. The recorded events are then returned.

Returns:

events : str

Recorded events (one per line).

Notes

Since VTK only allows recording events to a file, we use a temporary file from which we then read the events.

record_events_to_file(filename='record.log')

Records events during the interaction.

The recording is represented as a list of VTK events that happened during the interaction. The recording is going to be saved into filename.

Parameters:

filename : str

Name of the file that will contain the recording (.log|.log.gz).

render()

Renders only once

start()

Starts interaction

vtkRenderer

class dipy.viz.window.vtkRenderer

Bases: vtkRenderingCorePython.vtkViewport

vtkRenderer - abstract specification for renderers

Superclass: vtkViewport

vtkRenderer provides an abstract specification for renderers. A renderer is an object that controls the rendering process for objects. Rendering is the process of converting geometry, a specification for lights, and a camera view into an image. vtkRenderer also performs coordinate transformation between world coordinates, view coordinates (the computer graphics rendering coordinate system), and display coordinates (the actual screen coordinates on the display device). Certain advanced rendering features such as two-sided lighting can also be controlled.

@sa vtkRenderWindow vtkActor vtkCamera vtkLight vtkVolume

Methods

AddActor(vtkProp) C++: void AddActor(vtkProp *p) C++: void AddActor(vtkProp *p)
AddActor2D(...) C++: void AddActor2D(vtkProp *p)
AddCuller(...) C++: void AddCuller(vtkCuller *)
AddLight(vtkLight) C++: void AddLight(vtkLight *) C++: void AddLight(vtkLight *)
AddObserver(int, ...) C++: unsigned long AddObserver(const char *event,
AddViewProp(...) C++: void AddViewProp(vtkProp *)
AddVolume(...) C++: void AddVolume(vtkProp *p)
AutomaticLightCreationOff(...) C++: void AutomaticLightCreationOff()
AutomaticLightCreationOn(...) C++: void AutomaticLightCreationOn()
BackingStoreOff() C++: void BackingStoreOff() C++: void BackingStoreOff()
BackingStoreOn() C++: void BackingStoreOn() C++: void BackingStoreOn()
BreakOnError() C++: static void BreakOnError() C++: static void BreakOnError()
CaptureGL2PSSpecialProp(...) C++: int CaptureGL2PSSpecialProp(vtkProp *)
Clear() C++: virtual void Clear() C++: virtual void Clear()
ClearLights() C++: virtual void ClearLights(void) C++: virtual void ClearLights(void)
ComputeAspect() C++: virtual void ComputeAspect() C++: virtual void ComputeAspect()
ComputeVisiblePropBounds([float, float, ...) Compute the bounding box of all the visible props Used in
CreateLight() C++: void CreateLight(void) C++: void CreateLight(void)
DebugOff() C++: virtual void DebugOff() C++: virtual void DebugOff()
DebugOn() C++: virtual void DebugOn() C++: virtual void DebugOn()
DeviceRender() C++: virtual void DeviceRender() C++: virtual void DeviceRender()
DeviceRenderOpaqueGeometry(...) C++: virtual void DeviceRenderOpaqueGeometry()
DeviceRenderTranslucentPolygonalGeometry(...) C++: virtual void DeviceRenderTranslucentPolygonalGeometry()
DisplayToLocalDisplay(float, ...) C++: virtual void DisplayToLocalDisplay(double &x, double &y)
DisplayToNormalizedDisplay(float, ...) C++: virtual void DisplayToNormalizedDisplay(double &u, double &v)
DisplayToView() C++: virtual void DisplayToView() C++: virtual void DisplayToView()
DisplayToWorld() C++: void DisplayToWorld() C++: void DisplayToWorld()
DrawOff() C++: void DrawOff() C++: void DrawOff()
DrawOn() C++: void DrawOn() C++: void DrawOn()
EraseOff() C++: void EraseOff() C++: void EraseOff()
EraseOn() C++: void EraseOn() C++: void EraseOn()
FastDelete() C++: virtual void FastDelete() C++: virtual void FastDelete()
GetActiveCamera(...) C++: vtkCamera *GetActiveCamera()
GetActors(...) C++: vtkActorCollection *GetActors()
GetActors2D(...) C++: vtkActor2DCollection *GetActors2D()
GetAddressAsString(...) C++: const char *GetAddressAsString()
GetAllocatedRenderTime(...) C++: virtual double GetAllocatedRenderTime()
GetAmbient() -> (float, float, ...) C++: double *GetAmbient()
GetAspect() -> (float, ...) C++: double *GetAspect()
GetAutomaticLightCreation(...) C++: int GetAutomaticLightCreation()
GetBackground() -> (float, float, ...) C++: double *GetBackground()
GetBackground2() -> (float, float, ...) C++: double *GetBackground2()
GetBackgroundTexture(...) C++: vtkTexture *GetBackgroundTexture()
GetBackingStore(...) C++: int GetBackingStore()
GetCenter() -> (float, ...) C++: virtual double *GetCenter()
GetClassName(...) C++: const char *GetClassName()
GetClippingRangeExpansion(...) C++: double GetClippingRangeExpansion()
GetClippingRangeExpansionMaxValue(...) C++: double GetClippingRangeExpansionMaxValue()
GetClippingRangeExpansionMinValue(...) C++: double GetClippingRangeExpansionMinValue()
GetCommand(...) C++: vtkCommand *GetCommand(unsigned long tag)
GetCullers(...) C++: vtkCullerCollection *GetCullers()
GetCurrentPickId(...) C++: unsigned int GetCurrentPickId()
GetDebug() -> bool C++: bool GetDebug() C++: bool GetDebug()
GetDelegate(...) C++: vtkRendererDelegate *GetDelegate()
GetDisplayPoint() -> (float, float, ...) C++: double *GetDisplayPoint()
GetDraw() -> int C++: int GetDraw() C++: int GetDraw()
GetErase() -> int C++: int GetErase() C++: int GetErase()
GetFXAAOptions(...) C++: vtkFXAAOptions *GetFXAAOptions()
GetGlobalWarningDisplay(...) C++: static int GetGlobalWarningDisplay()
GetGradientBackground(...) C++: bool GetGradientBackground()
GetInformation(...) C++: vtkInformation *GetInformation()
GetInteractive() -> int C++: int GetInteractive() C++: int GetInteractive()
GetIsPicking() -> int C++: int GetIsPicking() C++: int GetIsPicking()
GetLastRenderTimeInSeconds(...) C++: double GetLastRenderTimeInSeconds()
GetLastRenderingUsedDepthPeeling(...) C++: int GetLastRenderingUsedDepthPeeling()
GetLayer() -> int C++: int GetLayer() C++: int GetLayer()
GetLightFollowCamera(...) C++: int GetLightFollowCamera()
GetLights(...) C++: vtkLightCollection *GetLights()
GetMTime() -> int C++: vtkMTimeType GetMTime() C++: vtkMTimeType GetMTime()
GetMaximumNumberOfPeels(...) C++: int GetMaximumNumberOfPeels()
GetNearClippingPlaneTolerance(...) C++: double GetNearClippingPlaneTolerance()
GetNearClippingPlaneToleranceMaxValue(...) C++: double GetNearClippingPlaneToleranceMaxValue()
GetNearClippingPlaneToleranceMinValue(...) C++: double GetNearClippingPlaneToleranceMinValue()
GetNumberOfPropsRendered(...) C++: int GetNumberOfPropsRendered()
GetOcclusionRatio(...) C++: double GetOcclusionRatio()
GetOcclusionRatioMaxValue(...) C++: double GetOcclusionRatioMaxValue()
GetOcclusionRatioMinValue(...) C++: double GetOcclusionRatioMinValue()
GetOrigin() -> (int, ...) C++: virtual int *GetOrigin()
GetPass(...) C++: vtkRenderPass *GetPass()
GetPickHeight(...) C++: double GetPickHeight()
GetPickResultProps(...) C++: vtkPropCollection *GetPickResultProps()
GetPickWidth(...) C++: double GetPickWidth()
GetPickX() -> float C++: double GetPickX() C++: double GetPickX()
GetPickX1() -> float C++: double GetPickX1() C++: double GetPickX1()
GetPickX2() -> float C++: double GetPickX2() C++: double GetPickX2()
GetPickY() -> float C++: double GetPickY() C++: double GetPickY()
GetPickY1() -> float C++: double GetPickY1() C++: double GetPickY1()
GetPickY2() -> float C++: double GetPickY2() C++: double GetPickY2()
GetPickedZ(...) C++: virtual double GetPickedZ()
GetPixelAspect() -> (float, ...) C++: double *GetPixelAspect()
GetPreserveColorBuffer(...) C++: int GetPreserveColorBuffer()
GetPreserveDepthBuffer(...) C++: int GetPreserveDepthBuffer()
GetReferenceCount(...) C++: int GetReferenceCount()
GetRenderWindow(...) C++: vtkRenderWindow *GetRenderWindow()
GetSelector(...) C++: vtkHardwareSelector *GetSelector()
GetSize() -> (int, ...) C++: virtual int *GetSize()
GetTexturedBackground(...) C++: bool GetTexturedBackground()
GetTiledAspectRatio(...) C++: double GetTiledAspectRatio()
GetTiledSize([int, ...], [int, ...) C++: void GetTiledSize(int *width, int *height)
GetTiledSizeAndOrigin([int, ...], [int, ...) Get the size and origin of the viewport in display coordinates.
GetTimeFactor(...) C++: virtual double GetTimeFactor()
GetTwoSidedLighting(...) C++: int GetTwoSidedLighting()
GetUseDepthPeeling(...) C++: int GetUseDepthPeeling()
GetUseFXAA() -> bool C++: bool GetUseFXAA() C++: bool GetUseFXAA()
GetUseHiddenLineRemoval(...) C++: int GetUseHiddenLineRemoval()
GetUseShadows() -> int C++: int GetUseShadows() C++: int GetUseShadows()
GetVTKWindow(...) C++: virtual vtkWindow *GetVTKWindow()
GetViewPoint() -> (float, float, ...) C++: double *GetViewPoint()
GetViewProps(...) C++: vtkPropCollection *GetViewProps()
GetViewport() -> (float, float, float, ...) C++: double *GetViewport()
GetVolumes(...) C++: vtkVolumeCollection *GetVolumes()
GetWorldPoint() -> (float, float, float, ...) C++: double *GetWorldPoint()
GetZ(int, ...) C++: double GetZ(int x, int y)
GlobalWarningDisplayOff(...) C++: static void GlobalWarningDisplayOff()
GlobalWarningDisplayOn(...) C++: static void GlobalWarningDisplayOn()
GradientBackgroundOff(...) C++: void GradientBackgroundOff()
GradientBackgroundOn(...) C++: void GradientBackgroundOn()
HasObserver(int, ...) C++: int HasObserver(unsigned long event, vtkCommand *)
HasViewProp(...) C++: int HasViewProp(vtkProp *)
InitializeObjectBase(...) C++: void InitializeObjectBase()
InteractiveOff() C++: void InteractiveOff() C++: void InteractiveOff()
InteractiveOn() C++: void InteractiveOn() C++: void InteractiveOn()
InvokeEvent(int, ...) C++: int InvokeEvent(unsigned long event, void *callData)
IsA(string) -> int C++: int IsA(const char *name) C++: int IsA(const char *name)
IsActiveCameraCreated(...) C++: int IsActiveCameraCreated()
IsInViewport(int, ...) C++: virtual int IsInViewport(int x, int y)
IsTypeOf(...) C++: static vtkTypeBool IsTypeOf(const char *type)
LightFollowCameraOff(...) C++: void LightFollowCameraOff()
LightFollowCameraOn(...) C++: void LightFollowCameraOn()
LocalDisplayToDisplay(float, ...) C++: virtual void LocalDisplayToDisplay(double &x, double &y)
MakeCamera(...) C++: virtual vtkCamera *MakeCamera()
MakeLight(...) C++: virtual vtkLight *MakeLight()
Modified() C++: virtual void Modified() C++: virtual void Modified()
NewInstance(...) C++: vtkRenderer *NewInstance()
NormalizedDisplayToDisplay(float, ...) C++: virtual void NormalizedDisplayToDisplay(double &u, double &v)
NormalizedDisplayToViewport(float, ...) C++: virtual void NormalizedDisplayToViewport(double &x,
NormalizedViewportToView(float, float, ...) C++: virtual void NormalizedViewportToView(double &x, double &y,
NormalizedViewportToViewport(float, ...) C++: virtual void NormalizedViewportToViewport(double &u,
PickProp(float, ...) C++: vtkAssemblyPath *PickProp(double selectionX,
PickPropFrom(float, float, ...) C++: vtkAssemblyPath *PickPropFrom(double selectionX,
PreserveColorBufferOff(...) C++: void PreserveColorBufferOff()
PreserveColorBufferOn(...) C++: void PreserveColorBufferOn()
PreserveDepthBufferOff(...) C++: void PreserveDepthBufferOff()
PreserveDepthBufferOn(...) C++: void PreserveDepthBufferOn()
Register(...) C++: virtual void Register(vtkObjectBase *o)
ReleaseGraphicsResources(...) C++: virtual void ReleaseGraphicsResources(vtkWindow *)
RemoveActor(...) C++: void RemoveActor(vtkProp *p)
RemoveActor2D(...) C++: void RemoveActor2D(vtkProp *p)
RemoveAllLights() C++: void RemoveAllLights() C++: void RemoveAllLights()
RemoveAllObservers(...) C++: void RemoveAllObservers()
RemoveAllViewProps(...) C++: void RemoveAllViewProps(void)
RemoveCuller(...) C++: void RemoveCuller(vtkCuller *)
RemoveLight(...) C++: void RemoveLight(vtkLight *)
RemoveObserver(...) C++: void RemoveObserver(vtkCommand *)
RemoveObservers(int, ...) C++: void RemoveObservers(unsigned long event, vtkCommand *)
RemoveViewProp(...) C++: void RemoveViewProp(vtkProp *)
RemoveVolume(...) C++: void RemoveVolume(vtkProp *p)
Render() C++: virtual void Render() C++: virtual void Render()
ResetCamera(...) C++: virtual void ResetCamera()
ResetCameraClippingRange(...) C++: void ResetCameraClippingRange()
SafeDownCast(...) C++: vtkRenderer SafeDownCast(vtkObject o)
SetActiveCamera(...) C++: void SetActiveCamera(vtkCamera *)
SetAllocatedRenderTime(...) C++: void SetAllocatedRenderTime(double a)
SetAmbient(float, float, ...) C++: void SetAmbient(double, double, double)
SetAspect(float, ...) C++: void SetAspect(double, double)
SetAutomaticLightCreation(...) C++: void SetAutomaticLightCreation(int a)
SetBackground(float, float, ...) C++: void SetBackground(double, double, double)
SetBackground2(float, float, ...) C++: void SetBackground2(double, double, double)
SetBackgroundTexture(...) C++: virtual void SetBackgroundTexture(vtkTexture *)
SetBackingStore(...) C++: void SetBackingStore(int a)
SetClippingRangeExpansion(...) C++: void SetClippingRangeExpansion(double)
SetCurrentPickId(...) C++: void SetCurrentPickId(unsigned int a)
SetDebug(bool) C++: void SetDebug(bool debugFlag) C++: void SetDebug(bool debugFlag)
SetDelegate(...) C++: void SetDelegate(vtkRendererDelegate *d)
SetDisplayPoint(float, float, ...) C++: void SetDisplayPoint(double, double, double)
SetDraw(int) C++: void SetDraw(int a) C++: void SetDraw(int a)
SetErase(int) C++: void SetErase(int a) C++: void SetErase(int a)
SetFXAAOptions(...) C++: virtual void SetFXAAOptions(vtkFXAAOptions *)
SetGL2PSSpecialPropCollection(...) C++: void SetGL2PSSpecialPropCollection(vtkPropCollection *)
SetGlobalWarningDisplay(...) C++: static void SetGlobalWarningDisplay(int val)
SetGradientBackground(...) C++: void SetGradientBackground(bool a)
SetInformation(...) C++: virtual void SetInformation(vtkInformation *)
SetInteractive(...) C++: void SetInteractive(int a)
SetLayer(...) C++: virtual void SetLayer(int layer)
SetLightCollection(...) C++: void SetLightCollection(vtkLightCollection *lights)
SetLightFollowCamera(...) C++: void SetLightFollowCamera(int a)
SetMaximumNumberOfPeels(...) C++: void SetMaximumNumberOfPeels(int a)
SetNearClippingPlaneTolerance(...) C++: void SetNearClippingPlaneTolerance(double)
SetOcclusionRatio(...) C++: void SetOcclusionRatio(double)
SetPass(...) C++: void SetPass(vtkRenderPass *p)
SetPixelAspect(float, ...) C++: void SetPixelAspect(double, double)
SetPreserveColorBuffer(...) C++: void SetPreserveColorBuffer(int a)
SetPreserveDepthBuffer(...) C++: void SetPreserveDepthBuffer(int a)
SetReferenceCount(...) C++: void SetReferenceCount(int)
SetRenderWindow(...) C++: void SetRenderWindow(vtkRenderWindow *)
SetTexturedBackground(...) C++: void SetTexturedBackground(bool a)
SetTwoSidedLighting(...) C++: void SetTwoSidedLighting(int a)
SetUseDepthPeeling(...) C++: void SetUseDepthPeeling(int a)
SetUseFXAA(bool) C++: void SetUseFXAA(bool a) C++: void SetUseFXAA(bool a)
SetUseHiddenLineRemoval(...) C++: void SetUseHiddenLineRemoval(int a)
SetUseShadows(int) C++: void SetUseShadows(int a) C++: void SetUseShadows(int a)
SetViewPoint(float, float, ...) C++: void SetViewPoint(double, double, double)
SetViewport(float, float, float, ...) C++: void SetViewport(double, double, double, double)
SetWorldPoint(float, float, float, ...) C++: void SetWorldPoint(double, double, double, double)
StereoMidpoint(...) C++: virtual void StereoMidpoint()
TexturedBackgroundOff(...) C++: void TexturedBackgroundOff()
TexturedBackgroundOn(...) C++: void TexturedBackgroundOn()
Transparent() -> int C++: int Transparent() C++: int Transparent()
TwoSidedLightingOff(...) C++: void TwoSidedLightingOff()
TwoSidedLightingOn(...) C++: void TwoSidedLightingOn()
UnRegister(...) C++: virtual void UnRegister(vtkObjectBase *o)
UpdateLightsGeometryToFollowCamera(...) C++: virtual int UpdateLightsGeometryToFollowCamera(void)
UseDepthPeelingOff(...) C++: void UseDepthPeelingOff()
UseDepthPeelingOn() C++: void UseDepthPeelingOn() C++: void UseDepthPeelingOn()
UseFXAAOff() C++: void UseFXAAOff() C++: void UseFXAAOff()
UseFXAAOn() C++: void UseFXAAOn() C++: void UseFXAAOn()
UseHiddenLineRemovalOff(...) C++: void UseHiddenLineRemovalOff()
UseHiddenLineRemovalOn(...) C++: void UseHiddenLineRemovalOn()
UseShadowsOff() C++: void UseShadowsOff() C++: void UseShadowsOff()
UseShadowsOn() C++: void UseShadowsOn() C++: void UseShadowsOn()
ViewToDisplay() C++: virtual void ViewToDisplay() C++: virtual void ViewToDisplay()
ViewToNormalizedViewport(float, float, ...) C++: virtual void ViewToNormalizedViewport(double &x, double &y,
ViewToWorld(...) C++: void ViewToWorld()
ViewportToNormalizedDisplay(float, ...) C++: virtual void ViewportToNormalizedDisplay(double &x,
ViewportToNormalizedViewport(float, ...) C++: virtual void ViewportToNormalizedViewport(double &u,
VisibleActorCount(...) C++: int VisibleActorCount()
VisibleVolumeCount(...) C++: int VisibleVolumeCount()
WorldToDisplay() C++: void WorldToDisplay() C++: void WorldToDisplay()
WorldToView(...) C++: void WorldToView()
__init__()

Initialize self. See help(type(self)) for accurate signature.

AddActor(vtkProp) C++: void AddActor(vtkProp *p)

C++: void AddActor(vtkProp *p)

Add/Remove different types of props to the renderer. These methods are all synonyms to AddViewProp and RemoveViewProp. They are here for convenience and backwards compatibility.

AddCuller(vtkCuller) C++: void AddCuller(vtkCuller *)

C++: void AddCuller(vtkCuller *)

Add an culler to the list of cullers.

AddLight(vtkLight) C++: void AddLight(vtkLight *)

C++: void AddLight(vtkLight *)

Add a light to the list of lights.

AddVolume(vtkProp) C++: void AddVolume(vtkProp *p)

C++: void AddVolume(vtkProp *p)

Add/Remove different types of props to the renderer. These methods are all synonyms to AddViewProp and RemoveViewProp. They are here for convenience and backwards compatibility.

AutomaticLightCreationOff() C++: void AutomaticLightCreationOff()

C++: void AutomaticLightCreationOff()

Turn on/off a flag which disables the automatic light creation capability. Normally in VTK if no lights are associated with the renderer, then a light is automatically created. However, in special circumstances this feature is undesirable, so the following boolean is provided to disable automatic light creation. (Turn AutomaticLightCreation off if you do not want lights to be created.)

AutomaticLightCreationOn() C++: void AutomaticLightCreationOn()

C++: void AutomaticLightCreationOn()

Turn on/off a flag which disables the automatic light creation capability. Normally in VTK if no lights are associated with the renderer, then a light is automatically created. However, in special circumstances this feature is undesirable, so the following boolean is provided to disable automatic light creation. (Turn AutomaticLightCreation off if you do not want lights to be created.)

BackingStoreOff() C++: void BackingStoreOff()

C++: void BackingStoreOff()

Turn on/off using backing store. This may cause the re-rendering time to be slightly slower when the view changes. But it is much faster when the image has not changed, such as during an expose event.

BackingStoreOn() C++: void BackingStoreOn()

C++: void BackingStoreOn()

Turn on/off using backing store. This may cause the re-rendering time to be slightly slower when the view changes. But it is much faster when the image has not changed, such as during an expose event.

CaptureGL2PSSpecialProp(vtkProp) -> int C++: int CaptureGL2PSSpecialProp(vtkProp *)

C++: int CaptureGL2PSSpecialProp(vtkProp *)

This function is called to capture an instance of vtkProp that requires special handling during vtkRenderWindow::CaptureGL2PSSpecialProps().

Clear() C++: virtual void Clear()

C++: virtual void Clear()

Clear the image to the background color.

ClearLights() C++: virtual void ClearLights(void)

C++: virtual void ClearLights(void)

Internal method temporarily removes lights before reloading them into graphics pipeline.

ComputeVisiblePropBounds([float, float, float, float, float, float]) C++: void ComputeVisiblePropBounds(double bounds[6]) V.ComputeVisiblePropBounds() -> (float, float, float, float, float, float) C++: double *ComputeVisiblePropBounds()

Compute the bounding box of all the visible props Used in ResetCamera() and ResetCameraClippingRange()

CreateLight() C++: void CreateLight(void)

C++: void CreateLight(void)

Create and add a light to renderer.

DeviceRender() C++: virtual void DeviceRender()

C++: virtual void DeviceRender()

Create an image. Subclasses of vtkRenderer must implement this method.

DeviceRenderOpaqueGeometry() C++: virtual void DeviceRenderOpaqueGeometry()

C++: virtual void DeviceRenderOpaqueGeometry()

Render opaque polygonal geometry. Default implementation just calls UpdateOpaquePolygonalGeometry(). Subclasses of vtkRenderer that can deal with, e.g. hidden line removal must override this method.

DeviceRenderTranslucentPolygonalGeometry() C++: virtual void DeviceRenderTranslucentPolygonalGeometry()

C++: virtual void DeviceRenderTranslucentPolygonalGeometry()

Render translucent polygonal geometry. Default implementation just call UpdateTranslucentPolygonalGeometry(). Subclasses of vtkRenderer that can deal with depth peeling must override this method. It updates boolean ivar LastRenderingUsedDepthPeeling.

DrawOff() C++: void DrawOff()

C++: void DrawOff()

When this flag is off, render commands are ignored. It is used to either multiplex a vtkRenderWindow or render only part of a vtkRenderWindow. By default, Draw is on.

DrawOn() C++: void DrawOn()

C++: void DrawOn()

When this flag is off, render commands are ignored. It is used to either multiplex a vtkRenderWindow or render only part of a vtkRenderWindow. By default, Draw is on.

EraseOff() C++: void EraseOff()

C++: void EraseOff()

When this flag is off, the renderer will not erase the background or the Zbuffer. It is used to have overlapping renderers. Both the RenderWindow Erase and Render Erase must be on for the camera to clear the renderer. By default, Erase is on.

EraseOn() C++: void EraseOn()

C++: void EraseOn()

When this flag is off, the renderer will not erase the background or the Zbuffer. It is used to have overlapping renderers. Both the RenderWindow Erase and Render Erase must be on for the camera to clear the renderer. By default, Erase is on.

GetActiveCamera() -> vtkCamera C++: vtkCamera *GetActiveCamera()

C++: vtkCamera *GetActiveCamera()

Get the current camera. If there is not camera assigned to the renderer already, a new one is created automatically. This does not reset the camera.

GetActors() -> vtkActorCollection C++: vtkActorCollection *GetActors()

C++: vtkActorCollection *GetActors()

Return any actors in this renderer.

GetAllocatedRenderTime() -> float C++: virtual double GetAllocatedRenderTime()

C++: virtual double GetAllocatedRenderTime()

Set/Get the amount of time this renderer is allowed to spend rendering its scene. This is used by vtkLODActor’s.

GetAmbient() -> (float, float, float) C++: double *GetAmbient()

C++: double *GetAmbient()

Set the intensity of ambient lighting.

GetAutomaticLightCreation() -> int C++: int GetAutomaticLightCreation()

C++: int GetAutomaticLightCreation()

Turn on/off a flag which disables the automatic light creation capability. Normally in VTK if no lights are associated with the renderer, then a light is automatically created. However, in special circumstances this feature is undesirable, so the following boolean is provided to disable automatic light creation. (Turn AutomaticLightCreation off if you do not want lights to be created.)

GetBackgroundTexture() -> vtkTexture C++: vtkTexture *GetBackgroundTexture()

C++: vtkTexture *GetBackgroundTexture()

Set/Get the texture to be used for the background. If set and enabled this gets the priority over the gradient background.

GetBackingStore() -> int C++: int GetBackingStore()

C++: int GetBackingStore()

Turn on/off using backing store. This may cause the re-rendering time to be slightly slower when the view changes. But it is much faster when the image has not changed, such as during an expose event.

GetClassName() -> string C++: const char *GetClassName()

C++: const char *GetClassName()

GetClippingRangeExpansion() -> float C++: double GetClippingRangeExpansion()

C++: double GetClippingRangeExpansion()

Specify enlargement of bounds when resetting the camera clipping range. By default the range is not expanded by any percent of the (far - near) on the near and far sides

GetClippingRangeExpansionMaxValue() -> float C++: double GetClippingRangeExpansionMaxValue()

C++: double GetClippingRangeExpansionMaxValue()

Specify enlargement of bounds when resetting the camera clipping range. By default the range is not expanded by any percent of the (far - near) on the near and far sides

GetClippingRangeExpansionMinValue() -> float C++: double GetClippingRangeExpansionMinValue()

C++: double GetClippingRangeExpansionMinValue()

Specify enlargement of bounds when resetting the camera clipping range. By default the range is not expanded by any percent of the (far - near) on the near and far sides

GetCullers() -> vtkCullerCollection C++: vtkCullerCollection *GetCullers()

C++: vtkCullerCollection *GetCullers()

Return the collection of cullers.

GetDelegate() -> vtkRendererDelegate C++: vtkRendererDelegate *GetDelegate()

C++: vtkRendererDelegate *GetDelegate()

Set/Get a custom Render call. Allows to hook a Render call from an external project.It will be used in place of vtkRenderer::Render() if it is not NULL and its Used ivar is set to true. Initial value is NULL.

GetDraw() -> int C++: int GetDraw()

C++: int GetDraw()

When this flag is off, render commands are ignored. It is used to either multiplex a vtkRenderWindow or render only part of a vtkRenderWindow. By default, Draw is on.

GetErase() -> int C++: int GetErase()

C++: int GetErase()

When this flag is off, the renderer will not erase the background or the Zbuffer. It is used to have overlapping renderers. Both the RenderWindow Erase and Render Erase must be on for the camera to clear the renderer. By default, Erase is on.

GetFXAAOptions() -> vtkFXAAOptions C++: vtkFXAAOptions *GetFXAAOptions()

C++: vtkFXAAOptions *GetFXAAOptions()

The configuration object for FXAA antialiasing.

GetInformation() -> vtkInformation C++: vtkInformation *GetInformation()

C++: vtkInformation *GetInformation()

Set/Get the information object associated with this algorithm.

GetInteractive() -> int C++: int GetInteractive()

C++: int GetInteractive()

Turn on/off interactive status. An interactive renderer is one that can receive events from an interactor. Should only be set if there are multiple renderers in the same section of the viewport.

GetLastRenderTimeInSeconds() -> float C++: double GetLastRenderTimeInSeconds()

C++: double GetLastRenderTimeInSeconds()

Get the time required, in seconds, for the last Render call.

GetLastRenderingUsedDepthPeeling() -> int C++: int GetLastRenderingUsedDepthPeeling()

C++: int GetLastRenderingUsedDepthPeeling()

Tells if the last call to DeviceRenderTranslucentPolygonalGeometry() actually used depth peeling. Initial value is false.

GetLayer() -> int C++: int GetLayer()

C++: int GetLayer()

Set/Get the layer that this renderer belongs to. This is only used if there are layered renderers.

  • Note: Changing the layer will update the PreserveColorBuffer setting. If
  • the layer is 0, PreserveColorBuffer will be set to false, making the
  • bottom renderer opaque. If the layer is non-zero, PreserveColorBuffer will
  • be set to true, giving the renderer a transparent background. If other
  • PreserveColorBuffer configurations are desired, they must be adjusted after
  • the layer is set.
GetLightFollowCamera() -> int C++: int GetLightFollowCamera()

C++: int GetLightFollowCamera()

Turn on/off the automatic repositioning of lights as the camera moves. If LightFollowCamera is on, lights that are designated as Headlights or CameraLights will be adjusted to move with this renderer’s camera. If LightFollowCamera is off, the lights will not be adjusted.

  • (Note: In previous versions of vtk, this light-tracking
  • functionality was part of the interactors, not the renderer. For
  • backwards compatibility, the older, more limited interactor
  • behavior is enabled by default. To disable this mode, turn the
  • interactor’s LightFollowCamera flag OFF, and leave the renderer’s
  • LightFollowCamera flag ON.)
GetLights() -> vtkLightCollection C++: vtkLightCollection *GetLights()

C++: vtkLightCollection *GetLights()

Return the collection of lights.

GetMTime() -> int C++: vtkMTimeType GetMTime()

C++: vtkMTimeType GetMTime()

Return the MTime of the renderer also considering its ivars.

GetMaximumNumberOfPeels() -> int C++: int GetMaximumNumberOfPeels()

C++: int GetMaximumNumberOfPeels()

In case of depth peeling, define the maximum number of peeling layers. Initial value is 4. A special value of 0 means no maximum limit. It has to be a positive value.

GetNearClippingPlaneTolerance() -> float C++: double GetNearClippingPlaneTolerance()

C++: double GetNearClippingPlaneTolerance()

Specify tolerance for near clipping plane distance to the camera as a percentage of the far clipping plane distance. By default this will be set to 0.01 for 16 bit zbuffers and 0.001 for higher depth z buffers

GetNearClippingPlaneToleranceMaxValue() -> float C++: double GetNearClippingPlaneToleranceMaxValue()

C++: double GetNearClippingPlaneToleranceMaxValue()

Specify tolerance for near clipping plane distance to the camera as a percentage of the far clipping plane distance. By default this will be set to 0.01 for 16 bit zbuffers and 0.001 for higher depth z buffers

GetNearClippingPlaneToleranceMinValue() -> float C++: double GetNearClippingPlaneToleranceMinValue()

C++: double GetNearClippingPlaneToleranceMinValue()

Specify tolerance for near clipping plane distance to the camera as a percentage of the far clipping plane distance. By default this will be set to 0.01 for 16 bit zbuffers and 0.001 for higher depth z buffers

GetNumberOfPropsRendered() -> int C++: int GetNumberOfPropsRendered()

C++: int GetNumberOfPropsRendered()

Should be used internally only during a render Get the number of props that were rendered using a RenderOpaqueGeometry or RenderTranslucentPolygonalGeometry call. This is used to know if something is in the frame buffer.

GetOcclusionRatio() -> float C++: double GetOcclusionRatio()

C++: double GetOcclusionRatio()

In case of use of depth peeling technique for rendering translucent material, define the threshold under which the algorithm stops to iterate over peel layers. This is the ratio of the number of pixels that have been touched by the last layer over the total number of pixels of the viewport area. Initial value is 0.0, meaning rendering have to be exact. Greater values may speed-up the rendering with small impact on the quality.

GetOcclusionRatioMaxValue() -> float C++: double GetOcclusionRatioMaxValue()

C++: double GetOcclusionRatioMaxValue()

In case of use of depth peeling technique for rendering translucent material, define the threshold under which the algorithm stops to iterate over peel layers. This is the ratio of the number of pixels that have been touched by the last layer over the total number of pixels of the viewport area. Initial value is 0.0, meaning rendering have to be exact. Greater values may speed-up the rendering with small impact on the quality.

GetOcclusionRatioMinValue() -> float C++: double GetOcclusionRatioMinValue()

C++: double GetOcclusionRatioMinValue()

In case of use of depth peeling technique for rendering translucent material, define the threshold under which the algorithm stops to iterate over peel layers. This is the ratio of the number of pixels that have been touched by the last layer over the total number of pixels of the viewport area. Initial value is 0.0, meaning rendering have to be exact. Greater values may speed-up the rendering with small impact on the quality.

GetPass() -> vtkRenderPass C++: vtkRenderPass *GetPass()

C++: vtkRenderPass *GetPass()

GetPreserveColorBuffer() -> int C++: int GetPreserveColorBuffer()

C++: int GetPreserveColorBuffer()

By default, the renderer at layer 0 is opaque, and all non-zero layer renderers are transparent. This flag allows this behavior to be overridden. If true, this setting will force the renderer to preserve the existing color buffer regardless of layer. If false, it will always be cleared at the start of rendering.

  • This flag influences the Transparent() method, and is updated by calls to
  • SetLayer(). For this reason it should only be set after changing the layer.
GetPreserveDepthBuffer() -> int C++: int GetPreserveDepthBuffer()

C++: int GetPreserveDepthBuffer()

By default, the depth buffer is reset for each renderer. If this flag is true, this renderer will use the existing depth buffer for its rendering.

GetRenderWindow() -> vtkRenderWindow C++: vtkRenderWindow *GetRenderWindow()

C++: vtkRenderWindow *GetRenderWindow()

Specify the rendering window in which to draw. This is automatically set when the renderer is created by MakeRenderer. The user probably shouldn’t ever need to call this method.

GetSelector() -> vtkHardwareSelector C++: vtkHardwareSelector *GetSelector()

C++: vtkHardwareSelector *GetSelector()

Get the current hardware selector. If the Selector is set, it implies the current render pass is for selection. Mappers/Properties may choose to behave differently when rendering for hardware selection.

GetTexturedBackground() -> bool C++: bool GetTexturedBackground()

C++: bool GetTexturedBackground()

Set/Get whether this viewport should have a textured background. Default is off.

GetTiledAspectRatio() -> float C++: double GetTiledAspectRatio()

C++: double GetTiledAspectRatio()

Compute the aspect ratio of this renderer for the current tile. When tiled displays are used the aspect ratio of the renderer for a given tile may be different that the aspect ratio of the renderer when rendered in it entirity

GetTimeFactor() -> float C++: virtual double GetTimeFactor()

C++: virtual double GetTimeFactor()

Get the ratio between allocated time and actual render time. TimeFactor has been taken out of the render process. It is still computed in case someone finds it useful. It may be taken away in the future.

GetTwoSidedLighting() -> int C++: int GetTwoSidedLighting()

C++: int GetTwoSidedLighting()

Turn on/off two-sided lighting of surfaces. If two-sided lighting is off, then only the side of the surface facing the light(s) will be lit, and the other side dark. If two-sided lighting on, both sides of the surface will be lit.

GetUseDepthPeeling() -> int C++: int GetUseDepthPeeling()

C++: int GetUseDepthPeeling()

Turn on/off rendering of translucent material with depth peeling technique. The render window must have alpha bits (ie call SetAlphaBitPlanes(1)) and no multisample buffer (ie call SetMultiSamples(0) ) to support depth peeling. If UseDepthPeeling is on and the GPU supports it, depth peeling is used for rendering translucent materials. If UseDepthPeeling is off, alpha blending is used. Initial value is off.

GetUseFXAA() -> bool C++: bool GetUseFXAA()

C++: bool GetUseFXAA()

Turn on/off FXAA anti-aliasing, if supported. Initial value is off.

GetUseHiddenLineRemoval() -> int C++: int GetUseHiddenLineRemoval()

C++: int GetUseHiddenLineRemoval()

If this flag is true and the rendering engine supports it, wireframe geometry will be drawn using hidden line removal.

GetUseShadows() -> int C++: int GetUseShadows()

C++: int GetUseShadows()

Turn on/off rendering of shadows if supported Initial value is off.

GetVTKWindow() -> vtkWindow C++: virtual vtkWindow *GetVTKWindow()

C++: virtual vtkWindow *GetVTKWindow()

Specify the rendering window in which to draw. This is automatically set when the renderer is created by MakeRenderer. The user probably shouldn’t ever need to call this method.

GetVolumes() -> vtkVolumeCollection C++: vtkVolumeCollection *GetVolumes()

C++: vtkVolumeCollection *GetVolumes()

Return the collection of volumes.

GetZ(int, int) -> float C++: double GetZ(int x, int y)

C++: double GetZ(int x, int y)

Given a pixel location, return the Z value. The z value is normalized (0,1) between the front and back clipping planes.

InteractiveOff() C++: void InteractiveOff()

C++: void InteractiveOff()

Turn on/off interactive status. An interactive renderer is one that can receive events from an interactor. Should only be set if there are multiple renderers in the same section of the viewport.

InteractiveOn() C++: void InteractiveOn()

C++: void InteractiveOn()

Turn on/off interactive status. An interactive renderer is one that can receive events from an interactor. Should only be set if there are multiple renderers in the same section of the viewport.

IsA(string) -> int C++: int IsA(const char *name)

C++: int IsA(const char *name)

IsActiveCameraCreated() -> int C++: int IsActiveCameraCreated()

C++: int IsActiveCameraCreated()

This method returns 1 if the ActiveCamera has already been set or automatically created by the renderer. It returns 0 if the ActiveCamera does not yet exist.

LightFollowCameraOff() C++: void LightFollowCameraOff()

C++: void LightFollowCameraOff()

Turn on/off the automatic repositioning of lights as the camera moves. If LightFollowCamera is on, lights that are designated as Headlights or CameraLights will be adjusted to move with this renderer’s camera. If LightFollowCamera is off, the lights will not be adjusted.

  • (Note: In previous versions of vtk, this light-tracking
  • functionality was part of the interactors, not the renderer. For
  • backwards compatibility, the older, more limited interactor
  • behavior is enabled by default. To disable this mode, turn the
  • interactor’s LightFollowCamera flag OFF, and leave the renderer’s
  • LightFollowCamera flag ON.)
LightFollowCameraOn() C++: void LightFollowCameraOn()

C++: void LightFollowCameraOn()

Turn on/off the automatic repositioning of lights as the camera moves. If LightFollowCamera is on, lights that are designated as Headlights or CameraLights will be adjusted to move with this renderer’s camera. If LightFollowCamera is off, the lights will not be adjusted.

  • (Note: In previous versions of vtk, this light-tracking
  • functionality was part of the interactors, not the renderer. For
  • backwards compatibility, the older, more limited interactor
  • behavior is enabled by default. To disable this mode, turn the
  • interactor’s LightFollowCamera flag OFF, and leave the renderer’s
  • LightFollowCamera flag ON.)
MakeCamera() -> vtkCamera C++: virtual vtkCamera *MakeCamera()

C++: virtual vtkCamera *MakeCamera()

Create a new Camera sutible for use with this type of Renderer. For example, a vtkMesaRenderer should create a vtkMesaCamera in this function. The default is to just call vtkCamera::New.

MakeLight() -> vtkLight C++: virtual vtkLight *MakeLight()

C++: virtual vtkLight *MakeLight()

Create a new Light sutible for use with this type of Renderer. For example, a vtkMesaRenderer should create a vtkMesaLight in this function. The default is to just call vtkLight::New.

NewInstance() -> vtkRenderer C++: vtkRenderer *NewInstance()

C++: vtkRenderer *NewInstance()

PickProp(float, float) -> vtkAssemblyPath C++: vtkAssemblyPath *PickProp(double selectionX, double selectionY) V.PickProp(float, float, float, float) -> vtkAssemblyPath C++: vtkAssemblyPath *PickProp(double selectionX1, double selectionY1, double selectionX2, double selectionY2)
C++: vtkAssemblyPath *PickProp(double selectionX,
double selectionY)

V.PickProp(float, float, float, float) -> vtkAssemblyPath C++: vtkAssemblyPath *PickProp(double selectionX1,

double selectionY1, double selectionX2, double selectionY2)

Return the prop (via a vtkAssemblyPath) that has the highest z value at the given x, y position in the viewport. Basically, the top most prop that renders the pixel at selectionX, selectionY will be returned. If nothing was picked then NULL is returned. This method selects from the renderers Prop list.

PreserveColorBufferOff() C++: void PreserveColorBufferOff()

C++: void PreserveColorBufferOff()

By default, the renderer at layer 0 is opaque, and all non-zero layer renderers are transparent. This flag allows this behavior to be overridden. If true, this setting will force the renderer to preserve the existing color buffer regardless of layer. If false, it will always be cleared at the start of rendering.

  • This flag influences the Transparent() method, and is updated by calls to
  • SetLayer(). For this reason it should only be set after changing the layer.
PreserveColorBufferOn() C++: void PreserveColorBufferOn()

C++: void PreserveColorBufferOn()

By default, the renderer at layer 0 is opaque, and all non-zero layer renderers are transparent. This flag allows this behavior to be overridden. If true, this setting will force the renderer to preserve the existing color buffer regardless of layer. If false, it will always be cleared at the start of rendering.

  • This flag influences the Transparent() method, and is updated by calls to
  • SetLayer(). For this reason it should only be set after changing the layer.
PreserveDepthBufferOff() C++: void PreserveDepthBufferOff()

C++: void PreserveDepthBufferOff()

By default, the depth buffer is reset for each renderer. If this flag is true, this renderer will use the existing depth buffer for its rendering.

PreserveDepthBufferOn() C++: void PreserveDepthBufferOn()

C++: void PreserveDepthBufferOn()

By default, the depth buffer is reset for each renderer. If this flag is true, this renderer will use the existing depth buffer for its rendering.

ReleaseGraphicsResources(vtkWindow) C++: virtual void ReleaseGraphicsResources(vtkWindow *)

C++: virtual void ReleaseGraphicsResources(vtkWindow *)

RemoveActor(vtkProp) C++: void RemoveActor(vtkProp *p)

C++: void RemoveActor(vtkProp *p)

Add/Remove different types of props to the renderer. These methods are all synonyms to AddViewProp and RemoveViewProp. They are here for convenience and backwards compatibility.

RemoveAllLights() C++: void RemoveAllLights()

C++: void RemoveAllLights()

Remove all lights from the list of lights.

RemoveCuller(vtkCuller) C++: void RemoveCuller(vtkCuller *)

C++: void RemoveCuller(vtkCuller *)

Remove an actor from the list of cullers.

RemoveLight(vtkLight) C++: void RemoveLight(vtkLight *)

C++: void RemoveLight(vtkLight *)

Remove a light from the list of lights.

RemoveVolume(vtkProp) C++: void RemoveVolume(vtkProp *p)

C++: void RemoveVolume(vtkProp *p)

Add/Remove different types of props to the renderer. These methods are all synonyms to AddViewProp and RemoveViewProp. They are here for convenience and backwards compatibility.

Render() C++: virtual void Render()

C++: virtual void Render()

CALLED BY vtkRenderWindow ONLY. End-user pass your way and call vtkRenderWindow::Render(). Create an image. This is a superclass method which will in turn call the DeviceRender method of Subclasses of vtkRenderer.

ResetCamera() C++: virtual void ResetCamera() V.ResetCamera([float, float, float, float, float, float]) C++: virtual void ResetCamera(double bounds[6]) V.ResetCamera(float, float, float, float, float, float) C++: virtual void ResetCamera(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)

C++: virtual void ResetCamera() V.ResetCamera([float, float, float, float, float, float]) C++: virtual void ResetCamera(double bounds[6]) V.ResetCamera(float, float, float, float, float, float) C++: virtual void ResetCamera(double xmin, double xmax,

double ymin, double ymax, double zmin, double zmax)

Automatically set up the camera based on the visible actors. The camera will reposition itself to view the center point of the actors, and move along its initial view plane normal (i.e., vector defined from camera position to focal point) so that all of the actors can be seen.

ResetCameraClippingRange() C++: void ResetCameraClippingRange() V.ResetCameraClippingRange([float, float, float, float, float, float]) C++: void ResetCameraClippingRange(double bounds[6]) V.ResetCameraClippingRange(float, float, float, float, float, float) C++: void ResetCameraClippingRange(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)

C++: void ResetCameraClippingRange() V.ResetCameraClippingRange([float, float, float, float, float,

float])

C++: void ResetCameraClippingRange(double bounds[6]) V.ResetCameraClippingRange(float, float, float, float, float,

float)
C++: void ResetCameraClippingRange(double xmin, double xmax,
double ymin, double ymax, double zmin, double zmax)

Reset the camera clipping range based on the bounds of the visible actors. This ensures that no props are cut off

SafeDownCast(vtkObject) -> vtkRenderer C++: vtkRenderer *SafeDownCast(vtkObject* o)

C++: vtkRenderer SafeDownCast(vtkObject o)

SetActiveCamera(vtkCamera) C++: void SetActiveCamera(vtkCamera *)

C++: void SetActiveCamera(vtkCamera *)

Specify the camera to use for this renderer.

SetAllocatedRenderTime(float) C++: void SetAllocatedRenderTime(double a)

C++: void SetAllocatedRenderTime(double a)

Set/Get the amount of time this renderer is allowed to spend rendering its scene. This is used by vtkLODActor’s.

SetAmbient(float, float, float) C++: void SetAmbient(double, double, double) V.SetAmbient((float, float, float)) C++: void SetAmbient(double a[3])

C++: void SetAmbient(double, double, double) V.SetAmbient((float, float, float)) C++: void SetAmbient(double a[3])

SetAutomaticLightCreation(int) C++: void SetAutomaticLightCreation(int a)

C++: void SetAutomaticLightCreation(int a)

Turn on/off a flag which disables the automatic light creation capability. Normally in VTK if no lights are associated with the renderer, then a light is automatically created. However, in special circumstances this feature is undesirable, so the following boolean is provided to disable automatic light creation. (Turn AutomaticLightCreation off if you do not want lights to be created.)

SetBackgroundTexture(vtkTexture) C++: virtual void SetBackgroundTexture(vtkTexture *)

C++: virtual void SetBackgroundTexture(vtkTexture *)

Set/Get the texture to be used for the background. If set and enabled this gets the priority over the gradient background.

SetBackingStore(int) C++: void SetBackingStore(int a)

C++: void SetBackingStore(int a)

Turn on/off using backing store. This may cause the re-rendering time to be slightly slower when the view changes. But it is much faster when the image has not changed, such as during an expose event.

SetClippingRangeExpansion(float) C++: void SetClippingRangeExpansion(double)

C++: void SetClippingRangeExpansion(double)

Specify enlargement of bounds when resetting the camera clipping range. By default the range is not expanded by any percent of the (far - near) on the near and far sides

SetDelegate(vtkRendererDelegate) C++: void SetDelegate(vtkRendererDelegate *d)

C++: void SetDelegate(vtkRendererDelegate *d)

Set/Get a custom Render call. Allows to hook a Render call from an external project.It will be used in place of vtkRenderer::Render() if it is not NULL and its Used ivar is set to true. Initial value is NULL.

SetDraw(int) C++: void SetDraw(int a)

C++: void SetDraw(int a)

When this flag is off, render commands are ignored. It is used to either multiplex a vtkRenderWindow or render only part of a vtkRenderWindow. By default, Draw is on.

SetErase(int) C++: void SetErase(int a)

C++: void SetErase(int a)

When this flag is off, the renderer will not erase the background or the Zbuffer. It is used to have overlapping renderers. Both the RenderWindow Erase and Render Erase must be on for the camera to clear the renderer. By default, Erase is on.

SetFXAAOptions(vtkFXAAOptions) C++: virtual void SetFXAAOptions(vtkFXAAOptions *)

C++: virtual void SetFXAAOptions(vtkFXAAOptions *)

The configuration object for FXAA antialiasing.

SetGL2PSSpecialPropCollection(vtkPropCollection) C++: void SetGL2PSSpecialPropCollection(vtkPropCollection *)

C++: void SetGL2PSSpecialPropCollection(vtkPropCollection *)

Set the prop collection object used during vtkRenderWindow::CaptureGL2PSSpecialProps(). Do not call manually, this is handled automatically by the render window.

SetInformation(vtkInformation) C++: virtual void SetInformation(vtkInformation *)

C++: virtual void SetInformation(vtkInformation *)

Set/Get the information object associated with this algorithm.

SetInteractive(int) C++: void SetInteractive(int a)

C++: void SetInteractive(int a)

Turn on/off interactive status. An interactive renderer is one that can receive events from an interactor. Should only be set if there are multiple renderers in the same section of the viewport.

SetLayer(int) C++: virtual void SetLayer(int layer)

C++: virtual void SetLayer(int layer)

Set/Get the layer that this renderer belongs to. This is only used if there are layered renderers.

  • Note: Changing the layer will update the PreserveColorBuffer setting. If
  • the layer is 0, PreserveColorBuffer will be set to false, making the
  • bottom renderer opaque. If the layer is non-zero, PreserveColorBuffer will
  • be set to true, giving the renderer a transparent background. If other
  • PreserveColorBuffer configurations are desired, they must be adjusted after
  • the layer is set.
SetLightCollection(vtkLightCollection) C++: void SetLightCollection(vtkLightCollection *lights)

C++: void SetLightCollection(vtkLightCollection *lights)

Set the collection of lights. We cannot name it SetLights because of TestSetGet pre lights_exist: lights!=0 post lights_set: lights==this->GetLights()

SetLightFollowCamera(int) C++: void SetLightFollowCamera(int a)

C++: void SetLightFollowCamera(int a)

Turn on/off the automatic repositioning of lights as the camera moves. If LightFollowCamera is on, lights that are designated as Headlights or CameraLights will be adjusted to move with this renderer’s camera. If LightFollowCamera is off, the lights will not be adjusted.

  • (Note: In previous versions of vtk, this light-tracking
  • functionality was part of the interactors, not the renderer. For
  • backwards compatibility, the older, more limited interactor
  • behavior is enabled by default. To disable this mode, turn the
  • interactor’s LightFollowCamera flag OFF, and leave the renderer’s
  • LightFollowCamera flag ON.)
SetMaximumNumberOfPeels(int) C++: void SetMaximumNumberOfPeels(int a)

C++: void SetMaximumNumberOfPeels(int a)

In case of depth peeling, define the maximum number of peeling layers. Initial value is 4. A special value of 0 means no maximum limit. It has to be a positive value.

SetNearClippingPlaneTolerance(float) C++: void SetNearClippingPlaneTolerance(double)

C++: void SetNearClippingPlaneTolerance(double)

Specify tolerance for near clipping plane distance to the camera as a percentage of the far clipping plane distance. By default this will be set to 0.01 for 16 bit zbuffers and 0.001 for higher depth z buffers

SetOcclusionRatio(float) C++: void SetOcclusionRatio(double)

C++: void SetOcclusionRatio(double)

In case of use of depth peeling technique for rendering translucent material, define the threshold under which the algorithm stops to iterate over peel layers. This is the ratio of the number of pixels that have been touched by the last layer over the total number of pixels of the viewport area. Initial value is 0.0, meaning rendering have to be exact. Greater values may speed-up the rendering with small impact on the quality.

SetPass(vtkRenderPass) C++: void SetPass(vtkRenderPass *p)

C++: void SetPass(vtkRenderPass *p)

SetPreserveColorBuffer(int) C++: void SetPreserveColorBuffer(int a)

C++: void SetPreserveColorBuffer(int a)

By default, the renderer at layer 0 is opaque, and all non-zero layer renderers are transparent. This flag allows this behavior to be overridden. If true, this setting will force the renderer to preserve the existing color buffer regardless of layer. If false, it will always be cleared at the start of rendering.

  • This flag influences the Transparent() method, and is updated by calls to
  • SetLayer(). For this reason it should only be set after changing the layer.
SetPreserveDepthBuffer(int) C++: void SetPreserveDepthBuffer(int a)

C++: void SetPreserveDepthBuffer(int a)

By default, the depth buffer is reset for each renderer. If this flag is true, this renderer will use the existing depth buffer for its rendering.

SetRenderWindow(vtkRenderWindow) C++: void SetRenderWindow(vtkRenderWindow *)

C++: void SetRenderWindow(vtkRenderWindow *)

Specify the rendering window in which to draw. This is automatically set when the renderer is created by MakeRenderer. The user probably shouldn’t ever need to call this method.

SetTexturedBackground(bool) C++: void SetTexturedBackground(bool a)

C++: void SetTexturedBackground(bool a)

Set/Get whether this viewport should have a textured background. Default is off.

SetTwoSidedLighting(int) C++: void SetTwoSidedLighting(int a)

C++: void SetTwoSidedLighting(int a)

Turn on/off two-sided lighting of surfaces. If two-sided lighting is off, then only the side of the surface facing the light(s) will be lit, and the other side dark. If two-sided lighting on, both sides of the surface will be lit.

SetUseDepthPeeling(int) C++: void SetUseDepthPeeling(int a)

C++: void SetUseDepthPeeling(int a)

Turn on/off rendering of translucent material with depth peeling technique. The render window must have alpha bits (ie call SetAlphaBitPlanes(1)) and no multisample buffer (ie call SetMultiSamples(0) ) to support depth peeling. If UseDepthPeeling is on and the GPU supports it, depth peeling is used for rendering translucent materials. If UseDepthPeeling is off, alpha blending is used. Initial value is off.

SetUseFXAA(bool) C++: void SetUseFXAA(bool a)

C++: void SetUseFXAA(bool a)

Turn on/off FXAA anti-aliasing, if supported. Initial value is off.

SetUseHiddenLineRemoval(int) C++: void SetUseHiddenLineRemoval(int a)

C++: void SetUseHiddenLineRemoval(int a)

If this flag is true and the rendering engine supports it, wireframe geometry will be drawn using hidden line removal.

SetUseShadows(int) C++: void SetUseShadows(int a)

C++: void SetUseShadows(int a)

Turn on/off rendering of shadows if supported Initial value is off.

StereoMidpoint() C++: virtual void StereoMidpoint()

C++: virtual void StereoMidpoint()

Do anything necessary between rendering the left and right viewpoints in a stereo render. Doesn’t do anything except in the derived vtkIceTRenderer in ParaView.

TexturedBackgroundOff() C++: void TexturedBackgroundOff()

C++: void TexturedBackgroundOff()

Set/Get whether this viewport should have a textured background. Default is off.

TexturedBackgroundOn() C++: void TexturedBackgroundOn()

C++: void TexturedBackgroundOn()

Set/Get whether this viewport should have a textured background. Default is off.

Transparent() -> int C++: int Transparent()

C++: int Transparent()

Returns a boolean indicating if this renderer is transparent. It is transparent if it is not in the deepest layer of its render window.

TwoSidedLightingOff() C++: void TwoSidedLightingOff()

C++: void TwoSidedLightingOff()

Turn on/off two-sided lighting of surfaces. If two-sided lighting is off, then only the side of the surface facing the light(s) will be lit, and the other side dark. If two-sided lighting on, both sides of the surface will be lit.

TwoSidedLightingOn() C++: void TwoSidedLightingOn()

C++: void TwoSidedLightingOn()

Turn on/off two-sided lighting of surfaces. If two-sided lighting is off, then only the side of the surface facing the light(s) will be lit, and the other side dark. If two-sided lighting on, both sides of the surface will be lit.

UpdateLightsGeometryToFollowCamera() -> int C++: virtual int UpdateLightsGeometryToFollowCamera(void)

C++: virtual int UpdateLightsGeometryToFollowCamera(void)

Ask the lights in the scene that are not in world space (for instance, Headlights or CameraLights that are attached to the camera) to update their geometry to match the active camera.

UseDepthPeelingOff() C++: void UseDepthPeelingOff()

C++: void UseDepthPeelingOff()

Turn on/off rendering of translucent material with depth peeling technique. The render window must have alpha bits (ie call SetAlphaBitPlanes(1)) and no multisample buffer (ie call SetMultiSamples(0) ) to support depth peeling. If UseDepthPeeling is on and the GPU supports it, depth peeling is used for rendering translucent materials. If UseDepthPeeling is off, alpha blending is used. Initial value is off.

UseDepthPeelingOn() C++: void UseDepthPeelingOn()

C++: void UseDepthPeelingOn()

Turn on/off rendering of translucent material with depth peeling technique. The render window must have alpha bits (ie call SetAlphaBitPlanes(1)) and no multisample buffer (ie call SetMultiSamples(0) ) to support depth peeling. If UseDepthPeeling is on and the GPU supports it, depth peeling is used for rendering translucent materials. If UseDepthPeeling is off, alpha blending is used. Initial value is off.

UseFXAAOff() C++: void UseFXAAOff()

C++: void UseFXAAOff()

Turn on/off FXAA anti-aliasing, if supported. Initial value is off.

UseFXAAOn() C++: void UseFXAAOn()

C++: void UseFXAAOn()

Turn on/off FXAA anti-aliasing, if supported. Initial value is off.

UseHiddenLineRemovalOff() C++: void UseHiddenLineRemovalOff()

C++: void UseHiddenLineRemovalOff()

If this flag is true and the rendering engine supports it, wireframe geometry will be drawn using hidden line removal.

UseHiddenLineRemovalOn() C++: void UseHiddenLineRemovalOn()

C++: void UseHiddenLineRemovalOn()

If this flag is true and the rendering engine supports it, wireframe geometry will be drawn using hidden line removal.

UseShadowsOff() C++: void UseShadowsOff()

C++: void UseShadowsOff()

Turn on/off rendering of shadows if supported Initial value is off.

UseShadowsOn() C++: void UseShadowsOn()

C++: void UseShadowsOn()

Turn on/off rendering of shadows if supported Initial value is off.

ViewToWorld() C++: void ViewToWorld() V.ViewToWorld(float, float, float) C++: virtual void ViewToWorld(double &wx, double &wy, double &wz)

C++: void ViewToWorld() V.ViewToWorld(float, float, float) C++: virtual void ViewToWorld(double &wx, double &wy, double &wz)

Convert view point coordinates to world coordinates.

VisibleActorCount() -> int C++: int VisibleActorCount()

C++: int VisibleActorCount()

Returns the number of visible actors.

VisibleVolumeCount() -> int C++: int VisibleVolumeCount()

C++: int VisibleVolumeCount()

Returns the number of visible volumes.

WorldToView() C++: void WorldToView() V.WorldToView(float, float, float) C++: virtual void WorldToView(double &wx, double &wy, double &wz)

C++: void WorldToView() V.WorldToView(float, float, float) C++: virtual void WorldToView(double &wx, double &wy, double &wz)

Convert world point coordinates to view coordinates.

add

dipy.viz.window.add(ren, a)

Add a specific actor

analyze_renderer

dipy.viz.window.analyze_renderer(ren)

analyze_snapshot

dipy.viz.window.analyze_snapshot(im, bg_color=(0, 0, 0), colors=None, find_objects=True, strel=None)

Analyze snapshot from memory or file

Parameters:

im: str or array

If string then the image is read from a file otherwise the image is read from a numpy array. The array is expected to be of shape (X, Y, 3) where the last dimensions are the RGB values.

colors: tuple (3,) or list of tuples (3,)

List of colors to search in the image

find_objects: bool

If True it will calculate the number of objects that are different from the background and return their position in a new image.

strel: 2d array

Structure element to use for finding the objects.

Returns:

report : ReportSnapshot

This is an object with attibutes like colors_found that give information about what was found in the current snapshot array im.

asbytes

dipy.viz.window.asbytes(s)

clear

dipy.viz.window.clear(ren)

Remove all actors from the renderer

copy

dipy.viz.window.copy(x)

Shallow copy operation on arbitrary Python objects.

See the module’s __doc__ string for more info.

open_file_dialog

dipy.viz.window.open_file_dialog(file_types=[('All files', '*')])

Simple Tk file dialog for opening files

Parameters:

file_types : tuples of tuples

Accepted file types.

Returns:

file_paths : sequence of str

Returns the full paths of all selected files

optional_package

dipy.viz.window.optional_package(name, trip_msg=None)

Return package-like thing and module setup for package name

Parameters:

name : str

package name

trip_msg : None or str

message to give when someone tries to use the return package, but we could not import it, and have returned a TripWire object instead. Default message if None.

Returns:

pkg_like : module or TripWire instance

If we can import the package, return it. Otherwise return an object raising an error when accessed

have_pkg : bool

True if import for package was successful, false otherwise

module_setup : function

callable usually set as setup_module in calling namespace, to allow skipping tests.

record

dipy.viz.window.record(ren=None, cam_pos=None, cam_focal=None, cam_view=None, out_path=None, path_numbering=False, n_frames=1, az_ang=10, magnification=1, size=(300, 300), reset_camera=True, verbose=False)

This will record a video of your scene

Records a video as a series of .png files of your scene by rotating the azimuth angle az_angle in every frame.

Parameters:

ren : vtkRenderer() object

as returned from function ren()

cam_pos : None or sequence (3,), optional

Camera’s position. If None then default camera’s position is used.

cam_focal : None or sequence (3,), optional

Camera’s focal point. If None then default camera’s focal point is used.

cam_view : None or sequence (3,), optional

Camera’s view up direction. If None then default camera’s view up vector is used.

out_path : str, optional

Output path for the frames. If None a default dipy.png is created.

path_numbering : bool

When recording it changes out_path to out_path + str(frame number)

n_frames : int, optional

Number of frames to save, default 1

az_ang : float, optional

Azimuthal angle of camera rotation.

magnification : int, optional

How much to magnify the saved frame. Default is 1.

size : (int, int)

(width, height) of the window. Default is (300, 300).

reset_camera : bool

If True Call ren.reset_camera(). Otherwise you need to set the

camera before calling this function.

verbose : bool

print information about the camera. Default is False.

Examples

>>> from dipy.viz import window, actor
>>> ren = window.Renderer()
>>> a = actor.axes()
>>> ren.add(a)
>>> # uncomment below to record
>>> # window.record(ren)
>>> #check for new images in current directory

ren

dipy.viz.window.ren(background=None)

Create a renderer.

Parameters:

background : tuple

Initial background color of renderer

Returns:

v : Renderer

Examples

>>> from dipy.viz import window, actor
>>> import numpy as np
>>> r = window.Renderer()
>>> lines=[np.random.rand(10,3)]
>>> c=actor.line(lines, window.colors.red)
>>> r.add(c)
>>> #window.show(r)

renderer

dipy.viz.window.renderer(background=None)

Create a renderer.

Parameters:

background : tuple

Initial background color of renderer

Returns:

v : Renderer

Examples

>>> from dipy.viz import window, actor
>>> import numpy as np
>>> r = window.Renderer()
>>> lines=[np.random.rand(10,3)]
>>> c=actor.line(lines, window.colors.red)
>>> r.add(c)
>>> #window.show(r)

rm

dipy.viz.window.rm(ren, a)

Remove a specific actor

rm_all

dipy.viz.window.rm_all(ren)

Remove all actors from the renderer

save_file_dialog

dipy.viz.window.save_file_dialog(initial_file='dipy.png', default_ext='.png', file_types=(('PNG file', '*.png'), ('All Files', '*.*')))

Simple Tk file dialog for saving a file

Parameters:

initial_file : str

For example dipy.png.

default_ext : str

Default extension to appear in the save dialog.

file_types : tuples of tuples

Accepted file types.

Returns:

filepath : str

Complete filename of saved file

setup_module

dipy.viz.window.setup_module()

show

dipy.viz.window.show(ren, title='DIPY', size=(300, 300), png_magnify=1, reset_camera=True, order_transparent=False)

Show window with current renderer

Parameters:

ren : Renderer() or vtkRenderer()

The scene that holds all the actors.

title : string

A string for the window title bar. Default is DIPY and current version.

size : (int, int)

(width, height) of the window. Default is (300, 300).

png_magnify : int

Number of times to magnify the screenshot. Default is 1. This can be used to save high resolution screenshots when pressing ‘s’ inside the window.

reset_camera : bool

Default is True. You can change this option to False if you want to keep the camera as set before calling this function.

order_transparent : bool

True is useful when you want to order transparent actors according to their relative position to the camera. The default option which is False will order the actors according to the order of their addition to the Renderer().

Notes

Default interaction keys for

  • 3d navigation are with left, middle and right mouse dragging
  • resetting the camera press ‘r’
  • saving a screenshot press ‘s’
  • for quiting press ‘q’

Examples

>>> import numpy as np
>>> from dipy.viz import window, actor
>>> r = window.Renderer()
>>> lines=[np.random.rand(10,3),np.random.rand(20,3)]
>>> colors=np.array([[0.2,0.2,0.2],[0.8,0.8,0.8]])
>>> c=actor.line(lines,colors)
>>> r.add(c)
>>> l=actor.label(text="Hello")
>>> r.add(l)
>>> #window.show(r)

snapshot

dipy.viz.window.snapshot(ren, fname=None, size=(300, 300), offscreen=True, order_transparent=False)

Saves a snapshot of the renderer in a file or in memory

Parameters:

ren : vtkRenderer

as returned from function renderer()

fname : str or None

Save PNG file. If None return only an array without saving PNG.

size : (int, int)

(width, height) of the window. Default is (300, 300).

offscreen : bool

Default True. Go stealthmode no window should appear.

order_transparent : bool

Default False. Use depth peeling to sort transparent objects.

Returns:

arr : ndarray

Color array of size (width, height, 3) where the last dimension holds the RGB values.

vtk_to_numpy

dipy.viz.window.vtk_to_numpy(vtk_array)

Converts a VTK data array to a numpy array.

Given a subclass of vtkDataArray, this function returns an appropriate numpy array containing the same data – it actually points to the same data.

WARNING: This does not work for bit arrays.

Parameters:

- vtk_array : vtkDataArray

The VTK data array to be converted.

warn

dipy.viz.window.warn()

Issue a warning, or maybe ignore it or raise an exception.