AFQ.viz.fury_backend#

Attributes#

Functions#

_inline_interact(scene, inline, interact)

Helper function to reuse across viz functions

visualize_bundles(seg_sft[, img, n_points, bundle, ...])

Visualize bundles in 3D using VTK.

scene_rotate_forward(show_m, scene)

create_gif(figure, file_name[, n_frames, az_ang, size])

Convert a Fury Scene object into a gif

visualize_roi(roi[, resample_to, name, figure, color, ...])

Render a region of interest into a VTK viz as a volume

visualize_volume(volume[, x, y, z, figure, flip_axes, ...])

Visualize a volume

_draw_core(sls, n_points, figure, bundle_name, ...)

single_bundle_viz(indiv_profile, seg_sft, bundle, ...)

Visualize a single bundle in 3D with core bundle and associated profile

Module Contents#

AFQ.viz.fury_backend.viz_logger[source]#
AFQ.viz.fury_backend._inline_interact(scene, inline, interact)[source]#

Helper function to reuse across viz functions

AFQ.viz.fury_backend.visualize_bundles(seg_sft, img=None, n_points=None, bundle=None, colors=None, color_by_direction=False, opacity=1.0, line_width=2.0, flip_axes=None, figure=None, background=(1, 1, 1), interact=False, inline=False, **kwargs)[source]#

Visualize bundles in 3D using VTK. Parameters not described below are extras to conform fury and plotly APIs.

Parameters:
seg_sftSegmentedSFT, str

A SegmentedSFT containing streamline information or a path to a segmented trk file.

imgNifti1Image, optional

Image to register streamlines to. Default: None

n_pointsint or None

n_points to resample streamlines to before plotting. If None, no resampling is done.

bundlestr or int, optional

The name of a bundle to select from among the keys in bundle_dict or an integer for selection from the sft metadata.

colorsdict or list

If this is a dict, keys are bundle names and values are RGB tuples. If this is a list, each item is an RGB tuple. Defaults to a list with Tableau 20 RGB values if bundle_dict is None, or dict from bundles to Tableau 20 RGB values if bundle_dict is not None.

color_by_directionbool

Whether to color by direction instead of by bundle. Default: False

opacityfloat

Float between 0 and 1 defining the opacity of the bundle. Default: 1.0

backgroundtuple, optional

RGB values for the background. Default: (1, 1, 1), which is white background.

figurefury Scene object, optional

If provided, the visualization will be added to this Scene. Default: Initialize a new Scene.

interactbool

Whether to provide an interactive VTK window for interaction. Default: False

inlinebool

Whether to embed the visualization inline in a notebook. Only works in the notebook context. Default: False.

Returns:
Fury Scene object
AFQ.viz.fury_backend.scene_rotate_forward(show_m, scene)[source]#
AFQ.viz.fury_backend.create_gif(figure, file_name, n_frames=36, az_ang=-10, size=(600, 600))[source]#

Convert a Fury Scene object into a gif

Make a video from a Fury Show Manager.

Parameters:
figureFury Scene object

The Fury Scene object to render.

file_namestr

The name of the output file.

n_framesint

The number of frames to render. Default: 36

az_angfloat

The angle to rotate the camera around the z-axis for each frame, in degrees. Default: -10

sizetuple

The size of the output gif, in pixels. Default: (600, 600)

AFQ.viz.fury_backend.visualize_roi(roi, resample_to=None, name='ROI', figure=None, color=None, flip_axes=None, opacity=1.0, inline=False, interact=False)[source]#

Render a region of interest into a VTK viz as a volume

Parameters:
roistr or Nifti1Image

The ROI information

resample_toNifti1Image, optional

If not None, the ROI will be resampled to the space of this image. Default: None

name: str, optional

Name of ROI for the legend. Default: ‘ROI’

colorndarray, optional

RGB color for ROI. Default: np.array([1, 0, 0])

flip_axesNone

This parameter is to conform fury and plotly APIs.

opacityfloat, optional

Opacity of ROI. Default: 1.0

figurefury Scene object, optional

If provided, the visualization will be added to this Scene. Default: Initialize a new Scene.

interactbool

Whether to provide an interactive VTK window for interaction. Default: False

inlinebool

Whether to embed the visualization inline in a notebook. Only works in the notebook context. Default: False.

Returns:
Fury Scene object
AFQ.viz.fury_backend.visualize_volume(volume, x=None, y=None, z=None, figure=None, flip_axes=None, opacity=0.6, inline=True, interact=False)[source]#

Visualize a volume

Parameters:
volumendarray or str

3d volume to visualize.

figurefury Scene object, optional

If provided, the visualization will be added to this Scene. Default: Initialize a new Scene.

flip_axesNone

This parameter is to conform fury and plotly APIs.

opacityfloat, optional

Initial opacity of slices. Default: 0.6

interactbool

Whether to provide an interactive VTK window for interaction. Default: False

inlinebool

Whether to embed the visualization inline in a notebook. Only works in the notebook context. Default: False.

Returns:
Fury Scene object
AFQ.viz.fury_backend._draw_core(sls, n_points, figure, bundle_name, indiv_profile, labelled_points, dimensions, flip_axes)[source]#
AFQ.viz.fury_backend.single_bundle_viz(indiv_profile, seg_sft, bundle, scalar_name, img=None, flip_axes=None, labelled_nodes=None, figure=None, include_profile=False)[source]#

Visualize a single bundle in 3D with core bundle and associated profile

Parameters:
indiv_profilendarray

A numpy array containing a tract profile for this bundle for a scalar.

seg_sftSegmentedSFT, str

A SegmentedSFT containing streamline information or a path to a segmented trk file.

bundlestr or int

The name of the bundle to be used as the label for the plot, and for selection from the sft metadata.

scalar_namestr

The name of the scalar being used.

imgNifti1Image, optional

Image to register streamlines to. Default: None

flip_axesndarray

Which axes to flip, to orient the image as RAS, which is how we visualize. For example, if the input image is LAS, use [True, False, False]. Default: [False, False, False]

labelled_nodeslist or ndarray

Which nodes to label. -1 indicates the last node. Default: [0, -1]

figurePlotly Figure object, optional

If provided, the visualization will be added to this Figure. Default: Initialize a new Figure.

include_profilebool, optional

Not yet implemented in fury. Default: False

Returns:
Fury Figure object