actors
¶
Module: actors.odf_slicer
¶
|
VTK actor for visualizing slices of ODF field. |
|
Apply affine matrix aff to points pts. |
|
Create colors from a specific colormap and return it as an array of shape (N,3) where every row gives the corresponding r,g,b value. |
|
Set polydata colors with a numpy array (ndarrays Nx3 int). |
|
Set polydata triangles with a numpy array (ndarrays Nx3 int). |
|
Set polydata vertices with a numpy array (ndarrays Nx3 int). |
OdfSlicerActor
¶
-
class
fury.actors.odf_slicer.
OdfSlicerActor
(odfs, vertices, faces, indices, scale, norm, radial_scale, shape, global_cm, colormap, opacity, affine=None, B=None)[source]¶ Bases:
vtkmodules.vtkRenderingCore.vtkActor
VTK actor for visualizing slices of ODF field.
- Parameters
odfs (ndarray) – SF or SH coefficients 2-dimensional array.
vertices (ndarray) – The sphere vertices used for SH to SF projection.
faces (ndarray) – Indices of sphere vertices forming triangles. Should be ordered clockwise (see fury.utils.fix_winding_order).
indices (tuple) – Indices given in tuple(x_indices, y_indices, z_indices) format for mapping 2D ODF array to 3D voxel grid.
scale (float) – Multiplicative factor to apply to ODF amplitudes.
norm (bool) – Normalize SF amplitudes so that the maximum ODF amplitude per voxel along a direction is 1.
radial_scale (bool) – Scale sphere points by ODF values.
global_cm (bool) – If True the colormap will be applied in all ODFs. If False it will be applied individually at each voxel.
colormap (None or str) – The name of the colormap to use. Matplotlib colormaps are supported (e.g., ‘inferno’). If None then a RGB colormap is used.
opacity (float) – Takes values from 0 (fully transparent) to 1 (opaque).
affine (array) – optional 4x4 transformation array from native coordinates to world coordinates.
B (ndarray (n_coeffs, n_vertices)) – Optional SH to SF matrix for projecting odfs given in SH coefficents on the sphere. If None, then the input is assumed to be expressed in SF coefficients.
-
__init__
(odfs, vertices, faces, indices, scale, norm, radial_scale, shape, global_cm, colormap, opacity, affine=None, B=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
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).
apply_affine¶
-
fury.actors.odf_slicer.
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]]]...)
create_colormap¶
-
fury.actors.odf_slicer.
create_colormap
(v, name='plasma', auto=True)[source]¶ Create colors from a specific colormap and return it as an array of shape (N,3) where every row gives the corresponding r,g,b value. The colormaps we use are similar with those of matplotlib.
- Parameters
v ((N,) array) – vector of values to be mapped in RGB colors according to colormap
name (str.) – Name of the colormap. Currently implemented: ‘jet’, ‘blues’, ‘accent’, ‘bone’ and matplotlib colormaps if you have matplotlib installed. For example, we suggest using ‘plasma’, ‘viridis’ or ‘inferno’. ‘jet’ is popular but can be often misleading and we will deprecate it the future.
auto (bool,) – if auto is True then v is interpolated to [0, 1] from v.min() to v.max()
Notes
FURY supports a few colormaps for those who do not use Matplotlib, for more colormaps consider downloading Matplotlib (see matplotlib.org).