magmap.gui.vis_3d module

class magmap.gui.vis_3d.Vis3D(scene)[source]

Bases: object

3D visualization object for handling Mayavi/VTK tasks.

Variables:
  • scene – Mayavi scene.

  • fn_update_coords – Callback to update coordinates; defaults to None.

  • surfaces – List of Mayavi surfaces for each displayed channel; defaults to None.

  • blobs3d – List of Mayavi glyphs, where each glyph typically contains many 3D points representing blob positions; defaults to None.

  • blobs3d_in – Mayavi glyphs of blobs inside the ROI; defaults to None.

  • matches3d – Mayavi glyphs of blob matches; defaults to None.

clear_scene()[source]

Clear the scene.

plot_2d_shadows(roi, flipz=False)[source]

Plots 2D shadows in each axis around the 3D visualization.

Parameters:
  • roi (numpy.ndarray) – Region of interest.

  • flipz (bool) – True to invert roi along z-axis to match handedness of Matplotlib with z progressing upward; defaults to False.

plot_3d_points(roi, channel, flipz=False, offset=None)[source]

Plots all pixels as points in 3D space.

Points falling below a given threshold will be removed, allowing the viewer to see through the presumed background to masses within the region of interest.

Parameters:
  • roi (numpy.ndarray) – Region of interest either as a 3D z,y,x or 4D z,y,x,c array.

  • channel (int) – Channel to select, which can be None to indicate all channels.

  • flipz (bool) – True to invert the ROI along the z-axis to match the handedness of Matplotlib with z progressing upward; defaults to False.

  • offset (Sequence[int]) – Origin coordinates in z,y,x; defaults to None.

Returns:

True if points were rendered, False if no points to render.

Return type:

bool

plot_3d_surface(roi, channel, segment=False, flipz=False, offset=None)[source]

Plots areas with greater intensity as 3D surfaces.

The scene will be cleared before display.

Parameters:
  • roi (numpy.ndarray) – Region of interest either as a 3D z,y,x or 4D z,y,x,c array.

  • channel (int) – Channel to select, which can be None to indicate all channels.

  • segment (bool) – True to denoise and segment roi before displaying, which may remove artifacts that might otherwise lead to spurious surfaces. Defaults to False.

  • flipz (default: False) – True to invert roi along z-axis to match handedness of Matplotlib with z progressing upward; defaults to False.

  • offset (Sequence[int]) – Origin coordinates in z,y,x; defaults to None.

Returns:

List of Mayavi surfaces for each displayed channel, which are also stored in surfaces.

Return type:

list

show_blobs(blobs, segs_in_mask, cmap, roi_offset, roi_size, show_shadows=False, flipz=None, clear=False)[source]

Show 3D blobs as points.

Parameters:
  • blobs (Blobs) – Detected blobs. Blob matches will also be displayed.

  • segs_in_mask (ndarray) – Boolean mask for segments within the ROI; all other segments are assumed to be from padding and border regions surrounding the ROI.

  • cmap (ndarray) – Colormap as a 2D Numpy array in the format [[R, G, B, alpha], ...].

  • roi_offset (Sequence[int]) – Region of interest offset in z,y,x.

  • roi_size (Sequence[int]) – Region of interest size in z,y,x. Used to show the ROI outline.

  • show_shadows (bool, default: False) – True if shadows of blobs should be depicted on planes behind the blobs; defaults to False.

  • flipz (Optional[bool], default: None) – True to invert blobs along the z-axis to match the handedness of Matplotlib with z progressing upward; defaults to False.

  • clear (bool, default: False) – Clear existing blobs before showing new ones.

Returns:

  • scale: the current size of glyphs

  • mask: the mask size for glyphs, the denominator for the fraction of glyphs displayed

Return type:

Tuple of

show_roi_outline(roi_offset, roi_size)[source]

Show plot outline to show ROI borders.

Parameters:
  • roi_offset (Sequence[int]) – Region of interest offset in z,y,x.

  • roi_size (Sequence[int]) – Region of interest size in z,y,x.

Returns:

Outline object.

Return type:

mayavi.modules.outline.Outline

update_img_display(minimum=None, maximum=None, brightness=None, contrast=None, alpha=None)[source]

Update the displayed image settings.

Parameters:
  • minimum (float) – Minimum intensity.

  • maximum (float) – Maximum intensity.

  • brightness (float) – Brightness gamma.

  • contrast (float) – Contrast factor.

  • alpha (float) – Opacity, from 0-1, where 1 is fully opaque.

Returns: