viz#

Visualization tools.

Functions and classes for visualizing diffusion MRI data, streamlines, and tensors (powered by FURY and Matplotlib).

Module: viz.gmem#

Module: viz.horizon#

Horizon interactive visualization application.

Module: viz.horizon.app#

Horizon(*[, tractograms, images, pams, ...])

horizon(*[, tractograms, images, pams, ...])

Horizon is deprecated and will be removed with future releases.

Module: viz.panel#

build_label(text, *[, font_size, bold])

Simple utility function to build labels

slicer_panel(scene, iren, *[, data, affine, ...])

Slicer panel with slicer included

Module: viz.plotting#

plotting functions

compare_maps(fits, maps, *[, transpose, ...])

Compare one or more scalar maps for different fits or models.

compare_qti_maps(gt, fit1, fit2, mask, *[, ...])

Compare one or more qti derived maps obtained with different fitting routines.

bundle_profile_plot(x, profile, ylabel, *[, ...])

Plot bundle profile.

image_mosaic(images, *[, ax_labels, ...])

Draw a mosaic of 2D images using pyplot.imshow().

Module: viz.projections#

Visualization tools for 2D projections of 3D functions on the sphere, such as ODFs.

sph_project(vertices, val, *[, ax, vmin, ...])

Draw a signal on a 2D projection of the sphere.

Module: viz.regtools#

simple_plot(file_name, title, x, y, xlabel, ...)

Saves the simple plot with given x and y values

overlay_images(img0, img1, *[, title0, ...])

Plot two images one on top of the other using red and green channels.

draw_lattice_2d(nrows, ncols, delta)

Create a regular lattice of nrows x ncols squares.

plot_2d_diffeomorphic_map(mapping, *[, ...])

Draw the effect of warping a regular lattice by a diffeomorphic map.

plot_slices(V, *[, slice_indices, fname])

Plot 3 slices from the given volume: 1 sagittal, 1 coronal and 1 axial

overlay_slices(L, R, *[, slice_index, ...])

Plot three overlaid slices from the given volumes.

Module: viz.skyline#

Skyline: interactive 3D viewer for diffusion images, tractography, and related data.

Module: viz.skyline.UI#

ImGui-based UI widgets and window management for Skyline.

Module: viz.skyline.UI.elements#

Reusable ImGui controls styled for the Skyline sidebar.

colors_equal(color_a, color_b)

Return True when two RGB-like values represent the same color.

normalize_picker_color(color, *[, fallback])

Return an RGB tuple suitable for ImGui color picker widgets.

render_file_dialog(*[, title, name, ...])

Open a native file dialog and forward the result to callback.

open_confirmation_dialog(title, message, *)

Drive a modal confirmation popup for the current frame.

loading(title, message, show)

Show or hide a centered modal loading indicator.

warning_message(message)

Draw a warning icon with primary-colored text.

color_picker(*[, label, selected_color, ...])

Create color picker from selected color.

downloader(label, callback, *[, extension, ...])

Render a themed file downloader button.

uploader(label, callback, *[, extension, ...])

Render a themed file uploader button.

toggle_button(value, *[, label])

Render a toggle button with an icon indicating the on/off state.

render_section_header(label, *[, is_open, ...])

Draw a custom section header with a toggle arrow.

render_group(label, items, *[, row_height, ...])

Render a grouped list with a tree-like label column and custom rows.

create_numeric_input(label, value, *[, ...])

Render a themed numeric spinner with editable value field.

segmented_switch(label, options, value, *[, ...])

Render a segmented switch control.

dropdown(label, options, value, *[, width, ...])

Render a themed dropdown/combobox control.

thin_slider(label, value, min_value, ...[, ...])

Render a compact slider with a thin track and circular thumb.

two_disk_slider(label, values, min_value, ...)

Render a range slider with two circular thumbs on a thin track.

Module: viz.skyline.UI.manager#

Skyline sidebar window: section grouping, file dialogs, and font setup.

UIManager()

Represent UIManager in Skyline.

UIWindow(title, *[, default_open, flags, ...])

Represent UIWindow in Skyline.

Module: viz.skyline.UI.theme#

Theme utilities for Skyline UI components.

hex_to_rgba(hex_color, *[, alpha])

Convert hex colors to rgba

Module: viz.skyline.app#

Application entry points and main Skyline viewer class.

Skyline(*[, visualizer_type, images, peaks, ...])

Represent Skyline in Skyline.

skyline_from_files(fnames, *[, rois, ...])

Launch Skyline GUI from files.

skyline(*[, visualizer_type, images, peaks, ...])

Launch Skyline GUI.

Module: viz.skyline.compute#

run_async(func, callback, *args, **kwargs)

Execute a function asynchronously in a background thread.

process_async_callbacks()

Drain the async task queue and run each callback on the calling thread.

Module: viz.skyline.io#

Load mixed media files for Skyline from disk paths.

EMERGENCY_REF supplies a fallback NIfTI header (MNI-like spacing) when tractograms must load before any matching reference image is available.

load_files(fnames, *[, rois, shm_coeffs])

Load the provided list of files.

load_npy(fname)

Load a numpy file containing BUAN color values.

Module: viz.skyline.render#

Rendering backends and visualization types for Skyline.

Module: viz.skyline.render.image#

NIfTI-backed volume slicers with linked UI controls for Skyline.

Image3D(name, volume, *[, affine, ...])

Represent Image3D in Skyline.

create_image_visualization(input, idx, *[, ...])

Create image visualization from input

Module: viz.skyline.render.peak#

Peak direction (PAM) slicers for Skyline.

Peak3D(name, peaks, *[, affine, ...])

Represent Peak3D in Skyline.

create_peak_visualization(input, idx, *[, ...])

Create peak visualization from input

Module: viz.skyline.render.renderer#

Shared FURY window factory and base class for Skyline visualizations.

Visualization(path, render_callback)

Represent Visualization in Skyline.

affine_voxel_sizes(affine)

Return voxel sizes from an affine matrix.

slice_slider_bounds(shape, *[, affine])

Return affine-aware integer bounds for slice sliders.

slice_state_from_slider_values(slider_values, *)

Convert slice slider values to slicing state coordinates.

slice_slider_values_from_state(state, *[, ...])

Convert slicing state coordinates to slice slider values.

voxel_values_from_slice_state(state, *[, affine])

Convert slicing state coordinates to voxel coordinates.

create_window(*[, visualizer_type, size, ...])

Create a FURY ShowManager based on the visualizer type.

Module: viz.skyline.render.roi#

Binary ROI masks meshed as translucent contours.

ROI3D(name, roi, *[, affine, opacity, ...])

Represent ROI3D in Skyline.

create_roi_visualization(input, idx, *[, ...])

Create ROI visualization from input

Module: viz.skyline.render.sh_billboard#

GPU billboard pipeline for dense spherical-harmonic glyphs in Skyline.

SlicedSphGlyphMaterial(*[, active_slice_x, ...])

Represent SlicedSphGlyphMaterial in Skyline.

Billboard([geometry, material])

Base mesh class for instanced glyph billboards (Fury Mesh subclass).

SphGlyphBillboard([geometry, material])

Multi-glyph SH billboard with LUT baking and per-glyph coefficient buffers.

BillboardSphGlyphShader(wobject)

Represent BillboardSphGlyphShader in Skyline.

enable_octahedral_lut(actor, *[, lut_res, ...])

Bake radius or Hermite LUT chunks on actor if GPU memory allows.

sph_glyph_billboard_sliced(coeffs, centers, ...)

Create a sliced billboard SH glyph actor.

Module: viz.skyline.render.sh_slicer#

SH Glyph Slicer for Skyline.

SHSlicer(coeffs_4d, *[, voxel_sizes, scale, ...])

Represent SHSlicer in Skyline.

SHGlyph3D(name, coeffs, *[, affine, ...])

Represent SHGlyph3D in Skyline.

create_shm_visualization(input, idx, *[, ...])

Create SH glyph visualization from input.

Module: viz.skyline.render.streamline#

Tractography layers, clustering, and BUAN coloring for Skyline.

Streamline3D(name, sft, *[, line_type, ...])

Represent Streamline3D in Skyline.

ClusterStreamline3D(name, sft, thr, *[, ...])

Represent ClusterStreamline3D in Skyline.

create_colormap(n, *[, hue, saturation, value])

Build an RGB lookup table sampled along HSV space.

apply_buan_colors(streamlines, buan_pvals, *)

Assign BUAN p-value-derived RGB colors per streamline or sample.

create_cluster_help(*[, position, size])

Create a 2D text panel summarizing cluster interaction shortcuts.

create_streamline_visualization(input, idx, *)

Create streamline visualization from input

create_streamline(lines, *[, color, ...])

Instantiate Fury line or tube geometry for polyline streamlines.

Module: viz.skyline.render.surface#

Mesh surfaces (FreeSurfer/GIFTI) with Phong or basic materials.

Surface(name, vertices, faces, *[, affine, ...])

Represent Surface in Skyline.

create_surface_visualization(input, idx, *)

Create surface visualization from input

Module: viz.skyline.wgsl#

WGSL shader sources for DIPY’s SH billboard rendering pipeline.

load_dipy_wgsl(name)

Load a UTF-8 WGSL/Jinja template shipped inside dipy.viz.skyline.wgsl.

Module: viz.streamline#

show_bundles(bundles, *[, interactive, ...])

Render bundles to visualize them interactively or save them into a png.

viz_two_bundles(b1, b2, fname, *[, c1, c2, ...])

Render and plot two bundles to visualize them.

viz_vector_field(points_aligned, directions, ...)

Render and plot vector field.

viz_displacement_mag(bundle, offsets, fname, *)

Render and plot displacement magnitude over the bundle.

GlobalHorizon#

class dipy.viz.gmem.GlobalHorizon[source]#

Bases: object

Horizon#

class dipy.viz.horizon.app.Horizon(*, tractograms=None, images=None, pams=None, surfaces=None, cluster=False, rgb=False, cluster_thr=15.0, random_colors=None, length_gt=0, length_lt=1000, clusters_gt=0, clusters_lt=10000, world_coords=True, interactive=True, out_png='tmp.png', recorded_events=None, return_showm=False, bg_color=(0, 0, 0), order_transparent=True, buan=False, buan_colors=None, roi_images=False, roi_colors=(1, 0, 0), surface_colors=((1, 0, 0),))[source]#

Bases: object

Methods

build_show

horizon#

dipy.viz.horizon.app.horizon(*, tractograms=None, images=None, pams=None, surfaces=None, cluster=False, rgb=False, cluster_thr=15.0, random_colors=None, bg_color=(0, 0, 0), order_transparent=True, length_gt=0, length_lt=1000, clusters_gt=0, clusters_lt=10000, world_coords=True, interactive=True, buan=False, buan_colors=None, roi_images=False, roi_colors=(1, 0, 0), out_png='tmp.png', recorded_events=None, return_showm=False)[source]#

Horizon is deprecated and will be removed with future releases. Please use Skyline.

Horizon is deprecated and will be removed in future releases. Please use Skyline instead.

  • deprecated from version: 1.13.0

  • Will raise <class ‘dipy.utils.deprecator.ExpiredDeprecationError’> as of version: 2.0.0

See [1] for further details about Horizon.

Parameters:
tractogramssequence of StatefulTractograms

