AFQ.viz.fury_backend#

Module Contents#

Functions#

_inline_interact(scene, inline, interact)

Helper function to reuse across viz functions

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

Visualize bundles in 3D using VTK.

scene_rotate_forward(scene)

create_gif(figure, file_name[, n_frames, zoom, ...])

Convert a Fury Scene object into a gif

visualize_roi(roi[, affine_or_mapping, static_img, ...])

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

Attributes#

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, n_points=None, bundle=None, colors=None, color_by_direction=False, opacity=1.0, line_width=2.0, flip_axes=[False, False, False], 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.

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(scene)[source]#
AFQ.viz.fury_backend.create_gif(figure, file_name, n_frames=60, zoom=1, z_offset=0.5, size=(600, 600), rotate_forward=True)[source]#

Convert a Fury Scene object into a gif

Parameters
figure: Fury Scene object

Scene to be converted to a gif

file_name: str

File to save gif to.

n_frames: int, optional

Number of frames in gif. Will be evenly distributed throughout the rotation. Default: 60

zoom: int, optional

How much to magnify the figure in the fig. Default: 1

size: tuple, optional

Size of the gif. Default: (600, 600)

rotate_forward: bool, optional

Whether to rotate the figure forward before converting to a gif. Generally necessary for fury scenes. Default: True

AFQ.viz.fury_backend.visualize_roi(roi, affine_or_mapping=None, static_img=None, roi_affine=None, static_affine=None, reg_template=None, name='ROI', figure=None, color=np.array([1, 0, 0]), 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

affine_or_mappingndarray, Nifti1Image, or str, optional

An affine transformation or mapping to apply to the ROIs before visualization. Default: no transform.

static_img: str or Nifti1Image, optional

Template to resample roi to. Default: None

roi_affine: ndarray, optional

Default: None

static_affine: ndarray, optional

Default: None

reg_template: str or Nifti1Image, optional

Template to use for registration. 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, flip_axes=[False, False, False], labelled_nodes=[0, -1], 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.

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