colormap

boys2rgb(v) boys 2 rgb cool colormap
cc(na, nd)
colormap_lookup_table([scale_range, …]) Lookup table for the colormap.
create_colormap(v[, name, auto]) Create colors from a specific colormap and return it as an array of shape (N,3) where every row gives the corresponding r,g,b value.
get_cmap(name) Makes a callable, similar to maptlotlib.pyplot.get_cmap.
line_colors(streamlines[, cmap]) Create colors for streamlines to be used in actor.line
optional_package(name[, trip_msg]) Return package-like thing and module setup for package name.
orient2rgb(v) Standard orientation 2 rgb colormap.
pjoin(a, *p) Join two or more pathname components, inserting ‘/’ as needed.
ss(na, nd)
warn Issue a warning, or maybe ignore it or raise an exception.

boys2rgb

fury.colormap.boys2rgb(v)[source]

boys 2 rgb cool colormap

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

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

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

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

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

given in V.

Examples

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

cc

fury.colormap.cc(na, nd)[source]

colormap_lookup_table

fury.colormap.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 : vtkLookupTable

create_colormap

fury.colormap.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, 10] 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).

get_cmap

fury.colormap.get_cmap(name)[source]

Makes a callable, similar to maptlotlib.pyplot.get_cmap.

line_colors

fury.colormap.line_colors(streamlines, cmap='rgb_standard')[source]

Create colors for streamlines to be used in actor.line

Parameters:
streamlines : sequence of ndarrays
cmap : (‘rgb_standard’, ‘boys_standard’)
Returns:
colors : ndarray

optional_package

fury.colormap.optional_package(name, trip_msg=None)[source]

Return package-like thing and module setup for package name.

Parameters:
name : str

package name

trip_msg : None or str

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

Returns:
pkg_like : module or TripWire instance

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

have_pkg : bool

True if import for package was successful, false otherwise

module_setup : function

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

Examples

Typical use would be something like this at the top of a module using an optional package: >>> from fury.optpkg import optional_package >>> pkg, have_pkg, setup_module = optional_package(‘not_a_package’) Of course in this case the package doesn’t exist, and so, in the module: >>> have_pkg False and >>> pkg.some_function() #doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): … TripWireError: We need package not_a_package for these functions, but import not_a_package raised an ImportError If the module does exist - we get the module >>> pkg, _, _ = optional_package(‘os’) >>> hasattr(pkg, ‘path’) True Or a submodule if that’s what we asked for >>> subpkg, _, _ = optional_package(‘os.path’) >>> hasattr(subpkg, ‘dirname’) True

orient2rgb

fury.colormap.orient2rgb(v)[source]

Standard orientation 2 rgb colormap.

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

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

given in V.

Examples

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

pjoin

fury.colormap.pjoin(a, *p)

Join two or more pathname components, inserting ‘/’ as needed. If any component is an absolute path, all previous path components will be discarded. An empty last part will result in a path that ends with a separator.

ss

fury.colormap.ss(na, nd)[source]

warn

fury.colormap.warn()

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