actor

Module that provide actors to render.

Actor

alias of vtkmodules.vtkRenderingCore.vtkActor

ArrowSource

alias of vtkmodules.vtkFiltersSources.vtkArrowSource

Assembly

alias of vtkmodules.vtkRenderingCore.vtkAssembly

ButterflySubdivisionFilter

alias of vtkmodules.vtkFiltersModeling.vtkButterflySubdivisionFilter

CellArray

alias of vtkmodules.vtkCommonDataModel.vtkCellArray

CellPicker

alias of vtkmodules.vtkRenderingCore.vtkCellPicker

CleanPolyData

alias of vtkmodules.vtkFiltersCore.vtkCleanPolyData

ConeSource

alias of vtkmodules.vtkFiltersSources.vtkConeSource

Container([layout])

Provides functionalities for grouping multiple actors using a given layout.

ContourFilter

alias of vtkmodules.vtkFiltersCore.vtkContourFilter

CylinderSource

alias of vtkmodules.vtkFiltersSources.vtkCylinderSource

DataSetMapper

alias of vtkmodules.vtkRenderingCore.vtkDataSetMapper

DiskSource

alias of vtkmodules.vtkFiltersSources.vtkDiskSource

FloatArray

alias of vtkmodules.vtkCommonCore.vtkFloatArray

Follower

alias of vtkmodules.vtkRenderingCore.vtkFollower

ImageActor

alias of vtkmodules.vtkRenderingCore.vtkImageActor

ImageData

alias of vtkmodules.vtkCommonDataModel.vtkImageData

ImageMapToColors

alias of vtkmodules.vtkImagingCore.vtkImageMapToColors

ImageReslice

alias of vtkmodules.vtkImagingCore.vtkImageReslice

LODActor

alias of vtkmodules.vtkRenderingLOD.vtkLODActor

LookupTable

alias of vtkmodules.vtkCommonCore.vtkLookupTable

LoopSubdivisionFilter

alias of vtkmodules.vtkFiltersModeling.vtkLoopSubdivisionFilter

Matrix4x4

alias of vtkmodules.vtkCommonMath.vtkMatrix4x4

OdfSlicerActor(odfs, vertices, faces, ...[, ...])

VTK actor for visualizing slices of ODF field.

OutlineFilter

alias of vtkmodules.vtkFiltersModeling.vtkOutlineFilter

PeakActor(directions, indices[, values, ...])

VTK actor for visualizing slices of ODF field.

Points

alias of vtkmodules.vtkCommonCore.vtkPoints

PolyData

alias of vtkmodules.vtkCommonDataModel.vtkPolyData

PolyDataMapper

alias of vtkmodules.vtkRenderingCore.vtkPolyDataMapper

PolyDataMapper2D

alias of vtkmodules.vtkRenderingCore.vtkPolyDataMapper2D

PolyDataNormals

alias of vtkmodules.vtkFiltersCore.vtkPolyDataNormals

PolyVertex

alias of vtkmodules.vtkCommonDataModel.vtkPolyVertex

ScalarBarActor

alias of vtkmodules.vtkRenderingAnnotation.vtkScalarBarActor

SphereSource

alias of vtkmodules.vtkFiltersSources.vtkSphereSource

SplineFilter

alias of vtkmodules.vtkFiltersGeneral.vtkSplineFilter

TextActor3D

alias of vtkmodules.vtkRenderingCore.vtkTextActor3D

Texture

alias of vtkmodules.vtkRenderingCore.vtkTexture

TextureMapToPlane

alias of vtkmodules.vtkFiltersTexture.vtkTextureMapToPlane

TexturedActor2D

alias of vtkmodules.vtkRenderingCore.vtkTexturedActor2D

TexturedSphereSource

alias of vtkmodules.vtkFiltersSources.vtkTexturedSphereSource

Transform

alias of vtkmodules.vtkCommonTransforms.vtkTransform

TubeFilter

alias of vtkmodules.vtkFiltersCore.vtkTubeFilter

UnstructuredGrid

alias of vtkmodules.vtkCommonDataModel.vtkUnstructuredGrid

VectorText

alias of vtkmodules.vtkRenderingFreeType.vtkVectorText

partial

partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.

add_shader_callback(actor, callback[, priority])

Add a shader callback to the actor.

apply_affine(aff, pts)

Apply affine matrix aff to points pts.

arrow(centers, directions, colors[, ...])

Visualize one or many arrows with differents features.

attribute_to_actor(actor, arr, attr_name[, deep])

Link a numpy array with vertex attribute.

axes([scale, colorx, colory, colorz, opacity])

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

billboard(centers[, colors, scales, vs_dec, ...])

Create a billboard actor.

box(centers[, directions, colors, scales])

Visualize one or many boxes with different features.

colormap_lookup_table([scale_range, ...])

Lookup table for the colormap.

cone(centers, directions, colors[, heights, ...])

Visualize one or many cones with different features.

contour_from_label(data[, affine, color])

Generate surface actor from a labeled Array.

contour_from_roi(data[, affine, color, opacity])

Generate surface actor from a binary ROI.

cube(centers[, directions, colors, scales])

Visualize one or many cubes with different features.

cylinder(centers, directions, colors[, ...])

Visualize one or many cylinder with different features.

deprecate_with_version(message[, since, ...])

Return decorator function for deprecation warning / error.

deprecated_params(old_name[, new_name, ...])

Deprecate a renamed or removed function argument.

disk(centers, directions, colors[, rinner, ...])

Visualize one or many disks with different features.

dots(points[, color, opacity, dot_size])

Create one or more 3d points.

figure(pic[, interpolation])

Return a figure as an image actor.

fix_winding_order(vertices, triangles[, ...])

Return corrected triangles.

frustum(centers[, directions, colors, scales])

Visualize one or many frustum pyramids with different features.

get_actor_from_primitive(vertices, triangles)

Get actor from a vtkPolyData.

grid(actors[, captions, caption_offset, ...])

Creates a grid of actors that lies in the xy-plane.

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.

load(filename)

load_image(filename[, as_vtktype, use_pillow])

Load an image.

markers(centers[, colors, scales, marker, ...])

Create a marker actor with different shapes.

numpy_to_vtk_colors(colors)

Convert Numpy color array to a vtk color array.

numpy_to_vtk_matrix(array)

Convert a numpy array to a VTK matrix.

octagonalprism(centers[, directions, ...])

Visualize one or many octagonal prisms with different features.

odf_slicer(odfs[, affine, mask, sphere, ...])

Create an actor for rendering a grid of ODFs given an array of spherical function (SF) or spherical harmonics (SH) coefficients.

peak(peaks_dirs[, peaks_values, mask, ...])

Visualize peak directions as given from peaks_from_model.

peak_slicer(peaks_dirs[, peaks_values, ...])

Visualize peak directions as given from peaks_from_model.

pentagonalprism(centers[, directions, ...])

Visualize one or many pentagonal prisms with different features.

point(points, colors[, point_radius, phi, ...])

Visualize points as sphere glyphs

rectangle(centers[, directions, colors, scales])

Visualize one or many rectangles with different features.

repeat_sources(centers, colors[, ...])

Transform a vtksource to glyph.

replace_shader_in_actor(actor, shader_type, code)

Set and Replace the shader template with a new one.

rgb_to_vtk(data)

RGB or RGBA images to VTK arrays.

rhombicuboctahedron(centers[, directions, ...])

Visualize one or many rhombicuboctahedron with different features.

scalar_bar([lookup_table, title])

Default scalar bar actor for a given colormap (colorbar)

sdf(centers[, directions, colors, ...])

Create a SDF primitive based actor

set_input(vtk_object, inp)

Set Generic input function which takes into account VTK 5 or 6.

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).

shader_to_actor(actor, shader_type[, ...])

Apply your own substitutions to the shader creation process.

shallow_copy(vtk_object)

Create a shallow copy of a given vtkObject object.

slicer(data[, affine, value_range, opacity, ...])

Cut 3D scalar or rgb volumes into 2D images.

sphere(centers, colors[, radii, phi, theta, ...])

Visualize one or many spheres with different colors and radii

square(centers[, directions, colors, scales])

Visualize one or many squares with different features.

streamtube(lines[, colors, opacity, ...])

Use streamtubes to visualize polylines.

superquadric(centers[, roundness, ...])

Visualize one or many superquadrics with different features.

surface(vertices[, faces, colors, smooth, ...])

Generate a surface actor from an array of vertices.

tensor_slicer(evals, evecs[, affine, mask, ...])

Slice many tensors as ellipsoids in native or world coordinates.

text_3d(text[, position, color, font_size, ...])

Generate 2D text that lives in the 3D world

texture(rgb[, interp])

Map an RGB or RGBA texture on a plane.

texture_2d(rgb[, interp])

Create 2D texture from array

texture_on_sphere(rgb[, theta, phi, interpolate])

texture_update(texture_actor, arr)

Updates texture of an actor by updating the vtkImageData assigned to the vtkTexture object.

triangularprism(centers[, directions, ...])

Visualize one or many regular triangular prisms with different features.

vector_text([text, pos, scale, color])

Create a label actor.

Actor

fury.actor.Actor

alias of vtkmodules.vtkRenderingCore.vtkActor

ArrowSource

fury.actor.ArrowSource

alias of vtkmodules.vtkFiltersSources.vtkArrowSource

Assembly

fury.actor.Assembly

alias of vtkmodules.vtkRenderingCore.vtkAssembly

ButterflySubdivisionFilter

fury.actor.ButterflySubdivisionFilter

alias of vtkmodules.vtkFiltersModeling.vtkButterflySubdivisionFilter

CellArray

fury.actor.CellArray

alias of vtkmodules.vtkCommonDataModel.vtkCellArray

CellPicker

fury.actor.CellPicker

alias of vtkmodules.vtkRenderingCore.vtkCellPicker

CleanPolyData

fury.actor.CleanPolyData

alias of vtkmodules.vtkFiltersCore.vtkCleanPolyData

ConeSource

fury.actor.ConeSource

alias of vtkmodules.vtkFiltersSources.vtkConeSource

Container

class fury.actor.Container(layout=<fury.layout.Layout object>)[source]

Bases: object

Provides functionalities for grouping multiple actors using a given layout.

anchor

Anchor of this container used when laying out items in a container. The anchor point is relative to the center of the container. Default: (0, 0, 0).

Type

3-tuple of float

padding

Padding around this container bounding box. The 6-tuple represents (pad_x_neg, pad_x_pos, pad_y_neg, pad_y_pos, pad_z_neg, pad_z_pos). Default: (0, 0, 0, 0, 0, 0)

Type

6-tuple of float

__init__(layout=<fury.layout.Layout object>)[source]
Parameters

layout (fury.layout.Layout object) – Items of this container will be arranged according to layout.

AddPosition(position)[source]
GetBounds()[source]

Get the bounds of the container.

GetCenter()[source]

Get the center of the bounding box.

GetLength()[source]

Get the length of bounding box diagonal.

GetPosition()[source]
GetVisibility()[source]
NewInstance()[source]
SetPosition(position)[source]
SetVisibility(visibility)[source]
ShallowCopy(other)[source]
add(*items, **kwargs)[source]

Adds some items to this container.

Parameters
  • items (vtkProp3D objects) – Items to add to this container.

  • borrow (bool) – If True the items are added as-is, otherwise a shallow copy is made first. If you intend to reuse the items elsewhere you should set borrow=False. Default: True.

add_to_scene(ren)[source]

Adds the items of this container to a given scene.

clear()[source]

Clears all items of this container.

property items
update()[source]

Updates the position of the items of this container.

ContourFilter

fury.actor.ContourFilter

alias of vtkmodules.vtkFiltersCore.vtkContourFilter

CylinderSource

fury.actor.CylinderSource

alias of vtkmodules.vtkFiltersSources.vtkCylinderSource

DataSetMapper

fury.actor.DataSetMapper

alias of vtkmodules.vtkRenderingCore.vtkDataSetMapper

DiskSource

fury.actor.DiskSource

alias of vtkmodules.vtkFiltersSources.vtkDiskSource

FloatArray

fury.actor.FloatArray

alias of vtkmodules.vtkCommonCore.vtkFloatArray

Follower

fury.actor.Follower

alias of vtkmodules.vtkRenderingCore.vtkFollower

ImageActor

fury.actor.ImageActor

alias of vtkmodules.vtkRenderingCore.vtkImageActor

ImageData

fury.actor.ImageData

alias of vtkmodules.vtkCommonDataModel.vtkImageData

ImageMapToColors

fury.actor.ImageMapToColors

alias of vtkmodules.vtkImagingCore.vtkImageMapToColors

ImageReslice

fury.actor.ImageReslice

alias of vtkmodules.vtkImagingCore.vtkImageReslice

LODActor

fury.actor.LODActor

alias of vtkmodules.vtkRenderingLOD.vtkLODActor

LookupTable

fury.actor.LookupTable

alias of vtkmodules.vtkCommonCore.vtkLookupTable

LoopSubdivisionFilter

fury.actor.LoopSubdivisionFilter

alias of vtkmodules.vtkFiltersModeling.vtkLoopSubdivisionFilter

Matrix4x4

fury.actor.Matrix4x4

alias of vtkmodules.vtkCommonMath.vtkMatrix4x4

OdfSlicerActor

class fury.actor.OdfSlicerActor(odfs, vertices, faces, indices, scale, norm, radial_scale, shape, global_cm, colormap, opacity, affine=None, B=None)[source]

Bases: vtkmodules.vtkRenderingCore.vtkActor

VTK actor for visualizing slices of ODF field.

Parameters
  • odfs (ndarray) – SF or SH coefficients 2-dimensional array.

  • vertices (ndarray) – The sphere vertices used for SH to SF projection.

  • faces (ndarray) – Indices of sphere vertices forming triangles. Should be ordered clockwise (see fury.utils.fix_winding_order).

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

  • scale (float) – Multiplicative factor to apply to ODF amplitudes.

  • norm (bool) – Normalize SF amplitudes so that the maximum ODF amplitude per voxel along a direction is 1.

  • radial_scale (bool) – Scale sphere points by ODF values.

  • global_cm (bool) – If True the colormap will be applied in all ODFs. If False it will be applied individually at each voxel.

  • colormap (None or str) – The name of the colormap to use. Matplotlib colormaps are supported (e.g., ‘inferno’). If None then a RGB colormap is used.

  • opacity (float) – Takes values from 0 (fully transparent) to 1 (opaque).

  • affine (array) – optional 4x4 transformation array from native coordinates to world coordinates.

  • B (ndarray (n_coeffs, n_vertices)) – Optional SH to SF matrix for projecting odfs given in SH coefficents on the sphere. If None, then the input is assumed to be expressed in SF coefficients.

__init__(odfs, vertices, faces, indices, scale, norm, radial_scale, shape, global_cm, colormap, opacity, affine=None, B=None)[source]
display(x=None, y=None, z=None)[source]

Display a slice along x, y, or z axis.

display_extent(x1, x2, y1, y2, z1, z2)[source]

Set visible volume from x1 (inclusive) to x2 (inclusive), y1 (inclusive) to y2 (inclusive), z1 (inclusive) to z2 (inclusive).

set_opacity(opacity)[source]

Set opacity value of ODFs to display.

slice_along_axis(slice_index, axis='zaxis')[source]

Slice ODF field at given slice_index along axis in [‘xaxis’, ‘yaxis’, zaxis’].

update_sphere(vertices, faces, B)[source]

Dynamically change the sphere used for SH to SF projection.

OutlineFilter

fury.actor.OutlineFilter

alias of vtkmodules.vtkFiltersModeling.vtkOutlineFilter

PeakActor

class fury.actor.PeakActor(directions, indices, values=None, affine=None, colors=None, lookup_colormap=None, linewidth=1)[source]

Bases: vtkmodules.vtkRenderingCore.vtkActor

VTK actor for visualizing slices of ODF field.

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

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

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

  • affine (array, optional) – 4x4 transformation array from native coordinates to world coordinates.

  • colors (None or string ('rgb_standard') or tuple (3D or 4D) or) –

    array/ndarray (N, 3 or 4) or array/ndarray (K, 3 or 4) or

    array/ndarray(N, ) or array/ndarray (K, )

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

  • lookup_colormap (vtkLookupTable, optional) – Add a default lookup table to the colormap. Default is None which calls fury.actor.colormap_lookup_table().

  • linewidth (float, optional) – Line thickness. Default is 1.

__init__(directions, indices, values=None, affine=None, colors=None, lookup_colormap=None, linewidth=1)[source]
property cross_section
display_cross_section(x, y, z)[source]
display_extent(x1, x2, y1, y2, z1, z2)[source]
property global_opacity
property high_ranges
property is_range
property linewidth
property low_ranges
property max_centers
property min_centers

Points

fury.actor.Points

alias of vtkmodules.vtkCommonCore.vtkPoints

PolyData

fury.actor.PolyData

alias of vtkmodules.vtkCommonDataModel.vtkPolyData

PolyDataMapper

fury.actor.PolyDataMapper

alias of vtkmodules.vtkRenderingCore.vtkPolyDataMapper

PolyDataMapper2D

fury.actor.PolyDataMapper2D

alias of vtkmodules.vtkRenderingCore.vtkPolyDataMapper2D

PolyDataNormals

fury.actor.PolyDataNormals

alias of vtkmodules.vtkFiltersCore.vtkPolyDataNormals

PolyVertex

fury.actor.PolyVertex

alias of vtkmodules.vtkCommonDataModel.vtkPolyVertex

ScalarBarActor

fury.actor.ScalarBarActor

alias of vtkmodules.vtkRenderingAnnotation.vtkScalarBarActor

SphereSource

fury.actor.SphereSource

alias of vtkmodules.vtkFiltersSources.vtkSphereSource

SplineFilter

fury.actor.SplineFilter

alias of vtkmodules.vtkFiltersGeneral.vtkSplineFilter

TextActor3D

fury.actor.TextActor3D

alias of vtkmodules.vtkRenderingCore.vtkTextActor3D

Texture

fury.actor.Texture

alias of vtkmodules.vtkRenderingCore.vtkTexture

TextureMapToPlane

fury.actor.TextureMapToPlane

alias of vtkmodules.vtkFiltersTexture.vtkTextureMapToPlane

TexturedActor2D

fury.actor.TexturedActor2D

alias of vtkmodules.vtkRenderingCore.vtkTexturedActor2D

TexturedSphereSource

fury.actor.TexturedSphereSource

alias of vtkmodules.vtkFiltersSources.vtkTexturedSphereSource

Transform

fury.actor.Transform

alias of vtkmodules.vtkCommonTransforms.vtkTransform

TubeFilter

fury.actor.TubeFilter

alias of vtkmodules.vtkFiltersCore.vtkTubeFilter

UnstructuredGrid

fury.actor.UnstructuredGrid

alias of vtkmodules.vtkCommonDataModel.vtkUnstructuredGrid

VectorText

fury.actor.VectorText

alias of vtkmodules.vtkRenderingFreeType.vtkVectorText

partial

class fury.actor.partial[source]

Bases: object

partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.

__init__()
args

tuple of arguments to future partial calls

func

function object to use in future partial calls

keywords

dictionary of keyword arguments to future partial calls

add_shader_callback

fury.actor.add_shader_callback(actor, callback, priority=0.0)[source]

Add a shader callback to the actor.

Parameters
  • actor (vtkActor) – Rendered Object

  • callback (callable) – function or class that contains 3 parameters: caller, event, calldata. This callback will be trigger at each UpdateShaderEvent event.

  • priority (float, optional) – Commands with a higher priority are called first.

Returns

id_observer – An unsigned Int tag which can be used later to remove the event or retrieve the vtkCommand used in the observer. See more at: https://vtk.org/doc/nightly/html/classvtkObject.html

Return type

int

Examples

add_shader_callback(actor, func_call1)
id_observer = add_shader_callback(actor, func_call2)
actor.GetMapper().RemoveObserver(id_observer)

Priority calls

test_values = []
def callbackLow(_caller, _event, calldata=None):
    program = calldata
    if program is not None:
        test_values.append(0)

def callbackHigh(_caller, _event, calldata=None):
    program = calldata
    if program is not None:
        test_values.append(999)

def callbackMean(_caller, _event, calldata=None):
    program = calldata
    if program is not None:
        test_values.append(500)

fs.add_shader_callback(
        actor, callbackHigh, 999)
fs.add_shader_callback(
        actor, callbackLow, 0)
id_mean = fs.add_shader_callback(
        actor, callbackMean, 500)

showm.start()
# test_values = [999, 500, 0, 999, 500, 0, ...]

apply_affine

fury.actor.apply_affine(aff, pts)[source]

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 – transformed points

Return type

(…, N-1) array

Notes

Copied from nibabel to remove dependency.

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]]]...)

arrow

fury.actor.arrow(centers, directions, colors, heights=1.0, resolution=10, tip_length=0.35, tip_radius=0.1, shaft_radius=0.03, vertices=None, faces=None)[source]

Visualize one or many arrows with differents features.

Parameters
  • centers (ndarray, shape (N, 3)) – Arrow positions

  • directions (ndarray, shape (N, 3)) – The orientation vector of the arrow.

  • colors (ndarray (N,3) or (N, 4) or tuple (3,) or tuple (4,)) – RGB or RGBA (for opacity) R, G, B and A should be at the range [0, 1]

  • heights (ndarray, shape (N)) – The height of the arrow.

  • resolution (int) – The resolution of the arrow.

  • tip_length (float) – The tip size of the arrow (default: 0.35)

  • tip_radius (float) – the tip radius of the arrow (default: 0.1)

  • shaft_radius (float) – The shaft radius of the arrow (default: 0.03)

  • vertices (ndarray, shape (N, 3)) – The point cloud defining the arrow.

  • faces (ndarray, shape (M, 3)) – If faces is None then a arrow is created based on directions, heights and resolution. If not then a arrow is created with the provided vertices and faces.

Returns

arrow_actor

Return type

Actor

Examples

>>> from fury import window, actor
>>> scene = window.Scene()
>>> centers = np.random.rand(5, 3)
>>> directions = np.random.rand(5, 3)
>>> heights = np.random.rand(5)
>>> arrow_actor = actor.arrow(centers, directions, (1, 1, 1), heights)
>>> scene.add(arrow_actor)
>>> # window.show(scene)

attribute_to_actor

fury.actor.attribute_to_actor(actor, arr, attr_name, deep=True)[source]

Link a numpy array with vertex attribute.

Parameters
  • actor (vtkActor) – Rendered Object

  • arr (ndarray) – array to link to vertices

  • attr_name (str) – vertex attribute name. the vtk array will take the same name as the attribute.

  • deep (bool, optional) – If True a deep copy is applied. Otherwise a shallow copy is applied, by default True

axes

fury.actor.axes(scale=(1, 1, 1), colorx=(1, 0, 0), colory=(0, 1, 0), colorz=(0, 0, 1), opacity=1)[source]

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

arrow_actor

Return type

Actor

billboard

fury.actor.billboard(centers, colors=(0, 1, 0), scales=1, vs_dec=None, vs_impl=None, fs_dec=None, fs_impl=None, gs_dec=None, gs_impl=None)[source]

Create a billboard actor.

Billboards are 2D elements incrusted in a 3D world. It offers you the possibility to draw differents shapes/elements at the shader level.

Parameters
  • centers (ndarray, shape (N, 3)) – Superquadrics positions

  • colors (ndarray (N,3) or (N, 4) or tuple (3,) or tuple (4,)) – RGB or RGBA (for opacity) R, G, B and A should be at the range [0, 1]

  • scales (ndarray, shape (N) or (N,3) or float or int, optional) – The height of the cone.

  • vs_dec (str or list of str, optional) – vertex shaders code that contains all variable/function delarations

  • vs_impl (str or list of str, optional) – vertex shaders code that contains all variable/function implementation

  • fs_dec (str or list of str, optional) – Fragment shaders code that contains all variable/function delarations

  • fs_impl (str or list of str, optional) – Fragment shaders code that contains all variable/function implementation

  • gs_dec (str or list of str, optional) – Geometry shaders code that contains all variable/function delarations

  • gs_impl (str or list of str, optional) – Geometry shaders code that contains all variable/function mplementation

Returns

sq_actor

Return type

Actor

box

fury.actor.box(centers, directions=(1, 0, 0), colors=(1, 0, 0), scales=(1, 2, 3))[source]

Visualize one or many boxes with different features.

Parameters
  • centers (ndarray, shape (N, 3)) – Box positions

  • directions (ndarray, shape (N, 3), optional) – The orientation vector of the box.

  • colors (ndarray (N,3) or (N, 4) or tuple (3,) or tuple (4,), optional) – RGB or RGBA (for opacity) R, G, B and A should be at the range [0, 1]

  • scales (int or ndarray (N,3) or tuple (3,), optional) – Box size on each direction (x, y), default(1)

Returns

box_actor

Return type

Actor

Examples

>>> from fury import window, actor
>>> scene = window.Scene()
>>> centers = np.random.rand(5, 3)
>>> dirs = np.random.rand(5, 3)
>>> box_actor = actor.box(centers, dirs, (1, 1, 1))
>>> scene.add(box_actor)
>>> # window.show(scene)

colormap_lookup_table

fury.actor.colormap_lookup_table(scale_range=(0, 1), hue_range=(0.8, 0), saturation_range=(1, 1), value_range=(0.8, 0.8))[source]

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

Return type

LookupTable

cone

fury.actor.cone(centers, directions, colors, heights=1.0, resolution=10, vertices=None, faces=None)[source]

Visualize one or many cones with different features.

Parameters
  • centers (ndarray, shape (N, 3)) – Cone positions

  • directions (ndarray, shape (N, 3)) – The orientation vector of the cone.

  • colors (ndarray (N,3) or (N, 4) or tuple (3,) or tuple (4,)) – RGB or RGBA (for opacity) R, G, B and A should be at the range [0, 1]

  • heights (ndarray, shape (N)) – The height of the cone.

  • resolution (int) – The resolution of the cone.

  • vertices (ndarray, shape (N, 3)) – The point cloud defining the cone.

  • faces (ndarray, shape (M, 3)) – If faces is None then a cone is created based on directions, heights and resolution. If not then a cone is created with the provided vertices and faces.

Returns

cone_actor

Return type

Actor

Examples

>>> from fury import window, actor
>>> scene = window.Scene()
>>> centers = np.random.rand(5, 3)
>>> directions = np.random.rand(5, 3)
>>> heights = np.random.rand(5)
>>> cone_actor = actor.cone(centers, directions, (1, 1, 1), heights)
>>> scene.add(cone_actor)
>>> # window.show(scene)

contour_from_label

fury.actor.contour_from_label(data, affine=None, color=None)[source]

Generate surface actor from a labeled Array.

The color and opacity of individual surfaces can be customized.

Parameters
  • data (array, shape (X, Y, Z)) – A labeled array 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 ((N, 3) or (N, 4) ndarray) – RGB/RGBA values in [0,1]. Default is None. If None then random colors are used. Alpha channel is set to 1 by default.

Returns

contour_assembly – Array surface object displayed in space coordinates as calculated by the affine parameter in the order of their roi ids.

Return type

vtkAssembly

contour_from_roi

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

Generate 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 – ROI surface object displayed in space coordinates as calculated by the affine parameter.

Return type

vtkAssembly

cube

fury.actor.cube(centers, directions=(1, 0, 0), colors=(1, 0, 0), scales=1)[source]

Visualize one or many cubes with different features.

Parameters
  • centers (ndarray, shape (N, 3)) – Cube positions

  • directions (ndarray, shape (N, 3), optional) – The orientation vector of the cube.

  • colors (ndarray (N,3) or (N, 4) or tuple (3,) or tuple (4,), optional) – RGB or RGBA (for opacity) R, G, B and A should be at the range [0, 1]

  • scales (int or ndarray (N,3) or tuple (3,), optional) – Cube size, default=1

Returns

cube_actor

Return type

Actor

Examples

>>> from fury import window, actor
>>> scene = window.Scene()
>>> centers = np.random.rand(5, 3)
>>> dirs = np.random.rand(5, 3)
>>> cube_actor = actor.cube(centers, dirs)
>>> scene.add(cube_actor)
>>> # window.show(scene)

cylinder

fury.actor.cylinder(centers, directions, colors, radius=0.05, heights=1, capped=False, resolution=6, vertices=None, faces=None)[source]

Visualize one or many cylinder with different features.

Parameters
  • centers (ndarray, shape (N, 3)) – Cylinder positions

  • directions (ndarray, shape (N, 3)) – The orientation vector of the cylinder.

  • colors (ndarray (N,3) or (N, 4) or tuple (3,) or tuple (4,)) – RGB or RGBA (for opacity) R, G, B and A should be at the range [0, 1]

  • radius (float) – cylinder radius, default: 1

  • heights (ndarray, shape (N)) – The height of the arrow.

  • capped (bool) – Turn on/off whether to cap cylinder with polygons. Default (False)

  • resolution (int) – Number of facets used to define cylinder.

  • vertices (ndarray, shape (N, 3)) – The point cloud defining the sphere.

  • faces (ndarray, shape (M, 3)) – If faces is None then a sphere is created based on theta and phi angles If not then a sphere is created with the provided vertices and faces.

Returns

cylinder_actor

Return type

Actor

Examples

>>> from fury import window, actor
>>> scene = window.Scene()
>>> centers = np.random.rand(5, 3)
>>> dirs = np.random.rand(5, 3)
>>> heights = np.random.rand(5)
>>> actor = actor.cylinder(centers, dirs, (1, 1, 1), heights=heights)
>>> scene.add(actor)
>>> # window.show(scene)

deprecate_with_version

fury.actor.deprecate_with_version(message, since='', until='', version_comparator=<function cmp_pkg_version>, warn_class=<class 'DeprecationWarning'>, error_class=<class 'fury.deprecator.ExpiredDeprecationError'>)[source]

Return decorator function for deprecation warning / error.

The decorated function / method will:

  • Raise the given warning_class warning when the function / method gets called, up to (and including) version until (if specified);

  • Raise the given error_class error when the function / method gets called, when the package version is greater than version until (if specified).

