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.horizon.tab#

Horizon tab UI components (deprecated).

Module: viz.horizon.tab.base#

HorizonUIElement(visibility, selected_value, obj)

Dataclass to define properties of horizon ui elements.

HorizonTab()

Base for different tabs available in horizon.

TabManager(tabs, win_size, on_tab_changed, ...)

A Manager for tabs of the table panel.

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

Simple utility function to build labels.

build_slider(initial_value, max_value, *[, ...])

Create a horizon theme based disk-knob slider.

build_checkbox(*[, labels, checked_labels, ...])

Create horizon theme checkboxes.

build_radio_button(*[, labels, ...])

Create horizon theme radio buttons.

build_switcher(*[, items, label, ...])

Create horizon theme switcher.

Module: viz.horizon.tab.cluster#

ClustersTab(clusters_visualizer, threshold)

Module: viz.horizon.tab.peak#

PeaksTab(peak_actor, title, fname)

Module: viz.horizon.tab.roi#

ROIsTab(contour_actors)

Module: viz.horizon.tab.slice#

SlicesTab(slices_visualizer, tab_name, ...)

Interaction tab for slice visualization.

Module: viz.horizon.tab.surface#

SurfaceTab(visualizer, tab_name, file_name)

Module: viz.horizon.util#

check_img_shapes(images)

Check if the images have same shapes.

check_img_dtype(images)

Check supplied image dtype.

show_ellipsis(text, text_size, available_size)

Apply ellipsis to the text.

unpack_surface(surface)

Unpack surface data.

unpack_data(data, *[, return_size])

horizon.util.unpack_data is deprecated and will be removed in a future version.

check_peak_size(pams, *[, ref_img_shape, ...])

Check shape of peaks.

Module: viz.horizon.visualizer#

Horizon visualizer components (deprecated).

Module: viz.horizon.visualizer.cluster#

ClustersVisualizer(show_manager, scene, ...)

Module: viz.horizon.visualizer.peak#

PeakActor(directions, indices, *[, values, ...])

FURY actor for visualizing DWI peaks.

PeaksVisualizer(pam, world_coords, fname)

peak(peaks_dirs, *[, peaks_values, mask, ...])

Visualize peak directions as given from peaks_from_model function.

Module: viz.horizon.visualizer.slice#

SlicesVisualizer(interactor, scene, data, *)

Module: viz.horizon.visualizer.surface#

SurfaceVisualizer(surface, scene, color)

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 and tractography.

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

Registry of named UIWindow instances for the Skyline scene.

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

Sidebar window that groups visualization sections and file dialogs.

Module: viz.skyline.UI.theme#

Theme utilities for Skyline UI components.

hex_to_rgba(hex_color, *[, alpha])

Convert a hex color code to an RGBA tuple.

Module: viz.skyline.app#

Skyline viewer application entry points.

Expose the Skyline class and the skyline/skyline_from_files functions used to construct and launch the FURY-based multi-modal viewer.

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

The Skyline viewer, hosting the FURY scene, UI, and visualizations.

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

Launch the Skyline GUI from file paths.

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

Launch the Skyline GUI.

Module: viz.skyline.compute#

Run callables in background threads with main-thread callback delivery.

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

Execute func asynchronously in a background daemon 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, peaks, ...])

Load images, peaks, surfaces, and tractograms from fnames.

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

A NIfTI-backed volume slicer with linked opacity and colormap controls.

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

Create an Image3D visualization from already-loaded image data.

Module: viz.skyline.render.peak#

Peak direction (PAM) slicers for Skyline.

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

Represent a peak-direction (PAM) vector-field slicer in Skyline.

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

Create a peak visualization from loaded PAM data.

Module: viz.skyline.render.renderer#

Shared FURY window factory and base class for Skyline visualizations.

Visualization(path, render_callback)

Base class for a single visualization layer in the Skyline sidebar.

affine_voxel_sizes(affine)

Return voxel sizes from an affine matrix.

format_affine_info(affine)

Build the shared "voxel sizes + order + affine" block for info panels.

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

A binary ROI mask rendered as a translucent contour surface.

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

Create an ROI3D visualization from already-loaded ROI data.

Module: viz.skyline.render.sh_billboard#

GPU billboard pipeline for spherical-harmonic ODF glyphs.

Each ODF glyph is a camera-facing quad; the fragment shader ray-marches it to find where the view ray meets the SH surface r(omega) = sum(c_lm * Y_lm(omega)). Because evaluating that sum per pixel is expensive, bake_hermite_lut() pre-bakes it into a cube-map Hermite LUT that the shader samples instead, falling back to direct evaluation when no LUT is baked. See individual function/class docstrings for details (LUT layout and chunking, shader bindings, etc.).

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

SH glyph material with world-space slice positions and visibility flags.

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)

Pygfx shader: template variables and bindings for the ODF billboard pipeline.

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

Bake a cube-mapped Hermite LUT 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 – the entry point for ODF visualization.

Builds a GPU-accelerated 3-D visualization of orientation distribution functions (ODFs) from a 4-D array of spherical-harmonic coefficients and a voxel-to-world affine. create_shm_visualization unpacks the input tuple into a SHGlyph3D, which owns a SHSlicer that builds the billboard actor via sph_glyph_billboard_sliced() and drives its per-axis slice uniforms. See individual class/method docstrings for coordinate-space and slicing details.

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

Build and drive the single billboard actor backing an ODF visualization.

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

High-level ODF visualization: UI widgets, sync, and slice state.

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

Non-clustered tractography layer rendered as a single line or tube actor.

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

Clustered tractography layer that groups streamlines with QuickBundlesX.

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 a Streamline3D or ClusterStreamline3D from a loaded tractogram.

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

A triangular mesh surface rendered with a Phong or basic material.

create_surface_visualization(input, idx, *)

Create a Surface visualization from already-loaded mesh data.

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.app.Horizon.build_show is deprecated and will be removed in a future version.

build_show()[source]#

horizon.app.Horizon.build_show is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

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

HorizonUIElement#

class dipy.viz.horizon.tab.base.HorizonUIElement(visibility: bool, selected_value: Any, obj: Any)[source]#

Bases: object

Dataclass to define properties of horizon ui elements.

HorizonTab#

class dipy.viz.horizon.tab.base.HorizonTab[source]#

Bases: ABC

Base for different tabs available in horizon.

Attributes:
actors

List of actors associated with the tab.

elements

list of underlying FURY ui elements in the tab.

name

Name of the tab.

tab_id

Id of the tab.

Methods

build(tab_id)

Build all the elements under the tab.

hide()

Hide elements from the scene.

on_slice_change(_x_value, _y_value, _z_value)

Assign in TabManager if require to update something while the slice

on_tab_selected()

Implement if require to update something while the tab becomes

show()

Show elements in the scene.

abstract property actors#

List of actors associated with the tab.

horizon.tab.HorizonTab.actors is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

abstractmethod build(tab_id)[source]#

Build all the elements under the tab.

horizon.tab.HorizonTab.build is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Parameters:
tab_idint

Id of the tab.

property elements#

list of underlying FURY ui elements in the tab.

horizon.tab.HorizonTab.elements is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

hide()[source]#

Hide elements from the scene.

horizon.tab.HorizonTab.hide is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Parameters:
*argsHorizonUIElement or FURY actors

Elements to be hidden.

abstract property name#

Name of the tab.

horizon.tab.HorizonTab.name is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

on_slice_change(_x_value, _y_value, _z_value)[source]#
Assign in TabManager if require to update something while the slice

changes.

horizon.tab.HorizonTab.on_slice_change is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

on_tab_selected()[source]#
Implement if require to update something while the tab becomes

active.

horizon.tab.HorizonTab.on_tab_selected is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

show()[source]#

Show elements in the scene.

horizon.tab.HorizonTab.show is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Parameters:
*argsHorizonUIElement or FURY actors

Elements to be hidden.

property tab_id#

Id of the tab. Reference for Tab Manager to identify the tab.

horizon.tab.HorizonTab.tab_id is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Returns:
int

TabManager#

class dipy.viz.horizon.tab.base.TabManager(tabs, win_size, on_tab_changed, add_to_scene, *, remove_from_scene, sync_slices=False, sync_volumes=False, sync_peaks=False)[source]#

Bases: object

A Manager for tabs of the table panel.

Attributes:
tab_uiTabUI

FURY TabUI object.

Methods

handle_text_overflows()

horizon.tab.TabManager.handle_text_overflows is deprecated and will be removed in a future version.

reposition(win_size)

horizon.tab.TabManager.reposition is deprecated and will be removed in a future version.

synchronize_slices(active_tab_id, x_value, ...)

horizon.tab.TabManager.synchronize_slices is deprecated and will be removed in a future version.

synchronize_volumes(active_tab_id, value)

Synchronize volumes for all the images with volumes.

handle_text_overflows()[source]#

horizon.tab.TabManager.handle_text_overflows is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

reposition(win_size)[source]#

horizon.tab.TabManager.reposition is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Reposition the tabs panel.

Parameters:
win_size(float, float)

size of the horizon window.

synchronize_slices(active_tab_id, x_value, y_value, z_value)[source]#

horizon.tab.TabManager.synchronize_slices is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Synchronize slicers for all the images and peaks.

Parameters:
active_tab_id: int

tab_id of the action performing tab

x_value: float

