utils#

remove_observer_from_actor(actor, id)

Remove the observer with the given id from the actor.

set_input(vtk_object, inp)

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

numpy_to_vtk_points(points)

Convert Numpy points array to a vtk points array.

numpy_to_vtk_colors(colors)

Convert Numpy color array to a vtk color array.

numpy_to_vtk_cells(data, *[, is_coords])

Convert numpy array to a vtk cell array.

numpy_to_vtk_image_data(array, *[, spacing, ...])

Convert numpy array to a vtk image data.

map_coordinates_3d_4d(input_array, indices)

Evaluate input_array at the given indices using trilinear interpolation.

lines_to_vtk_polydata(lines, *[, colors])

Create a vtkPolyData with lines and colors.

get_polydata_lines(line_polydata)

Convert vtk polydata to a list of lines ndarrays.

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_polydata_tcoord(polydata)

Get texture coordinates (ndarrays Nx2 float) from a vtk polydata.

get_polydata_normals(polydata)

Get vertices normal (ndarrays Nx3 int) from a vtk polydata.

get_polydata_tangents(polydata)

Get vertices tangent (ndarrays Nx3 int) from a vtk polydata.

get_polydata_colors(polydata)

Get points color (ndarrays Nx3 int) from a vtk polydata.

get_polydata_field(polydata, field_name, *)

Get a field from a vtk polydata.

add_polydata_numeric_field(polydata, ...[, ...])

Add a field to a vtk polydata.

set_polydata_primitives_count(polydata, ...)

Add primitives count to polydata.

get_polydata_primitives_count(polydata)

Get primitives count from actor's polydata.

primitives_count_to_actor(actor, ...)

Add primitives count to actor's polydata.

primitives_count_from_actor(actor)

Get primitives count from actor's polydata.

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

set_polydata_normals(polydata, normals)

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

set_polydata_tangents(polydata, tangents)

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

set_polydata_colors(polydata, colors, *[, ...])

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

set_polydata_tcoords(polydata, tcoords)

Set polydata texture coordinates with a numpy array (ndarrays Nx2 float).

update_polydata_normals(polydata)

Generate and update polydata normals.

get_polymapper_from_polydata(polydata)

Get vtkPolyDataMapper from a vtkPolyData.

get_actor_from_polymapper(poly_mapper)

Get actor from a vtkPolyDataMapper.

get_actor_from_polydata(polydata)

Get actor from a vtkPolyData.

get_actor_from_primitive(vertices, triangles, *)

Get actor from a vtkPolyData.

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

Transform a vtksource to glyph.

apply_affine_to_actor(act, affine)

Apply affine matrix affine to the actor act.

apply_affine(aff, pts)

Apply affine matrix aff to points pts.

asbytes(s)

vtk_matrix_to_numpy(matrix)

Convert VTK matrix to numpy array.

numpy_to_vtk_matrix(array)

Convert a numpy array to a VTK matrix.

get_bounding_box_sizes(actor)

Get the bounding box sizes of an actor.

get_grid_cells_position(shapes, *[, ...])

Construct a XY-grid based on the cells content shape.

shallow_copy(vtk_object)

Create a shallow copy of a given vtkObject object.

rotate(actor, *[, rotation])

Rotate actor around axis by angle.

rgb_to_vtk(data)

RGB or RGBA images to VTK arrays.

normalize_v3(arr)

Normalize a numpy array of 3 component vectors shape=(N, 3).

normals_from_v_f(vertices, faces)

Calculate normals from vertices and faces.

tangents_from_direction_of_anisotropy(...)

Calculate tangents from normals and a 3D vector representing the

triangle_order(vertices, faces)

Determine the winding order of a given set of vertices and a triangle.

change_vertices_order(triangle)

Change the vertices order of a given triangle.

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

Return corrected triangles.

vertices_from_actor(actor, *[, as_vtk])

Access to vertices from actor.

colors_from_actor(actor, *[, array_name, as_vtk])

Access colors from actor which uses polydata.

normals_from_actor(act)

Access normals from actor which uses polydata.

tangents_from_actor(act)

Access tangents from actor which uses polydata.

array_from_actor(actor, array_name, *[, as_vtk])

Access array from actor which uses polydata.

normals_to_actor(act, normals)

Set normals to actor which uses polydata.

tangents_to_actor(act, tangents)

Set tangents to actor which uses polydata.

compute_bounds(actor)

Compute Bounds of actor.