Parameters
  • message (str) – Message explaining deprecation, giving possible alternatives.

  • since (str, optional) – Released version at which object was first deprecated.

  • until (str, optional) – Last released version at which this function will still raise a deprecation warning. Versions higher than this will raise an error.

  • version_comparator (callable) – Callable accepting string as argument, and return 1 if string represents a higher version than encoded in the version_comparator`, 0 if the version is equal, and -1 if the version is lower. For example, the version_comparator may compare the input version string to the current package version string.

  • warn_class (class, optional) – Class of warning to generate for deprecation.

  • error_class (class, optional) – Class of error to generate when version_comparator returns 1 for a given argument of until.

Returns

deprecator – Function returning a decorator.

Return type

func

deprecated_params

fury.actor.deprecated_params(old_name, new_name=None, since='', until='', version_comparator=<function cmp_pkg_version>, arg_in_kwargs=False, warn_class=<class 'fury.deprecator.ArgsDeprecationWarning'>, error_class=<class 'fury.deprecator.ExpiredDeprecationError'>, alternative='')[source]

Deprecate a renamed or removed function argument.

The decorator assumes that the argument with the old_name was removed from the function signature and the new_name replaced it at the same position in the signature. If the old_name argument is given when calling the decorated function the decorator will catch it and issue a deprecation warning and pass it on as new_name argument.

Parameters
  • old_name (str or list/tuple thereof) – The old name of the argument.

  • new_name (str or list/tuple thereof or None, optional) – The new name of the argument. Set this to None to remove the argument old_name instead of renaming it.

  • since (str or number or list/tuple thereof, optional) – The release at which the old argument became deprecated.

  • until (str or number or list/tuple thereof, optional) – Last released version at which this function will still raise a deprecation warning. Versions higher than this will raise an error.

  • version_comparator (callable) – Callable accepting string as argument, and return 1 if string represents a higher version than encoded in the version_comparator, 0 if the version is equal, and -1 if the version is lower. For example, the version_comparator may compare the input version string to the current package version string.

  • arg_in_kwargs (bool or list/tuple thereof, optional) – If the argument is not a named argument (for example it was meant to be consumed by **kwargs) set this to True. Otherwise the decorator will throw an Exception if the new_name cannot be found in the signature of the decorated function. Default is False.

  • warn_class (warning, optional) – Warning to be issued.

  • error_class (Exception, optional) – Error to be issued

  • alternative (str, optional) – An alternative function or class name that the user may use in place of the deprecated object if new_name is None. The deprecation warning will tell the user about this alternative if provided.

Raises

TypeError – If the new argument name cannot be found in the function signature and arg_in_kwargs was False or if it is used to deprecate the name of the *args-, **kwargs-like arguments. At runtime such an Error is raised if both the new_name and old_name were specified when calling the function and “relax=False”.

Notes

This function is based on the Astropy (major modification). https://github.com/astropy/astropy. See COPYING file distributed along with the astropy package for the copyright and license terms.

Examples

The deprecation warnings are not shown in the following examples. To deprecate a positional or keyword argument:: >>> from fury.deprecator import deprecated_params >>> @deprecated_params(‘sig’, ‘sigma’, ‘0.3’) … def test(sigma): … return sigma >>> test(2) 2 >>> test(sigma=2) 2 >>> test(sig=2) # doctest: +SKIP 2

It is also possible to replace multiple arguments. The old_name, new_name and since have to be tuple or list and contain the same number of entries:: >>> @deprecated_params([‘a’, ‘b’], [‘alpha’, ‘beta’], … [‘0.2’, 0.4]) … def test(alpha, beta): … return alpha, beta >>> test(a=2, b=3) # doctest: +SKIP (2, 3)

disk

fury.actor.disk(centers, directions, colors, rinner=0.3, router=0.7, cresolution=6, rresolution=2, vertices=None, faces=None)[source]

Visualize one or many disks with different features.

Parameters
  • centers (ndarray, shape (N, 3)) – Disk positions

  • directions (ndarray, shape (N, 3)) – The orientation vector of the disk.

  • colors (ndarray (N,3) or (N, 4) or tuple (3,) or tuple (4,)) – RGB or RGBA (for opacity) R, G, B and A should be at the range [0, 1]

  • rinner (float) – disk inner radius, default: 0.3

  • router (float) – disk outer radius, default: 0.5

  • cresolution (int, optional) – Number of facets used to define perimeter of disk, default: 6

  • rresolution (int, optional) – Number of facets used radially, default: 2

  • vertices (ndarray, shape (N, 3)) – The point cloud defining the disk.

  • faces (ndarray, shape (M, 3)) – If faces is None then a disk is created based on theta and phi angles If not then a disk is created with the provided vertices and faces.

Returns

disk_actor

Return type

Actor

Examples

>>> from fury import window, actor
>>> import numpy as np
>>> scene = window.Scene()
>>> centers = np.random.rand(5, 3)
>>> dirs = np.random.rand(5, 3)
>>> colors = np.random.rand(5, 4)
>>> actor = actor.disk(centers, dirs, colors,
>>>                    rinner=.1, router=.8, cresolution=30)
>>> scene.add(actor)
>>> window.show(scene)

dots

fury.actor.dots(points, color=(1, 0, 0), opacity=1, dot_size=5)[source]

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

dot_actor

Return type

Actor

figure

fury.actor.figure(pic, interpolation='nearest')[source]

Return a figure as an image actor.

Parameters
  • pic (filename or numpy RGBA array) –

  • interpolation (str) – Options are nearest, linear or cubic. Default is nearest.

Returns

image_actor

Return type

vtkImageActor

fix_winding_order

fury.actor.fix_winding_order(vertices, triangles, clockwise=False)[source]

Return corrected triangles.

Given an ordering of the triangle’s three vertices, a triangle can appear to have a clockwise winding or counter-clockwise winding. Clockwise means that the three vertices, in order, rotate clockwise around the triangle’s center.

Parameters
  • vertices (ndarray) – array of vertices corresponding to a shape

  • triangles (ndarray) – array of triangles corresponding to a shape

  • clockwise (bool) – triangle order type: clockwise (default) or counter-clockwise.

Returns

corrected_triangles – The corrected order of the vert parameter

Return type

ndarray

frustum

fury.actor.frustum(centers, directions=(1, 0, 0), colors=(0, 1, 0), scales=1)[source]

Visualize one or many frustum pyramids with different features.

Parameters
  • centers (ndarray, shape (N, 3)) – Frustum pyramid positions

  • directions (ndarray, shape (N, 3)) – The orientation vector of the frustum pyramid.

  • colors (ndarray (N,3) or (N, 4) or tuple (3,) or tuple (4,)) – RGB or RGBA (for opacity) R, G, B and A should be at the range [0, 1]

  • scales (int or ndarray (N,3) or tuple (3,), optional) – Frustum pyramid size on each direction (x, y), default(1)

Returns

frustum_actor

Return type

Actor

Examples

>>> from fury import window, actor
>>> scene = window.Scene()
>>> centers = np.random.rand(4, 3)
>>> dirs = np.random.rand(4, 3)
>>> colors = np.random.rand(4, 3)
>>> scales = np.random.rand(4, 1)
>>> actor = actor.frustum(centers, dirs, colors, scales)
>>> scene.add(actor)
>>> # window.show(scene)

get_actor_from_primitive

fury.actor.get_actor_from_primitive(vertices, triangles, colors=None, normals=None, backface_culling=True)[source]

Get actor from a vtkPolyData.

Parameters
  • vertices ((Mx3) ndarray) – XYZ coordinates of the object

  • triangles ((Nx3) ndarray) – Indices into vertices; forms triangular faces.

  • colors ((Nx3) or (Nx4) ndarray) – RGB or RGBA (for opacity) R, G, B and A should be at the range [0, 1] N is equal to the number of vertices.

  • normals ((Nx3) ndarray) – normals, represented as 2D ndarrays (Nx3) (one per vertex)

  • backface_culling (bool) – culling of polygons based on orientation of normal with respect to camera. If backface culling is True, polygons facing away from camera are not drawn. Default: True

Returns

actor

Return type

actor

grid

fury.actor.grid(actors, captions=None, caption_offset=(0, - 100, 0), cell_padding=0, cell_shape='rect', aspect_ratio=1.7777777777777777, dim=None)[source]

Creates a grid of actors that lies in the xy-plane.

Parameters
  • actors (list of vtkProp3D objects) – Actors to be layout in a grid manner.

  • captions (list of vtkProp3D objects or list of str) – Objects serving as captions (can be any vtkProp3D object, not necessarily text). There should be one caption per actor. By default, there are no captions.

  • caption_offset (tuple of float (optional)) – Tells where to position the caption w.r.t. the center of its associated actor. Default: (0, -100, 0).

  • cell_padding (tuple of 2 floats or float) – Each grid cell will be padded according to (pad_x, pad_y) i.e. horizontally and vertically. Padding is evenly distributed on each side of the cell. If a single float is provided then both pad_x and pad_y will have the same value.

  • cell_shape (str) – Specifies the desired shape of every grid cell. ‘rect’ ensures the cells are the tightest. ‘square’ ensures the cells are as wide as high. ‘diagonal’ ensures the content of the cells can be rotated without colliding with content of the neighboring cells.

  • aspect_ratio (float) – Aspect ratio of the grid (width/height). Default: 16:9.

  • dim (tuple of int) – Dimension (nb_rows, nb_cols) of the grid. If provided, aspect_ratio will be ignored.

Returns

Object that represents the grid containing all the actors and captions, if any.

Return type

fury.actor.Container object

label

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

Create a label actor.

Label function has been renamed vector_text

  • deprecated from version: 0.7.1

  • Will raise <class ‘fury.deprecator.ExpiredDeprecationError’> as of version: 0.9.0

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 – Label.

Return type

Actor object

Examples

>>> from fury import window, actor
>>> scene = window.Scene()
>>> l = actor.label(text='Hello')
>>> scene.add(l)
>>> #window.show(scene)

line

fury.actor.line(lines, colors=None, opacity=1, linewidth=1, spline_subdiv=None, lod=True, lod_points=10000, lod_points_size=3, lookup_colormap=None, depth_cue=False, fake_tube=False)[source]

Create an actor for one or more lines.

Parameters
  • lines (list of arrays) –

  • colors (array (N, 3), list of arrays, tuple (3,), array (K,)) – If None or False, 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.

  • 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, optional) – Use LODActor(level of detail) rather than Actor. Default is True. Level of detail actors do not render the full geometry when the frame rate is low.

  • lod_points (int, optional) – 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 (vtkLookupTable, optional) – Add a default lookup table to the colormap. Default is None which calls fury.actor.colormap_lookup_table().

  • depth_cue (boolean, optional) – Add a size depth cue so that lines shrink with distance to the camera. Works best with linewidth <= 1.

  • fake_tube (boolean, optional) – Add shading to lines to approximate the look of tubes.

Returns

v – Line.

Return type

Actor or LODActor object

Examples

>>> from fury import actor, window
>>> scene = window.Scene()
>>> lines = [np.random.rand(10, 3), np.random.rand(20, 3)]
>>> colors = np.random.rand(2, 3)
>>> c = actor.line(lines, colors)
>>> scene.add(c)
>>> #window.show(scene)

lines_to_vtk_polydata

fury.actor.lines_to_vtk_polydata(lines, colors=None)[source]

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,)) – If None or False, 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)

  • color_is_scalar (bool, true if the color array is a single scalar) – Scalar array could be used with a colormap lut None if no color was used

load

fury.actor.load(filename)[source]

load_image

fury.actor.load_image(filename, as_vtktype=False, use_pillow=True)[source]

Load an image.

Parameters
  • filename (str) – should be png, bmp, jpeg or jpg files

  • as_vtktype (bool, optional) – if True, return vtk output otherwise an ndarray. Default False.

  • use_pillow (bool, optional) – Use pillow python library to load the files. Default True

Returns

image – desired image array

Return type

ndarray or vtk output

markers

fury.actor.markers(centers, colors=(0, 1, 0), scales=1, marker='3d', marker_opacity=0.8, edge_width=0.0, edge_color=(255, 255, 255), edge_opacity=0.8)[source]

Create a marker actor with different shapes.

Parameters
  • centers (ndarray, shape (N, 3)) –

  • colors (ndarray (N,3) or (N, 4) or tuple (3,) or tuple (4,)) – RGB or RGBA (for opacity) R, G, B and A should be at the range [0, 1]

  • scales (ndarray, shape (N) or (N,3) or float or int, optional) –

  • marker (str or a list) – Available markers are: ‘3d’, ‘o’, ‘s’, ‘d’, ‘^’, ‘p’, ‘h’, ‘s6’, ‘x’, ‘+’, optional

  • marker_opacity (float, optional) –

  • edge_width (int, optional) –

  • edge_color (ndarray, shape (3), optional) –

Returns

sq_actor

Return type

Actor

numpy_to_vtk_colors

fury.actor.numpy_to_vtk_colors(colors)[source]

Convert Numpy color array to a vtk color array.

Parameters

colors (ndarray) –

Returns

vtk_colors

Return type

vtkDataArray

Notes

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

Examples

>>> import numpy as np
>>> from fury.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_matrix

fury.actor.numpy_to_vtk_matrix(array)[source]

Convert a numpy array to a VTK matrix.

octagonalprism

fury.actor.octagonalprism(centers, directions=(1, 0, 0), colors=(1, 0, 0), scales=1)[source]

Visualize one or many octagonal prisms with different features.

Parameters
  • centers (ndarray, shape (N, 3)) – Octagonal prism positions

  • directions (ndarray, shape (N, 3)) – The orientation vector of the octagonal prism.

  • colors (ndarray (N,3) or (N, 4) or tuple (3,) or tuple (4,)) – RGB or RGBA (for opacity) R, G, B and A should be at the range [0, 1]

  • scales (int or ndarray (N,3) or tuple (3,), optional) – Octagonal prism size on each direction (x, y), default(1)

Returns

oct_actor

Return type

Actor

Examples

>>> from fury import window, actor
>>> scene = window.Scene()
>>> centers = np.random.rand(3, 3)
>>> dirs = np.random.rand(3, 3)
>>> colors = np.random.rand(3, 3)
>>> scales = np.random.rand(3, 1)
>>> actor = actor.octagonalprism(centers, dirs, colors, scales)
>>> scene.add(actor)
>>> # window.show(scene)

odf_slicer

fury.actor.odf_slicer(odfs, affine=None, mask=None, sphere=None, scale=0.5, norm=True, radial_scale=True, opacity=1.0, colormap=None, global_cm=False, B_matrix=None)[source]

Create an actor for rendering a grid of ODFs given an array of spherical function (SF) or spherical harmonics (SH) coefficients.

Parameters
  • odfs (ndarray) – 4D ODFs array in SF or SH coefficients. If SH coefficients, B_matrix must be supplied.

  • affine (array) – 4x4 transformation array from native coordinates to world coordinates.

  • mask (ndarray) – 3D mask to apply to ODF field.

  • sphere (dipy Sphere) – The sphere used for SH to SF projection. If None, a default sphere of 100 vertices will be used.

  • scale (float) – Multiplicative factor to apply to ODF amplitudes.

  • norm (bool) – Normalize SF amplitudes so that the maximum ODF amplitude per voxel along a direction is 1.

  • radial_scale (bool) – Scale sphere points by ODF values.

  • opacity (float) – Takes values from 0 (fully transparent) to 1 (opaque).

  • colormap (None or str or tuple) – The name of the colormap to use. Matplotlib colormaps are supported (e.g., ‘inferno’). A plain color can be supplied as a RGB tuple in range [0, 255]. If None then a RGB colormap is used.

  • global_cm (bool) – If True the colormap will be applied in all ODFs. If False it will be applied individually at each voxel.

  • B_matrix (ndarray (n_coeffs, n_vertices)) – Optional SH to SF matrix for projecting odfs given in SH coefficents on the sphere. If None, then the input is assumed to be expressed in SF coefficients.

Returns

actor – Actor representing the ODF field.

Return type

OdfSlicerActor

peak

fury.actor.peak(peaks_dirs, peaks_values=None, mask=None, affine=None, colors=None, linewidth=1, lookup_colormap=None)[source]

Visualize peak directions as given from peaks_from_model.

Parameters
  • peaks_dirs (ndarray) – Peak directions. The shape of the array should be (X, Y, Z, D, 3).

  • peaks_values (ndarray, optional) – Peak values. The shape of the array should be (X, Y, Z, D).

  • affine (array, optional) – 4x4 transformation array from native coordinates to world coordinates.

  • mask (ndarray, optional) – 3D mask

  • colors (tuple or None, optional) – Default None. If None then every peak gets an orientation color in similarity to a DEC map.

  • lookup_colormap (vtkLookupTable, optional) – Add a default lookup table to the colormap. Default is None which calls fury.actor.colormap_lookup_table().

  • linewidth (float, optional) – Line thickness. Default is 1.

Returns

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

Return type

PeakActor

Examples

>>> from fury import actor, window
>>> import numpy as np
>>> scene = window.Scene()
>>> peak_dirs = np.random.rand(3, 3, 3, 3, 3)
>>> c = actor.peak(peak_dirs)
>>> scene.add(c)
>>> #window.show(scene)

peak_slicer

fury.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, symmetric=True)[source]

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 LODActor(level of detail) rather than Actor. 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.

  • symmetric (bool, optional) – If True, peaks are drawn for both peaks_dirs and -peaks_dirs. Else, peaks are only drawn for directions given by peaks_dirs. Default is True.

Returns

peak_actor

Return type

Actor

See also

fury.actor.odf_slice()

pentagonalprism

fury.actor.pentagonalprism(centers, directions=(1, 0, 0), colors=(1, 0, 0), scales=1)[source]

Visualize one or many pentagonal prisms with different features.

Parameters
  • centers (ndarray, shape (N, 3), optional) – Pentagonal prism positions

  • directions (ndarray, shape (N, 3), optional) – The orientation vector of the pentagonal prism.

  • colors (ndarray (N,3) or (N, 4) or tuple (3,) or tuple (4,), optional) – RGB or RGBA (for opacity) R, G, B and A should be at the range [0, 1]

  • scales (int or ndarray (N,3) or tuple (3,), optional) – Pentagonal prism size on each direction (x, y), default(1)

Returns

pent_actor

Return type

Actor

Examples

>>> import numpy as np
>>> from fury import window, actor
>>> scene = window.Scene()
>>> centers = np.random.rand(3, 3)
>>> dirs = np.random.rand(3, 3)
>>> colors = np.random.rand(3, 3)
>>> scales = np.random.rand(3, 1)
>>> actor_pentagonal = actor.pentagonalprism(centers, dirs, colors, scales)
>>> scene.add(actor_pentagonal)
>>> # window.show(scene)

point

fury.actor.point(points, colors, point_radius=0.1, phi=8, theta=8, opacity=1.0)[source]

Visualize points as sphere glyphs

Parameters
  • points (ndarray, shape (N, 3)) –

  • colors (ndarray (N,3) or tuple (3,)) –

  • point_radius (float) –

  • phi (int) –

  • theta (int) –

  • opacity (float, optional) – Takes values from 0 (fully transparent) to 1 (opaque). Default is 1.

Returns

point_actor

Return type

Actor

Examples

>>> from fury import window, actor
>>> scene = window.Scene()
>>> pts = np.random.rand(5, 3)
>>> point_actor = actor.point(pts, window.colors.coral)
>>> scene.add(point_actor)
>>> # window.show(scene)

rectangle

fury.actor.rectangle(centers, directions=(1, 0, 0), colors=(1, 0, 0), scales=(1, 2, 0))[source]

Visualize one or many rectangles with different features.

Parameters
  • centers (ndarray, shape (N, 3)) – Rectangle positions

  • directions (ndarray, shape (N, 3), optional) – The orientation vector of the rectangle.

  • colors (ndarray (N,3) or (N, 4) or tuple (3,) or tuple (4,), optional) – RGB or RGBA (for opacity) R, G, B and A should be at the range [0, 1]

  • scales (int or ndarray (N,3) or tuple (3,), optional) – Rectangle size on each direction (x, y), default(1)

Returns

rect_actor

Return type

Actor

Examples

>>> from fury import window, actor
>>> scene = window.Scene()
>>> centers = np.random.rand(5, 3)
>>> dirs = np.random.rand(5, 3)
>>> rect_actor = actor.rectangle(centers, dirs)
>>> scene.add(rect_actor)
>>> # window.show(scene)

repeat_sources

fury.actor.repeat_sources(centers, colors, active_scalars=1.0, directions=None, source=None, vertices=None, faces=None, orientation=None)[source]

Transform a vtksource to glyph.

replace_shader_in_actor

fury.actor.replace_shader_in_actor(actor, shader_type, code)[source]

Set and Replace the shader template with a new one.

Parameters
  • actor (vtkActor) – Object where you want to set the shader code.

  • shader_type (str) – Shader type: vertex, geometry, fragment

  • code (str) – new shader template code

rgb_to_vtk

fury.actor.rgb_to_vtk(data)[source]

RGB or RGBA images to VTK arrays.

Parameters

data (ndarray) – Shape can be (X, Y, 3) or (X, Y, 4)

Returns

Return type

vtkImageData

rhombicuboctahedron

fury.actor.rhombicuboctahedron(centers, directions=(1, 0, 0), colors=(1, 0, 0), scales=1)[source]

Visualize one or many rhombicuboctahedron with different features.

Parameters
  • centers (ndarray, shape (N, 3)) – Rhombicuboctahedron positions

  • directions (ndarray, shape (N, 3)) – The orientation vector(s) of the Rhombicuboctahedron(s)

  • colors (ndarray (N,3) or (N, 4) or tuple (3,) or tuple (4,)) – RGB or RGBA (for opacity) R, G, B and A should be at the range [0, 1]

  • scales (int or ndarray (N,3) or tuple (3,), optional) – Rhombicuboctahedron size on each direction (x, y), default(1)

Returns

rcoh_actor

Return type

Actor

Examples

>>> from fury import window, actor
>>> scene = window.Scene()
>>> centers = np.random.rand(3, 3)
>>> dirs = np.random.rand(3, 3)
>>> colors = np.random.rand(3, 3)
>>> scales = np.random.rand(3, 1)
>>> actor = actor.rhombicuboctahedron(centers, dirs, colors, scales)
>>> scene.add(actor)
>>> # window.show(scene)

scalar_bar

fury.actor.scalar_bar(lookup_table=None, title=' ')[source]

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

Return type

vtkScalarBarActor

sdf

fury.actor.sdf(centers, directions=(1, 0, 0), colors=(1, 0, 0), primitives='torus', scales=1)[source]

Create a SDF primitive based actor

Parameters
  • centers (ndarray, shape (N, 3)) – SDF primitive positions

  • colors (ndarray (N,3) or (N, 4) or tuple (3,) or tuple (4,), optional) – RGB or RGBA (for opacity) R, G, B and A should be at the range [0, 1]

  • directions (ndarray, shape (N, 3)) – The orientation vector of the SDF primitive.

  • primitives (str, list, tuple, np.ndarray) – The primitive of choice to be rendered. Options are sphere, torus and ellipsoid. Default is torus.

  • scales (float) – The size of the SDF primitive

Returns

box_actor

Return type

Actor

set_input

fury.actor.set_input(vtk_object, inp)[source]

Set Generic input function which takes into account VTK 5 or 6.

Parameters
  • vtk_object (vtk object) –

  • inp (vtkPolyData or vtkImageData or vtkAlgorithmOutput) –

Returns

Return type

vtk_object

Notes

This can be used in the following way::

from fury.utils import set_input poly_mapper = set_input(PolyDataMapper(), poly_data)

set_polydata_triangles

fury.actor.set_polydata_triangles(polydata, triangles)[source]

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

fury.actor.set_polydata_vertices(polydata, vertices)[source]

Set polydata vertices with a numpy array (ndarrays Nx3 int).

Parameters
  • polydata (vtkPolyData) –

  • vertices (vertices, represented as 2D ndarrays (Nx3)) –

shader_to_actor

fury.actor.shader_to_actor(actor, shader_type, impl_code='', decl_code='', block='valuepass', keep_default=True, replace_first=True, replace_all=False, debug=False)[source]

Apply your own substitutions to the shader creation process.

A bunch of string replacements is applied to a shader template. Using this function you can apply your own string replacements to add features you desire

Parameters
  • actor (vtkActor) – Object where you want to add the shader code.

  • shader_type (str) – Shader type: vertex, geometry, fragment

  • impl_code (str, optional) – shader implementation code, should be a string or filename

  • decl_code (str, optional) – shader declaration code, should be a string or filename by default None

  • block (str, optional) – section name to be replaced. vtk use of heavy string replacments to to insert shader and make it flexible. Each section of the shader template have a specific name. For more informations: https://vtk.org/Wiki/Shaders_In_VTK. The possible values are: position, normal, light, tcoord, color, clip, camera, prim_id, valuepass. by default valuepass

  • keep_default (bool, optional) – keep the default block tag to let VTK replace it with its default behavior. By default True

  • replace_first (bool, optional) – If True, apply this change before the standard VTK replacements by default True

  • replace_all (bool, optional) – [description], by default False

  • debug (bool, optional) – introduce a small error to debug shader code. by default False

shallow_copy

fury.actor.shallow_copy(vtk_object)[source]

Create a shallow copy of a given vtkObject object.

slicer

fury.actor.slicer(data, affine=None, value_range=None, opacity=1.0, lookup_colormap=None, interpolation='linear', picking_tol=0.025)[source]

Cut 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. If rgb then values expected on the range [0, 255].

  • 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, optional) – If None (default) then a grayscale map is created.

  • interpolation (string, optional) – 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, optional) – The tolerance for the vtkCellPicker, specified as a fraction of rendering window size.

Returns

image_actor – 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.

Return type

ImageActor

sphere

fury.actor.sphere(centers, colors, radii=1.0, phi=16, theta=16, vertices=None, faces=None, opacity=1)[source]

Visualize one or many spheres with different colors and radii

Parameters
  • centers (ndarray, shape (N, 3)) – Spheres positions

  • colors (ndarray (N,3) or (N, 4) or tuple (3,) or tuple (4,)) – RGB or RGBA (for opacity) R, G, B and A should be at the range [0, 1]

  • radii (float or ndarray, shape (N,)) – Sphere radius

  • phi (int) –

  • theta (int) –

  • vertices (ndarray, shape (N, 3)) – The point cloud defining the sphere.

  • faces (ndarray, shape (M, 3)) – If faces is None then a sphere is created based on theta and phi angles If not then a sphere is created with the provided vertices and faces.

  • opacity (float, optional) – Takes values from 0 (fully transparent) to 1 (opaque). Default is 1.

Returns

sphere_actor

Return type

Actor

Examples

>>> from fury import window, actor
>>> scene = window.Scene()
>>> centers = np.random.rand(5, 3)
>>> sphere_actor = actor.sphere(centers, window.colors.coral)
>>> scene.add(sphere_actor)
>>> # window.show(scene)

square

fury.actor.square(centers, directions=(1, 0, 0), colors=(1, 0, 0), scales=1)[source]

Visualize one or many squares with different features.

Parameters
  • centers (ndarray, shape (N, 3)) – Square positions

  • directions (ndarray, shape (N, 3), optional) – The orientation vector of the square.

  • colors (ndarray (N,3) or (N, 4) or tuple (3,) or tuple (4,), optional) – RGB or RGBA (for opacity) R, G, B and A should be at the range [0, 1]

  • scales (int or ndarray (N,3) or tuple (3,), optional) – Square size on each direction (x, y), default(1)

Returns

sq_actor

Return type

Actor

Examples

>>> from fury import window, actor
>>> scene = window.Scene()
>>> centers = np.random.rand(5, 3)
>>> dirs = np.random.rand(5, 3)
>>> sq_actor = actor.square(centers, dirs)
>>> scene.add(sq_actor)
>>> # window.show(scene)

streamtube

fury.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)[source]

Use 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,)) – If None or False, 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.

  • opacity (float, optional) – Takes values from 0 (fully transparent) to 1 (opaque). Default is 1.

  • linewidth (float, optional) – Default is 0.01.

  • tube_sides (int, optional) – Default is 9.

  • lod (bool, optional) – Use LODActor(level of detail) rather than Actor. Default is True. Level of detail actors do not render the full geometry when the frame rate is low.

  • lod_points (int, optional) – Number of points to be used when LOD is in effect. Default is 10000.

  • lod_points_size (int, optional) – Size of points when lod is in effect. Default is 3.

  • spline_subdiv (int, optional) – Number of splines subdivision to smooth streamtubes. Default is None.

  • lookup_colormap (vtkLookupTable, optional) – Add a default lookup table to the colormap. Default is None which calls fury.actor.colormap_lookup_table().

Examples

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

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.

superquadric

fury.actor.superquadric(centers, roundness=(1, 1), directions=(1, 0, 0), colors=(1, 0, 0), scales=1)[source]

Visualize one or many superquadrics with different features.

Parameters
  • centers (ndarray, shape (N, 3)) – Superquadrics positions

  • roundness (ndarray, shape (N, 2) or tuple/list (2,), optional) – parameters (Phi and Theta) that control the shape of the superquadric

  • directions (ndarray, shape (N, 3) or tuple (3,), optional) – The orientation vector of the cone.

  • colors (ndarray (N,3) or (N, 4) or tuple (3,) or tuple (4,)) – RGB or RGBA (for opacity) R, G, B and A should be at the range [0, 1]

  • scales (ndarray, shape (N) or (N,3) or float or int, optional) – The height of the cone.

Returns

spq_actor

Return type

Actor

Examples

>>> from fury import window, actor
>>> scene = window.Scene()
>>> centers = np.random.rand(3, 3) * 10
>>> directions = np.random.rand(3, 3)
>>> scales = np.random.rand(3)
>>> colors = np.random.rand(3, 3)
>>> roundness = np.array([[1, 1], [1, 2], [2, 1]])
>>> sq_actor = actor.superquadric(centers, roundness=roundness,
...                               directions=directions,
...                               colors=colors, scales=scales)
>>> scene.add(sq_actor)
>>> # window.show(scene)

surface

fury.actor.surface(vertices, faces=None, colors=None, smooth=None, subdivision=3)[source]

Generate a surface actor from an array of vertices.

The color and smoothness of the surface can be customized by specifying the type of subdivision algorithm and the number of subdivisions.

Parameters
  • vertices (array, shape (X, Y, Z)) – The point cloud defining the surface.

  • faces (array) – An array of precomputed triangulation for the point cloud. It is an optional parameter, it is computed locally if None

  • colors ((N, 3) array) – Specifies the colors associated with each vertex in the vertices array. Range should be 0 to 1. Optional parameter, if not passed, all vertices are colored white

  • smooth (string - "loop" or "butterfly") – Defines the type of subdivision to be used for smoothing the surface

  • subdivision (integer, default = 3) – Defines the number of subdivisions to do for each triangulation of the point cloud. The higher the value, smoother the surface but at the cost of higher computation

Returns

surface_actor – An Actor visualizing the final surface computed from the point cloud is returned.

Return type

Actor

tensor_slicer

fury.actor.tensor_slicer(evals, evecs, affine=None, mask=None, sphere=None, scale=2.2, norm=True, opacity=1.0, scalar_colors=None)[source]

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

tensor_actor – Ellipsoid

Return type

Actor

text_3d

fury.actor.text_3d(text, position=(0, 0, 0), color=(1, 1, 1), font_size=12, font_family='Arial', justification='left', vertical_justification='bottom', bold=False, italic=False, shadow=False)[source]

Generate 2D text that lives in the 3D world

Parameters
  • text (str) –

  • position (tuple) –

  • color (tuple) –

  • font_size (int) –

  • font_family (str) –

  • justification (str) – Left, center or right (default left)

  • vertical_justification (str) – Bottom, middle or top (default bottom)

  • bold (bool) –

  • italic (bool) –

  • shadow (bool) –

Returns

Return type

Text3D

texture

fury.actor.texture(rgb, interp=True)[source]

Map an RGB or RGBA texture on a plane.

Parameters
  • rgb (ndarray) – Input 2D RGB or RGBA array. Dtype should be uint8.

  • interp (bool) – Interpolate between grid centers. Default True.

Returns

act

Return type

Actor

texture_2d

fury.actor.texture_2d(rgb, interp=False)[source]

Create 2D texture from array

Parameters
  • rgb (ndarray) – Input 2D RGB or RGBA array. Dtype should be uint8.

  • interp (bool) – Interpolate between grid centers. Default True.

Returns

Return type

vtkTexturedActor

texture_on_sphere

fury.actor.texture_on_sphere(rgb, theta=60, phi=60, interpolate=True)[source]

texture_update

fury.actor.texture_update(texture_actor, arr)[source]

Updates texture of an actor by updating the vtkImageData assigned to the vtkTexture object.

Parameters
  • texture_actor (Actor) – Actor whose texture is to be updated.

  • arr (ndarray) – Input 2D image in the form of RGB or RGBA array. This is the new image to be rendered on the actor. Dtype should be uint8.

  • Implementation

  • --------------

  • docs/examples/viz_video_on_plane.py (Check) –

triangularprism

fury.actor.triangularprism(centers, directions=(1, 0, 0), colors=(1, 0, 0), scales=1)[source]

Visualize one or many regular triangular prisms with different features.

Parameters
  • centers (ndarray, shape (N, 3)) – Triangular prism positions

  • directions (ndarray, shape (N, 3)) – The orientation vector(s) of the triangular prism(s)

  • colors (ndarray (N,3) or (N, 4) or tuple (3,) or tuple (4,)) – RGB or RGBA (for opacity) R, G, B and A should be at the range [0, 1]

  • scales (int or ndarray (N,3) or tuple (3,), optional) – Triangular prism size on each direction (x, y), default(1)

Returns

tprism_actor

Return type

Actor

Examples

>>> from fury import window, actor
>>> scene = window.Scene()
>>> centers = np.random.rand(3, 3)
>>> dirs = np.random.rand(3, 3)
>>> colors = np.random.rand(3, 3)
>>> scales = np.random.rand(3, 1)
>>> actor = actor.triangularprism(centers, dirs, colors, scales)
>>> scene.add(actor)
>>> # window.show(scene)

vector_text

fury.actor.vector_text(text='Origin', pos=(0, 0, 0), scale=(0.2, 0.2, 0.2), color=(1, 1, 1))[source]

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 – Label.

Return type

Actor object

Examples

>>> from fury import window, actor
>>> scene = window.Scene()
>>> l = actor.label(text='Hello')
>>> scene.add(l)
>>> #window.show(scene)