viz
viz.app
viz.gmem
viz.panel
viz.projections
viz.regtools
GlobalHorizon
Horizon
Space
StatefulTractogram
Streamlines
GlobalHorizon
GlobalHorizon
Download icons for fury Return package-like thing and module setup for package name Read specific icon from specific style. Methods Enum to simplify future change to convention Class for stateful representation of collections of streamlines Object designed to be identical no matter the file format (trk, tck, vtk, fib, dpy). alias of Apply a shader to an actor (act) that access shared memory Simple utility function to build labels Generate colors that are maximally perceptually distinct. Interactive medical visualization - Invert the Horizon! Euclidean length of streamlines Return package-like thing and module setup for package name Run QuickBundlesX and then run again on the centroids of the last layer Save the stateful tractogram in any format (trk/tck/vtk/vtp/fib/dpy) Slicer panel with slicer included Simple utility function to build labels Return package-like thing and module setup for package name Slicer panel with slicer included Visualization tools for 2D projections of 3D functions on the sphere, such as
ODFs. Decorator replaces custom skip test markup in doctests. Return package-like thing and module setup for package name Draw a signal on a 2D projection of the sphere. Create a regular lattice of nrows x ncols squares. Return package-like thing and module setup for package name Plot two images one on top of the other using red and green channels. Plot three overlaid slices from the given volumes. Draw the effect of warping a regular lattice by a diffeomorphic map. Plot 3 slices from the given volume: 1 sagital, 1 coronal and 1 axial Saves the simple plot with given x and y values Return package-like thing and module setup for package name package name 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. If we can import the package, return it. Otherwise return an object
raising an error when accessed True if import for package was successful, false otherwise callable usually set as Examples Typical use would be something like this at the top of a module using an
optional package: Of course in this case the package doesn’t exist, and so, in the module: and If the module does exist - we get the module Or a submodule if that’s what we asked for Read specific icon from specific style. Current icon style. Default is icomoon. Filename of icon. This should be found in folder HOME/.fury/style/.
Default is infinity.png. Complete path of icon. Bases: Bases: Methods Add streamline actors to the scene build_scene build_show remove_cluster_actors Interactive medical visualization - Invert the Horizon! StatefulTractograms are used for making sure that the coordinate
systems are correct Each tuple contains data and affine Contains peak directions and spherical harmonic coefficients Enable QuickBundlesX clustering Distance threshold used for clustering. Default value 15.0 for
small animal data you may need to use something smaller such
as 2.0. The threshold is in mm. For this parameter to be active
Given multiple tractograms and/or ROIs then each tractogram and/or
ROI will be shown with a different color. If no value is provided,
both the tractograms and the ROIs will have a different random
color generated from a distinguishable colormap. If the effect
should only be applied to one of the 2 types, then use the
options ‘tracts’ and ‘rois’ for the tractograms and the ROIs
respectively. Clusters with average length greater than Clusters with average length less than Clusters with size greater than Clusters with size less than Show data in their world coordinates (not native voxel coordinates)
Default True. Allow user interaction. If False then Horizon goes on stealth mode
and just saves pictures. Filename of saved picture. File path to replay recorded events Return ShowManager object. Used only at Python level. Can be used
for extending Horizon’s cababilities externally and for testing
purposes. Define the background color of the scene.
Default is black (0, 0, 0) Default True. Use depth peeling to sort transparent objects.
If True also enables anti-aliasing. Enables BUAN framework visualization. Default is False. List of colors for bundles. Displays binary images as contours. Default is False. Define the colors of the roi images. Default is red (1, 0, 0) References Garyfallidis E., M-A. Cote, B.Q. Chandio,
S. Fadnavis, J. Guaje, R. Aggarwal, E. St-Onge, K.S. Juneja,
S. Koudoro, D. Reagan, DIPY Horizon: fast, modular, unified and
adaptive visualization, Proceedings of: International Society of
Magnetic Resonance in Medicine (ISMRM), Montreal, Canada, 2019. Bases: Enum to simplify future change to convention Bases: Class for stateful representation of collections of streamlines
Object designed to be identical no matter the file format
(trk, tck, vtk, fib, dpy). Facilitate transformation between space and
data manipulation for each streamline / point. Getter for the reference affine Getter for data_per_point Getter for data_per_streamline Getter for the reference dimensions Getter for origin standard Getter for the current space Getter for spatial attribute Partially safe getter for streamlines Getter for the reference voxel order Getter for the reference voxel sizes Methods Compatibility verification of two StatefulTractogram to ensure space, origin, data_per_point and data_per_streamline consistency Compute the bounding box of the streamlines in their current state Create an instance of StatefulTractogram from another instance of StatefulTractogram. Return a list of the data_per_point attribute names Return a list of the data_per_streamline attribute names Safe getter for streamlines (for slicing) Verify that the bounding box is valid in voxel space. Remove streamlines with invalid coordinates from the object. Safe function to shift streamlines so the center of voxel is the origin Safe function to shift streamlines so the corner of voxel is the origin Safe function to change streamlines to a particular origin standard False means NIFTI (center) and True means TrackVis (corner) Safe function to transform streamlines and update state Safe function to transform streamlines to a particular space using an enum and update state Safe function to transform streamlines and update state Safe function to transform streamlines and update state Create a strict, state-aware, robust tractogram Streamlines of the tractogram Nifti1Header, trk.header (dict) or another Stateful Tractogram
Reference that provides the spatial attributes.
Typically a nifti-related object from the native diffusion used for
streamlines generation Current space in which the streamlines are (vox, voxmm or rasmm)
After tracking the space is VOX, after loading with nibabel
the space is RASMM Current origin in which the streamlines are (center or corner)
After loading with nibabel the origin is CENTER Dictionary in which each key has X items, each items has Y_i items
X being the number of streamlines
Y_i being the number of points on streamlines #i Dictionary in which each key has X items
X being the number of streamlines Notes Very important to respect the convention, verify that streamlines
match the reference and are effectively in the right space. Any change to the number of streamlines, data_per_point or
data_per_streamline requires particular verification. In a case of manipulation not allowed by this object, use Nibabel
directly and be careful. Compatibility verification of two StatefulTractogram to ensure space,
origin, data_per_point and data_per_streamline consistency Compute the bounding box of the streamlines in their current state 8 corners of the XYZ aligned box, all zeros if no streamlines Create an instance of StatefulTractogram from another instance
of StatefulTractogram. Streamlines of the tractogram The other StatefulTractgram to copy the space_attribute AND
state from. Dictionary in which each key has X items, each items has Y_i items
X being the number of streamlines
Y_i being the number of points on streamlines #i Dictionary in which each key has X items
X being the number of streamlines Verify that the bounding box is valid in voxel space.
Negative coordinates or coordinates above the volume dimensions
are considered invalid in voxel space. Are the streamlines within the volume of the associated reference Remove streamlines with invalid coordinates from the object.
Will also remove the data_per_point and data_per_streamline.
Invalid coordinates are any X,Y,Z values above the reference
dimensions or below zero Epsilon value for the bounding box verification.
Default is 1e-6. Tuple of two list, indices_to_remove, indices_to_keep Safe function to change streamlines to a particular origin standard
False means NIFTI (center) and True means TrackVis (corner) 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. Background RGB color, to make sure that your colors are also
distinguishable from the background. Default: (0, 0, 0). Additional RGB colors to be distinguishable from. Number of colors desired. Default: generate as many colors as needed. 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 Interactive medical visualization - Invert the Horizon! StatefulTractograms are used for making sure that the coordinate
systems are correct Each tuple contains data and affine Contains peak directions and spherical harmonic coefficients Enable QuickBundlesX clustering Distance threshold used for clustering. Default value 15.0 for
small animal data you may need to use something smaller such
as 2.0. The threshold is in mm. For this parameter to be active
Given multiple tractograms and/or ROIs then each tractogram and/or
ROI will be shown with different color. If no value is provided both
the tractograms and the ROIs will have a different random color
generated from a distinguishable colormap. If the effect should only be
applied to one of the 2 objects, then use the options ‘tracts’ and
‘rois’ for the tractograms and the ROIs respectively. Define the background color of the scene. Default is black (0, 0, 0) Default True. Use depth peeling to sort transparent objects.
If True also enables anti-aliasing. Clusters with average length greater than Clusters with average length less than Clusters with size greater than Clusters with size less than Show data in their world coordinates (not native voxel coordinates)
Default True. Allow user interaction. If False then Horizon goes on stealth mode
and just saves pictures. Enables BUAN framework visualization. Default is False. List of colors for bundles. Displays binary images as contours. Default is False. Define the color of the roi images. Default is red (1, 0, 0) Filename of saved picture. File path to replay recorded events Return ShowManager object. Used only at Python level. Can be used
for extending Horizon’s cababilities externally and for testing
purposes. References Garyfallidis E., M-A. Cote, B.Q. Chandio,
S. Fadnavis, J. Guaje, R. Aggarwal, E. St-Onge, K.S. Juneja,
S. Koudoro, D. Reagan, DIPY Horizon: fast, modular, unified and
adaptive visualization, Proceedings of: International Society of
Magnetic Resonance in Medicine (ISMRM), Montreal, Canada, 2019. Euclidean length of streamlines Length is in mm only if streamlines are expressed in world coordinates. If ndarray, must have shape (N,3) where N is the number of points
of the streamline.
If list, each item must be ndarray shape (Ni,3) where Ni is the number
of points of streamline i.
If If there is only one streamline, a scalar representing the length of the
streamline.
If there are several streamlines, ndarray containing the length of every
streamline. Examples Return package-like thing and module setup for package name package name 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. If we can import the package, return it. Otherwise return an object
raising an error when accessed True if import for package was successful, false otherwise callable usually set as Examples Typical use would be something like this at the top of a module using an
optional package: Of course in this case the package doesn’t exist, and so, in the module: and If the module does exist - we get the module Or a submodule if that’s what we asked for Run QuickBundlesX and then run again on the centroids of the last layer Running again QuickBundles at a layer has the effect of merging
some of the clusters that maybe originally devided because of branching.
This function help obtain a result at a QuickBundles quality but with
QuickBundlesX speed. The merging phase has low cost because it is applied
only on the centroids rather than the entire dataset. List of distance thresholds for QuickBundlesX. Number of points for discretizing each streamline Randomly select a specific number of streamlines. If None all the
streamlines are used. If None then RandomState is initialized internally. If True, log information. Default False. Contains the clusters of the last layer of QuickBundlesX after merging. References Garyfallidis E. et al., QuickBundles a method for
tractography simplification, Frontiers in Neuroscience,
vol 6, no 175, 2012. Garyfallidis E. et al. QuickBundlesX: Sequential
clustering of millions of streamlines in multiple
levels of detail at record execution time. Proceedings
of the, International Society of Magnetic Resonance
in Medicine (ISMRM). Singapore, 4187, 2016. Save the stateful tractogram in any format (trk/tck/vtk/vtp/fib/dpy) The stateful tractogram to save Filename with valid extension Verification for negative voxel coordinates or values above the
volume dimensions. Default is True, to enforce valid file. True if the saving operation was successful Slicer panel with slicer included If True then the affine is applied. Default None Bases: Bases: Return package-like thing and module setup for package name package name 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. If we can import the package, return it. Otherwise return an object
raising an error when accessed True if import for package was successful, false otherwise callable usually set as Examples Typical use would be something like this at the top of a module using an
optional package: Of course in this case the package doesn’t exist, and so, in the module: and If the module does exist - we get the module Or a submodule if that’s what we asked for Slicer panel with slicer included If True then the affine is applied. Default None Decorator replaces custom skip test markup in doctests. Say a function has a docstring: This decorator will evaluate the expresssion after For example, if the module global Return package-like thing and module setup for package name package name 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. If we can import the package, return it. Otherwise return an object
raising an error when accessed True if import for package was successful, false otherwise callable usually set as Examples Typical use would be something like this at the top of a module using an
optional package: Of course in this case the package doesn’t exist, and so, in the module: and If the module does exist - we get the module Or a submodule if that’s what we asked for Draw a signal on a 2D projection of the sphere. unit vector points of the sphere Function values. If specified, draw onto this existing axis instead. Values to cut the z Matplotlib figure axis Examples Create a regular lattice of nrows x ncols squares. Creates an image (2D array) of a regular lattice of nrows x ncols squares.
The size of each square is delta x delta pixels (not counting the
separation lines). The lines are one pixel width. the number of squares to be drawn vertically the number of squares to be drawn horizontally the size of each square of the grid. Each square is delta x delta
pixels the image (2D array) of the segular lattice. The shape (R, C) of the
array is given by
R = 1 + (delta + 1) * nrows
C = 1 + (delta + 1) * ncols Return package-like thing and module setup for package name package name 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. If we can import the package, return it. Otherwise return an object
raising an error when accessed True if import for package was successful, false otherwise callable usually set as Examples Typical use would be something like this at the top of a module using an
optional package: Of course in this case the package doesn’t exist, and so, in the module: and If the module does exist - we get the module Or a submodule if that’s what we asked for Plot two images one on top of the other using red and green channels. Creates a figure containing three images: the first image to the left
plotted on the red channel of a color image, the second to the right
plotted on the green channel of a color image and the two given images on
top of each other using the red channel for the first image and the green
channel for the second one. It is assumed that both images have the same
shape. The intended use of this function is to visually assess the quality
of a registration result. the image to be plotted on the red channel, to the left of the figure the image to be plotted on the green channel, to the right of the
figure the title to be written on top of the image to the left. By default, no
title is displayed. the title to be written on top of the middle image. By default, no
title is displayed. the title to be written on top of the image to the right. By default,
no title is displayed. the file name to write the resulting figure. If None (default), the
image is not saved. Plot three overlaid slices from the given volumes. Creates a figure containing three images: the gray scale k-th slice of
the first volume (L) to the left, where k=slice_index, the k-th slice of
the second volume (R) to the right and the k-th slices of the two given
images on top of each other using the red channel for the first volume and
the green channel for the second one. It is assumed that both volumes have
the same shape. The intended use of this function is to visually assess the
quality of a registration result. the first volume to extract the slice from plotted to the left the second volume to extract the slice from, plotted to the right the index of the slices (along the axis given by slice_type) to be
overlaid. If None, the slice along the specified axis is used the type of slice to be extracted:
0=sagital, 1=coronal (default), 2=axial. the string to be written as the title of the left image. By default,
no title is displayed. the string to be written as the title of the right image. By default,
no title is displayed. the name of the file to write the image to. If None (default), the
figure is not saved to disk. Draw the effect of warping a regular lattice by a diffeomorphic map. Draws a diffeomorphic map by showing the effect of the deformation on a
regular grid. The resulting figure contains two images: the direct
transformation is plotted to the left, and the inverse transformation is
plotted to the right. the diffeomorphic map to be drawn the size (in pixels) of the squares of the regular lattice to be used
to plot the warping effects. Each square will be delta x delta pixels.
By default, the size will be 10 pixels. the name of the file the figure will be written to. If None (default),
the figure will not be saved to disk. the shape of the grid image after being deformed by the direct
transformation. By default, the shape of the deformed grid is the
same as the grid of the displacement field, which is by default
equal to the shape of the fixed image. In other words, the resulting
deformed grid (deformed by the direct transformation) will normally
have the same shape as the fixed image. the affine transformation mapping the direct grid’s coordinates to
physical space. By default, this transformation will correspond to
the image-to-world transformation corresponding to the default
direct_grid_shape (in general, if users specify a direct_grid_shape,
they should also specify direct_grid2world). the shape of the grid image after being deformed by the inverse
transformation. By default, the shape of the deformed grid under the
inverse transform is the same as the image used as “moving” when
the diffeomorphic map was generated by a registration algorithm
(so it corresponds to the effect of warping the static image towards
the moving). the affine transformation mapping inverse grid’s coordinates to
physical space. By default, this transformation will correspond to
the image-to-world transformation corresponding to the default
inverse_grid_shape (in general, if users specify an inverse_grid_shape,
they should also specify inverse_grid2world). if True (default), the deformed grids will be plotted using matplotlib,
else the grids are just returned Image with the grid showing the effect of transforming the moving image to
the static image. The shape will be direct_grid_shape if specified,
otherwise the shape of the static image. Image with the grid showing the effect of transforming the static image to
the moving image. Shape will be inverse_grid_shape if specified,
otherwise the shape of the moving image. Notes The default value for the affine transformation is “-1” to handle the case
in which the user provides “None” as input meaning “identity”. If we used
None as default, we wouldn’t know if the user specifically wants to use
the identity (specifically passing None) or if it was left unspecified,
meaning to use the appropriate default matrix. Plot 3 slices from the given volume: 1 sagital, 1 coronal and 1 axial Creates a figure showing the axial, coronal and sagittal slices at the
requested positions of the given volume. The requested slices are specified
by slice_indices. the 3D volume to extract the slices from the indices of the sagital (slice_indices[0]), coronal
(slice_indices[1])
and axial (slice_indices[2]) slices to be displayed. If None, the
middle slices along each direction are displayed. the name of the file to save the figure to. If None (default), the
figure is not saved to disk. Saves the simple plot with given x and y values file name for saving the plot title of the plot x-axis values to be plotted y-axis values to be plotted label for x-axis label for y-axisviz
optional_package
(name[, trip_msg])read_viz_icons
([style, fname])Module:
viz.app
Horizon
([tractograms, images, pams, ...])Space
(value)StatefulTractogram
(streamlines, reference, space)
nibabel.streamlines.array_sequence.ArraySequence
apply_shader
(hz, act)build_label
(text[, font_size, bold])distinguishable_colormap
([bg, exclude, ...])horizon
([tractograms, images, pams, ...])
optional_package
(name[, trip_msg])qbx_and_merge
(streamlines, thresholds[, ...])save_tractogram
(sft, filename[, ...])
slicer_panel
(scene, iren[, data, affine, ...])Module:
viz.gmem
Module:
viz.panel
build_label
(text[, font_size, bold])optional_package
(name[, trip_msg])
slicer_panel
(scene, iren[, data, affine, ...])Module:
viz.projections
doctest_skip_parser
(func)optional_package
(name[, trip_msg])
sph_project
(vertices, val[, ax, vmin, vmax, ...])Module:
viz.regtools
draw_lattice_2d
(nrows, ncols, delta)optional_package
(name[, trip_msg])overlay_images
(img0, img1[, title0, ...])overlay_slices
(L, R[, slice_index, ...])plot_2d_diffeomorphic_map
(mapping[, delta, ...])plot_slices
(V[, slice_indices, fname])
simple_plot
(file_name, title, x, y, xlabel, ...)fetch_viz_icons
optional_package
TripWire
instancesetup_module
in calling namespace, to allow
skipping tests.>>> from dipy.utils.optpkg import optional_package
>>> pkg, have_pkg, setup_module = optional_package('not_a_package')
>>> have_pkg
False
>>> pkg.some_function()
Traceback (most recent call last):
...
TripWireError: We need package not_a_package for these functions, but
``import not_a_package`` raised an ImportError
>>> pkg, _, _ = optional_package('os')
>>> hasattr(pkg, 'path')
True
>>> subpkg, _, _ = optional_package('os.path')
>>> hasattr(subpkg, 'dirname')
True
read_viz_icons
GlobalHorizon
object
Horizon
object
add_cluster_actors
(scene, tractograms, threshold)
cluster
should be enabled.length_gt
amount
in mm will be shown.length_lt
amount in mm
will be shown.clusters_gt
will be shown.clusters_lt
will be shown.
Space
enum.Enum
StatefulTractogram
object
affine
data_per_point
data_per_streamline
dimensions
origin
space
space_attributes
streamlines
voxel_order
voxel_sizes
are_compatible
(sft_1, sft_2)
from_sft
(streamlines, sft[, data_per_point, ...])
remove_invalid_streamlines
([epsilon])
to_origin
(target_origin)to_rasmm
()to_space
(target_space)to_vox
()to_voxmm
()
Streamlines
apply_shader
build_label
distinguishable_colormap
>>> 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. ])]
horizon
cluster
should be enabled.length_gt
amount
in mm will be shown.length_lt
amount in mm
will be shown.clusters_gt
will be shown.clusters_lt
will be shown.
length
dipy.tracking.Streamlines
dipy.tracking.Streamlines
, its common_shape must be 3.
>>> from dipy.tracking.streamline import length
>>> import numpy as np
>>> streamline = np.array([[1, 1, 1], [2, 3, 4], [0, 0, 0]])
>>> expected_length = np.sqrt([1+2**2+3**2, 2**2+3**2+4**2]).sum()
>>> length(streamline) == expected_length
True
>>> streamlines = [streamline, np.vstack([streamline, streamline[::-1]])]
>>> expected_lengths = [expected_length, 2*expected_length]
>>> lengths = [length(streamlines[0]), length(streamlines[1])]
>>> np.allclose(lengths, expected_lengths)
True
>>> length([])
0.0
>>> length(np.array([[1, 2, 3]]))
0.0
optional_package
TripWire
instancesetup_module
in calling namespace, to allow
skipping tests.>>> from dipy.utils.optpkg import optional_package
>>> pkg, have_pkg, setup_module = optional_package('not_a_package')
>>> have_pkg
False
>>> pkg.some_function()
Traceback (most recent call last):
...
TripWireError: We need package not_a_package for these functions, but
``import not_a_package`` raised an ImportError
>>> pkg, _, _ = optional_package('os')
>>> hasattr(pkg, 'path')
True
>>> subpkg, _, _ = optional_package('os.path')
>>> hasattr(subpkg, 'dirname')
True
qbx_and_merge
save_tractogram
setup_module
slicer_panel
GlobalHorizon
object
GlobalHorizon
object
build_label
optional_package
TripWire
instancesetup_module
in calling namespace, to allow
skipping tests.>>> from dipy.utils.optpkg import optional_package
>>> pkg, have_pkg, setup_module = optional_package('not_a_package')
>>> have_pkg
False
>>> pkg.some_function()
Traceback (most recent call last):
...
TripWireError: We need package not_a_package for these functions, but
``import not_a_package`` raised an ImportError
>>> pkg, _, _ = optional_package('os')
>>> hasattr(pkg, 'path')
True
>>> subpkg, _, _ = optional_package('os.path')
>>> hasattr(subpkg, 'dirname')
True
setup_module
slicer_panel
doctest_skip_parser
>>> something # skip if not HAVE_AMODULE
>>> something + else
>>> something # skip if HAVE_BMODULE
skip if
. If this
evaluates to True, then the comment is replaced by # doctest: +SKIP
.
If False, then the comment is just removed. The expression is evaluated in
the globals
scope of func.HAVE_AMODULE
is False, and module
global HAVE_BMODULE
is False, the returned function will have
docstring:>>> something
>>> something + else
>>> something
optional_package
TripWire
instancesetup_module
in calling namespace, to allow
skipping tests.>>> from dipy.utils.optpkg import optional_package
>>> pkg, have_pkg, setup_module = optional_package('not_a_package')
>>> have_pkg
False
>>> pkg.some_function()
Traceback (most recent call last):
...
TripWireError: We need package not_a_package for these functions, but
``import not_a_package`` raised an ImportError
>>> pkg, _, _ = optional_package('os')
>>> hasattr(pkg, 'path')
True
>>> subpkg, _, _ = optional_package('os.path')
>>> hasattr(subpkg, 'dirname')
True
setup_module
sph_project
>>> from dipy.data import default_sphere
>>> verts = default_sphere.vertices
>>> ax = sph_project(verts.T, np.random.rand(len(verts.T)))
draw_lattice_2d
optional_package
TripWire
instancesetup_module
in calling namespace, to allow
skipping tests.>>> from dipy.utils.optpkg import optional_package
>>> pkg, have_pkg, setup_module = optional_package('not_a_package')
>>> have_pkg
False
>>> pkg.some_function()
Traceback (most recent call last):
...
TripWireError: We need package not_a_package for these functions, but
``import not_a_package`` raised an ImportError
>>> pkg, _, _ = optional_package('os')
>>> hasattr(pkg, 'path')
True
>>> subpkg, _, _ = optional_package('os.path')
>>> hasattr(subpkg, 'dirname')
True
overlay_images
overlay_slices
plot_2d_diffeomorphic_map
plot_slices
setup_module
simple_plot