x-value of the active slicer

y_value: float

y-value of the active slicer

z_value: float

z-value of the active slicer

synchronize_volumes(active_tab_id, value)[source]#

Synchronize volumes for all the images with volumes.

horizon.tab.TabManager.synchronize_volumes is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Parameters:
active_tab_idint

tab_id of the action performing tab

valuefloat

volume value of the active volume slider

property tab_ui#

FURY TabUI object.

horizon.tab.TabManager.tab_ui is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

build_label#

dipy.viz.horizon.tab.base.build_label(text, *, font_size=16, bold=False)[source]#

Simple utility function to build labels.

horizon.tab.build_label is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Parameters:
textstr
font_sizeint, optional
boldbool, optional
Returns:
labelTextBlock2D

build_slider#

dipy.viz.horizon.tab.base.build_slider(initial_value, max_value, *, min_value=0, length=450, line_width=3, radius=8, font_size=16, text_template='{value:.1f} ({ratio:.0%})', on_moving_slider=<function <lambda>>, on_value_changed=<function <lambda>>, on_change=<function <lambda>>, on_handle_released=<function <lambda>>, label='', label_font_size=16, label_style_bold=False, is_double_slider=False)[source]#

Create a horizon theme based disk-knob slider.

horizon.tab.build_slider is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Parameters:
initial_valuefloat, (float, float)

Initial value(s) of the slider.

max_valuefloat

Maximum value of the slider.

min_valuefloat, optional

Minimum value of the slider.

lengthint, optional

Length of the slider.

line_widthint, optional

Width of the line on which the disk will slide.

radiusint, optional

Radius of the disk handle.

font_sizeint, optional

Size of the text to display alongside the slider (pt).

text_templatestr, callable, optional

If str, text template can contain one or multiple of the replacement fields: {value:}, {ratio:}. If callable, this instance of :class:LineSlider2D will be passed as argument to the text template function.

on_moving_slidercallable, optional

When the slider is interacted by the user.

on_value_changedcallable, optional

When value of the slider changed programmatically.

on_changecallable, optional

When value of the slider changed.

on_handle_released: callable, optional

When handle released.

labelstr, optional

Label to ui element for slider

label_font_sizeint, optional

Size of label text to display with slider

label_style_boldbool, optional

Is label should have bold style.

is_double_sliderbool, optional

True if the slider allows to adjust two values.

Returns:
labelHorizonUIElement

Slider label.

HorizonUIElement

Slider.

build_checkbox#

dipy.viz.horizon.tab.base.build_checkbox(*, labels=None, checked_labels=None, padding=1, font_size=16, on_change=<function <lambda>>)[source]#

Create horizon theme checkboxes.

horizon.tab.build_checkbox is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Parameters:
labelslist(str), optional

List of labels of each option.

checked_labels: list(str), optional

List of labels that are checked on setting up.

paddingfloat, optional

The distance between two adjacent options element

font_sizeint, optional

Size of the text font.

on_changecallback, optional

When checkbox value changed

Returns:
checkboxHorizonUIElement

build_radio_button#

dipy.viz.horizon.tab.base.build_radio_button(*, labels=None, checked_labels=None, padding=1, font_size=16, on_change=<function <lambda>>)[source]#

Create horizon theme radio buttons.

horizon.tab.build_radio_button is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Parameters:
labelslist(str), optional

List of labels of each option.

checked_labels: list(str), optional

List of labels that are checked on setting up.

paddingfloat, optional

The distance between two adjacent options element

font_sizeint, optional

Size of the text font.

on_changecallback, optional

When radio button value changed

Returns:
radioHorizonUIElement

build_switcher#

dipy.viz.horizon.tab.base.build_switcher(*, items=None, label='', initial_selection=0, on_prev_clicked=<function <lambda>>, on_next_clicked=<function <lambda>>, on_value_changed=<function <lambda>>)[source]#

Create horizon theme switcher.

horizon.tab.build_switcher is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Parameters:
itemslist, optional

dictionaries with keys ‘label’ and ‘value’. Label will be used to show it to user and value will be used for selection.

labelstr, optional

label for the switcher.

initial_selectionint, optional

index of the selected item initially.

on_prev_clickedcallback, optional

method providing a callback when prev value is selected in switcher.

on_next_clickedcallback, optional

method providing a callback when next value is selected in switcher.

on_value_changedcallback, optional

method providing a callback when either prev or next value selected in switcher.

Returns:
HorizonCombineElement(

label: HorizonUIElement, element(switcher): HorizonUIElement)

Notes

switcher: consists ‘obj’ which is an array providing FURY UI elements used.

ClustersTab#

class dipy.viz.horizon.tab.cluster.ClustersTab(clusters_visualizer, threshold)[source]#

Bases: HorizonTab

Attributes:
actors

All the actors in the visualizer.

centroid_actors

Centroid actors of the tractograms.

cluster_actors

Cluster actors of the tractograms.

elements

list of underlying FURY ui elements in the tab.

name

Title of the tab.

tab_id

Id of the tab.

Methods

build(tab_id)

Position the elements in the tab.

hide()

Hide elements from the scene.

on_slice_change(_x_value, _y_value, _z_value)

Assign in TabManager if require to update something while the slice

on_tab_selected()

Implement if require to update something while the tab becomes

show()

Show elements in the scene.

property actors#

All the actors in the visualizer.

horizon.tab.ClustersTab.actors is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Returns:
list
build(tab_id)[source]#

Position the elements in the tab.

horizon.tab.ClustersTab.build is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Parameters:
tab_idint

Id of the tab.

property centroid_actors#

Centroid actors of the tractograms.

horizon.tab.ClustersTab.centroid_actors is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Returns:
dict

various properties of centroids.

property cluster_actors#

Cluster actors of the tractograms.

horizon.tab.ClustersTab.cluster_actors is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Returns:
dict

various properties of clusters.

property name#

Title of the tab.

horizon.tab.ClustersTab.name is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Returns:
str

PeaksTab#

class dipy.viz.horizon.tab.peak.PeaksTab(peak_actor, title, fname)[source]#

Bases: HorizonTab

Attributes:
actors

actors controlled by tab.

elements

list of underlying FURY ui elements in the tab.

name

Name of the tab.

tab_id

Id of the tab.

Methods

build(tab_id)

Build all the elements under the tab.

hide()

Hide elements from the scene.

on_slice_change(_x_value, _y_value, _z_value)

Assign in TabManager if require to update something while the slice

on_tab_selected()

Trigger when tab becomes active.

show()

Show elements in the scene.

update_slices(x_slice, y_slice, z_slice)

Updates slicer positions.

property actors#

actors controlled by tab.

horizon.tab.PeaksTab.actors is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Returns:
list

List of actors.

build(tab_id)[source]#

Build all the elements under the tab.

horizon.tab.PeaksTab.build is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Parameters:
tab_idint

Id of the tab.

property name#

Name of the tab.

horizon.tab.PeaksTab.name is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Returns:
str
on_tab_selected()[source]#

Trigger when tab becomes active.

horizon.tab.PeaksTab.on_tab_selected is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

update_slices(x_slice, y_slice, z_slice)[source]#

Updates slicer positions.

horizon.tab.PeaksTab.update_slices is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Parameters:
x_slice: float

x-value where the slicer should be placed

y_slice: float

y-value where the slicer should be placed

z_slice: float

z-value where the slicer should be placed

ROIsTab#

class dipy.viz.horizon.tab.roi.ROIsTab(contour_actors)[source]#

Bases: HorizonTab

Attributes:
actors

Actors controlled by tab.

elements

list of underlying FURY ui elements in the tab.

name

Title of the tab.

tab_id

Id of the tab.

Methods

build(tab_id)

Position the elements in the tab.

hide()

Hide elements from the scene.

on_slice_change(_x_value, _y_value, _z_value)

Assign in TabManager if require to update something while the slice

on_tab_selected()

Implement if require to update something while the tab becomes

show()

Show elements in the scene.

property actors#

Actors controlled by tab.

horizon.tab.ROIsTab.actors is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Returns:
list
build(tab_id)[source]#

Position the elements in the tab.

horizon.tab.ROIsTab.build is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Parameters:
tab_idint

Identifier for the tab. Index of the tab in TabUI.

property name#

Title of the tab.

horizon.tab.ROIsTab.name is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Returns:
str

SlicesTab#

class dipy.viz.horizon.tab.slice.SlicesTab(slices_visualizer, tab_name, file_name, *, force_render=<function SlicesTab.<lambda>>)[source]#

Bases: HorizonTab

Interaction tab for slice visualization.

Attributes:
namestr

Name of the tab.

Methods

build(tab_id)

Build all the elements under the tab.

hide()

Hide elements from the scene.

on_slice_change(_x_value, _y_value, _z_value)

Assign in TabManager if require to update something while the slice

on_tab_selected()

Trigger when tab becomes active.

show()

Show elements in the scene.

update_slices(x_slice, y_slice, z_slice)

Updates slicer positions.

update_volume(volume)

Updates volume based on passed volume.

property actors#

visualization actors controlled by tab.

horizon.tab.SlicesTab.actors is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

build(tab_id)[source]#

Build all the elements under the tab.

horizon.tab.SlicesTab.build is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Parameters:
tab_idint

Id of the tab.

property file_name#

Name of the file opened in the tab.

horizon.tab.SlicesTab.file_name is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

