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.

distinguishable_colormap([bg, exclude, …])

Generate colors that are maximally perceptually distinct.

get_cmap(name)

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

Get 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
varray, 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
carray, 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_rangetuple

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_rangetuple of floats

HSV values (min 0 and max 1). Default is (0.8, 0).

saturation_rangetuple of floats

HSV values (min 0 and max 1). Default is (1, 1).

value_rangetuple of floats

HSV value (min 0 and max 1). Default is (0.8, 0.8).

Returns
lookup_tablevtkLookupTable

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

namestr.

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.

autobool,

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

distinguishable_colormap

fury.colormap.distinguishable_colormap(bg=(0, 0, 0), exclude=[], nb_colors=None)[source]

Generate colors that are maximally perceptually distinct.

This function generates a set of colors which are distinguishable by reference to the “Lab” color space, which more closely matches human color perception than RGB. Given an initial large list of possible colors, it iteratively chooses the entry in the list that is farthest (in Lab space) from all previously-chosen entries. While this “greedy” algorithm does not yield a global maximum, it is simple and efficient. Moreover, the sequence of colors is consistent no matter how many you request, which facilitates the users’ ability to learn the color order and avoids major changes in the appearance of plots when adding or removing lines.

Parameters
bgtuple (optional)

Background RGB color, to make sure that your colors are also distinguishable from the background. Default: (0, 0, 0).

excludelist of tuples (optional)

Additional RGB colors to be distinguishable from.

nb_colorsint (optional)

Number of colors desired. Default: generate as many colors as needed.

Returns
iterable of ndarray

If nb_colors is provided, returns a list of RBG colors. Otherwise, yields the next RBG color maximally perceptually distinct from previous ones.

Notes

Code was initially in matlab and was rewritten in Python for dipy by the Dipy Team. Thank you Tim Holy for putting this online. Visit http://www.mathworks.com/matlabcentral/fileexchange/29702 for the original implementation (v1.2), 14 Dec 2010 (Updated 07 Feb 2011).

Examples

>>> from dipy.viz.colormap import distinguishable_colormap
>>> # Generate 5 colors
>>> [c for i, c in zip(range(5), distinguishable_colormap())]
[array([ 0.,  1.,  0.]),
 array([ 1.,  0.,  1.]),
 array([ 1.        ,  0.75862069,  0.03448276]),
 array([ 0.        ,  1.        ,  0.89655172]),
 array([ 0.        ,  0.17241379,  1.        ])]

get_cmap

fury.colormap.get_cmap(name)[source]

Make 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
streamlinessequence of ndarrays
cmap(‘rgb_standard’, ‘boys_standard’)
Returns
colorsndarray

optional_package

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

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

Parameters
namestr

package name

trip_msgNone 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_likemodule or TripWire instance

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

have_pkgbool

True if import for package was successful, false otherwise

module_setupfunction

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]

Get Standard orientation 2 rgb colormap.

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

Returns
carray, 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.