update_actor(actor, *[, all_arrays])

Update actor.

get_bounds(actor)

Return Bounds of actor.

represent_actor_as_wireframe(actor)

Returns the actor wireframe.

update_surface_actor_colors(actor, colors)

Update colors of a surface actor.

color_check(pts_len, *[, colors])

Returns a VTK scalar array containing colors information for each one of the points according to the policy defined by the parameter colors.

is_ui(actor)

Method to check if the passed actor is UI or vtkProp3D

set_actor_origin(actor, *[, center])

Change the origin of an actor to a custom position.

minmax_norm(data[, axis])

Returns the min-max normalization of data along an axis.

remove_observer_from_actor#

fury.utils.remove_observer_from_actor(actor, id)[source]#

Remove the observer with the given id from the actor.

Parameters:
actorvtkActor
idint

id of the observer to remove

set_input#

fury.utils.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:
vtk_object

Notes

This can be used in the following way::

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

numpy_to_vtk_points#

fury.utils.numpy_to_vtk_points(points)[source]#

Convert Numpy points array to a vtk points array.

Parameters:
pointsndarray
Returns:
vtk_pointsvtkPoints()

numpy_to_vtk_colors#

fury.utils.numpy_to_vtk_colors(colors)[source]#

Convert Numpy color array to a vtk color array.

Parameters:
colors: ndarray
Returns:
vtk_colorsvtkDataArray

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_cells#

fury.utils.numpy_to_vtk_cells(data, *, is_coords=True)[source]#

Convert numpy array to a vtk cell array.

Parameters:
datandarray

points coordinate or connectivity array (e.g triangles).

is_coordsndarray

Select the type of array. default: True.

Returns:
vtk_cellvtkCellArray

connectivity + offset information

numpy_to_vtk_image_data#

fury.utils.numpy_to_vtk_image_data(array, *, spacing=(1.0, 1.0, 1.0), origin=(0.0, 0.0, 0.0), deep=True)[source]#

Convert numpy array to a vtk image data.

Parameters:
arrayndarray

pixel coordinate and colors values.

spacing(float, float, float) (optional)

sets the size of voxel (unit of space in each direction x,y,z)

origin(float, float, float) (optional)

sets the origin at the given point

deepbool (optional)

decides the type of copy(ie. deep or shallow)

Returns:
vtk_imagevtkImageData

map_coordinates_3d_4d#

fury.utils.map_coordinates_3d_4d(input_array, indices)[source]#

Evaluate input_array at the given indices using trilinear interpolation.

Parameters:
input_arrayndarray,

3D or 4D array

indicesndarray
Returns:
outputndarray

1D or 2D array

lines_to_vtk_polydata#

fury.utils.lines_to_vtk_polydata(lines, *, colors=None)[source]#

Create a vtkPolyData with lines and colors.

Parameters:
lineslist

list of N curves represented as 2D ndarrays