property name#

Name of the tab.

horizon.tab.SlicesTab.name is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

on_tab_selected()[source]#

Trigger when tab becomes active.

horizon.tab.SlicesTab.on_tab_selected is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

update_slices(x_slice, y_slice, z_slice)[source]#

Updates slicer positions.

horizon.tab.SlicesTab.update_slices is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Parameters:
x_slice: float

x-value where the slicer should be placed

y_slice: float

y-value where the slicer should be placed

z_slice: float

z-value where the slicer should be placed

update_volume(volume)[source]#

Updates volume based on passed volume.

horizon.tab.SlicesTab.update_volume is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Parameters:
volumefloat

value of where the volume slider should be placed

SurfaceTab#

class dipy.viz.horizon.tab.surface.SurfaceTab(visualizer, tab_name, file_name)[source]#

Bases: HorizonTab

Attributes:
actors

Actors controlled by this tab.

elements

list of underlying FURY ui elements in the tab.

name

Name of the tab.

tab_id

Id of the tab.

Methods

build(tab_id)

Build all the elements under the tab.

hide()

Hide elements from the scene.

on_slice_change(_x_value, _y_value, _z_value)

Assign in TabManager if require to update something while the slice

on_tab_selected()

Implement if require to update something while the tab becomes

show()

Show elements in the scene.

property actors#

Actors controlled by this tab.

horizon.tab.SurfaceTab.actors is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

build(tab_id)[source]#

Build all the elements under the tab.

horizon.tab.SurfaceTab.build is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Parameters:
tab_idint

Id of the tab.

property name#

Name of the tab.

horizon.tab.SurfaceTab.name is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Returns:
str

check_img_shapes#

dipy.viz.horizon.util.check_img_shapes(images)[source]#

Check if the images have same shapes. It also provides details about the volumes are same or not. If the shapes are not equal it will return False for both shape and volume.

horizon.util.check_img_shapes is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Parameters:
imageslist
Returns:
tuple

tuple[0] = True, if shapes are equal. tuple[1] = True, if volumes are equal.

check_img_dtype#

dipy.viz.horizon.util.check_img_dtype(images)[source]#

Check supplied image dtype.

horizon.util.check_img_dtype is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

If not supported numerical type, fallback to supported numerical types (either int32 or float 32). If non-numerical type, skip the data.

Parameters:
imageslist

Each image is tuple of (data, affine).

Returns:
list

Valid images from the provided images.

show_ellipsis#

dipy.viz.horizon.util.show_ellipsis(text, text_size, available_size)[source]#

Apply ellipsis to the text.

horizon.util.show_ellipsis is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Parameters:
textstring

Text required to be check for ellipsis.

text_sizefloat

Current size of the text in pixels.

available_sizefloat

Size available to fit the text. This will be used to truncate the text and show ellipsis.

Returns:
string

Text after processing for ellipsis.

unpack_surface#

dipy.viz.horizon.util.unpack_surface(surface)[source]#

Unpack surface data.

horizon.util.unpack_surface is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Parameters:
surfacetuple

It either contains (vertices, faces) or (vertices, faces, fname).

Returns:
tuple

If surface with (vertices, faces) it will convert to (vertices, faces, None). Otherwise it will be passed as it is.

unpack_data#

dipy.viz.horizon.util.unpack_data(data, *, return_size=3)[source]#

horizon.util.unpack_data is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

check_peak_size#

dipy.viz.horizon.util.check_peak_size(pams, *, ref_img_shape=None, sync_imgs=False)[source]#

Check shape of peaks.

horizon.util.check_peak_size is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Parameters:
pamstuple

(PeaksAndMetrics, fname).

ref_img_shapetuple, optional

3D shape of the image, by default None.

sync_imgsbool, optional

True if the images are synchronized, by default False.

Returns:
bool

If the peaks are aligned with images and other peaks.

ClustersVisualizer#

class dipy.viz.horizon.visualizer.cluster.ClustersVisualizer(show_manager, scene, tractograms, *, enable_callbacks=True)[source]#

Bases: object

Attributes:
centroid_actors

horizon.visualizer.ClustersVisualizer.centroid_actors is deprecated and will be removed in a future version. Use Skyline instead.

cluster_actors

horizon.visualizer.ClustersVisualizer.cluster_actors is deprecated and will be removed in a future version. Use Skyline instead.

lengths

horizon.visualizer.ClustersVisualizer.lengths is deprecated and will be removed in a future version. Use Skyline instead.

sizes

horizon.visualizer.ClustersVisualizer.sizes is deprecated and will be removed in a future version. Use Skyline instead.

tractogram_clusters

horizon.visualizer.ClustersVisualizer.tractogram_clusters is deprecated and will be removed in a future version. Use Skyline instead.

Methods

add_cluster_actors(tract_idx, streamlines, ...)

horizon.visualizer.ClustersVisualizer.add_cluster_actors is deprecated and will be removed in a future version.

recluster_tractograms(thr)

horizon.visualizer.ClustersVisualizer.recluster_tractograms is deprecated and will be removed in a future version.

add_cluster_actors(tract_idx, streamlines, thr, colors)[source]#

horizon.visualizer.ClustersVisualizer.add_cluster_actors is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

property centroid_actors#

horizon.visualizer.ClustersVisualizer.centroid_actors is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

property cluster_actors#

horizon.visualizer.ClustersVisualizer.cluster_actors is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

property lengths#

horizon.visualizer.ClustersVisualizer.lengths is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

recluster_tractograms(thr)[source]#

horizon.visualizer.ClustersVisualizer.recluster_tractograms is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

property sizes#

horizon.visualizer.ClustersVisualizer.sizes is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

property tractogram_clusters#

horizon.visualizer.ClustersVisualizer.tractogram_clusters is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

PeakActor#

class dipy.viz.horizon.visualizer.peak.PeakActor(directions, indices, *, values=None, affine=None, colors=None, lookup_colormap=None, linewidth=1, symmetric=True)[source]#

Bases: Actor

FURY actor for visualizing DWI peaks.

Parameters:
directionsndarray

Peak directions. The shape of the array should be (X, Y, Z, D, 3).

indicestuple

Indices given in tuple(x_indices, y_indices, z_indices) format for mapping 2D ODF array to 3D voxel grid.

valuesndarray, optional

Peak values. The shape of the array should be (X, Y, Z, D).

affinearray, optional

4x4 transformation array from native coordinates to world coordinates.

colorsNone or string (‘rgb_standard’) or tuple (3D or 4D) or array/ndarray (N, 3 or 4) or (K, 3 or 4) or (N, ) or (K, )

If None a standard orientation colormap is used for every line. If one tuple of color is used. Then all streamlines will have the same color. If an array (N, 3 or 4) is given, where N is equal to the number of points. Then every point is colored with a different RGB(A) color. If an array (K, 3 or 4) is given, where K is equal to the number of lines. Then every line is colored with a different RGB(A) color. If an array (N, ) is given, where N is the number of points then these are considered as the values to be used by the colormap. If an array (K,) is given, where K is the number of lines then these are considered as the values to be used by the colormap.

lookup_colormapvtkLookupTable, optional

Add a default lookup table to the colormap. Look at fury.actor.colormap_lookup_table() for more information.

linewidthfloat, optional

Line thickness.

symmetric: bool, optional

If True, peaks are drawn for both peaks_dirs and -peaks_dirs. Else, peaks are only drawn for directions given by peaks_dirs.

Attributes:
cross_section

horizon.visualizer.PeakActor.cross_section is deprecated and will be removed in a future version. Use Skyline instead.

global_opacity

horizon.visualizer.PeakActor.global_opacity is deprecated and will be removed in a future version. Use Skyline instead.

high_ranges

horizon.visualizer.PeakActor.high_ranges is deprecated and will be removed in a future version. Use Skyline instead.

is_range

horizon.visualizer.PeakActor.is_range is deprecated and will be removed in a future version. Use Skyline instead.

linewidth

horizon.visualizer.PeakActor.linewidth is deprecated and will be removed in a future version. Use Skyline instead.

low_ranges

horizon.visualizer.PeakActor.low_ranges is deprecated and will be removed in a future version. Use Skyline instead.

max_centers

horizon.visualizer.PeakActor.max_centers is deprecated and will be removed in a future version. Use Skyline instead.

min_centers

horizon.visualizer.PeakActor.min_centers is deprecated and will be removed in a future version. Use Skyline instead.

Methods

display_cross_section(x, y, z)

horizon.visualizer.PeakActor.display_cross_section is deprecated and will be removed in a future version.

display_extent(x1, x2, y1, y2, z1, z2)

horizon.visualizer.PeakActor.display_extent is deprecated and will be removed in a future version.

property cross_section#

horizon.visualizer.PeakActor.cross_section is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

display_cross_section(x, y, z)[source]#

horizon.visualizer.PeakActor.display_cross_section is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

display_extent(x1, x2, y1, y2, z1, z2)[source]#

horizon.visualizer.PeakActor.display_extent is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

property global_opacity#

horizon.visualizer.PeakActor.global_opacity is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

property high_ranges#

horizon.visualizer.PeakActor.high_ranges is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

property is_range#

horizon.visualizer.PeakActor.is_range is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

property linewidth#

horizon.visualizer.PeakActor.linewidth is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

property low_ranges#

horizon.visualizer.PeakActor.low_ranges is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

