AFQ.viz.fury_backend

Module Contents

Functions

_inline_interact(scene, inline, interact)

Helper function to reuse across viz functions

visualize_bundles(sft, affine=None, n_points=None, bundle_dict=None, bundle=None, colors=None, shade_by_volume=None, color_by_streamline=None, sbv_lims=[None, None], include_profiles=(None, None), flip_axes=[False, False, False], opacity=1.0, figure=None, background=(1, 1, 1), interact=False, inline=False)

Visualize bundles in 3D using VTK.

scene_rotate_forward(scene)

create_gif(figure, file_name, n_frames=60, zoom=1, z_offset=0.5, size=(600, 600), rotate_forward=True)

Convert a Fury Scene object into a gif

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)

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

visualize_volume(volume, x=None, y=None, z=None, figure=None, flip_axes=None, opacity=0.6, inline=True, interact=False)

Visualize a volume

Attributes

viz_logger

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(sft, affine=None, n_points=None, bundle_dict=None, bundle=None, colors=None, shade_by_volume=None, color_by_streamline=None, sbv_lims=[None, None], include_profiles=(None, None), flip_axes=[False, False, False], opacity=1.0, figure=None, background=(1, 1, 1), interact=False, inline=False)[source]

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

Parameters
sftStateful Tractogram, str

A Stateful Tractogram containing streamline information or a path to a trk file In order to visualize individual bundles, the Stateful Tractogram must contain a bundle key in it’s data_per_streamline which is a list of bundle ‘uid’.

affinendarray, optional

An affine transformation to apply to the streamlines before visualization. Default: no transform.

n_pointsint or None

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

bundle_dictdict, optional

Keys are names of bundles and values are dicts that should include a key ‘uid’ with values as integers for selection from the sft metadata. Default: bundles are either not identified, or identified only as unique integers in the metadata.

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.

shade_by_volumendarray or str, optional

3d volume use to shade the bundles. If None, no shading is performed. Only works when using the plotly backend. Default: None

sbv_limsndarray

Of the form (lower bound, upper bound). Shading based on shade_by_volume will only differentiate values within these bounds. If lower bound is None, will default to 0. If upper bound is None, will default to the maximum value in shade_by_volume. Default: [None, None]

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