colorsarray (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_datavtkPolyData
color_is_scalarbool, true if the color array is a single scalar

Scalar array could be used with a colormap lut None if no color was used

get_polydata_lines#

fury.utils.get_polydata_lines(line_polydata)[source]#

Convert vtk polydata to a list of lines ndarrays.

Parameters:
line_polydatavtkPolyData
Returns:
lineslist

List of N curves represented as 2D ndarrays

get_polydata_triangles#

fury.utils.get_polydata_triangles(polydata)[source]#

Get triangles (ndarrays Nx3 int) from a vtk polydata.

Parameters:
polydatavtkPolyData
Returns:
outputarray (N, 3)

triangles

get_polydata_vertices#

fury.utils.get_polydata_vertices(polydata)[source]#

Get vertices (ndarrays Nx3 int) from a vtk polydata.

Parameters:
polydatavtkPolyData
Returns:
outputarray (N, 3)

points, represented as 2D ndarrays

get_polydata_tcoord#

fury.utils.get_polydata_tcoord(polydata)[source]#

Get texture coordinates (ndarrays Nx2 float) from a vtk polydata.

Parameters:
polydatavtkPolyData
Returns:
outputarray (N, 2)

Tcoords, represented as 2D ndarrays. None if there are no texture in the vtk polydata.

get_polydata_normals#

fury.utils.get_polydata_normals(polydata)[source]#

Get vertices normal (ndarrays Nx3 int) from a vtk polydata.

Parameters:
polydatavtkPolyData
Returns:
outputarray (N, 3)

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

get_polydata_tangents#

fury.utils.get_polydata_tangents(polydata)[source]#

Get vertices tangent (ndarrays Nx3 int) from a vtk polydata.

Parameters:
polydatavtkPolyData
Returns:
outputarray (N, 3)

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

get_polydata_colors#

fury.utils.get_polydata_colors(polydata)[source]#

Get points color (ndarrays Nx3 int) from a vtk polydata.

Parameters:
polydatavtkPolyData
Returns:
outputarray (N, 3)

Colors. None if no normals in the vtk polydata.

get_polydata_field#

fury.utils.get_polydata_field(polydata, field_name, *, as_vtk=False)[source]#

Get a field from a vtk polydata.

Parameters:
polydatavtkPolyData
field_namestr
as_vtkoptional

By default, ndarray is returned.

Returns:
outputndarray or vtkDataArray

Field data. The return type depends on the value of the as_vtk parameter. None if the field is not found.

add_polydata_numeric_field#

fury.utils.add_polydata_numeric_field(polydata, field_name, field_data, *, array_type=6)[source]#

Add a field to a vtk polydata.

Parameters:
polydatavtkPolyData
field_namestr
field_databool, int, float, double, numeric array or ndarray
array_typevtkArrayType

set_polydata_primitives_count#

fury.utils.set_polydata_primitives_count(polydata, primitives_count)[source]#

Add primitives count to polydata.

Parameters:
polydata: vtkPolyData
primitives_countint

get_polydata_primitives_count#

fury.utils.get_polydata_primitives_count(polydata)[source]#

Get primitives count from actor’s polydata.

Parameters:
polydata: vtkPolyData
Returns:
primitives countint

primitives_count_to_actor#

fury.utils.primitives_count_to_actor(actor, primitives_count)[source]#

Add primitives count to actor’s polydata.

Parameters:
actor: :class: `UI` or `vtkProp3D` actor
primitives_countint

primitives_count_from_actor#

fury.utils.primitives_count_from_actor(actor)[source]#

Get primitives count from actor’s polydata.

Parameters:
actor: :class: `UI` or `vtkProp3D` actor
Returns:
primitives countint

set_polydata_triangles#

fury.utils.set_polydata_triangles(polydata, triangles)[source]#

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

Parameters:
polydatavtkPolyData
trianglesarray (N, 3)

triangles, represented as 2D ndarrays (Nx3)

set_polydata_vertices#

fury.utils.set_polydata_vertices(polydata, vertices)[source]#

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

Parameters:
polydatavtkPolyData
verticesvertices, represented as 2D ndarrays (Nx3)

set_polydata_normals#

fury.utils.set_polydata_normals(polydata, normals)[source]#

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

Parameters:
polydatavtkPolyData
normalsnormals, represented as 2D ndarrays (Nx3) (one per vertex)

set_polydata_tangents#

fury.utils.set_polydata_tangents(polydata, tangents)[source]#

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

Parameters:
polydatavtkPolyData
tangentstangents, represented as 2D ndarrays (Nx3) (one per vertex)

set_polydata_colors#

fury.utils.set_polydata_colors(polydata, colors, *, array_name='colors')[source]#

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

Parameters:
polydatavtkPolyData
colorscolors, represented as 2D ndarrays (Nx3)

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

set_polydata_tcoords#

fury.utils.set_polydata_tcoords(polydata, tcoords)[source]#

Set polydata texture coordinates with a numpy array (ndarrays Nx2 float).

Parameters:
polydatavtkPolyData
tcoordstexture coordinates, represented as 2D ndarrays (Nx2)

(one per vertex range (0, 1))

update_polydata_normals#

fury.utils.update_polydata_normals(polydata)[source]#

Generate and update polydata normals.

Parameters:
polydatavtkPolyData

get_polymapper_from_polydata#

fury.utils.get_polymapper_from_polydata(polydata)[source]#

Get vtkPolyDataMapper from a vtkPolyData.

Parameters:
polydatavtkPolyData
Returns:
poly_mappervtkPolyDataMapper

get_actor_from_polymapper#

fury.utils.get_actor_from_polymapper(poly_mapper)[source]#

Get actor from a vtkPolyDataMapper.

Parameters:
poly_mappervtkPolyDataMapper
Returns:
actoractor

get_actor_from_polydata#

fury.utils.get_actor_from_polydata(polydata)[source]#

Get actor from a vtkPolyData.

Parameters:
polydatavtkPolyData
Returns:
actoractor

get_actor_from_primitive#

fury.utils.get_actor_from_primitive(vertices, triangles, *, colors=None, normals=None, backface_culling=True, prim_count=1)[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

prim_count: int, optional

primitives count to be associated with the actor

Returns:
actoractor

repeat_sources#

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

Transform a vtksource to glyph.

apply_affine_to_actor#

fury.utils.apply_affine_to_actor(act, affine)[source]#

Apply affine matrix affine to the actor act.

Parameters:
act: Actor
affine: (4, 4) array-like

Homogeneous affine, for 3D object.

Returns:
transformed_act: Actor

apply_affine#

fury.utils.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

Homogeneous 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

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

asbytes#

fury.utils.asbytes(s)[source]#

vtk_matrix_to_numpy#

fury.utils.vtk_matrix_to_numpy(matrix)[source]#

Convert VTK matrix to numpy array.

numpy_to_vtk_matrix#

fury.utils.numpy_to_vtk_matrix(array)[source]#

Convert a numpy array to a VTK matrix.

get_bounding_box_sizes#

fury.utils.get_bounding_box_sizes(actor)[source]#

Get the bounding box sizes of an actor.

get_grid_cells_position#

fury.utils.get_grid_cells_position(shapes, *, aspect_ratio=1.7777777777777777, dim=None)[source]#

Construct a XY-grid based on the cells content shape.

This function generates the coordinates of every grid cell. The width and height of every cell correspond to the largest width and the largest height respectively. The grid dimensions will automatically be adjusted to respect the given aspect ratio unless they are explicitly specified.

The grid follows a row-major order with the top left corner being at coordinates (0,0,0) and the bottom right corner being at coordinates (nb_cols*cell_width, -nb_rows*cell_height, 0). Note that the X increases while the Y decreases.

Parameters:
shapeslist of tuple of int

The shape (width, height) of every cell content.

aspect_ratiofloat (optional)

Aspect ratio of the grid (width/height). Default: 16:9.

dimtuple of int (optional)

Dimension (nb_rows, nb_cols) of the grid, if provided.

Returns:
ndarray

3D coordinates of every grid cell.

shallow_copy#

fury.utils.shallow_copy(vtk_object)[source]#

Create a shallow copy of a given vtkObject object.

rotate#

fury.utils.rotate(actor, *, rotation=(90, 1, 0, 0))[source]#

Rotate actor around axis by angle.

Parameters:
actoractor or other prop
rotationtuple

Rotate with angle w around axis x, y, z. Needs to be provided in the form (w, x, y, z).

rgb_to_vtk#

fury.utils.rgb_to_vtk(data)[source]#

RGB or RGBA images to VTK arrays.

Parameters:
datandarray

Shape can be (X, Y, 3) or (X, Y, 4)

Returns:
vtkImageData

normalize_v3#

fury.utils.normalize_v3(arr)[source]#

Normalize a numpy array of 3 component vectors shape=(N, 3).

Parameters:
arrayndarray

Shape (N, 3)

Returns:
norm_array

normals_from_v_f#

fury.utils.normals_from_v_f(vertices, faces)[source]#

Calculate normals from vertices and faces.

Parameters:
vericesndarray
facesndarray
Returns:
normalsndarray

Shape same as vertices

tangents_from_direction_of_anisotropy#

fury.utils.tangents_from_direction_of_anisotropy(normals, direction)[source]#
Calculate tangents from normals and a 3D vector representing the

direction of anisotropy.

Parameters:
normalsnormals, represented as 2D ndarrays (Nx3) (one per vertex)
directiontuple (3,) or array (3,)
Returns:
outputarray (N, 3)

Tangents, represented as 2D ndarrays (Nx3).

triangle_order#

fury.utils.triangle_order(vertices, faces)[source]#

Determine the winding order of a given set of vertices and a triangle.

Parameters:
verticesndarray

array of vertices making up a shape

facesndarray

array of triangles

Returns:
orderint

If the order is counter clockwise (CCW), returns True. Otherwise, returns False.

change_vertices_order#

fury.utils.change_vertices_order(triangle)[source]#

Change the vertices order of a given triangle.

Parameters:
trianglendarray, shape(1, 3)

array of 3 vertices making up a triangle

Returns:
new_trianglendarray, shape(1, 3)

new array of vertices making up a triangle in the opposite winding order of the given parameter

fix_winding_order#

fury.utils.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:
verticesndarray

array of vertices corresponding to a shape

trianglesndarray

array of triangles corresponding to a shape

clockwisebool

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

Returns:
corrected_trianglesndarray

The corrected order of the vert parameter

vertices_from_actor#

fury.utils.vertices_from_actor(actor, *, as_vtk=False)[source]#

Access to vertices from actor.

Parameters:
actoractor
as_vtk: bool, optional

by default, ndarray is returned.

Returns:
verticesndarray

colors_from_actor#

fury.utils.colors_from_actor(actor, *, array_name='colors', as_vtk=False)[source]#

Access colors from actor which uses polydata.

Parameters:
actoractor
array_name: str
as_vtk: bool, optional

by default, numpy array is returned.

Returns:
outputarray (N, 3)

Colors

normals_from_actor#

fury.utils.normals_from_actor(act)[source]#

Access normals from actor which uses polydata.

Parameters:
actactor
Returns:
outputarray (N, 3)

Normals

tangents_from_actor#

fury.utils.tangents_from_actor(act)[source]#

Access tangents from actor which uses polydata.

Parameters:
actactor
Returns:
outputarray (N, 3)

Tangents

array_from_actor#

fury.utils.array_from_actor(actor, array_name, *, as_vtk=False)[source]#

Access array from actor which uses polydata.

Parameters:
actoractor
array_name: str
as_vtk_type: bool, optional

by default, ndarray is returned.

Returns:
outputarray (N, 3)

normals_to_actor#

fury.utils.normals_to_actor(act, normals)[source]#

Set normals to actor which uses polydata.

Parameters:
actactor
normalsnormals, represented as 2D ndarrays (Nx3) (one per vertex)
Returns:
actor

tangents_to_actor#

fury.utils.tangents_to_actor(act, tangents)[source]#

Set tangents to actor which uses polydata.

Parameters:
actactor
tangentstangents, represented as 2D ndarrays (Nx3) (one per vertex)

compute_bounds#

fury.utils.compute_bounds(actor)[source]#

Compute Bounds of actor.

Parameters:
actoractor

update_actor#

fury.utils.update_actor(actor, *, all_arrays=True)[source]#

Update actor.

Parameters:
actoractor
all_arrays: bool, optional

if False, only vertices are updated if True, all arrays associated to the actor are updated Default: True

get_bounds#

fury.utils.get_bounds(actor)[source]#

Return Bounds of actor.

Parameters:
actoractor
Returns:
verticesndarray

represent_actor_as_wireframe#

fury.utils.represent_actor_as_wireframe(actor)[source]#

Returns the actor wireframe.

Parameters:
actoractor
Returns:
actoractor

update_surface_actor_colors#

fury.utils.update_surface_actor_colors(actor, colors)[source]#

Update colors of a surface actor.

Parameters:
actorsurface actor
colorsndarray of shape (N, 3) having colors. The colors should be in the

range [0, 1].

color_check#

fury.utils.color_check(pts_len, *, colors=None)[source]#

Returns a VTK scalar array containing colors information for each one of the points according to the policy defined by the parameter colors.

Parameters:
pts_lenint

length of points ndarray

colorsNone or tuple (3D or 4D) or array/ndarray (N, 3 or 4)

If None a predefined color is used for each point. If a tuple of color is used. Then all points 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.

Returns:
color_arrayvtkDataArray

vtk scalar array with name ‘colors’.

global_opacityfloat

returns 1 if the colors array doesn’t contain opacity otherwise -1. If colors array has 4 dimensions, it checks values of the fourth dimension. If the value is the same, then assign it to global_opacity.

is_ui#

fury.utils.is_ui(actor)[source]#

Method to check if the passed actor is UI or vtkProp3D

Parameters:
actor: :class: `UI` or `vtkProp3D`

actor that is to be checked

set_actor_origin#

fury.utils.set_actor_origin(actor, *, center=None)[source]#

Change the origin of an actor to a custom position.

Parameters:
actor: Actor

The actor object to change origin for.

center: ndarray, optional, default: None

The new center position. If None, the origin will be set to the mean of the actor’s vertices.

minmax_norm#

fury.utils.minmax_norm(data, axis=1)[source]#

Returns the min-max normalization of data along an axis.

Parameters:
data: ndarray

2D array

axis: int, optional

axis for the function to be applied on

Returns:
outputndarray