property max_centers#

horizon.visualizer.PeakActor.max_centers is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

property min_centers#

horizon.visualizer.PeakActor.min_centers is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

PeaksVisualizer#

class dipy.viz.horizon.visualizer.peak.PeaksVisualizer(pam, world_coords, fname)[source]#

Bases: object

Attributes:
actors

horizon.visualizer.PeaksVisualizer.actors is deprecated and will be removed in a future version. Use Skyline instead.

property actors#

horizon.visualizer.PeaksVisualizer.actors is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

peak#

dipy.viz.horizon.visualizer.peak.peak(peaks_dirs, *, peaks_values=None, mask=None, affine=None, colors=None, linewidth=1, lookup_colormap=None, symmetric=True)[source]#

Visualize peak directions as given from peaks_from_model function.

horizon.visualizer.peak is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

Parameters:
peaks_dirsndarray

Peak directions. The shape of the array should be (X, Y, Z, D, 3).

peaks_valuesndarray, optional

Peak values. The shape of the array should be (X, Y, Z, D).

affinearray, optional

4x4 transformation array from native coordinates to world coordinates.

maskndarray, optional

3D mask

colorstuple or None, optional

Default None. If None then every peak gets an orientation color in similarity to a DEC map.

lookup_colormapvtkLookupTable, optional

Add a default lookup table to the colormap. Look at fury.actor.colormap_lookup_table() for more information.

linewidthfloat, optional

Line thickness. Default is 1.

symmetricbool, optional

If True, peaks are drawn for both peaks_dirs and -peaks_dirs. Else, peaks are only drawn for directions given by peaks_dirs. Default is True.

Returns:
peak_actorPeakActor

Actor or LODActor representing the peaks directions and/or magnitudes.

SlicesVisualizer#

class dipy.viz.horizon.visualizer.slice.SlicesVisualizer(interactor, scene, data, *, affine=None, world_coords=False, percentiles=(0, 100), rgb=False, fname=None)[source]#

Bases: object

Attributes:
data_shape

horizon.visualizer.SlicesVisualizer.data_shape is deprecated and will be removed in a future version. Use Skyline instead.

intensities_range

horizon.visualizer.SlicesVisualizer.intensities_range is deprecated and will be removed in a future version. Use Skyline instead.

rgb

horizon.visualizer.SlicesVisualizer.rgb is deprecated and will be removed in a future version. Use Skyline instead.

selected_slices

horizon.visualizer.SlicesVisualizer.selected_slices is deprecated and will be removed in a future version. Use Skyline instead.

slice_actors

horizon.visualizer.SlicesVisualizer.slice_actors is deprecated and will be removed in a future version. Use Skyline instead.

volume_max

horizon.visualizer.SlicesVisualizer.volume_max is deprecated and will be removed in a future version. Use Skyline instead.

volume_min

horizon.visualizer.SlicesVisualizer.volume_min is deprecated and will be removed in a future version. Use Skyline instead.

Methods

change_volume(next_idx, intensity_ratios, ...)

horizon.visualizer.SlicesVisualizer.change_volume is deprecated and will be removed in a future version.

register_picker_callback(callback)

horizon.visualizer.SlicesVisualizer.register_picker_callback is deprecated and will be removed in a future version.

change_volume(next_idx, intensity_ratios, visible_slices)[source]#

horizon.visualizer.SlicesVisualizer.change_volume is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

property data_shape#

horizon.visualizer.SlicesVisualizer.data_shape is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

property intensities_range#

horizon.visualizer.SlicesVisualizer.intensities_range is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

register_picker_callback(callback)[source]#

horizon.visualizer.SlicesVisualizer.register_picker_callback is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

property rgb#

horizon.visualizer.SlicesVisualizer.rgb is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

property selected_slices#

horizon.visualizer.SlicesVisualizer.selected_slices is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

property slice_actors#

horizon.visualizer.SlicesVisualizer.slice_actors is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

property volume_max#

horizon.visualizer.SlicesVisualizer.volume_max is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

property volume_min#

horizon.visualizer.SlicesVisualizer.volume_min is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

SurfaceVisualizer#

class dipy.viz.horizon.visualizer.surface.SurfaceVisualizer(surface, scene, color)[source]#

Bases: object

Attributes:
actors

horizon.visualizer.SurfaceVisualizer.actors is deprecated and will be removed in a future version. Use Skyline instead.

property actors#

horizon.visualizer.SurfaceVisualizer.actors is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

build_label#

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

Simple utility function to build labels

panel.build_label is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

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

panel.slicer_panel is deprecated and will be removed in a future version. Use Skyline instead.

  • deprecated from version: 1.13.0

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

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=), "peak" (peaks=), "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.

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.

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

  • “roi”: Region of Interest files

  • “shm_coeff”: Spherical Harmonics Coefficients files

  • “buan_colors”: BUAN color mapping files

file_namestr, optional

File name suggested in the save dialog.

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 str, 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

  • “roi”: Region of Interest files

  • “shm_coeff”: Spherical Harmonics Coefficients files

  • “buan_colors”: BUAN color mapping files

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.

show_infobool, optional

Whether to show the info button.

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

Registry of named UIWindow instances for the Skyline scene.

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

Sidebar window that groups visualization sections and file dialogs.

Parameters:
titlestr

Title text shown in the UI.

default_openbool, optional

Whether the window starts expanded.

flagsint, optional

Extra imgui.WindowFlags_ bitmask combined with the built-in flags.

postuple(int, int), optional

Window position in screen coordinates.

sizetuple(int, int), optional

Window size in pixels.

logo_tex_refTextureId, optional

Texture reference for the logo drawn in the title area.

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.

snapshot_callbackcallable, optional

Callback invoked when a snapshot path is selected.

Attributes:
section_open_states

Collapsed/open flags for each registered section id.

sections

Mapping of 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.

Returns:
dict

Mapping of section name to its collapsed/open bool state.

property sections#

Mapping of section id to (renderer_callable, viz_type) tuples.

Returns:
dict

Registered sections keyed by name.

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 a hex color code to an RGBA tuple.

Parameters:
hex_colorstr

Hex color code, with or without a leading #.

alphafloat, optional

Alpha channel value as a fraction in [0, 1].

Returns:
tuple of float

(r, g, b, alpha) with each channel a fraction in [0, 1].

Skyline#

class dipy.viz.skyline.app.Skyline(*, visualizer_type='standalone', images=None, peaks=None, rois=None, surfaces=None, tractograms=None, sh_coeffs=None, sh_basis='descoteaux07', 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=None, initial_filenames=None, initial_rois=None, initial_peaks=None, initial_shm_coeffs=None, out_dir=None, out_stealth_png=None)[source]#

Bases: object

The Skyline viewer, hosting the FURY scene, UI, and visualizations.

Parameters:
visualizer_type{“standalone”, “gui”, “jupyter”, “stealth”}, optional

Kind of window to create. The options map to FURY window types via create_window:

  • “standalone”: a default interactive window.

  • “gui”: a Qt-based window.

  • “jupyter”: an inline Jupyter notebook window.

  • “stealth”: an offscreen window with no GUI, used for scripted snapshots.

An unrecognized value logs an error and terminates the process.

imageslist of tuple, optional

(data, affine) or (data, affine, filename) tuples where data is a nibabel image or ndarray and filename is a display label.

peakslist of tuple, optional

(peak_dirs, affine, filename, peak_values) tuples; see create_peak_visualization.

roislist of tuple, optional

Already-loaded ROI data to show at startup, as (roi, affine) or (roi, affine, filename) tuples.

surfaceslist of tuple, optional

Already-loaded surface data to show at startup, as (vertices, faces) or (vertices, faces, filename) tuples.

tractogramslist of tuple, optional

Already-loaded tractogram data to show at startup, as (sft,) or (sft, filename) tuples, where sft is a StatefulTractogram. Entries with no streamlines are skipped with a warning.

sh_coeffslist of tuple, optional

Already-loaded spherical harmonic coefficient data to show at startup, as (coeffs, affine), (coeffs, affine, filename) or (coeffs, affine, filename, basis_type) tuples. coeffs must be a 4D ndarray, otherwise the entry is skipped with a warning.

sh_basisstr, optional

SH basis of NIfTI ODFs: "descoteaux07" (DIPY legacy) or "tournier07" (MRtrix3).

is_clusterbool, optional

Whether to cluster the tractograms.

is_light_versionbool, optional

Whether to render tractograms as "Line" instead of "Tube", which improves performance for large tractograms.

glass_brainbool, optional

Whether to render surfaces black with the "basic" material at 25% opacity and default the background to white.

bg_colortuple of float, optional

Background color of the scene as an RGB tuple in [0, 1]. If None, it is white when glass_brain is True, otherwise dark gray.

tract_colorsstr or tuple of float or None, optional

Coloring scheme for the tractograms: "direction" for directionally colored streamlines, "random" for the next color from a distinguishable colormap per tractogram, an RGB(A) tuple in [0, 1], or a string of three space-separated numbers parsed to such a tuple. If None, "direction" is used.

cluster_thrfloat, optional

Final distance threshold, in mm, used by qbx_and_merge when clustering is enabled; small-animal data may need a smaller value such as 2.0.

cluster_size_thrint, optional

Clusters with size less than cluster_size_thr are hidden. If None, the 50th percentile of the cluster size distribution is used.

