actor
#
Module that provide actors to render.
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
|
Provides functionalities for grouping multiple actors using a given layout. |
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
|
VTK actor for visualizing slices of ODF field. |
alias of |
|
|
VTK actor for visualizing slices of ODF field. |
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
alias of |
|
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords. |
|
|
Add a shader callback to the actor. |
|
Apply affine matrix aff to points pts. |
|
Visualize one or many arrows with differents features. |
|
Link a numpy array with vertex attribute. |
|
Create an actor with the coordinate's system axes where red = x, green = y, blue = z. |
|
Create a billboard actor. |
|
Visualize one or many boxes with different features. |
|
Returns a VTK scalar array containing colors information for each one of the points according to the policy defined by the parameter colors. |
|
Lookup table for the colormap. |
|
Merge GLSL shader code from a list of strings. |
|
Visualize one or many cones with different features. |
|
Generate surface actor from a labeled Array. |
|
Generate surface actor from a binary ROI. |
|
Visualize one or many cubes with different features. |
|
Visualize one or many cylinder with different features. |
|
Return decorator function for deprecation warning / error. |
|
Deprecate a renamed or removed function argument. |
|
Visualize one or many disks with different features. |
|
Create one or more 3d points. |
|
dots function has been renamed dot |
|
Return a figure as an image actor. |
|
Return corrected triangles. |
|
Visualize one or many frustum pyramids with different features. |
|
Get actor from a vtkPolyData. |
|
Creates a grid of actors that lies in the xy-plane. |
|
Import a Fury shader. |
|
Create a label actor. |
|
Create an actor for one or more lines. |
|
Create a vtkPolyData with lines and colors. |
|
Load an image. |
|
Create a marker actor with different shapes. |
|
Convert Numpy color array to a vtk color array. |
|
Convert a numpy array to a VTK matrix. |
|
Visualize one or many octagonal prisms with different features. |
|
Create an actor for rendering a grid of ODFs given an array of spherical function (SF) or spherical harmonics (SH) coefficients. |
|
Visualize peak directions as given from |
|
Visualize peak directions as given from |
|
Visualize one or many pentagonal prisms with different features. |
|
Visualize points as sphere glyphs |
|
Visualize one or many rectangles with different features. |
|
Transform a vtksource to glyph. |
|
Set and replace the shader template with a new one. |
|
RGB or RGBA images to VTK arrays. |
|
Visualize one or many rhombicuboctahedron with different features. |
|
Default scalar bar actor for a given colormap (colorbar) |
|
Create a SDF primitive based actor |
|
Set Generic input function which takes into account VTK 5 or 6. |
|
Add primitives count to polydata. |
|
Set polydata triangles with a numpy array (ndarrays Nx3 int). |
|
Set polydata vertices with a numpy array (ndarrays Nx3 int). |
|
Apply your own substitutions to the shader creation process. |
|
Create a shallow copy of a given vtkObject object. |
|
Cut 3D scalar or rgb volumes into 2D images. |
|
Visualize one or many spheres with different colors and radii |
|
Visualize one or many squares with different features. |
|
Use streamtubes to visualize polylines. |
|
Visualize one or many superquadrics with different features. |
|
Generate a surface actor from an array of vertices. |
|
Slice many tensors as ellipsoids in native or world coordinates. |
|
Generate 2D text that lives in the 3D world |
|
Map an RGB or RGBA texture on a plane. |
|
Create 2D texture from array |
|
|
|
Updates texture of an actor by updating the vtkImageData assigned to the vtkTexture object. |
|
Visualize one or many regular triangular prisms with different features. |
|
Create a label actor. |
Actor
#
- fury.actor.Actor#
alias of
vtkActor
ArrowSource
#
- fury.actor.ArrowSource#
alias of
vtkArrowSource
Assembly
#
- fury.actor.Assembly#
alias of
vtkAssembly
ButterflySubdivisionFilter
#
- fury.actor.ButterflySubdivisionFilter#
alias of
vtkButterflySubdivisionFilter
CellArray
#
- fury.actor.CellArray#
alias of
vtkCellArray
CellPicker
#
- fury.actor.CellPicker#
alias of
vtkCellPicker
CleanPolyData
#
- fury.actor.CleanPolyData#
alias of
vtkCleanPolyData
ConeSource
#
- fury.actor.ConeSource#
alias of
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.
- 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.
- property items#
ContourFilter
#
- fury.actor.ContourFilter#
alias of
vtkContourFilter
CylinderSource
#
- fury.actor.CylinderSource#
alias of
vtkCylinderSource
DataSetMapper
#
- fury.actor.DataSetMapper#
alias of
vtkDataSetMapper
DiskSource
#
- fury.actor.DiskSource#
alias of
vtkDiskSource
FloatArray
#
- fury.actor.FloatArray#
alias of
vtkFloatArray
Follower
#
- fury.actor.Follower#
alias of
vtkFollower
ImageActor
#
- fury.actor.ImageActor#
alias of
vtkImageActor
ImageData
#
- fury.actor.ImageData#
alias of
vtkImageData
ImageMapToColors
#
- fury.actor.ImageMapToColors#
alias of
vtkImageMapToColors
ImageReslice
#
- fury.actor.ImageReslice#
alias of
vtkImageReslice
LODActor
#
- fury.actor.LODActor#
alias of
vtkLODActor
LinearExtrusionFilter
#
- fury.actor.LinearExtrusionFilter#
alias of
vtkLinearExtrusionFilter
LookupTable
#
- fury.actor.LookupTable#
alias of
vtkLookupTable
LoopSubdivisionFilter
#
- fury.actor.LoopSubdivisionFilter#
alias of
vtkLoopSubdivisionFilter
Matrix4x4
#
- fury.actor.Matrix4x4#
alias of
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:
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_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).
OutlineFilter
#
- fury.actor.OutlineFilter#
alias of
vtkOutlineFilter
PeakActor
#
- class fury.actor.PeakActor(directions, indices, values=None, affine=None, colors=None, lookup_colormap=None, linewidth=1, symmetric=True)[source]#
Bases:
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.
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.
- __init__(directions, indices, values=None, affine=None, colors=None, lookup_colormap=None, linewidth=1, symmetric=True)[source]#
- property cross_section#
- 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
vtkPoints
PolyData
#
- fury.actor.PolyData#
alias of
vtkPolyData
PolyDataMapper
#
- fury.actor.PolyDataMapper#
alias of
vtkPolyDataMapper
PolyDataMapper2D
#
- fury.actor.PolyDataMapper2D#
alias of
vtkPolyDataMapper2D
PolyDataNormals
#
- fury.actor.PolyDataNormals#
alias of
vtkPolyDataNormals
PolyVertex
#
- fury.actor.PolyVertex#
alias of
vtkPolyVertex
ScalarBarActor
#
- fury.actor.ScalarBarActor#
alias of
vtkScalarBarActor
SphereSource
#
- fury.actor.SphereSource#
alias of
vtkSphereSource
SplineFilter
#
- fury.actor.SplineFilter#
alias of
vtkSplineFilter
TextActor3D
#
- fury.actor.TextActor3D#
alias of
vtkTextActor3D
Texture
#
- fury.actor.Texture#
alias of
vtkTexture
TextureMapToPlane
#
- fury.actor.TextureMapToPlane#
alias of
vtkTextureMapToPlane
TexturedActor2D
#
- fury.actor.TexturedActor2D#
alias of
vtkTexturedActor2D
TexturedSphereSource
#
- fury.actor.TexturedSphereSource#
alias of
vtkTexturedSphereSource
Transform
#
- fury.actor.Transform#
alias of
vtkTransform
TransformPolyDataFilter
#
- fury.actor.TransformPolyDataFilter#
alias of
vtkTransformPolyDataFilter
TubeFilter
#
- fury.actor.TubeFilter#
alias of
vtkTubeFilter
UnstructuredGrid
#
- fury.actor.UnstructuredGrid#
alias of
vtkUnstructuredGrid
VectorText
#
- fury.actor.VectorText#
alias of
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) – Fury actor you want to add the callback to.
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:
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, scales=1, vertices=None, faces=None, repeat_primitive=True)[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) – Fury actor you want to add the vertex attribute to.
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. 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, gs_prog=None, fs_dec=None, fs_impl=None)[source]#
Create a billboard actor.
Billboards are 2D elements placed in a 3D world. They offer possibility to draw different shapes/elements at the fragment shader level.
- Parameters:
centers (ndarray, shape (N, 3)) – Billboard 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 scale of the billboards.
vs_dec (str or list of str, optional) – Vertex Shader code that contains all variable/function declarations.
vs_impl (str or list of str, optional) – Vertex Shaders code that contains all variable/function implementations.
gs_prog (str, optional) – Geometry Shader program.
fs_dec (str or list of str, optional) – Fragment Shaders code that contains all variable/function declarations.
fs_impl (str or list of str, optional) – Fragment Shaders code that contains all variable/function implementation.
- Returns:
billboard_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)
color_check#
- fury.actor.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_len (int) – length of points ndarray
colors (None 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_array (vtkDataArray) – vtk scalar array with name ‘colors’.
global_opacity (float) – 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.
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
compose_shader#
cone#
- fury.actor.cone(centers, directions, colors, heights=1.0, resolution=10, vertices=None, faces=None, use_primitive=True)[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.
use_primitive (boolean, optional) – If True uses primitives to create the cone actor.
- 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 versionuntil
(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 ofuntil
.
- 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 thenew_name
replaced it at the same position in the signature. If theold_name
argument is given when calling the decorated function the decorator will catch it and issue a deprecation warning and pass it on asnew_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 argumentold_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, theversion_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 toTrue
. Otherwise the decorator will throw an Exception if thenew_name
cannot be found in the signature of the decorated function. Default isFalse
.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). 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
andsince
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)
dot#
- fury.actor.dot(points, colors=None, opacity=None, dot_size=5)[source]#
Create one or more 3d points.
- Parameters:
points (ndarray, (N, 3)) – dots 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]
opacity (float, optional) – Takes values from 0 (fully transparent) to 1 (opaque). If a value is given, each dot will have the same opacity otherwise opacity is set to 1 by default, or is defined by Alpha parameter in colors if given.
dot_size (int) –
- Returns:
dot_actor
- Return type:
Actor
See also
dots#
- fury.actor.dots(points, colors=None, opacity=None, dot_size=5)#
dots function has been renamed dot
deprecated from version: 0.8.1
Will raise <class ‘fury.deprecator.ExpiredDeprecationError’> as of version: 0.9.0
Create one or more 3d points.
- Parameters:
points (ndarray, (N, 3)) – dots 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]
opacity (float, optional) – Takes values from 0 (fully transparent) to 1 (opaque). If a value is given, each dot will have the same opacity otherwise opacity is set to 1 by default, or is defined by Alpha parameter in colors if given.
dot_size (int) –
- Returns:
dot_actor
- Return type:
Actor
See also
figure#
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, 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:
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
import_fury_shader#
- fury.actor.import_fury_shader(shader_file)[source]#
Import a Fury shader.
- Parameters:
shader_file (str) – Filename of shader. The file must be in the fury/shaders directory and must have the one of the supported extensions specified by the Khronos Group (KhronosGroup/glslang).
- Returns:
code – GLSL shader code.
- Return type:
label#
- fury.actor.label(text='Origin', pos=(0, 0, 0), scale=(0.2, 0.2, 0.2), color=(1, 1, 1), direction=(0, 0, 1), extrusion=0.0, align_center=False)#
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.direction ((3,) array_like, optional, default: (0, 0, 1)) – The direction of the label. If None, label will follow the camera.
extrusion (float, optional) – The extrusion amount of the text in Z axis.
align_center (bool, optional, default: True) – If True, the anchor of the actor will be the center of the text. If False, the anchor will be at the left bottom of the text.
- Returns:
l – Label.
- Return type:
Actor object
Examples
>>> from fury import window, actor >>> scene = window.Scene() >>> l = actor.vector_text(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_image#
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#
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:
peak#
- fury.actor.peak(peaks_dirs, peaks_values=None, mask=None, affine=None, colors=None, linewidth=1, lookup_colormap=None, symmetric=True)[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.
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 – Actor or LODActor representing the peaks directions and/or magnitudes.
- Return type:
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:
- Returns:
point_actor
- Return type:
Actor
See also
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
See also
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#
replace_shader_in_actor#
rgb_to_vtk#
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
See also
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) –
- 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_primitives_count#
set_polydata_triangles#
set_polydata_vertices#
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 set of string replacements is applied to a shader template. This function let’s apply custom string replacements.
- Parameters:
actor (vtkActor) – Fury actor you want to set the shader code to.
shader_type (str) – Shader type: vertex, fragment
impl_code (str, optional) – Shader implementation code, should be a string or filename. Default None.
decl_code (str, optional) – Shader declaration code, should be a string or filename. Default None.
block (str, optional) – Section name to be replaced. VTK use of heavy string replacements to insert shader and make it flexible. Each section of the shader template have a specific name. For more information: 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. Default True.
replace_first (bool, optional) – If True, apply this change before the standard VTK replacements. Default True.
replace_all (bool, optional) – [description], by default False
debug (bool, optional) – Introduce a small error to debug shader code. Default False.
shallow_copy#
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, use_primitive=False)[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, optional) – Set the number of points in the latitude direction
theta (int, optional) – Set the number of points in the longitude direction
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.
use_primitive (boolean, optional) – If True, uses primitives to create an actor.
- 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.See also
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#
texture#
texture_2d#
texture_on_sphere#
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), direction=(0, 0, 1), extrusion=0.0, align_center=False)[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.direction ((3,) array_like, optional, default: (0, 0, 1)) – The direction of the label. If None, label will follow the camera.
extrusion (float, optional) – The extrusion amount of the text in Z axis.
align_center (bool, optional, default: True) – If True, the anchor of the actor will be the center of the text. If False, the anchor will be at the left bottom of the text.
- Returns:
l – Label.
- Return type:
Actor object
Examples
>>> from fury import window, actor >>> scene = window.Scene() >>> l = actor.vector_text(text='Hello') >>> scene.add(l) >>> #window.show(scene)