:py:mod:`AFQ.viz.fury_backend` ============================== .. py:module:: AFQ.viz.fury_backend Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: AFQ.viz.fury_backend._inline_interact AFQ.viz.fury_backend.visualize_bundles AFQ.viz.fury_backend.scene_rotate_forward AFQ.viz.fury_backend.create_gif AFQ.viz.fury_backend.visualize_roi AFQ.viz.fury_backend.visualize_volume AFQ.viz.fury_backend._draw_core AFQ.viz.fury_backend.single_bundle_viz Attributes ~~~~~~~~~~ .. autoapisummary:: AFQ.viz.fury_backend.viz_logger .. py:data:: viz_logger .. py:function:: _inline_interact(scene, inline, interact) Helper function to reuse across viz functions .. !! processed by numpydoc !! .. py:function:: visualize_bundles(sft, n_points=None, bundle_dict=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) Visualize bundles in 3D using VTK. Parameters not described below are extras to conform fury and plotly APIs. :Parameters: **sft** : Stateful 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'`. **n_points** : int or None n_points to resample streamlines to before plotting. If None, no resampling is done. **bundle_dict** : dict, optional Keys are names of bundles and values are dicts that specify them. Default: bundles are either not identified, or identified only as unique integers in the metadata. **bundle** : str 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. **colors** : dict 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_direction** : bool Whether to color by direction instead of by bundle. Default: False **opacity** : float Float between 0 and 1 defining the opacity of the bundle. Default: 1.0 **background** : tuple, optional RGB values for the background. Default: (1, 1, 1), which is white background. **figure** : fury Scene object, optional If provided, the visualization will be added to this Scene. Default: Initialize a new Scene. **interact** : bool Whether to provide an interactive VTK window for interaction. Default: False **inline** : bool Whether to embed the visualization inline in a notebook. Only works in the notebook context. Default: False. :Returns: Fury Scene object .. .. !! processed by numpydoc !! .. py:function:: scene_rotate_forward(scene) .. py:function:: 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 :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 .. !! processed by numpydoc !! .. py:function:: 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 :Parameters: **roi** : str or Nifti1Image The ROI information **affine_or_mapping** : ndarray, 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' **color** : ndarray, optional RGB color for ROI. Default: np.array([1, 0, 0]) **flip_axes** : None This parameter is to conform fury and plotly APIs. **opacity** : float, optional Opacity of ROI. Default: 1.0 **figure** : fury Scene object, optional If provided, the visualization will be added to this Scene. Default: Initialize a new Scene. **interact** : bool Whether to provide an interactive VTK window for interaction. Default: False **inline** : bool Whether to embed the visualization inline in a notebook. Only works in the notebook context. Default: False. :Returns: Fury Scene object .. .. !! processed by numpydoc !! .. py:function:: visualize_volume(volume, x=None, y=None, z=None, figure=None, flip_axes=None, opacity=0.6, inline=True, interact=False) Visualize a volume :Parameters: **volume** : ndarray or str 3d volume to visualize. **figure** : fury Scene object, optional If provided, the visualization will be added to this Scene. Default: Initialize a new Scene. **flip_axes** : None This parameter is to conform fury and plotly APIs. **opacity** : float, optional Initial opacity of slices. Default: 0.6 **interact** : bool Whether to provide an interactive VTK window for interaction. Default: False **inline** : bool Whether to embed the visualization inline in a notebook. Only works in the notebook context. Default: False. :Returns: Fury Scene object .. .. !! processed by numpydoc !! .. py:function:: _draw_core(sls, n_points, figure, bundle_name, indiv_profile, labelled_points, dimensions, flip_axes) .. py:function:: single_bundle_viz(indiv_profile, sft, bundle, scalar_name, bundle_dict=None, flip_axes=[False, False, False], labelled_nodes=[0, -1], figure=None, include_profile=False) Visualize a single bundle in 3D with core bundle and associated profile :Parameters: **indiv_profile** : ndarray A numpy array containing a tract profile for this bundle for a scalar. **sft** : Stateful Tractogram, str A Stateful Tractogram containing streamline information. If bundle is an int, the Stateful Tractogram must contain a bundle key in it's data_per_streamline which is a list of bundle `'uid'. Otherwise, the entire Stateful Tractogram will be used as the bundle for the visualization. **bundle** : str or int The name of the bundle to be used as the label for the plot, and for selection from the sft metadata. **scalar_name** : str The name of the scalar being used. **bundle_dict** : dict, optional This parameter is used if bundle is an int. Keys are names of bundles and values are dicts that specify them. Default: Either the entire sft is treated as a bundle, or identified only as unique integers in the metadata. **flip_axes** : ndarray 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_nodes** : list or ndarray Which nodes to label. -1 indicates the last node. Default: [0, -1] **figure** : Plotly Figure object, optional If provided, the visualization will be added to this Figure. Default: Initialize a new Figure. **include_profile** : bool, optional Not yet implemented in fury. Default: False :Returns: Fury Figure object .. .. !! processed by numpydoc !!