cluster_length_thrfloat, optional

Clusters with average length less than cluster_length_thr mm are hidden. If None, the 25th percentile of the cluster length distribution is used.

buan_pvalsstr, optional

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

rgbbool or None, optional

None: auto-detect from structured NIfTI DT_RGB24 dtype; show toggle for other 4D volumes with 3 or 4 channels. True: force RGB mode. False: never treat as RGB.

initial_filenameslist of str, optional

File paths loaded asynchronously into the viewer on startup. If neither preloaded data nor initial files are given and a UI exists, the file dialog opens on start.

initial_roislist of str, optional

ROI file paths loaded asynchronously into the viewer on startup.

initial_peakslist of str, optional

List of .pam5 or NIfTI (.nii, .nii.gz) peak file paths to load into the Skyline viewer on startup.

initial_shm_coeffslist of str, optional

Spherical harmonic coefficient file paths loaded asynchronously into the viewer on startup.

out_dirstr or Path, optional

Directory for the stealth-mode output image; created if missing. Used only when visualizer_type is "stealth".

out_stealth_pngstr, optional

Output image name, without extension, used as the stealth window title. Used only when visualizer_type is "stealth".

Attributes:
visualizations

Return every visualization currently tracked by the viewer.

Methods

before_render()

Refresh and render, or defer to a request if mid-UI-draw.

draw_ui()

Draw the ImGui overlay for a single frame.

enqueue_scene_op(func, *args, **kwargs)

Run or defer a scene-mutating callable.

handle_key_events(event)

Forward a key event to clustered tractogram visualizations.

handle_resize(size)

Update cached layout state after the window is resized.

loader(show, *[, message])

Show or hide the UI's loading indicator.

request_refresh()

Flag the viewer for a refresh on the next UI frame.

before_render()[source]#

Refresh and render, or defer to a request if mid-UI-draw.

Called after the constructor’s initial load and whenever a change needs to be shown outside of the draw_ui frame callback.

draw_ui()[source]#

Draw the ImGui overlay for a single frame.

Invoked as the ImGui GUI callback. Renders the UI window, then drains pending tractogram switches, visualizations, synchronization requests, and scene operations queued while drawing, applying a pending background color change and refreshing if required.

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

Run or defer a scene-mutating callable.

Runs func immediately unless the UI is currently drawing, in which case the call is queued for _flush_pending_scene_ops and coalesced with any previously queued call sharing the same bound method or function name.

Parameters:
funccallable

Scene-mutating callable to run or defer.

*argstuple

Positional arguments forwarded to func.

**kwargsdict

Keyword arguments forwarded to func.

handle_key_events(event)[source]#

Forward a key event to clustered tractogram visualizations.

Registered as the renderer’s "key_down" event handler.

Parameters:
eventEvent

Interaction event from the renderer callback.

handle_resize(size)[source]#

Update cached layout state after the window is resized.

Registered as the window’s resize callback.

Parameters:
sizetuple of int

New window size, in pixels, as (width, height).

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

Show or hide the UI’s loading indicator.

Parameters:
showbool

Whether to show the UI element/loader.

messagestr, optional

Message text shown to the user.

request_refresh()[source]#

Flag the viewer for a refresh on the next UI frame.

The actual actor sync and render happen later, either at the end of the current draw_ui call or on the next before_render call.

property visualizations#

Return every visualization currently tracked by the viewer.

Returns:
list

The list of visualizations in the Skyline viewer.

skyline_from_files#

dipy.viz.skyline.app.skyline_from_files(fnames, *, rois=None, peaks=None, shm_coeffs=None, sh_basis='descoteaux07', 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=None, out_dir=None, out_stealth_png=None)[source]#

Launch the Skyline GUI from file paths.

Loads every path in the background and constructs the corresponding Skyline viewer, forwarding fnames/rois/shm_coeffs as initial_filenames/initial_rois/initial_shm_coeffs.

Parameters:
fnameslist of str

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 (.trk, .trx, .dpy, .tck, .vtk, .vtp, .fib)

Unsupported extensions are logged and skipped; .npy entries are ignored.

roislist of str, optional

File paths for ROIs to be loaded into the Skyline viewer. Only NIfTI images (.nii, .nii.gz) are supported; other extensions are logged and skipped.

peakslist, optional

Tuple of path for each peaks file (.pam5, or NIfTI with shape (X, Y, Z, 3*N) or (X, Y, Z, N, 3)) to be added to the Skyline viewer.

shm_coeffslist of str, optional

File paths for spherical harmonics coefficients to be loaded into the Skyline viewer. Only .pam5 files are supported; other extensions are silently skipped.

sh_basisstr, optional

SH basis of NIfTI ODFs: ‘descoteaux07’ (DIPY legacy) or ‘tournier07’ (MRtrix3).

is_clusterbool, optional

Whether to cluster the tractograms.

is_light_versionbool, optional

Whether to render tractograms as "Line" instead of "Tube", which improves performance for large tractograms.

glass_brainbool, optional

Whether to render surfaces black with the "basic" material at 25% opacity and default the background to white.

bg_colortuple of float, optional

Background color of the scene as an RGB tuple in [0, 1]. If None, it is white when glass_brain is True, otherwise dark gray.

tract_colorsstr or tuple of float or None, optional

Coloring scheme for the tractograms: "direction" for directionally colored streamlines, "random" for the next color from a distinguishable colormap per tractogram, an RGB(A) tuple in [0, 1], or a string of three space-separated numbers parsed to such a tuple. If None, "direction" is used.

cluster_thrfloat, optional

Final distance threshold, in mm, used by qbx_and_merge when clustering is enabled; small-animal data may need a smaller value such as 2.0.

cluster_size_thrint, optional

Clusters with size less than cluster_size_thr are hidden. If None, the 50th percentile of the cluster size distribution is used.

cluster_length_thrfloat, optional

Clusters with average length less than cluster_length_thr mm are hidden. If None, the 25th percentile of the cluster length distribution is used.

buan_pvalsstr, optional

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

stealthbool, optional

Whether to render offscreen and save a snapshot instead of opening an interactive window; sets visualizer_type to "stealth".

rgbbool or None, optional

None: auto-detect from structured NIfTI DT_RGB24 dtype; show toggle for other 4D volumes with 3 or 4 channels. True: force RGB mode. False: never treat as RGB.

out_dirstr or Path, optional

Directory for the stealth-mode output image; created if missing. Used only when stealth is True.

out_stealth_pngstr, optional

Output image name, without extension, used as the stealth window title. Used only when stealth is True.

Returns:
Skyline

The constructed viewer, returned once construction returns from its blocking self.window.start() call.

skyline#

dipy.viz.skyline.app.skyline(*, visualizer_type='standalone', images=None, peaks=None, rois=None, surfaces=None, tractograms=None, sh_coeffs=None, sh_basis='descoteaux07', 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=None, initial_filenames=None, initial_rois=None, initial_peaks=None, initial_shm_coeffs=None, out_dir=None, out_stealth_png=None)[source]#

Launch the Skyline GUI.

Constructs and returns a Skyline viewer with the given data.

Parameters:
visualizer_type{“standalone”, “gui”, “jupyter”, “stealth”}, optional

Kind of window to create. The options map to FURY window types via create_window:

  • “standalone”: a default interactive window.

  • “gui”: a Qt-based window.

  • “jupyter”: an inline Jupyter notebook window.

  • “stealth”: an offscreen window with no GUI, used for scripted snapshots.

An unrecognized value logs an error and terminates the process.

imageslist of tuple, optional

(data, affine) or (data, affine, filename) tuples where data is a nibabel image or ndarray and filename is a display label.

peakslist of tuple, optional

(peak_dirs, affine, filename, peak_values) tuples; see create_peak_visualization.

roislist of tuple, optional

Already-loaded ROI data to show at startup, as (roi, affine) or (roi, affine, filename) tuples.

surfaceslist of tuple, optional

Already-loaded surface data to show at startup, as (vertices, faces) or (vertices, faces, filename) tuples.

tractogramslist of tuple, optional

Already-loaded tractogram data to show at startup, as (sft,) or (sft, filename) tuples, where sft is a StatefulTractogram. Entries with no streamlines are skipped with a warning.

sh_coeffslist of tuple, optional

Already-loaded spherical harmonic coefficient data to show at startup, as (coeffs, affine), (coeffs, affine, filename) or (coeffs, affine, filename, basis_type) tuples. coeffs must be a 4D ndarray, otherwise the entry is skipped with a warning.

sh_basisstr, optional

SH basis of NIfTI ODFs: ‘descoteaux07’ (DIPY legacy) or ‘tournier07’ (MRtrix3).

is_clusterbool, optional

Whether to cluster the tractograms.

is_light_versionbool, optional

Whether to render tractograms as "Line" instead of "Tube", which improves performance for large tractograms.

glass_brainbool, optional

Whether to render surfaces black with the "basic" material at 25% opacity and default the background to white.

bg_colortuple of float, optional

Background color of the scene as an RGB tuple in [0, 1]. If None, it is white when glass_brain is True, otherwise dark gray.

tract_colorsstr or tuple of float or None, optional

Coloring scheme for the tractograms: "direction" for directionally colored streamlines, "random" for the next color from a distinguishable colormap per tractogram, an RGB(A) tuple in [0, 1], or a string of three space-separated numbers parsed to such a tuple. If None, "direction" is used.

