Volumetric Plotting#

A 3D volume figure may be created as follows.

visualization.volumetric.create_figure()#

Create a Plotter/Figure object to draw the visualization.

Returns:

fig – Plot/Figure object used to preview the visualization.

Return type:

pyvista.Plotter

Data may be added to the figure via,

visualization.volumetric.add_structure(fig, path, name, color=None, opacity=None, invert_x=False, invert_y=False, invert_z=False)#

Add structures to the visualization.

Parameters:
  • fig (pyvista.Plotter) – Plot/Figure object used to preview the visualization.

  • path (str) – Path to the to be added structure (*.obj format).

  • name (str) – Name of the added structure.

  • color (string) – Color of the points. Defaults to grey.

  • opacity (float) – Opacitiy of the added structure. Defaults to 0.5.

Returns:

mesh – Pyvista object representing the added structure.

Return type:

pyvista.core.pointset.PolyData

visualization.volumetric.add_volume(fig, pts, name, grid_step_cnt=100, max_filter_sz=10, gaussian_filter_sigma=6, opacity=None)#

Add a volume to the visulization. This function may be used to plot 3D heatmaps.

Parameters:
  • fig (pyvista.Plotter) – Plot/Figure object used to preview the visualization.

  • pts (np.ndarray, shape(n, 4) or shape(n, 6)) – Datapoints used to compute the volume/heatmap. Dimensions are x, y, z, and color.

  • name (str) – Name of the added volume.

  • grid_step_cnt (int) – Resolution of the pointcloud: Defaults to 100.

  • max_filter_sz (int) – Employed to make points bigger, for a more cohesive heatmap. Defaults to 10.

  • gaussian_filter_sigma (int) – Employed to blur the volume, making it appear more cohesive. Defaults to 6.

  • opacity (float) – Opacitiy of the added structure. Default: 0.5.

Returns:

mesh – Pyvista object representing the added volume.

Return type:

pyvista.core.pointset.ImageData

visualization.volumetric.add_polygon(fig, pts, faces, name, opacity)#

Add a polygon to the visualization.

Parameters:
  • fig (pyvista.Plotter) – Plot/Figure object used to preview the visualization.

  • pts (np.ndarray, shape(n_pts, 3)) – Points/Vertices defining the polygon.

  • faces (np.ndarray, shape(face_cnt, vtx_cnt) or shape(face_cnt * (vtx_cnt + 1),)) – Faces connect the individual vertices. These have to passed as either list of lists wherein the inner lists are individual faces (e.g. [[1, 2, 3], [1, 4, 3]]) or as a flattened list wherein each face starts with a number identifying the amount of vertices used in the next face (e.g. [3, 1, 2, 3, 3, 1, 4, 3]).

  • name (str) – Name of the added structure.

  • opacity (float) – Opacitiy of the added structure. Defaults to 0.5.

Returns:

mesh – Pyvista object representing the added structure.

Return type:

pyvista.core.pointset.PolyData

visualization.volumetric.add_cen_grav(fig, pts)#

Add a center of gravity to the visualization.

Parameters:
  • fig (pyvista.Plotter) – Plot/Figure object used to preview the visualization.

  • pts (np.ndarray, shape(n, 3)) – Datapoints used to compute the center of gravity from.

The figure can be configured as follows,

visualization.volumetric.add_axes(fig)#

Add axes to plot.

Parameters:

fig (pyvista.Plotter) – Plot/Figure object used to preview the visualization.

visualization.volumetric.set_black_background(fig)#

Set background to black.

Parameters:

fig (pyvista.Plotter) – Plot/Figure object used to preview the visualization.

The figure can be displayed via,

visualization.volumetric.show_figure(fig, screenshot_name)#

Show the pyvista plotter.

Parameters:
  • fig (pyvista.Plotter) – Plot/Figure object used to preview the visualization.

  • screenshot_name (string) – Name of the to be printed file.

The figure may be exported to blender via,

visualization.volumetric.export_to_blender(structs, volumes, vti_vtb_converter=None, outpath=None)#

Export structures and volumes to blender.

Parameters:
  • structs (list, pyvista.core.pointset.PolyData) – List of structures to be exported.

  • volumes (list, pyvista.core.pointset.ImageData) – List of volumes to be exported.

  • vti_vtb_converter (String) – Path to the vti to vtb converter. Code is available at neurophysiological-analysis/FiNN_extensions and needs to be compiled.

  • outpath (String) – Path to write the exported files to. Default is local directory ‘.’.