StatefulTractograms are used for making sure that the coordinate systems are correct

imagessequence of tuples

Each tuple contains data and affine

pamssequence of PeakAndMetrics

Contains peak directions and spherical harmonic coefficients

surfacessequence of tuples

Each tuple contains vertices and faces

clusterbool

Enable QuickBundlesX clustering

rgb: bool, optional

Enable the color image.

cluster_thrfloat

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 cluster should be enabled.

random_colorsstring

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.

bg_colorndarray or list or tuple

Define the background color of the scene. Default is black (0, 0, 0)

order_transparentbool

Default True. Use depth peeling to sort transparent objects. If True also enables anti-aliasing.

length_gtfloat

Clusters with average length greater than length_gt amount in mm will be shown.

length_ltfloat

Clusters with average length less than length_lt amount in mm will be shown.

clusters_gtint

Clusters with size greater than clusters_gt will be shown.

clusters_ltint

Clusters with size less than clusters_lt will be shown.

world_coordsbool

Show data in their world coordinates (not native voxel coordinates) Default True.

interactivebool

Allow user interaction. If False then Horizon goes on stealth mode and just saves pictures.

buanbool, optional

Enables BUAN framework visualization. Default is False.

buan_colorslist, optional

List of colors for bundles.

roi_imagesbool, optional

Displays binary images as contours. Default is False.

roi_colorsndarray or list or tuple, optional

Define the color of the roi images. Default is red (1, 0, 0)

out_pngstring

Filename of saved picture.

recorded_eventsstring

File path to replay recorded events

return_showmbool

Return ShowManager object. Used only at Python level. Can be used for extending Horizon’s capabilities externally and for testing purposes. This is ignored in Skyline.

References

build_label#

dipy.viz.panel.build_label(text, *, font_size=18, bold=False)[source]#

Simple utility function to build labels

Parameters:
textstr
font_sizeint
boldbool
Returns:
labelTextBlock2D

slicer_panel#

dipy.viz.panel.slicer_panel(scene, iren, *, data=None, affine=None, world_coords=False, pam=None, mask=None, mem=None)[source]#

Slicer panel with slicer included

Parameters:
sceneScene

Scene.

irenInteractor

Interactor.

data3d ndarray

Data to be sliced.

affine4x4 ndarray

Affine matrix.

world_coordsbool

If True then the affine is applied.

peaksPeaksAndMetrics

Default None

mem
Returns:
panelPanel

compare_maps#

dipy.viz.plotting.compare_maps(fits, maps, *, transpose=None, fit_labels=None, map_labels=None, fit_kwargs=None, map_kwargs=None, filename=None)[source]#

Compare one or more scalar maps for different fits or models.

Parameters:
fitslist

List of fits to be compared.

mapslist

Names of attributes to be compared. Default: ‘rtop’.

transposebool, optional

If False, different fits are placed on different rows and different maps on different columns. If True, the order is transposed. If None, the figures are placed such that there are more columns than rows. Default: None.

fit_labelslist, optional

Labels for the different fitting routines. If None the fits are labeled by number. Default: None.

map_labelslist, optional

Labels for the different attributes. If None the attribute names are used. Default: None.

fit_kwargslist or dict, optional

A dict or list of dicts with imshow options for each fitting routine. The dicts are passed to imshow as keyword-argument pairs. Default: {}.

map_kwargslist or dict, optional

A dict or list of dicts with imshow options for each MAP-MRI scalar. The dicts are passed to imshow as keyword-argument pairs. Default: {}.

filenamestring, optional

Filename where the image will be saved. Default: None.

compare_qti_maps#

dipy.viz.plotting.compare_qti_maps(gt, fit1, fit2, mask, *, maps=('fa', 'ufa'), fitname=('QTI', 'QTI+'), xlimits=([0, 1], [0.4, 1.5]), disprange=([0, 1], [0, 1]), slice=13)[source]#

Compare one or more qti derived maps obtained with different fitting routines.

Parameters:
gtqti fit object

The qti fit to be considered as ground truth

fit1qti fit object

First qti fit to be compared

fit2qti fit object

Second qti fit to be compared

masknp.ndarray

Boolean array indicating which voxels to retain for comparing the values

mapsarray-like, optional

QTI invariants to be compared

fitnamearray-like, optional

Names of the used QTI fitting routines

xlimitsarray-like, optional

X-Axis limits for the histograms visualization

disprangearray-like, optional

Display range for maps

sliceint, optional

Axial brain slice to be visualized

bundle_profile_plot#

dipy.viz.plotting.bundle_profile_plot(x, profile, ylabel, *, title='Bundle Profile', std=None, save_path=None, show=True)[source]#

Plot bundle profile.

Parameters:
xnp.ndarray

Integer array containing x-axis

profilenp.ndarray

Float array containing bundle profile

ylabelstr

ylabel for the plot

titlestr, optional

Plot title

stdnp.ndarray, optional

Float array containing standard deviations

save_pathstr, optional

If provided, save the figure to this path (e.g., “profile.png”)

showbool, optional

Whether to display the plot interactively

image_mosaic#

dipy.viz.plotting.image_mosaic(images, *, ax_labels=None, ax_kwargs=None, figsize=None, filename=None)[source]#

Draw a mosaic of 2D images using pyplot.imshow(). A colorbar is drawn beside each image.

Parameters:
images: list of ndarray

Images to render.

ax_labels: list of str, optional

Label for each image.

ax_kwargs: list of dictionaries, optional

keyword arguments passed to imshow for each image. One dictionary per image.

figsize: tuple of ints, optional

Figure size.

filename: str, optional

When given, figure is saved to disk under this name.

Returns:
fig: pyplot.Figure

The figure.

ax: pyplot.Axes or array of Axes

The subplots for each image.

sph_project#

dipy.viz.projections.sph_project(vertices, val, *, ax=None, vmin=None, vmax=None, cmap=None, cbar=True, tri=False, boundary=False, **basemap_args)[source]#

Draw a signal on a 2D projection of the sphere.

Parameters:
vertices(N,3) ndarray

Unit vector points of the sphere

val(N) ndarray

Function values.

axmpl axis, optional

If specified, draw onto this existing axis instead.

vminfloat, optional

Minimum value to cut the z.

vmaxfloat, optional

Minimum value to cut the z.

cmapmatplotlib.colors.Colormap, optional

Colormap.

cbarbool, optional

Whether to add the color-bar to the figure.

tribool, optional

Whether to display the plot triangulated as a pseudo-color plot.

boundarybool, optional

Whether to draw the boundary around the projection in a black line.

Returns:
axaxis

Matplotlib figure axis

Examples

>>> from dipy.data import default_sphere
>>> verts = default_sphere.vertices
>>> _ax = sph_project(verts.T, np.random.rand(len(verts.T)))

simple_plot#

dipy.viz.regtools.simple_plot(file_name, title, x, y, xlabel, ylabel)[source]#

Saves the simple plot with given x and y values

Parameters:
file_namestring

file name for saving the plot

titlestring

title of the plot

xinteger list

x-axis values to be plotted

yinteger list

y-axis values to be plotted

xlabelstring

label for x-axis

ylabelstring

label for y-axis

overlay_images#

dipy.viz.regtools.overlay_images(img0, img1, *, title0='', title_mid='', title1='', fname=None, **fig_kwargs)[source]#

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.

Parameters:
img0array, shape(R, C)

the image to be plotted on the red channel, to the left of the figure

img1array, shape(R, C)

the image to be plotted on the green channel, to the right of the figure

title0string, optional

the title to be written on top of the image to the left. By default, no title is displayed.

title_midstring, optional

the title to be written on top of the middle image. By default, no title is displayed.

title1string, optional

the title to be written on top of the image to the right. By default, no title is displayed.

fnamestring, optional

the file name to write the resulting figure. If None (default), the image is not saved.

fig_kwargsdict

Extra parameters for saving figure, e.g. dpi=300.

draw_lattice_2d#

dipy.viz.regtools.draw_lattice_2d(nrows, ncols, delta)[source]#

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.

Parameters:
nrowsint

the number of squares to be drawn vertically

ncolsint

the number of squares to be drawn horizontally

deltaint

the size of each square of the grid. Each square is delta x delta pixels

Returns:
latticearray, shape (R, C)

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

plot_2d_diffeomorphic_map#

dipy.viz.regtools.plot_2d_diffeomorphic_map(mapping, *, delta=10, fname=None, direct_grid_shape=None, direct_grid2world=-1, inverse_grid_shape=None, inverse_grid2world=-1, show_figure=True, **fig_kwargs)[source]#

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.

Parameters:
mappingDiffeomorphicMap object

the diffeomorphic map to be drawn

deltaint, optional

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.

fnamestring, optional

the name of the file the figure will be written to. If None (default), the figure will not be saved to disk.

direct_grid_shapetuple, shape (2,), optional

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.

direct_grid2worldarray, shape (3, 3), optional

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

inverse_grid_shapetuple, shape (2,), optional

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

inverse_grid2worldarray, shape (3, 3), optional

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

show_figurebool, optional

if True (default), the deformed grids will be plotted using matplotlib, else the grids are just returned

fig_kwargsdict

Extra parameters for saving figure, e.g. dpi=300.

Returns:
warped_forwardarray

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.

warped_backwardarray

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_slices#

dipy.viz.regtools.plot_slices(V, *, slice_indices=None, fname=None, **fig_kwargs)[source]#

Plot 3 slices from the given volume: 1 sagittal, 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.

Parameters:
Varray, shape (S, R, C)

the 3D volume to extract the slices from

slice_indicesarray, shape (3,), optional