cluster_thrfloat, optional

Final distance threshold, in mm, used by qbx_and_merge when clustering is enabled; small-animal data may need a smaller value such as 2.0.

cluster_size_thrint, optional

Clusters with size less than cluster_size_thr are hidden. If None, the 50th percentile of the cluster size distribution is used.

cluster_length_thrfloat, optional

Clusters with average length less than cluster_length_thr mm are hidden. If None, the 25th percentile of the cluster length distribution is used.

buan_pvalsstr, optional

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

rgbbool or None, optional

None: auto-detect from structured NIfTI DT_RGB24 dtype; show toggle for other 4D volumes with 3 or 4 channels. True: force RGB mode. False: never treat as RGB.

initial_filenameslist of str, optional

File paths loaded asynchronously into the viewer on startup. If neither preloaded data nor initial files are given and a UI exists, the file dialog opens on start.

initial_roislist of str, optional

ROI file paths loaded asynchronously into the viewer on startup.

initial_peakslist, optional

List of .pam5 or NIfTI (.nii, .nii.gz) peak file paths to load into the Skyline viewer on startup.

initial_shm_coeffslist of str, optional

Spherical harmonic coefficient file paths loaded asynchronously into the viewer on startup.

out_dirstr or Path, optional

Directory for the stealth-mode output image; created if missing. Used only when visualizer_type is "stealth".

out_stealth_pngstr, optional

Output image name, without extension, used as the stealth window title. Used only when visualizer_type is "stealth".

Returns:
Skyline

The constructed viewer, returned once construction returns from its blocking self.window.start() call.

run_async#

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

Execute func asynchronously in a background daemon thread.

Parameters:
funccallable

The function to execute in the background thread.

callbackcallable

Function invoked as callback(result, exception) once func completes, where result is its return value and exception is any exception it raised, or None on success.

*args

Positional arguments passed to func.

**kwargs

Keyword arguments passed to func.

Notes

callback is never called from the worker thread. It is queued together with the result and exception, and only runs when process_async_callbacks() drains the queue on whichever thread calls it (normally the main/UI thread). The worker thread is a daemon thread, so it does not block interpreter shutdown.

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, peaks=None, shm_coeffs=None, sh_basis='descoteaux07')[source]#

Load images, peaks, surfaces, and tractograms from fnames.

Dispatches each path by extension to the matching DIPY loader and collects the results into per-type lists. Extensions not recognized in fnames are logged and skipped; .npy entries are recognized but ignored (reserved for BUAN p-value files, not loaded here).

Parameters:
fnameslist of str or None

Paths to load. Supported extensions: images use .nii or .nii.gz; peaks use .pam5; surfaces use .pial, .gii, or .gii.gz; tractograms use .trk, .trx, .dpy, .tck, .vtk, .vtp, or .fib.

roislist of str, optional

Paths to ROI images (.nii or .nii.gz); other extensions are logged and skipped.

peakslist of str, optional

Paths of the peak files.

shm_coeffslist of str, optional

Paths to spherical-harmonic coefficient files (.pam5); other extensions are silently skipped.

sh_basisstr, optional

SH basis of NIfTI ODFs in shm_coeffs: "descoteaux07" or "tournier07".

Returns:
dict

Dictionary with keys "images", "peaks", "rois", "surfaces", "tractograms", "shm_coeffs", each a list of tuples for the matching create_*_visualization function:

  • images : (img, affine, fname) with a nibabel image object

  • rois : (data, affine, fname) with an ndarray

  • peaks : (pam, fname)

  • surfaces : (vertices, faces, fname)

  • tractograms : (sft, fname)

  • shm_coeffs : (coeffs, affine, fname, "descoteaux")

Notes

NIfTI peak files (.nii, .nii.gz) are accepted in two layouts: (X, Y, Z, N, 3), as written by dipy.io.peaks.pam_to_niftis(..., reshape_dirs=False), and (X, Y, Z, 3*N), as written with reshape_dirs=True and by MRtrix3 sh2peaks. Each "peaks" entry is a (peak_dirs, affine, filename, peak_values) tuple; peak_values is None for NIfTI peaks, since a NIfTI peaks file carries no magnitude information.

NIfTI ODF files must be a 4D volume whose last dimension is a symmetric SH coefficient count (1, 6, 15, 28, 45, …). Coefficients in the tournier07 (MRtrix3) basis are converted to legacy descoteaux07.

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:
ndarray or None

The loaded array, or None if the file could not be loaded.

Image3D#

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

Bases: Visualization

A NIfTI-backed volume slicer with linked opacity and colormap controls.

Renders orthogonal image slices with fury.actor.volume_slicer and exposes opacity, slice position, intensity range, colormap, and (for non-RGB 4D data) directional-volume controls through render_widgets.

Parameters:
namestr

Display name used in the Skyline UI.

volumenibabel.spatialimages.SpatialImage or ndarray

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

affinendarray, optional

Rendering affine; uses the image affine when omitted for image inputs.

interpolationstr, optional

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

render_callbackcallable, optional

Callback used to request a render/update.

opacityint, optional

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

rgbbool or None, optional

None: auto-detect from structured NIfTI DT_RGB24 dtype; show toggle for other 4D volumes with 3 or 4 channels. True: force RGB mode. False: never treat as RGB. Colormap and directional-volume controls are ignored when RGB.

value_percentilestuple(float, float), optional

Low/high percentiles used to compute scalar intensity limits.

colormapstr, optional

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

sync_callabckcallable, optional

Callback used to synchronize state across views.

Attributes:
active_volume

The 3D volume currently used for slicing and display.

actor

The volume-slicer actor rendering the current slices.

viz_type

The visualization type identifier derived from the subclass name.

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

Draw the ImGui controls for opacity, slices, colormap, and voxel info.

renderer(is_open, *[, group_visible])

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

update_state(new_state)

Synchronize slice positions and volume index from another view.

property active_volume#

The 3D volume currently used for slicing and display.

Returns:
ndarray

dwi[..., volume_idx] when the source data has a fourth (directional) axis and RGB mode is disabled, otherwise dwi.

property actor#

The volume-slicer actor rendering the current slices.

Returns:
VolumeSlicer

The actor of the image visualization.

render_widgets()[source]#

Draw the ImGui controls for opacity, slices, colormap, and voxel info.

Renders toggles for slice synchronization and RGB mode, an opacity slider, per-axis slice position sliders, an intensity percentile slider, a directional-volume slider (for non-RGB 4D data), a colormap dropdown, picked voxel/intensity text, and an interpolation switch. Committed changes queue scene updates via apply_scene_op() and, when synchronization is enabled, forward the new state through sync_callabck.

update_state(new_state)[source]#

Synchronize slice positions and volume index from another view.

Only applies when _synchronize is enabled. Updates the displayed slices to new_state[:3]; if a fourth value is present and the volume has that many directions, also switches the active directional volume, rebuilding the slicer actor.

Parameters:
new_statearray-like

New synchronized state as (x, y, z) or (x, y, z, volume_idx).

create_image_visualization#

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

Create an Image3D visualization from already-loaded image data.

Parameters:
inputtuple

Tuple of (data, affine, filename) or (data, affine) where data is a nibabel image or ndarray. The filename is a display label.

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 or None, optional

None: auto-detect from structured NIfTI DT_RGB24 dtype; show toggle for other 4D volumes with 3 or 4 channels. True: force RGB mode. False: never treat as 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.

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 a peak-direction (PAM) vector-field slicer in Skyline.

Parameters:
namestr

Display name used in the Skyline UI.

peaksndarray, shape (X, Y, Z, N, 3) or (X, Y, Z, 3)

Per-voxel peak directions rendered as a vector field.

affinendarray, optional

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

peak_valuesndarray or float, optional

Per-peak magnitude scaling the rendered line length; a scalar value is applied uniformly to every peak.

opacityint, optional

Initial value of the Opacity slider, in percent [0, 100]. Stored on self.opacity but not applied to the actor until the Opacity slider is changed once in render_widgets().

render_callbackcallable, optional

Callback used to request a render/update.

sync_callabckcallable, optional

Callback used to synchronize state across views.

Attributes:
actor

Vector-field actor group backing this peak visualization.

viz_type

The visualization type identifier derived from the subclass name.

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

Draw the sync toggle, scale, opacity, and per-axis slice controls.

renderer(is_open, *[, group_visible])

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

update_state(new_state)

Apply a synchronized state from another visualization.

property actor#

Vector-field actor group backing this peak visualization.

Returns:
Group

Parent group of chunked vector-field actors rendered as the three orthogonal peak-direction slices.

render_widgets()[source]#

Draw the sync toggle, scale, opacity, and per-axis slice controls.

update_state(new_state)[source]#

Apply a synchronized state from another visualization.

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 a peak visualization from loaded PAM data.

Parameters:
inputtuple

One of (peak_dirs, affine, filename, peak_values), (peak_dirs, affine, filename) or (peak_dirs, affine). peak_values may be None.

idxint

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

opacityint, optional

Initial opacity of the peak rendering, in percent [0, 100].

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.

Raises:
ValueError

If input is not a tuple of length 1 or 2.

Visualization#

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

Bases: object

Base class for a single visualization layer in the Skyline sidebar.

Parameters:
pathstr or Path

Path to the resource on disk.

render_callbackcallable, optional

Callback used to request a render/update.

Attributes:
actor

The FURY actor rendered for this visualization.

viz_type

The visualization type identifier derived from the subclass name.

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#

The FURY actor rendered for this visualization.

Returns:
object

The visualization’s underlying FURY actor object.

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.

Parameters:
funccallable

Scene-mutating callable to run, either directly or through the deferral callback.

*args

Positional arguments forwarded to func.

**kwargs

Keyword arguments forwarded to func.

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#

The visualization type identifier derived from the subclass name.

Returns:
str or None

One of "image", "surface", "peak", "roi", "tractography", or "sh_glyph" depending on the concrete subclass, or None if the subclass name is not recognized.

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.

format_affine_info#

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

Build the shared “voxel sizes + order + affine” block for info panels.

Parameters:
affinearray_like

Voxel-to-world affine.

Returns:
str

“Voxel Sizes: <sizes>nVoxel Order: <code>nAffine:n<matrix>”.

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_type{“standalone”, “gui”, “jupyter”, “stealth”}, optional

Type of visualizer to create:

  • “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 of int, optional

Window size in pixels as (width, height).

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.

Notes

If visualizer_type is not one of the recognized values, the error is logged and the process exits via sys.exit(1) instead of raising a Python exception.

ROI3D#

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

Bases: Visualization

A binary ROI mask rendered as a translucent contour surface.

Only the first volume along the last axis is used when roi is 4D.

Parameters:
namestr

Display name used in the Skyline UI.

roindarray

Binary ROI mask array used to build the contour surface.

affinendarray, optional

Voxel-to-world affine used to position the contour in world coordinates.

opacityint, optional

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

colortuple(float, float, float), optional

RGB color of the contour surface, in [0, 1].

render_callbackcallable, optional

Callback used to request a render/update.

Attributes:
actor

The contour actor rendering the ROI mask.

viz_type

The visualization type identifier derived from the subclass name.

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

Draw the ImGui controls for contour opacity and color.

renderer(is_open, *[, group_visible])

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

Raises:
ValueError

If roi is None or not an ndarray.

property actor#

The contour actor rendering the ROI mask.

Returns:
Contour

The actor of the ROI visualization.

render_widgets()[source]#

Draw the ImGui controls for contour opacity and color.

Renders an opacity slider and a color picker; committing a new color rebuilds the contour actor via _create_roi_actor().

create_roi_visualization#

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

Create an ROI3D visualization from already-loaded ROI data.

Parameters:
inputtuple

Tuple of (roi, affine, filename) or (roi, affine) holding an already-loaded binary ROI mask array and its affine, with an optional filename.

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.

Raises:
ValueError

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

SlicedSphGlyphMaterial#

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

Bases: SphGlyphMaterial

SH glyph material with world-space slice positions and visibility flags.

Parameters:
active_slice_xfloat, optional

World-space X coordinate of the visible slice plane; a negative value disables X-axis slicing.

active_slice_yfloat, optional

World-space Y coordinate of the visible slice plane; a negative value disables Y-axis slicing.

active_slice_zfloat, optional

World-space Z coordinate of the visible slice plane; a negative value disables Z-axis slicing.

vis_xint, optional

Nonzero to enable X-axis slice visibility, zero to hide it.

vis_yint, optional

Nonzero to enable Y-axis slice visibility, zero to hide it.

vis_zint, optional

Nonzero to enable Z-axis slice visibility, zero to hide it.

**kwargs

Forwarded to fury.material.SphGlyphMaterial.

Attributes:
active_slice_x
active_slice_y
active_slice_z
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
vis_y
vis_z
wireframe

Render geometry as a wireframe.

wireframe_thickness

The thickness of the lines when rendering as a wireframe.

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

Maximum SH order currently shaded.

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#

Maximum SH order currently shaded.

Returns:
int

Current SH truncation order, or -1 if never set.

BillboardSphGlyphShader#

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

Bases: MeshShader

Pygfx shader: template variables and bindings for the ODF billboard pipeline.

Reads flags/dimensions off wobject (the SphGlyphBillboard actor) at construction time and exposes them as WGSL template variables ({{ n_coeffs }}, {{ use_hermite_lut }}, etc.) consumed by sh_billboard.wgsl.

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

Wire the SH-coefficient and Hermite-LUT storage buffers.

get_bindings_info(wobject, shared, scene)

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

get_code()

Return the (still-templated) WGSL source for this shader.

get_pipeline_info(wobject, shared)

Subclasses must return a dict describing pipeline details.

get_render_info(wobject, shared)

Compute the instance/vertex counts pygfx needs to issue the draw call.

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

Wire the SH-coefficient and Hermite-LUT storage buffers.

Group 2 binding 0 is the flat SH coefficient buffer; group 3 bindings 0-7 are the (up to 8) Hermite LUT chunk buffers, padded out with a shared dummy vec4<f32> buffer when wobject has fewer chunks than that (or hasn’t baked a LUT at all), since WGSL bindings must all be declared even when unused.

Parameters:
wobjectSphGlyphBillboard

Billboard object being rendered.

sharedfury.lib.Shared

Pygfx object holding the shared device and pipeline caches.

scenefury.lib.Scene or None, optional

Scene the billboard belongs to; forwarded to the base MeshShader implementation when it accepts it.

Returns:
dict

Bindings dict with groups 2 and 3 populated, merged onto whatever the base MeshShader already provided.

get_code()[source]#

Return the (still-templated) WGSL source for this shader.

Returns:
str

WGSL source of sh_billboard.wgsl, with template variables such as {{ n_coeffs }} not yet substituted.

get_render_info(wobject, shared)[source]#

Compute the instance/vertex counts pygfx needs to issue the draw call.

Falls back to computing them from the geometry’s vertex buffer when the base MeshShader doesn’t already provide indices (e.g. before the geometry has been fully wired up).

Parameters:
wobjectSphGlyphBillboard

Billboard object being rendered.

sharedfury.lib.Shared

Pygfx object holding the shared device and pipeline caches.

Returns:
dict

{"indices": (vertex_count, instance_count, 0, 0)}.

bake_hermite_lut#

dipy.viz.skyline.render.sh_billboard.bake_hermite_lut(actor, *, lut_res=8, force_rebake=False, use_float16=False)[source]#

Bake a cube-mapped Hermite LUT on actor if GPU memory allows.

Parameters:
actorSphGlyphBillboard

Target billboard with populated billboard_count and coefficients.

lut_resint, optional

Cube-map resolution per face edge.

force_rebakebool, optional

Recompute even when flags indicate the LUT is ready.

use_float16bool, optional

Store the Hermite LUT 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)[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.

Returns:
SphGlyphBillboard

Configured billboard with baked Hermite LUTs.

SHSlicer#

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

Bases: object

Build and drive the single billboard actor backing an ODF visualization.

Owns the flattened, non-zero-only glyph data (coefficients, model-space centers, voxel indices) passed to sph_glyph_billboard_sliced(), and forwards per-axis slice/visibility/scale/opacity changes to that actor’s material without ever rebuilding the geometry.

Parameters:
coeffs_4dndarray, shape (X, Y, Z, C)

SH coefficients per voxel. Converted from descoteaux07 to Fury’s standard basis on construction if needed.

scalefloat, optional

Uniform billboard size multiplier relative to estimated SH radii.

l_maxint, optional

Maximum SH order to shade. For descoteaux/descoteaux07 input, capped to the order implied by coeffs_4d’s last axis when that is lower; for standard input it must not exceed that order (raises ValueError downstream otherwise).

lut_resint, optional

Cube-map Hermite LUT resolution per face edge.

maskndarray of bool, shape (X, Y, Z), optional

When given, voxels outside the mask are excluded even if their coefficients are non-zero.

basis_type{“standard”, “descoteaux”, “descoteaux07”}, optional

SH basis convention of coeffs_4d.

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

Glyph coloring: direction-mapped hue, or a two-color sign split.

Methods

build()

Build the billboard actor and add it to actor.

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)

Move the active slice plane on one axis to a world-space position.

show_axis(axis)

Enable axis visibility.

build()[source]#

Build the billboard actor and add it to actor.

Safe to call when every voxel is zero (or masked out): the group is then left empty and _glyph_actor stays None.

Returns:
Group

The (possibly empty) parent group holding the billboard actor.

hide_axis(axis)[source]#

Hide all slices for axis.

Parameters:
axis{“x”, “y”, “z”}

Which axis’s slice-visibility uniform to clear.

set_opacity(opacity)[source]#

Set opacity.

Parameters:
opacityfloat

Glyph opacity as a fraction, expected in [0, 1]. Below 1.0 the material’s alpha_mode switches to "blend".

set_scale(new_scale)[source]#

Update scale on the actor.

Parameters:
new_scalefloat

New uniform billboard size multiplier.

set_slice(axis, idx)[source]#

Move the active slice plane on one axis to a world-space position.

A no-op when idx matches the axis’s current position, so repeated calls from a UI slider don’t trigger redundant GPU uniform uploads.

Parameters:
axis{“x”, “y”, “z”}

Which per-axis slice-position uniform to update.

idxfloat

World-space coordinate of the new slice plane along axis.

show_axis(axis)[source]#

Enable axis visibility.

Parameters:
axis{“x”, “y”, “z”}

Which axis’s slice-visibility uniform to set.

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, basis_type='standard', color_type='orientation', mask=None, sync_callback=None)[source]#

Bases: Visualization

High-level ODF visualization: UI widgets, sync, and slice state.

Wraps a single SHSlicer and converts the shared, world-space state vector (synchronized across every Skyline visualization) into the per-axis slice positions the billboard shader expects.

Parameters:
namestr

Display name used in the Skyline UI.

coeffsndarray, shape (X, Y, Z, C)

SH coefficients per voxel.

affinendarray, optional

Voxel-to-world affine used to position slices in world coordinates. When None, state/slice positions are voxel indices instead.

render_callbackcallable, optional

Callback used to request a render/update.

scalefloat, optional

Per-glyph scale used only when affine is None; otherwise the scale is derived from the affine’s voxel sizes.

l_maxint, optional

Maximum SH order to shade.

lut_resint, optional

Cube-map Hermite LUT resolution per face edge.

basis_type{“standard”, “descoteaux”, “descoteaux07”}, optional

SH basis convention of coeffs.

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

Glyph coloring: direction-mapped hue, or a two-color sign split.

maskndarray of bool, optional

Boolean mask of valid voxels.

sync_callbackcallable, optional

Callback used to synchronize state across views.

Attributes:
actor

Group actor to add to the scene; delegates to the slicer.

viz_type

The visualization type identifier derived from the subclass name.

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

Draw the sync toggle, scale/opacity controls, and per-axis sliders.

renderer(is_open, *[, group_visible])

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

set_slice_visibility()

Show/hide each axis's slice per _slice_visibility.

set_slices()

Push the current state to the billboard material's slice uniforms.

update_state(new_state)

Apply a synchronized world-space state from another visualization.

property actor#

Group actor to add to the scene; delegates to the slicer.

Returns:
Group

Parent group containing the billboard actor.

render_widgets()[source]#

Draw the sync toggle, scale/opacity controls, and per-axis sliders.

set_slice_visibility()[source]#

Show/hide each axis’s slice per _slice_visibility.

set_slices()[source]#

Push the current state to the billboard material’s slice uniforms.

Snaps state to the nearest voxel (_voxel_from_world_state()), then forward-transforms that voxel back to world space (when an affine is present) before writing it to each axis’s active_slice_* uniform. This mirrors how Peak3D derives its cross section, and pairs with the vertex shader’s own snap-onto-plane logic to keep the rendered slice crisp for any affine, including rotated or axis-swapped ones.

update_state(new_state)[source]#

Apply a synchronized world-space state from another visualization.

Ignored when _synchronize is off (per-view slice sync toggle).

Parameters:
new_statearray-like

New shared world-space (x, y, z) state; only the first 3 components are used.

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

A basis_type present as the 4th tuple element overrides the basis_type keyword argument.

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.

basis_typestr, optional

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

color_typestr, optional

Color 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

Non-clustered tractography layer rendered as a single line or tube actor.

Parameters:
namestr

Display name used in the Skyline UI.

sftStatefulTractogram

Tractogram whose streamlines are rendered.

line_typestr, optional

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

colortuple(float, float, float), optional

RGB color of the streamlines in [0, 1].

render_callbackcallable, optional

Callback used to request a render/update.

switch_render_callbackcallable, optional

Callback invoked to switch to the clustered rendering mode.

buan_pvals_filestr, optional

File path to BUAN p-values used to color the streamlines on creation.

loadercallable, optional

Callback function to show/hide loader during asynchronous operations.

Attributes:
actor

Return the Fury line or tube actor rendering the streamlines.

viz_type

The visualization type identifier derived from the subclass name.

Methods

apply_scene_op(func, *args, **kwargs)

Run func immediately or defer it via _scene_op_callback.

handle_color_change(fname)

Recolor the streamlines from a BUAN p-values file and re-render.

render()

Request a window redraw through _render_callback when set.

render_widgets()

Draw the line-type, color, and BUAN coloring controls for this layer.

renderer(is_open, *[, group_visible])

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

property actor#

Return the Fury line or tube actor rendering the streamlines.

Returns:
Actor

The line or tube actor built by create_streamline().

handle_color_change(fname)[source]#

Recolor the streamlines from a BUAN p-values file and re-render.

Parameters:
fnamelist of str or None

Selected file path(s) from the uploader; only fname[0] is used. If None, the color is left unchanged.

render_widgets()[source]#

Draw the line-type, color, and BUAN coloring controls for this layer.

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

Clustered tractography layer that groups streamlines with QuickBundlesX.

Renders one centroid tube per cluster; clusters can be expanded to show their member streamlines, selected, hidden, and filtered by size or length. Clustering runs in a background thread unless async_clustering is False.

Parameters:
namestr

Display name used in the Skyline UI.

sftStatefulTractogram

Tractogram whose streamlines are clustered.

thrfloat

Initial clustering distance threshold, in mm.

line_typestr, optional

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

render_callbackcallable, optional

Callback used to request a render/update.

switch_render_callbackcallable, optional

Callback invoked to switch back to the non-clustered rendering mode.

loadercallable, optional

Callback function to show/hide loader during asynchronous operations.

size_thresholdint, optional

Minimum number of streamlines in a cluster to be visible. If None, it is set to 10.

length_thresholdfloat, optional

Minimum length of streamlines in a cluster to be visible. If None, it is set to 20.0.

async_clusteringbool, optional

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

Attributes:
actor

Return the group containing every centroid and cluster actor.

viz_type

The visualization type identifier derived from the subclass name.

Methods

apply_scene_op(func, *args, **kwargs)

Run func immediately or defer it via _scene_op_callback.

compute_visible_tractogram()

Build a tractogram containing the streamlines of selected clusters.

handle_key_events(event)

Expand, collapse, select, deselect, hide, or show clusters by key.

render()

Request a window redraw through _render_callback when set.

render_widgets()

Draw the line-type, threshold, size/length, and download controls.

renderer(is_open, *[, group_visible])

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

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

Save the selected clusters' streamlines to a file.

property actor#

Return the group containing every centroid and cluster actor.

Returns:
Group

Container actor holding one child per cluster (a centroid tube, or its expanded streamline actor).

compute_visible_tractogram()[source]#

Build a tractogram containing the streamlines of selected clusters.

Returns:
StatefulTractogram

Tractogram with the streamlines from every cluster whose selected state is True, in the same space as sft.

handle_key_events(event)[source]#

Expand, collapse, select, deselect, hide, or show clusters by key.

Recognizes "e" (expand), "c" (collapse), "a" (select all), "d" (deselect all), "h" (hide deselected), and "s" (show all) on event.key.

Parameters:
eventEvent

Interaction event from the renderer callback.

render_widgets()[source]#

Draw the line-type, threshold, size/length, and download controls.

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

Save the selected clusters’ streamlines to a file.

Matches the shared download-callback signature used across Skyline visualizations; rois and shm_coeffs are accepted but unused.

Parameters:
filenameslist of str

Selected save path(s) from the file dialog; only the first entry is used.

roislist of str or None, optional

Unused by this visualization.

shm_coeffslist of str or None, optional

Unused by this visualization.

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 a Streamline3D or ClusterStreamline3D from a loaded tractogram.

Parameters:
inputtuple

Tuple of (sft, filename) or (sft,), where sft is a StatefulTractogram.

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_colorsstr or tuple of float or None, optional

"random" picks the next color from colormap; "direction" or a 3- or 4-value tuple in [0, 1] is used as-is; any other string raises ValueError. If None, color is used unchanged.

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:
Streamline3D or ClusterStreamline3D

The created streamline visualization; a ClusterStreamline3D when is_cluster is True, otherwise a Streamline3D.

Raises:
ValueError

If input is not a 1- or 2-element tuple, or if tract_colors is a string other than "random"/"direction" and is not a 3- or 4-value tuple.

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 or None

Fury actor (line or tube container) ready to parent under a Group, or None when line_type is neither "Line" nor "Tube".

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

A triangular mesh surface rendered with a Phong or basic material.

Parameters:
namestr

Display name used in the Skyline UI.

verticesndarray

Vertex positions of the surface mesh, shape (N, 3).

facesndarray

Triangle face indices into vertices, shape (M, 3).

affinendarray, optional

Voxel-to-world affine; accepted but not currently used by this class.

colortuple(float, float, float), optional

RGB color applied to the surface mesh, in [0, 1].

opacityint, optional

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

texturendarray, optional

Texture image; accepted but not currently applied to the rendered mesh.

materialstr, optional

Material type for the mesh ("phong" or "basic").

render_callbackcallable, optional

Callback used to request a render/update.

Attributes:
actor

The mesh actor rendering the surface.

viz_type

The visualization type identifier derived from the subclass name.

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

Draw the ImGui controls for surface opacity and color.

renderer(is_open, *[, group_visible])

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

property actor#

The mesh actor rendering the surface.

Returns:
Mesh

The actor of the surface visualization.

render_widgets()[source]#

Draw the ImGui controls for surface opacity and color.

Renders an opacity slider and a color picker; committing a new color rebuilds the mesh actor via _create_surface_actor().

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 a Surface visualization from already-loaded mesh data.

Parameters:
inputtuple

Tuple of (vertices, faces, filename) or (vertices, faces) holding already-loaded mesh vertices and faces, with an optional filename.

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.

Raises:
ValueError

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

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.