the indices of the sagittal (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.

fnamestring, optional

the name of the file to save the figure to. If None (default), the figure is not saved to disk.

fig_kwargsdict

Extra parameters for saving figure, e.g. dpi=300.

overlay_slices#

dipy.viz.regtools.overlay_slices(L, R, *, slice_index=None, slice_type=1, ltitle='Left', rtitle='Right', fname=None, **fig_kwargs)[source]#

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.

Parameters:
Larray, shape (S, R, C)

the first volume to extract the slice from plotted to the left

Rarray, shape (S, R, C)

the second volume to extract the slice from, plotted to the right

slice_indexint, optional

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

slice_typeint, optional

the type of slice to be extracted: 0=sagittal, 1=coronal (default), 2=axial.

ltitlestring, optional

the string to be written as the title of the left image. By default, no title is displayed.

rtitlestring, optional

the string to be written as the title of the right image. By default, no title is displayed.

fnamestring, optional

the name of the file to write the image to. If None (default), the figure is not saved to disk.

fig_kwargs: extra parameters for saving figure, e.g. `dpi=300`.

colors_equal#

dipy.viz.skyline.UI.elements.colors_equal(color_a, color_b)[source]#

Return True when two RGB-like values represent the same color.

This function ignores the alpha channel.

Parameters:
color_atuple

First color to compare.

color_btuple

Second color to compare.

Returns:
bool

True when the two colors are equal, False otherwise.

normalize_picker_color#

dipy.viz.skyline.UI.elements.normalize_picker_color(color, *, fallback=(1.0, 0.0, 0.0))[source]#

Return an RGB tuple suitable for ImGui color picker widgets.

Parameters:
colortuple

Color to normalize.

fallbacktuple, optional

Fallback color to return if the input color is not valid.

Returns:
tuple

An RGB tuple suitable for ImGui color picker widgets.

render_file_dialog#

dipy.viz.skyline.UI.elements.render_file_dialog(*, title='Select File(s)', name='All File(s)', extensions='*.*', multiselect=True, callback=None, dialog_type='open', file_name='save_file', type='viz')[source]#

Open a native file dialog and forward the result to callback.

Parameters:
titlestr, optional

Dialog window title.

namestr, optional

Filter label shown in the dialog.

extensionsstr, optional

Extension filter string (platform-specific, e.g. "*.nii *.gz").

multiselectbool, optional

Allow multiple paths when dialog_type is "open".

callbackcallable or None, optional

Invoked with keyword arguments matching the selected type, or with None when the dialog is cancelled (BUAN branch uses a single argument).

dialog_type{“open”, “save”}, optional

Whether to pick existing files or choose a save location.

file_namestr, optional

Default file name for save dialogs.

typestr, optional

Callback convention: "viz" (filenames=), "roi" (rois=), "shm_coeff" (shm_coeffs=), or "buan_pvals" (raw list/None).

open_confirmation_dialog#

dipy.viz.skyline.UI.elements.open_confirmation_dialog(title, message, *, okay_text='Okay', cancel_text='Cancel')[source]#

Drive a modal confirmation popup for the current frame.

Parameters:
titlestr

Popup identifier; must be stable across frames.

messagestr

Body text shown inside the modal.

okay_textstr, optional

Label for the confirm button.

cancel_textstr, optional

Label for the dismiss button.

Returns:
str

One of "open", "already_open", "okay", or "cancel" depending on popup and button state for this frame.

loading#

dipy.viz.skyline.UI.elements.loading(title, message, show)[source]#

Show or hide a centered modal loading indicator.

Parameters:
titlestr

ImGui popup id used for the overlay modal.

messagestr

Status line shown under the spinner.

showbool

When False the modal is closed on the next draw.

None

warning_message#

dipy.viz.skyline.UI.elements.warning_message(message)[source]#

Draw a warning icon with primary-colored text.

Parameters:
messagestr

Warning to display on the current ImGui line.

None

color_picker#

dipy.viz.skyline.UI.elements.color_picker(*, label='', selected_color=(0, 0, 0), tooltip='Pick color', popup_id='color_picker_popup')[source]#

Create color picker from selected color.

Parameters:
labelstr, optional

Text to put next to the icon.

selected_colortuple, optional

Previously selected color.

tooltipstr, optional

Tooltip to show when hovering the color picker.

popup_idstr, optional

Stable popup identifier for this color picker instance.

Returns:
tuple

A tuple containing the changed state, the color, and the open state. changed is True if the user edited the color this frame, color contains RGB values in [0, 1] after any edit, and is_open is True when the color picker popup is currently open.

downloader#

dipy.viz.skyline.UI.elements.downloader(label, callback, *, extension='*.*', type='viz', file_name='save.txt')[source]#

Render a themed file downloader button.

Parameters:
labelstr

Text to display on the button.

callbackfunction

Function to call when the button is clicked. Should return the content to be saved.

extensionstr, optional

File extension for the saved file.

typestr, optional
Type of file being downloaded, used to determine callback behavior.
  • “viz”: Visualization files (default)

  • “roi”: Region of Interest files

  • “shm_coeff”: Spherical Harmonics Coefficients files

  • “buan_colors”: BUAN color mapping files

file_namestr, optional

Default file name suggested in the save dialog.

None

uploader#

dipy.viz.skyline.UI.elements.uploader(label, callback, *, extension='*.*', multiselect=False, selected=False, type='viz')[source]#

Render a themed file uploader button.

Parameters:
labelstr

Text to display on the button.

callbackfunction

Function to call with the selected file(s) when the button is clicked.

extensionstr, optional

File extension filter for the file dialog.

multiselectbool, optional

Whether to allow selecting multiple files.

selectedbool or string, optional

Whether the uploader is in a selected state, affecting its appearance.

typestr, optional
Type of file being uploaded, used to determine callback behavior.
  • “viz”: Visualization files (default)

  • “roi”: Region of Interest files

  • “shm_coeff”: Spherical Harmonics Coefficients files

  • “buan_colors”: BUAN color mapping files

None

toggle_button#

dipy.viz.skyline.UI.elements.toggle_button(value, *, label='')[source]#

Render a toggle button with an icon indicating the on/off state.

Parameters:
valuebool

Current state of the toggle.

labelstr

Text rendered next to the toggle button.

Returns:
tuple

The tuple of the state (changed, value).

render_section_header#

dipy.viz.skyline.UI.elements.render_section_header(label, *, is_open=True, is_visible=True, type=None, width=0, height=40, padding_x=12, info=None, show_close=True, show_info=True)[source]#

Draw a custom section header with a toggle arrow.

Parameters:
labelstr

Text to render in the header.

is_openbool, optional

Current open state for the section. The returned value reflects toggling.

is_visiblebool, optional

Current visibility state for the section.

typestr, optional

Type of section. Used to determine the icon shown.

widthint, optional

Header width in pixels. If 0 or negative, uses available width.

heightint, optional

Header height in pixels.

padding_xint, optional

Horizontal padding between the icon and label.

infostr, optional

Additional info text shown in a tooltip when hovering the header. If not provided, no tooltip is shown.

show_closebool, optional

Whether to show the close/remove button. Default is True.

show_infobool, optional

Whether to show the info button. Default is True.

Returns:
is_openbool

Updated expanded state for the section panel.

is_visiblebool

Updated actor visibility preference.

is_closebool

True if the user clicked remove this frame.

is_changedbool

True if the header body area triggered an open transition.

render_group#

dipy.viz.skyline.UI.elements.render_group(label, items, *, row_height=26, label_width=36, line_indent=8)[source]#

Render a grouped list with a tree-like label column and custom rows.

Parameters:
labelstr

Group heading shown above the table.

itemslist of tuple

Sequence of items where each entry is (render_fn) or (render_fn, args, kwargs). render_fn is called with the provided args/kwargs in the content column.

row_heightint, optional

Height of each row in pixels.

label_widthint, optional

Width of the label column in pixels.

line_indentint, optional

Horizontal indent for the guide line from the row start.

Returns:
list of tuple or None

A list of values returned from each render_fn call, or None when items is empty.

create_numeric_input#

dipy.viz.skyline.UI.elements.create_numeric_input(label, value, *, value_type='int', step=1, format='%.3f', label_width=0, width=106, height=32)[source]#

Render a themed numeric spinner with editable value field.

Parameters:
labelstr

Label rendered to the left. Use ##id to hide visible text.

valueint or float

Current numeric value.

value_type{“int”, “float”}, optional

Numeric type enforced for the value.

stepint or float, optional

Increment/decrement amount used by spinner clicks.

formatstr, optional

Display format used for floating-point values.

label_widthint, optional

Fixed width reserved for the label column in pixels. Use 0 to size from content.

widthint, optional

Width of the input box in pixels.

heightint, optional

Height of the input box in pixels.

Returns:
tuple(bool, int or float)

Whether the value changed and the resulting numeric value.

segmented_switch#

dipy.viz.skyline.UI.elements.segmented_switch(label, options, value, *, width=0, height=28)[source]#

Render a segmented switch control.

Parameters:
labelstr

Text rendered next to the switch.

optionslist of str

Labels for each segment in the switch.

valuestr

Currently selected option. If not found in options, the first option is used.

widthint, optional

Total width for the switch. If 0 or negative, uses the available width.

heightint, optional

Height for each segment in pixels.

Returns:
tuple(bool, str)

Whether the selection changed and the resulting option value.

thin_slider#

dipy.viz.skyline.UI.elements.thin_slider(label, value, min_value, max_value, *, width=0, step=1.0, track_height=2.0, thumb_radius=7.0, hitbox_height=20.0, text_format='.3f', value_type='float', value_unit=None, show_toggle=False, toggle=False)[source]#

Render a compact slider with a thin track and circular thumb.

Parameters:
labelstr

Text rendered next to the slider.

valuefloat

Current slider value.

min_valuefloat

Lower bound for the slider.

max_valuefloat

Upper bound for the slider.

widthint, optional

Widget width in pixels. Negative values use the available width.

stepfloat, optional

Increment applied when using keyboard arrows.

track_heightfloat, optional

Thickness of the slider track in pixels.

thumb_radiusfloat, optional

Radius of the circular thumb in pixels.

hitbox_heightfloat, optional

Height of the invisible button capturing pointer interactions.

text_formatstr, optional

Format specification passed when displaying float values.

value_type{“float”, “int”}, optional

Numeric type enforced for the slider value.

value_unitstr or None, optional

Optional unit suffix appended to the value display.

show_togglebool, optional

When True, prefix a clickable visibility icon before the label.

togglebool, optional

Current state for the visibility icon when show_toggle is True.

Returns:
tuple

(changed, value) or (changed, value, toggle) when show_toggle is True.

two_disk_slider#

dipy.viz.skyline.UI.elements.two_disk_slider(label, values, min_value, max_value, *, width=0, step=1.0, track_height=2.0, thumb_radius=7.0, hitbox_height=20.0, text_format='.3f', value_type='float', value_unit=None, min_gap=0.0, display_values=None)[source]#

Render a range slider with two circular thumbs on a thin track.

Parameters:
labelstr

Text rendered next to the slider.

valuestuple[float, float]

Current lower and upper values for the range.

min_valuefloat

Lower bound for the slider.

max_valuefloat

Upper bound for the slider.

widthint, optional

Widget width in pixels. Negative values use the available width.

stepfloat, optional

Increment applied when using keyboard arrows.

track_heightfloat, optional

Thickness of the slider track in pixels.

thumb_radiusfloat, optional

Radius of each circular thumb in pixels.

hitbox_heightfloat, optional

Height of the invisible button capturing pointer interactions.

text_formatstr, optional

Format specification passed when displaying float values.

value_type{“float”, “int”}, optional

Numeric type enforced for the slider values.

value_unitstr or None, optional

Optional unit suffix appended to the value display.

min_gapfloat, optional

Minimum allowed gap between the two thumbs.

display_valuestuple[float, float] or None, optional

Optional values shown in the text readout instead of the slider values. Useful for displaying absolute values while the thumbs operate on percentiles.

Returns:
tuple(bool, tuple[float or int, float or int])

Whether the slider values changed and the resulting numeric range.

UIManager#

class dipy.viz.skyline.UI.manager.UIManager[source]#

Bases: object

Represent UIManager in Skyline.

Methods

add_window(window_name, window_instance)

Register window_instance under window_name.

add_window(window_name, window_instance)[source]#

Register window_instance under window_name.

Parameters:
window_namestr

Dictionary key for later lookup.

window_instanceUIWindow

Arbitrary window object owned by the caller.

UIWindow#

class dipy.viz.skyline.UI.manager.UIWindow(title, *, default_open=True, flags=0, pos=(0, 0), size=(400, 400), logo_tex_ref=None, render_callback=None, file_dialog_callback=None, bg_color_callback=None, snapshot_callback=None)[source]#

Bases: object

Represent UIWindow in Skyline.

Parameters:
titlestr

Title text shown in the UI.

default_openbool, optional

Value for default open.

flagsint, optional

Value for flags.

postuple(int, int), optional

Value for pos.

sizetuple(int, int), optional

Value for size.

logo_tex_refTextureId, optional, optional

Value for logo tex ref.

render_callbackcallable, optional

Callback used to request a render/update.

file_dialog_callbackcallable, optional

Callback invoked after file selection.

bg_color_callbackcallable, optional

Callback invoked when background color changes.

Attributes:
section_open_states

Collapsed/open flags for each registered section id.

sections

Map section id to (renderer_callable, viz_type) tuples.

Methods

add(name, section_renderer, *[, viz_type])

Register a visualization section callable and optional grouping type.

remove(name)

Drop a section and its open-state bookkeeping.

render()

Draw the full sidebar for the current frame.

update_loader(*, show[, message])

Toggle the modal loading overlay.

add(name, section_renderer, *, viz_type=None)[source]#

Register a visualization section callable and optional grouping type.

Parameters:
namestr

Unique key, usually f"{path}:{display_name}".

section_renderercallable

renderer(is_open, group_visible=...) from Visualization.

viz_typestr or None, optional

One of the keys in _GROUP_ORDER used to cluster the sidebar.

remove(name)[source]#

Drop a section and its open-state bookkeeping.

Parameters:
namestr

Key previously passed to add().

render()[source]#

Draw the full sidebar for the current frame.

property section_open_states#

Collapsed/open flags for each registered section id.

property sections#

Map section id to (renderer_callable, viz_type) tuples.

update_loader(*, show, message=None)[source]#

Toggle the modal loading overlay.

Parameters:
showbool

When True, ensure the loading popup is opened.

messagestr, optional

User-facing status string.

hex_to_rgba#

dipy.viz.skyline.UI.theme.hex_to_rgba(hex_color, *, alpha=1.0)[source]#

Convert hex colors to rgba

Parameters:
hex_colorstr

Hexcode for the color.

alphafloat, optional

Transparency of the color.

Returns:
tuple

RGBA color tuple.

Skyline#

class dipy.viz.skyline.app.Skyline(*, visualizer_type='standalone', images=None, peaks=None, rois=None, surfaces=None, tractograms=None, sh_coeffs=None, is_cluster=False, is_light_version=False, glass_brain=False, bg_color=None, tract_colors=None, cluster_thr=15.0, cluster_size_thr=None, cluster_length_thr=None, buan_pvals=None, rgb=False, initial_filenames=None, initial_rois=None, initial_shm_coeffs=None, out_dir=None, out_stealth_png=None)[source]#

Bases: object

Represent Skyline in Skyline.

Parameters:
visualizer_typestr, optional

Value for visualizer type.

imageslist, optional

Value for images.

peaksndarray

Value for peaks.

roislist, optional

Value for rois.

surfaceslist, optional

Value for surfaces.

tractogramslist, optional

Value for tractograms.

sh_coeffslist, optional

Value for sh coeffs.

is_clusterbool, optional

Value for is cluster.

is_light_versionbool, optional

Value for is light version.

glass_brainbool, optional

Value for glass brain.

bg_colortuple(float, float, float), optional

Value for bg color.

tract_colorsstr or tuple, optional

Value for tract colors.

cluster_thrfloat, optional

Value for cluster thr.

cluster_size_thrint, optional

Value for cluster size thr.

cluster_length_thrfloat, optional

Value for cluster length thr.

buan_pvalsstr, optional

Value for buan pvals.

rgbbool, optional

Interpret a 4D volume as RGB/RGBA channels when True. Colormap and directional-volume controls are ignored in this mode.

initial_filenameslist, optional

Value for initial filenames.

initial_roislist, optional

Value for initial rois.

initial_shm_coeffslist, optional

Value for initial shm coeffs.

out_dirstr or Path, optional

Value for out dir.

out_stealth_pngstr, optional

Value for out stealth png.

Attributes:
visualizations

Handle visualizations for Skyline.

Methods

before_render()

Handle before render for Skyline.

draw_ui()

Handle draw ui for Skyline.

enqueue_scene_op(func, *args, **kwargs)

Handle enqueue scene op for Skyline.

handle_key_events(event)

Handle handle key events for Skyline.

handle_resize(size)

Handle handle resize for Skyline.

loader(show, *[, message])

Handle loader for Skyline.

request_refresh()

Handle request refresh for Skyline.

before_render()[source]#

Handle before render for Skyline. None

draw_ui()[source]#

Handle draw ui for Skyline. None

enqueue_scene_op(func, *args, **kwargs)[source]#

Handle enqueue scene op for Skyline.

Parameters:
funccallable

Value for func.

*argstuple

Value for args.

**kwargsdict

Value for kwargs.

handle_key_events(event)[source]#

Handle handle key events for Skyline.

Parameters:
eventEvent

Interaction event from the renderer callback.

handle_resize(size)[source]#

Handle handle resize for Skyline.

Parameters:
sizetuple(int, int), optional

Value for size.

loader(show, *, message=None)[source]#

Handle loader for Skyline.

Parameters:
showbool

Whether to show the UI element/loader.

messagestr, optional

Message text shown to the user.

request_refresh()[source]#

Handle request refresh for Skyline. None

property visualizations#

Handle visualizations for Skyline.

Returns:
list

The list of visualizations in the Skyline viewer.

skyline_from_files#

dipy.viz.skyline.app.skyline_from_files(fnames, *, rois=None, shm_coeffs=None, is_cluster=False, is_light_version=False, glass_brain=False, bg_color=None, tract_colors=None, cluster_thr=15.0, cluster_size_thr=None, cluster_length_thr=None, buan_pvals=None, stealth=False, rgb=False, out_dir=None, out_stealth_png=None)[source]#

Launch Skyline GUI from files.

Parameters:
fnameslist

List of file paths to be loaded into the Skyline viewer. Supported file types include: - NIfTI images (.nii, .nii.gz) - Peaks (.pam5) - Surfaces (.pial, .gii, .gii.gz) - Tractograms (.trx, .trk, .dpy, .tck, .vtk, .vtp, .fib)

roislist, optional

List of file paths for ROIs to be loaded into the Skyline viewer. Supported file types include NIfTI images (.nii, .nii.gz).

shm_coeffslist, optional

List of file paths for spherical harmonics coefficients to be loaded into the Skyline viewer. Supported file types include .pam5 files containing SH coefficients.

is_clusterbool, optional

Whether to cluster the tractograms.

is_light_versionbool, optional

Whether to use the light version of the tractogram rendering. This will render tractograms as lines instead of tubes, which can improve performance for large tractograms.

glass_brainbool, optional

Whether to use glass brain mode. This will overwrite the background color to white if not explicitly set by the user.

bg_colorvariable float, optional

Define the background color of the scene. Colors can be defined with 3 values and should be between [0-1]. For example, a value of (0, 0, 0) would mean the black color.

tract_colorsvariable float or str, optional

Define the colors of the tractograms. Colors can be defined with 3 values and should be between [0-1]. String options are ‘random’ for random colors for each tractogram, ‘direction’ for directionally colored streamlines. For example, a value of (1, 0, 0) would mean the red color.

cluster_thrfloat, optional

Distance threshold used for clustering. Default value 15.0 for small animal brains you may need to use something smaller such as 2.0. The distance is in mm. For this parameter to be active cluster should be enabled.

cluster_size_thrint, optional

Clusters with size less than cluster_size_thr will be hidden. If None, it will show all cluster above the 50th percentile of the cluster size distribution.

cluster_length_thrfloat, optional

Clusters with average length less than cluster_length_thr in mm will be hidden. If None, it will show all cluster above the 25th percentile of the cluster length distribution.

buan_pvalsstr, optional

File path for BUAN p-values to be used for BUAN-based coloring of tractograms.

stealthbool, optional

Do not use interactive mode just save figure.

rgbbool, optional

Enable the colors in the image if 4D data with RGB/RGBA channels.

out_dirstr or Path, optional

Output directory to save the figure if stealth mode is enabled.

out_stealth_pngstr, optional

Filename of saved picture if stealth mode is enabled.

Returns:
Skyline

Constructed viewer instance (blocking for interactive modes).

skyline#

dipy.viz.skyline.app.skyline(*, visualizer_type='standalone', images=None, peaks=None, rois=None, surfaces=None, tractograms=None, sh_coeffs=None, is_cluster=False, is_light_version=False, glass_brain=False, bg_color=None, tract_colors=None, cluster_thr=15.0, cluster_size_thr=None, cluster_length_thr=None, buan_pvals=None, rgb=False, initial_filenames=None, initial_rois=None, initial_shm_coeffs=None, out_dir=None, out_stealth_png=None)[source]#

Launch Skyline GUI.

Parameters:
visualizer_typestr, optional

Type of visualizer to create. The options are: - “standalone”: A standalone window with full interactivity. - “gui”: A Qt-based GUI window. - “jupyter”: An inline Jupyter notebook visualizer. - “stealth”: An offscreen visualizer without GUI.

imageslist, optional

List of path for each image to be added to the Skyline viewer.

peakslist, optional

List of path for each peak to be added to the Skyline viewer.

roislist, optional

List of path for each ROI to be added to the Skyline viewer.

surfaceslist, optional

List of path for each surface to be added to the Skyline viewer.

tractogramslist, optional

List of path for each tractogram to be added to the Skyline viewer.

is_clusterbool, optional

Whether to cluster the tractograms.

is_light_versionbool, optional

Whether to use the light version of the tractogram rendering. This will render tractograms as lines instead of tubes, which can improve performance for large tractograms.

glass_brainbool, optional

Whether to use glass brain mode. This will overwrite the background color to white if not explicitly set by the user.

bg_colorvariable float, optional

Define the background color of the scene. Colors can be defined with 3 values and should be between [0-1]. For example, a value of (0, 0, 0) would mean the black color.

tract_colorsvariable float or str, optional

Define the colors of the tractograms. Colors can be defined with 3 values and should be between [0-1]. String options are ‘random’ for random colors for each tractogram, ‘direction’ for directionally colored streamlines. For example, a value of (1, 0, 0) would mean the red color.

cluster_thrfloat, optional

Distance threshold used for clustering. Default value 15.0 for small animal brains you may need to use something smaller such as 2.0. The distance is in mm. For this parameter to be active cluster should be enabled.

cluster_size_thrint, optional

Clusters with size less than cluster_size_thr will be hidden. If None, it will show all cluster above the 50th percentile of the cluster size distribution.

cluster_length_thrfloat, optional

Clusters with average length less than cluster_length_thr in mm will be hidden. If None, it will show all cluster above the 25th percentile of the cluster length distribution.

rgbbool, optional

Enable the colors in the image if 4D data with RGB/RGBA channels.

buan_pvalsstr, optional

File path for BUAN p-values to be used for BUAN-based coloring of tractograms.

initial_filenameslist, optional

List of file paths to be loaded into the Skyline viewer on startup.

initial_roislist, optional

List of file paths for ROIs to be loaded into the Skyline viewer on startup.

initial_shm_coeffslist, optional

List of file paths for spherical harmonics coefficients to be loaded into the Skyline viewer on startup.

out_dirstr or Path, optional

Output directory to save the figure if stealth mode is enabled.

out_stealth_pngstr, optional

Filename of saved picture if stealth mode is enabled.

Returns:
Skyline

Constructed viewer instance (blocking for interactive modes).

run_async#

dipy.viz.skyline.compute.run_async(func, callback, *args, **kwargs)[source]#

Execute a function asynchronously in a background thread.

This function runs the provided function in a daemon thread and queues the callback to be executed on the main thread upon completion.

Parameters:
funccallable

The function to execute in the background.

callbackcallable

Function to call when execution completes. Must have signature: callback(result, exception) where result is the return value of func and exception is any exception raised during execution.

*argstuple

Positional arguments to pass to func.

**kwargsdict

Keyword arguments to pass to func.

Notes

The callback is not executed directly in the worker thread. Instead, it is queued for execution on the main thread via the callback queue. The worker thread is created as a daemon thread, so it will terminate if the main application closes.

process_async_callbacks#

dipy.viz.skyline.compute.process_async_callbacks()[source]#

Drain the async task queue and run each callback on the calling thread.

Pair this with run_async() on the main/UI thread so background work delivers results safely without blocking the worker thread.

load_files#

dipy.viz.skyline.io.load_files(fnames, *, rois=None, shm_coeffs=None)[source]#

Load the provided list of files.

Parameters:
fnameslist of str

Path of the file.

roislist of str, optional

Paths of the ROIs.

shm_coeffslist of str, optional

Paths of the SH coefficients files.

Returns:
dict

Dictionary containing the loaded images, peaks, ROIs, surfaces, tractograms, and spherical-harmonic coefficient data.

load_npy#

dipy.viz.skyline.io.load_npy(fname)[source]#

Load a numpy file containing BUAN color values.

Parameters:
fnamestr

Path to the .npy file.

Returns:
np.ndarray

The loaded numpy array.

Image3D#

class dipy.viz.skyline.render.image.Image3D(name, volume, *, affine=None, interpolation='linear', render_callback=None, opacity=100, rgb=False, value_percentiles=(2, 98), colormap='Gray', sync_callabck=None)[source]#

Bases: Visualization

Represent Image3D in Skyline.

Parameters:
namestr

Display name used in the Skyline UI.

volumenp.ndarray

Input image volume with shape (X, Y, Z) or (X, Y, Z, N).

affinenp.ndarray

Voxel-to-world affine used to position slices in world coordinates.

interpolationstr

Slice interpolation mode ("linear" or "nearest").

render_callbackcallable

Callback used to request a render/update.

opacityint

Slice opacity in percent, expected in [0, 100].

rgbbool

Interpret a 4D volume as RGB/RGBA channels when True. Colormap and directional-volume controls are ignored in this mode.

value_percentilestuple

Low/high percentiles used to compute scalar intensity limits.

colormapstr

Colormap used for scalar volumes; ignored when rgb is True.

sync_callabckcallable

Callback used to synchronize state across views.

Attributes:
active_volume

Handle active volume for Image3D.

actor

Handle actor for Image3D.

viz_type

Return the visualization type identifier string.

Methods

apply_scene_op(func, *args, **kwargs)

Run func immediately or defer it via _scene_op_callback.

render()

Request a window redraw through _render_callback when set.

render_widgets()

Handle render widgets for Image3D.

renderer(is_open, *[, group_visible])

Draw the sidebar header and optional widget body for this layer.

update_state(new_state)

Handle update state for Image3D.

property active_volume#

Handle active volume for Image3D.

Returns:
np.ndarray

The active volume of the image visualization.

property actor#

Handle actor for Image3D.

Returns:
VolumeSlicer

The actor of the image visualization.

render_widgets()[source]#

Handle render widgets for Image3D.

update_state(new_state)[source]#

Handle update state for Image3D.

Parameters:
new_statearray-like

New synchronized state for this visualization.

create_image_visualization#

dipy.viz.skyline.render.image.create_image_visualization(input, idx, *, interpolation='linear', render_callback=None, opacity=100, rgb=False, value_percentiles=(2, 98), colormap='Gray', sync_callabck=None)[source]#

Create image visualization from input

Parameters:
inputtuple

Tuple of the (data, affine, filename) or (data, affine)

idxint

Index of the image for naming purposes when filename is not provided.

interpolationstr, optional

Interpolation method for volume rendering. Options are “linear” or “nearest”.

render_callbackcallable, optional

Callback function to be called after rendering.

opacityint, optional

Opacity of the volume rendering.

rgbbool, optional

Whether the image is RGB

value_percentilestuple, optional

Percentiles for intensity value range. For example, (2, 98) will set the intensity range to be between the 2nd and 98th percentiles of the image intensities.

colormapstr, optional

The colormap to use for rendering. Options include “Gray”, “Inferno”, “Magma”, “Plasma”, and “Viridis”. This parameter is ignored if rgb=True.

sync_callabckcallable, optional

Callback function to synchronize slice positions across visualizations.

Returns:
Image3D

The created Image3D object.

Raises:
ValueError

If the input is not a tuple of length 2 or 3, or if rgb=True and the last dimension of the volume is not 3 or 4.

Peak3D#

class dipy.viz.skyline.render.peak.Peak3D(name, peaks, *, affine=None, peak_values=1.0, opacity=100, render_callback=None, sync_callabck=None)[source]#

Bases: Visualization

Represent Peak3D in Skyline.

Parameters:
namestr

Display name used in the Skyline UI.

peaksndarray

Value for peaks.

affinendarray, optional

Voxel-to-world affine used to position slices in world coordinates.

peak_valuesndarray or float, optional

Value for peak values.

opacityint, optional

Slice opacity in percent, expected in [0, 100].

render_callbackcallable, optional

Callback used to request a render/update.

sync_callabckcallable, optional

Callback used to synchronize state across views.

Attributes:
actor

Handle actor for Peak3D.

viz_type

Return the visualization type identifier string.

Methods

apply_scene_op(func, *args, **kwargs)

Run func immediately or defer it via _scene_op_callback.

render()

Request a window redraw through _render_callback when set.

render_widgets()

Handle render widgets for Peak3D.

renderer(is_open, *[, group_visible])

Draw the sidebar header and optional widget body for this layer.

update_state(new_state)

Handle update state for Peak3D.

property actor#

Handle actor for Peak3D.

Returns:
Group

The actor of the peak visualization.

render_widgets()[source]#

Handle render widgets for Peak3D.

update_state(new_state)[source]#

Handle update state for Peak3D.

Parameters:
new_statearray-like

New synchronized state for this visualization.

create_peak_visualization#

dipy.viz.skyline.render.peak.create_peak_visualization(input, idx, *, opacity=100, render_callback=None, sync_callabck=None)[source]#

Create peak visualization from input

Parameters:
inputtuple

Tuple of the (pam, filename) or (pam,)

idxint

Index of the peak for naming purposes if filename is not provided.

opacityint, optional

Opacity of the peak rendering.

render_callbackcallable, optional

Callback function to be called after rendering.

sync_callabckcallable, optional

Callback function to synchronize slice positions across visualizations.

Returns:
Peak3D

The created Peak3D object.

Visualization#

class dipy.viz.skyline.render.renderer.Visualization(path, render_callback)[source]#

Bases: object

Represent Visualization in Skyline.

Parameters:
pathstr or Path

Path to the resource on disk.

render_callbackcallable, optional

Callback used to request a render/update.

Attributes:
actor

Handle actor for Visualization.

viz_type

Return the visualization type identifier string.

Methods

apply_scene_op(func, *args, **kwargs)

Run func immediately or defer it via _scene_op_callback.

render()

Request a window redraw through _render_callback when set.

render_widgets()

Render control widgets for visualization.

renderer(is_open, *[, group_visible])

Draw the sidebar header and optional widget body for this layer.

property actor#

Handle actor for Visualization.

Raises:
NotImplementedError

if the method is not implemented in the subclass.

apply_scene_op(func, *args, **kwargs)[source]#

Run func immediately or defer it via _scene_op_callback.

render()[source]#

Request a window redraw through _render_callback when set.

render_widgets()[source]#

Render control widgets for visualization.

Raises:
NotImplementedError

if the method is not implemented in the subclass.

renderer(is_open, *, group_visible=True)[source]#

Draw the sidebar header and optional widget body for this layer.

Parameters:
is_openbool

Whether the collapsible section should start expanded this frame.

group_visiblebool, optional

Whether the parent group is visible. When False, the actor is hidden regardless of the individual visibility toggle.

Returns:
is_openbool

Updated expanded state after handling input.

is_removedbool

True if the user requested removal.

should_enable_groupbool

True if a hidden group must be re-enabled because visibility was toggled.

property viz_type#

Return the visualization type identifier string.

affine_voxel_sizes#

dipy.viz.skyline.render.renderer.affine_voxel_sizes(affine)[source]#

Return voxel sizes from an affine matrix.

Parameters:
affinendarray

Voxel-to-world affine.

Returns:
ndarray

Per-axis voxel sizes from the affine columns.

slice_slider_bounds#

dipy.viz.skyline.render.renderer.slice_slider_bounds(shape, *, affine=None)[source]#

Return affine-aware integer bounds for slice sliders.

Parameters:
shapetuple(int, int, int)

Original spatial data shape.

affinendarray, optional

Voxel-to-world affine used to position slices in world coordinates.

Returns:
tuple(tuple(int, int), tuple(int, int), tuple(int, int))

Per-axis inclusive slider bounds.

slice_state_from_slider_values#

dipy.viz.skyline.render.renderer.slice_state_from_slider_values(slider_values, *, affine=None)[source]#

Convert slice slider values to slicing state coordinates.

Parameters:
slider_valuesarray-like

Per-axis values displayed by the slice sliders.

affinendarray, optional

Voxel-to-world affine used by the visualization.

Returns:
ndarray

Slicing state in world coordinates when affine is provided, otherwise voxel coordinates.

slice_slider_values_from_state#

dipy.viz.skyline.render.renderer.slice_slider_values_from_state(state, *, affine=None)[source]#

Convert slicing state coordinates to slice slider values.

Parameters:
statearray-like

Current slicing state in world coordinates when affine is provided, otherwise voxel coordinates.

affinendarray, optional

Voxel-to-world affine used by the visualization.

Returns:
ndarray

Per-axis values to display in slice sliders.

voxel_values_from_slice_state#

dipy.viz.skyline.render.renderer.voxel_values_from_slice_state(state, *, affine=None)[source]#

Convert slicing state coordinates to voxel coordinates.

Parameters:
statearray-like

Current slicing state in world coordinates when affine is provided, otherwise voxel coordinates.

affinendarray, optional

Voxel-to-world affine used by the visualization.

Returns:
ndarray

Per-axis voxel coordinates.

create_window#

dipy.viz.skyline.render.renderer.create_window(*, visualizer_type='standalone', size=(1200, 1000), screen_config=None, title='DIPY SKYLINE')[source]#

Create a FURY ShowManager based on the visualizer type.

Used to host the main scene, optional ImGui overlay, and multi-viewport layouts in Skyline.

Parameters:
visualizer_typestr, optional

Type of visualizer to create. The options are: - “standalone”: A standalone window with full interactivity. - “gui”: A Qt-based GUI window. - “jupyter”: An inline Jupyter notebook visualizer. - “stealth”: An offscreen visualizer without GUI.

sizetuple, optional

Size of the window

screen_configlist, optional

Defines the screen layout. Can be a list of integers (vertical/horizontal sections) or a list of explicit bounding box tuples (x, y, w, h).

titlestr, optional

Window title; in stealth mode may be combined with out_dir upstream.

Returns:
ShowManager

An instance of FURY’s ShowManager configured according to the specified visualizer type.

ROI3D#

class dipy.viz.skyline.render.roi.ROI3D(name, roi, *, affine=None, opacity=100, color=(1, 0, 0), render_callback=None)[source]#

Bases: Visualization

Represent ROI3D in Skyline.

Parameters:
namestr

Display name used in the Skyline UI.

roindarray

ROI mask array used to build a contour surface.

affinendarray, optional

Voxel-to-world affine used to position slices in world coordinates.

opacityint, optional

Slice opacity in percent, expected in [0, 100].

colortuple(float, float, float), optional

Value for color.

render_callbackcallable, optional

Callback used to request a render/update.

Attributes:
actor

Handle actor for ROI3D.

viz_type

Return the visualization type identifier string.

Methods

apply_scene_op(func, *args, **kwargs)

Run func immediately or defer it via _scene_op_callback.

render()

Request a window redraw through _render_callback when set.

render_widgets()

Handle render widgets for ROI3D.

renderer(is_open, *[, group_visible])

Draw the sidebar header and optional widget body for this layer.

property actor#

Handle actor for ROI3D.

Returns:
Contour

The actor of the ROI visualization.

render_widgets()[source]#

Handle render widgets for ROI3D.

create_roi_visualization#

dipy.viz.skyline.render.roi.create_roi_visualization(input, idx, *, opacity=100, color=(1, 0, 0), render_callback=None)[source]#

Create ROI visualization from input

Parameters:
inputtuple

Tuple of the (roi, affine, filename) or (roi, affine)

idxint

Index of the ROI for naming purposes if filename is not provided.

opacityint, optional

Opacity of the ROI rendering.

colortuple, optional

Color of the ROI rendering.

render_callbackcallable, optional

Callback function to be called after rendering.

Returns:
ROI3D

The created ROI3D object.

SlicedSphGlyphMaterial#

class dipy.viz.skyline.render.sh_billboard.SlicedSphGlyphMaterial(*, active_slice_x=-1, active_slice_y=-1, active_slice_z=-1, vis_x=1, vis_y=1, vis_z=1, **kwargs)[source]#

Bases: SphGlyphMaterial

Represent SlicedSphGlyphMaterial in Skyline.

Parameters:
active_slice_xfloat, optional

Value for active slice x.

active_slice_yfloat, optional

Value for active slice y.

active_slice_zfloat, optional

Value for active slice z.

vis_xint, optional

Value for vis x.

vis_yint, optional

Value for vis y.

vis_zint, optional

Value for vis z.

**kwargsdict

Value for kwargs.

Attributes:
active_slice_x

Handle active slice x for SlicedSphGlyphMaterial.

active_slice_y

Handle active slice y for SlicedSphGlyphMaterial.

active_slice_z

Handle active slice z for SlicedSphGlyphMaterial.

alpha_compare

The way to compare the alpha value.

alpha_config

Dict that defines how the the resulting colors are combined with the target color texture.

alpha_method

The alpha method being used (readonly).

alpha_mode

Defines how the the resulting colors are combined with the target color texture.

alpha_test

The alpha test value for this material.

ao_map

The red channel of this texture is used as the ambient occlusion map.

ao_map_intensity

Intensity of the ambient occlusion effect.

clipping_mode

Set the behavior for multiple clipping planes: “ANY” or “ALL”.

clipping_plane_count

The number of clipping planes (readonly).

clipping_planes

A tuple of planes (abcd tuples) in world space.

color

The uniform color of the mesh.

color_mode

The way that color is applied to the mesh.

depth_compare

The way to compare the depth with the value in the buffer.

depth_test

Whether the object takes the depth buffer into account.

depth_write

Whether this material writes to the depth buffer, preventing other objects being drawn behind it.

depth_write_is_set

Whether the depth_write property is set.

emissive

The emissive (light) color of the mesh.

emissive_intensity

Intensity of the emissive light.

emissive_map

The emissive map color is modulated by the emissive color and the emissive intensity.

env_combine_mode

How the environment map affects the surface.

env_map

The environment map.

env_mapping_mode

The environment mapping mode.

flat_shading

Whether the mesh is rendered with flat shading.

light_map

The light map to define pre-baked lighting (in srgb).

light_map_intensity

Intensity of the baked light.

map

The texture map specifying the color for each texture coordinate.

maprange

The range of the geometry.texcoords that is projected onto the (color) map.

n_coeffs

Get the maximum number of spherical harmonic coefficients.

normal_map

The texture to create a normal map.

normal_scale

How much the normal map affects the material.

opacity

The opacity (a.k.a.

pick_write

Whether this material is picked by the pointer.

reflectivity

How much the environment map affects the surface.

refraction_ratio

The index of refraction (IOR) of air (approximately 1) divided by the index of refraction of the material.

render_queue

An integer that represents the group that the renderer uses to sort objects.

render_queue_is_set

Whether the render_queue property is set.

scale

Get the scale factor.

shininess

How shiny the specular highlight is; a higher value gives a sharper highlight.

side

Defines which side of faces will be rendered.

specular

The specular (highlight) color of the mesh.

specular_map

The specular map.

uniform_buffer

The uniform buffer object for this material.

vertex_colors
vis_x

Handle vis x for SlicedSphGlyphMaterial.

vis_y

Handle vis y for SlicedSphGlyphMaterial.

vis_z

Handle vis z for SlicedSphGlyphMaterial.

wireframe

Render geometry as a wireframe.

wireframe_thickness

The thickness of the lines when rendering as a wireframe.

property active_slice_x#

Handle active slice x for SlicedSphGlyphMaterial.

Returns:
float

The value of the active slice x.

property active_slice_y#

Handle active slice y for SlicedSphGlyphMaterial.

Returns:
float

The value of the active slice y.

property active_slice_z#

Handle active slice z for SlicedSphGlyphMaterial.

Returns:
float

The value of the active slice z.

property vis_x#

Handle vis x for SlicedSphGlyphMaterial.

Returns:
int

The value of the vis x.

property vis_y#

Handle vis y for SlicedSphGlyphMaterial.

Returns:
int

Returned value.

property vis_z#

Handle vis z for SlicedSphGlyphMaterial.

Returns:
int

The value of the vis z.

Billboard#

class dipy.viz.skyline.render.sh_billboard.Billboard(geometry=None, material=None, *args, **kwargs)[source]#

Bases: Mesh

Base mesh class for instanced glyph billboards (Fury Mesh subclass).

Attributes:
cast_shadow

Whether this object casts shadows, i.e.

children

tuple of children of this object. (read-only)

geometry

The object’s geometry, the data that defines (the shape of) this object.

id

An integer id smaller than 2**31 (read-only).

material

The object’s material, the data that defines the appearance of this object.

morph_target_influences

An ndarray of weights typically from 0-1 that specify how much of the morph is applied.

morph_target_names

A list of names for the morph targets.

nonlinear_transform

An optional nonlinear transform, expressed as WGSL shader code, applied to the raw vertex positions.

opacity

Get the opacity of the actor.

parent

Object’s parent in the scene graph (read-only).

receive_shadow

Whether this object receives shadows.

render_mask
render_order

Per-object rendering priority used to fine-tune the draw order within a render queue.

up

Relic of old WorldObjects that aliases with the new transform.up direction.

visible

Whether is object is rendered or not.

Methods

add(*objects[, before, keep_world_matrix])

Add child objects.

add_event_handler(*args)

Register an event handler.

clear(*[, keep_world_matrix])

Removes all children.

get_bounding_box()

Axis-aligned bounding box in local model space.

get_bounding_sphere()

Bounding Sphere in local model space.

get_world_bounding_box()

Axis aligned bounding box in world space.

get_world_bounding_sphere()

Bounding Sphere in world space.

handle_event(event)

Handle an incoming event.

iter([filter_fn, skip_invisible])

Create a generator that iterates over this objects and its children.

look_at(target)

Orient the object so it looks at the given position.

release_pointer_capture(pointer_id)

Release the pointer capture for the object that was registered to the given pointer_id.

remove(*objects[, keep_world_matrix])

Removes object as child of this object.

remove_event_handler(callback, *types)

Unregister an event handler.

rotate(rotation)

Rotate the actor by the given rotation.

scale(scales)

Scale the actor by the given scale factors.

set_pointer_capture(pointer_id, event_root)

Register this object to capture any other pointer events, until release_pointer_capture is called or an pointer_up event is encountered.

transform(matrix)

Apply a transformation matrix to the actor.

translate(translation)

Translate the actor by the given translation vector.

traverse(callback[, skip_invisible])

Executes the callback on this object and all descendants.

get_geometry_bounding_box

SphGlyphBillboard#

class dipy.viz.skyline.render.sh_billboard.SphGlyphBillboard(geometry=None, material=None, *args, **kwargs)[source]#

Bases: Billboard

Multi-glyph SH billboard with LUT baking and per-glyph coefficient buffers.

Attributes:
cast_shadow

Whether this object casts shadows, i.e.

children

tuple of children of this object. (read-only)

geometry

The object’s geometry, the data that defines (the shape of) this object.

id

An integer id smaller than 2**31 (read-only).

l_max

Handle l max for SphGlyphBillboard.

material

The object’s material, the data that defines the appearance of this object.

morph_target_influences

An ndarray of weights typically from 0-1 that specify how much of the morph is applied.

morph_target_names

A list of names for the morph targets.

nonlinear_transform

An optional nonlinear transform, expressed as WGSL shader code, applied to the raw vertex positions.

opacity

Get the opacity of the actor.

parent

Object’s parent in the scene graph (read-only).

receive_shadow

Whether this object receives shadows.

render_mask
render_order

Per-object rendering priority used to fine-tune the draw order within a render queue.

up

Relic of old WorldObjects that aliases with the new transform.up direction.

visible

Whether is object is rendered or not.

Methods

add(*objects[, before, keep_world_matrix])

Add child objects.

add_event_handler(*args)

Register an event handler.

clear(*[, keep_world_matrix])

Removes all children.

get_bounding_box()

Axis-aligned bounding box in local model space.

get_bounding_sphere()

Bounding Sphere in local model space.

get_world_bounding_box()

Axis aligned bounding box in world space.

get_world_bounding_sphere()

Bounding Sphere in world space.

handle_event(event)

Handle an incoming event.

iter([filter_fn, skip_invisible])

Create a generator that iterates over this objects and its children.

look_at(target)

Orient the object so it looks at the given position.

release_pointer_capture(pointer_id)

Release the pointer capture for the object that was registered to the given pointer_id.

remove(*objects[, keep_world_matrix])

Removes object as child of this object.

remove_event_handler(callback, *types)

Unregister an event handler.

rotate(rotation)

Rotate the actor by the given rotation.

scale(scales)

Scale the actor by the given scale factors.

set_pointer_capture(pointer_id, event_root)

Register this object to capture any other pointer events, until release_pointer_capture is called or an pointer_up event is encountered.

transform(matrix)

Apply a transformation matrix to the actor.

translate(translation)

Translate the actor by the given translation vector.

traverse(callback[, skip_invisible])

Executes the callback on this object and all descendants.

get_geometry_bounding_box

property l_max#

Handle l max for SphGlyphBillboard.

Returns:
int

The value of the l max.

BillboardSphGlyphShader#

class dipy.viz.skyline.render.sh_billboard.BillboardSphGlyphShader(wobject)[source]#

Bases: MeshShader

Represent BillboardSphGlyphShader in Skyline.

Parameters:
wobjectSphGlyphBillboard

Billboard object rendered by this shader.

Attributes:
hash

A hash of the current state of the shader.

Methods

define_binding(bindgroup, index, binding)

Define a uniform, buffer, sampler, or texture.

define_bindings(bindgroup, bindings_dict)

Define a collection of bindings organized in a dict.

define_generic_colormap(map, texcoords)

Define the given texture as the colormap to be used to lookup the final color from the (per-vertex or per-face) texcoords.

define_img_colormap(map)

Define the given texture view as the colormap to be used to lookup the final color from the image data.

generate_wgsl(**more_template_vars)

Generate the final WGSL.

get_bindings(wobject, shared[, scene])

Handle get bindings for BillboardSphGlyphShader.

get_bindings_info(wobject, shared, scene)

Subclasses must return a dict describing the buffers and textures used by this shader.

get_code()

Handle get code for BillboardSphGlyphShader.

get_pipeline_info(wobject, shared)

Subclasses must return a dict describing pipeline details.

get_render_info(wobject, shared)

Handle get render info for BillboardSphGlyphShader.

get_bindings(wobject, shared, scene=None)[source]#

Handle get bindings for BillboardSphGlyphShader.

Parameters:
wobjectSphGlyphBillboard

Billboard object rendered by this shader.

shareddict

Value for shared.

sceneScene, optional

Active rendering scene passed by the renderer.

Returns:
dict

The bindings of the billboard shader.

get_code()[source]#

Handle get code for BillboardSphGlyphShader.

Returns:
str

The code of the billboard shader.

get_render_info(wobject, shared)[source]#

Handle get render info for BillboardSphGlyphShader.

Parameters:
wobjectSphGlyphBillboard

Billboard object rendered by this shader.

shareddict

Value for shared.

Returns:
dict

The render info of the billboard shader.

enable_octahedral_lut#

dipy.viz.skyline.render.sh_billboard.enable_octahedral_lut(actor, *, lut_res=64, use_hermite=False, force_rebake=False, mapping_mode='octahedral', use_float16=False)[source]#

Bake radius or Hermite LUT chunks on actor if GPU memory allows.

Parameters:
actorSphGlyphBillboard

Target billboard with populated billboard_count and coefficients.

lut_resint, optional

Base cube-map or octahedral resolution per face/hemisphere.

use_hermitebool, optional

Allocate paired position/normal Hermite LUT texels.

force_rebakebool, optional

Recompute even when flags indicate the LUT is ready.

mapping_modestr, optional

One of "cube", "dual_hemi", "dual_paraboloid", or "fibonacci".

use_float16bool, optional

Store Hermite LUTs with reduced precision when supported.

sph_glyph_billboard_sliced#

dipy.viz.skyline.render.sh_billboard.sph_glyph_billboard_sliced(coeffs, centers, voxel_coords, *, color_type='orientation', l_max=None, scale=1.0, shininess=50, opacity=None, enable_picking=True, lut_res=8, use_hermite=True, mapping_mode='cube')[source]#

Create a sliced billboard SH glyph actor.

Every valid voxel lives in one single actor. Three uniforms (active_slice_x/y/z) select which slices are visible; switching is a uniform update with zero geometry rebuild.

A cube-mapped LUT is baked once at creation time so the fragment shader uses fast table lookups instead of per-pixel SH evaluation. Chunking is handled automatically by FURY based on GPU buffer limits.

Parameters:
coeffsndarray (M, n_coeffs)

Flat SH coefficients for every glyph.

centersndarray (M, 3)

World-space centres.

voxel_coordsndarray (M, 3) int32

Per-glyph integer voxel (ix, iy, iz).

color_type{“orientation”, “sign”}, optional

Encoding forwarded to the material (sign vs orientation hue).

l_maxint or None, optional

Explicit truncation order; inferred from coeffs when None.

scalefloat, optional

Uniform billboard size multiplier relative to estimated SH radii.

shininessfloat, optional

Phong exponent for glyph lighting.

opacityfloat or None, optional

Initial scalar opacity; forwarded to Fury validation when not None.

enable_pickingbool, optional

Whether picking handlers are installed on the billboard mesh.

lut_resint, optional

Cube-map LUT resolution per face edge.

use_hermitebool, optional

Use Hermite interpolation LUT.

mapping_modestr, optional

LUT mapping mode.

Returns:
SphGlyphBillboard

Configured billboard with slice index buffer and baked LUTs.

SHSlicer#

class dipy.viz.skyline.render.sh_slicer.SHSlicer(coeffs_4d, *, voxel_sizes=(1.0, 1.0, 1.0), scale=1.0, l_max=8, lut_res=32, use_hermite=True, mapping_mode='cube', mask=None, basis_type='standard', color_type='orientation')[source]#

Bases: object

Represent SHSlicer in Skyline.

Parameters:
coeffs_4dndarray

Value for coeffs 4d.

voxel_sizestuple(float, float, float), optional

Value for voxel sizes.

scalefloat, optional

Value for scale.

l_maxint, optional

Value for l max.

lut_resint, optional

Value for lut res.

use_hermitebool, optional

Value for use hermite.

mapping_modestr, optional

Value for mapping mode.

maskndarray, optional

Value for mask.

basis_typestr, optional

Value for basis type.

color_typestr, optional

Value for color type.

Methods

build()

Handle build for SHSlicer.

hide_axis(axis)

Hide all slices for axis.

set_opacity(opacity)

Set opacity.

set_scale(new_scale)

Update scale on the actor.

set_slice(axis, idx)

Show slice idx on axis via uniform update.

show_axis(axis)

Enable axis visibility.

build()[source]#

Handle build for SHSlicer.

hide_axis(axis)[source]#

Hide all slices for axis.

set_opacity(opacity)[source]#

Set opacity.

set_scale(new_scale)[source]#

Update scale on the actor.

set_slice(axis, idx)[source]#

Show slice idx on axis via uniform update.

show_axis(axis)[source]#

Enable axis visibility.

SHGlyph3D#

class dipy.viz.skyline.render.sh_slicer.SHGlyph3D(name, coeffs, *, affine=None, render_callback=None, scale=2.0, l_max=8, lut_res=8, use_hermite=True, mapping_mode='cube', basis_type='standard', color_type='orientation', mask=None, sync_callback=None)[source]#

Bases: Visualization

Represent SHGlyph3D in Skyline.

Parameters:
namestr

Display name used in the Skyline UI.

coeffsndarray

Value for coeffs.

affinendarray, optional

Voxel-to-world affine used to position slices in world coordinates.

render_callbackcallable, optional

Callback used to request a render/update.

scalefloat, optional

Value for scale.

l_maxint, optional

Value for l max.

lut_resint, optional

Value for lut res.

use_hermitebool, optional

Value for use hermite.

mapping_modestr, optional

Value for mapping mode.

basis_typestr, optional

Value for basis type.

color_typestr, optional

Value for color type.

maskndarray, optional

Value for mask.

sync_callbackcallable, optional

Callback used to synchronize state across views.

Attributes:
actor

Handle actor for SHGlyph3D.

viz_type

Return the visualization type identifier string.

Methods

apply_scene_op(func, *args, **kwargs)

Run func immediately or defer it via _scene_op_callback.

render()

Request a window redraw through _render_callback when set.

render_widgets()

Handle render widgets for SHGlyph3D.

renderer(is_open, *[, group_visible])

Draw the sidebar header and optional widget body for this layer.

set_slice_visibility()

Handle set slice visibility for SHGlyph3D.

set_slices()

Handle set slices for SHGlyph3D.

update_state(new_state)

Handle update state for SHGlyph3D.

property actor#

Handle actor for SHGlyph3D.

Returns:
Group

The actor of the SHGlyph3D visualization.

render_widgets()[source]#

Handle render widgets for SHGlyph3D.

set_slice_visibility()[source]#

Handle set slice visibility for SHGlyph3D.

set_slices()[source]#

Handle set slices for SHGlyph3D.

update_state(new_state)[source]#

Handle update state for SHGlyph3D.

Parameters:
new_statearray-like

New synchronized state for this visualization.

create_shm_visualization#

dipy.viz.skyline.render.sh_slicer.create_shm_visualization(input, idx, *, render_callback=None, scale=1.3, l_max=8, lut_res=8, use_hermite=True, mapping_mode='cube', basis_type='descoteaux07', color_type='orientation', mask=None, sync_callback=None)[source]#

Create SH glyph visualization from input.

Parameters:
inputtuple

Tuple of one of the following forms: - (coeffs, affine, filename, basis_type) - (coeffs, affine, filename) - (coeffs, affine)

idxint

Index used for naming when filename is not provided.

render_callbackcallable, optional

Callback function to be called after rendering.

scalefloat, optional

Initial per-glyph scale.

l_maxint, optional

Maximum SH order.

lut_resint, optional

LUT resolution.

use_hermitebool, optional

Whether to use Hermite analytic normals.

mapping_modestr, optional

Billboard mapping mode.

basis_typestr, optional

SH basis convention. Ignored if provided in input as 4th element.

color_typestr, optional

Colour mapping type.

maskndarray, optional

Boolean mask of valid voxels.

sync_callbackcallable, optional

Callback to trigger when synchronization is available.

Returns:
SHGlyph3D

The created SH glyph visualization object.

Raises:
ValueError

If input is not a tuple of length 2, 3, or 4.

Streamline3D#

class dipy.viz.skyline.render.streamline.Streamline3D(name, sft, *, line_type='Line', color=(1, 0, 0), render_callback=None, switch_render_callback=None, buan_pvals_file=None, loader=None)[source]#

Bases: Visualization

Represent Streamline3D in Skyline.

Parameters:
namestr

Display name used in the Skyline UI.

sftStatefulTractogram

Value for sft.

line_typestr, optional

Value for line type.

colortuple(float, float, float), optional

Value for color.

render_callbackcallable, optional

Callback used to request a render/update.

switch_render_callbackcallable, optional

Value for switch render callback.

buan_pvals_filestr, optional

Value for buan pvals file.

loadercallable, optional

Value for loader.

Attributes:
actor

Handle actor for Streamline3D.

viz_type

Return the visualization type identifier string.

Methods

apply_scene_op(func, *args, **kwargs)

Run func immediately or defer it via _scene_op_callback.

handle_color_change(fname)

Handle handle color change for Streamline3D.

render()

Request a window redraw through _render_callback when set.

render_widgets()

Handle render widgets for Streamline3D.

renderer(is_open, *[, group_visible])

Draw the sidebar header and optional widget body for this layer.

property actor#

Handle actor for Streamline3D.

Returns:
Line

Returned value.

handle_color_change(fname)[source]#

Handle handle color change for Streamline3D.

Parameters:
fnamestr

Value for fname.

render_widgets()[source]#

Handle render widgets for Streamline3D.

ClusterStreamline3D#

class dipy.viz.skyline.render.streamline.ClusterStreamline3D(name, sft, thr, *, line_type='Line', render_callback=None, switch_render_callback=None, loader=None, size_threshold=None, length_threshold=None, async_clustering=True)[source]#

Bases: Visualization

Represent ClusterStreamline3D in Skyline.

Parameters:
namestr

Display name used in the Skyline UI.

sftStatefulTractogram

Value for sft.

thrfloat, optional

Value for thr.

line_typestr, optional

Value for line type.

render_callbackcallable, optional

Callback used to request a render/update.

switch_render_callbackcallable, optional

Value for switch render callback.

loadercallable, optional

Value for loader.

size_thresholdint, optional

Value for size threshold.

length_thresholdfloat, optional

Value for length threshold.

async_clusteringbool, optional

Value for async clustering.

Attributes:
actor

Handle actor for ClusterStreamline3D.

viz_type

Return the visualization type identifier string.

Methods

apply_scene_op(func, *args, **kwargs)

Run func immediately or defer it via _scene_op_callback.

compute_visible_tractogram()

Handle compute visible tractogram for ClusterStreamline3D.

handle_key_events(event)

Handle handle key events for ClusterStreamline3D.

render()

Request a window redraw through _render_callback when set.

render_widgets()

Handle render widgets for ClusterStreamline3D.

renderer(is_open, *[, group_visible])

Draw the sidebar header and optional widget body for this layer.

save_tractogram(filenames, *[, rois, shm_coeffs])

Handle save tractogram for ClusterStreamline3D.

property actor#

Handle actor for ClusterStreamline3D.

Returns:
Group or Line

The actor of the ClusterStreamline3D visualization.

compute_visible_tractogram()[source]#

Handle compute visible tractogram for ClusterStreamline3D.

Returns:
StatefulTractogram

The visible tractogram of the ClusterStreamline3D visualization.

handle_key_events(event)[source]#

Handle handle key events for ClusterStreamline3D.

Parameters:
eventEvent

Interaction event from the renderer callback.

render_widgets()[source]#

Handle render widgets for ClusterStreamline3D.

save_tractogram(filenames, *, rois=None, shm_coeffs=None)[source]#

Handle save tractogram for ClusterStreamline3D.

Parameters:
filenameslist, optional

Value for filenames.

roislist, optional

Value for rois.

shm_coeffslist, optional

Value for shm coeffs.

create_colormap#

dipy.viz.skyline.render.streamline.create_colormap(n, *, hue=(0.0, 0.1), saturation=(0.8, 0.2), value=0.8)[source]#

Build an RGB lookup table sampled along HSV space.

Parameters:
nint

Number of discrete colors.

huetuple of float, optional

Hue endpoints passed through np.interp over the LUT indices.

saturationtuple of float, optional

Saturation endpoints interpolated like hue.

valuefloat, optional

Fixed HSV value (brightness) for every entry.

Returns:
ndarray, shape (n, 3)

Float32 RGB colors in [0, 1].

apply_buan_colors#

dipy.viz.skyline.render.streamline.apply_buan_colors(streamlines, buan_pvals, *, hue=(0.0, 0.1), saturation=(0.8, 0.2), value=0.8, buan_color_idx=None)[source]#

Assign BUAN p-value-derived RGB colors per streamline or sample.

Parameters:
streamlineslist of ndarray

Streamline arrays used for assignment mapping when buan_color_idx is omitted.

buan_pvalsndarray

Scalar p-values (or statistics) sampled per correspondence bin.

huetuple of float, optional

Passed to create_colormap().

saturationtuple of float, optional

Passed to create_colormap().

valuefloat, optional

Passed to create_colormap().

buan_color_idxndarray or None, optional

Precomputed indices into the LUT; if None, computed via assignment_map.

Returns:
buan_colorsndarray, shape (N, 3)

Per-streamline RGB colors.

buan_color_idxndarray

Integer LUT indices used for coloring.

create_cluster_help#

dipy.viz.skyline.render.streamline.create_cluster_help(*, position=(0, 0), size=(200, 180))[source]#

Create a 2D text panel summarizing cluster interaction shortcuts.

Parameters:
positiontuple of float, optional

Screen-space anchor for the block.

sizetuple of float, optional

Pixel width and height of the background rectangle.

Returns:
TextBlock2D

Fury overlay actor ready to be inserted into the scene.

create_streamline_visualization#

dipy.viz.skyline.render.streamline.create_streamline_visualization(input, idx, *, is_cluster=False, thr=15.0, line_type='Line', color=(1, 0, 0), render_callback=None, colormap=None, tract_colors=None, switch_render_callback=None, loader=None, size_threshold=None, length_threshold=None, buan_pvals_file=None, async_clustering=True)[source]#

Create streamline visualization from input

Parameters:
inputtuple

Tuple of the (sft, filename) or (sft,)

idxint

Index of the tractogram for naming purposes.

is_clusterbool, optional

Whether to cluster the streamline.

thrfloat, optional

Clustering distance threshold.

line_typestr, optional

The type of line to render (“Line” or “Tube”).

colortuple, optional

Color of the streamline rendering.

render_callbackcallable, optional

Callback function to be called after rendering.

colormapcolormap, optional

Colormap for clustering.

tract_colorsvariable float or str, optional

Define the colors of the tractograms. Colors can be defined with 3 values and should be between [0-1]. String options are ‘random’ for random colors for each tractogram, ‘direction’ for directionally colored streamlines. For example, a value of (1, 0, 0) would mean the red color.

switch_render_callbackcallable, optional

Callback function to switch rendering type, used for cluster visualization.

loadercallable, optional

Callback function to show/hide loader during asynchronous operations.

size_thresholdint, optional

Minimum number of streamlines in a cluster to be visible.

length_thresholdfloat, optional

Minimum length of streamlines in a cluster to be visible.

buan_pvals_filestr, optional

File path to BUAN p-values for coloring streamlines.

async_clusteringbool, optional

Whether to perform clustering asynchronously. Set to False to block until clustering completes (used in stealth mode).

Returns:
Visualization

The created streamline visualization object.

create_streamline#

dipy.viz.skyline.render.streamline.create_streamline(lines, *, color=(1, 0, 0), line_type='Line', segments=4)[source]#

Instantiate Fury line or tube geometry for polyline streamlines.

Parameters:
lineslist of ndarray

Each array is a (N, 3) polyline in world space.

colorndarray, tuple, or str, optional

Per-point, per-line, directional ("direction"), or constant RGB colors.

line_type{“Line”, “Tube”}, optional

Primitive style passed to Fury.

segmentsint, optional

Tube tessellation segments when line_type is "Tube".

Returns:
Actor

Fury actor (line or tube container) ready to parent under a Group.

Surface#

class dipy.viz.skyline.render.surface.Surface(name, vertices, faces, *, affine=None, color=(1, 0, 0), opacity=100, texture=None, material='phong', render_callback=None)[source]#

Bases: Visualization

Represent Surface in Skyline.

Parameters:
namestr

Display name used in the Skyline UI.

verticesndarray

Value for vertices.

facesndarray

Value for faces.

affinendarray, optional

Voxel-to-world affine used to position slices in world coordinates.

colortuple(float, float, float), optional

Value for color.

opacityint, optional

Slice opacity in percent, expected in [0, 100].

texturendarray, optional

Value for texture.

materialstr, optional

Value for material.

render_callbackcallable, optional

Callback used to request a render/update.

Attributes:
actor

Handle actor for Surface.

viz_type

Return the visualization type identifier string.

Methods

apply_scene_op(func, *args, **kwargs)

Run func immediately or defer it via _scene_op_callback.

render()

Request a window redraw through _render_callback when set.

render_widgets()

Handle render widgets for Surface.

renderer(is_open, *[, group_visible])

Draw the sidebar header and optional widget body for this layer.

property actor#

Handle actor for Surface.

Returns:
object

Returned value.

render_widgets()[source]#

Handle render widgets for Surface.

create_surface_visualization#

dipy.viz.skyline.render.surface.create_surface_visualization(input, idx, *, color=(1, 0, 0), opacity=100, texture=None, material='phong', render_callback=None)[source]#

Create surface visualization from input

Parameters:
inputtuple

Tuple of the (vertices, faces, filename) or (vertices, faces)

idxint

Index of the surface for naming purposes if filename is not provided.

colortuple, optional

Color of the surface rendering.

opacityint, optional

Opacity of the surface rendering.

texturendarray, optional

Texture to use for surface.

materialstr, optional

Material type for surface.

render_callbackcallable, optional

Callback function to be called after rendering.

Returns:
Surface

The created Surface object.

load_dipy_wgsl#

dipy.viz.skyline.wgsl.load_dipy_wgsl(name: str) str[source]#

Load a UTF-8 WGSL/Jinja template shipped inside dipy.viz.skyline.wgsl.

Parameters:
namestr

Relative filename inside the package resource tree.

Returns:
str

Shader source text.

show_bundles#

dipy.viz.streamline.show_bundles(bundles, *, interactive=True, view='sagittal', colors=None, linewidth=0.3, save_as=None)[source]#

Render bundles to visualize them interactively or save them into a png.

The function allows to just render the bundles in an interactive plot or to export them into a png file.

Parameters:
bundleslist

Bundles to be rendered.

interactiveboolean, optional

If True a 3D interactive rendering is created. Default is True.

viewstr, optional

Viewing angle. Supported options: ‘sagittal’, ‘axial’ and ‘coronal’.

colorslist, optional

Colors to be used for each bundle. If None default colors are used.

linewidthfloat, optional

Width of each rendered streamline. Default is 0.3.

save_asstr or Path, optional

If not None rendered scene is stored in a png file with that name. Default is None.

viz_two_bundles#

dipy.viz.streamline.viz_two_bundles(b1, b2, fname, *, c1=(1, 0, 0), c2=(0, 1, 0), interactive=False)[source]#

Render and plot two bundles to visualize them.

Parameters:
b1Streamlines

Bundle one to be rendered.

b2Streamlines

Bundle two to be rendered.

fname: str or Path

Rendered scene is stored in a png file with that name.

C1tuple, optional

Color to be used for first bundle. Default red.

C2tuple, optional

Color to be used for second bundle. Default green.

interactiveboolean, optional

If True a 3D interactive rendering is created. Default is True.

viz_vector_field#

dipy.viz.streamline.viz_vector_field(points_aligned, directions, colors, offsets, fname, *, bundle=None, interactive=False)[source]#

Render and plot vector field.

Parameters:
points_alignedList

List containing starting positions of vectors.

directionsList

List containing unitary directions of vectors.

colorsList

List containing colors for each vector.

offsetsList

List containing vector field modules.

fname: str

Rendered scene is stored in a png file with that name.

bundleStreamlines, optional

Bundle to be rendered with vector field (Default None).

interactiveboolean, optional

If True a 3D interactive rendering is created. Default is True.

viz_displacement_mag#

dipy.viz.streamline.viz_displacement_mag(bundle, offsets, fname, *, interactive=False)[source]#

Render and plot displacement magnitude over the bundle.

Parameters:
bundleStreamlines,

Bundle to be rendered.

offsetsList

List containing displacement magnitdues per point on the bundle.

fname: str

Rendered scene is stored in a png file with that name.

interactiveboolean, optional

If True a 3D interactive rendering is created. Default is True.