snake.toolkit.plotting#

Plotting utilities for the project.

Module Contents#

Functions#

get_coolgraywarm

Get a cool-warm colorbar, with gray inside the threshold.

_get_axis_properties

Generate mplt toolkit axes dividers for a 3D array.

_get_hdiv_vdiv

get_mask_cuts_mask

Get the optimal cut that expose maximum number of voxel in mask.

plot_frames_activ

Plot activation maps and background.

axis3dcut

Display a 3D image with zscore and ground truth ROI.

API#

snake.toolkit.plotting.get_coolgraywarm(thresh: float = 3, max: float = 7) matplotlib.colorbar.Colorbar[source]#

Get a cool-warm colorbar, with gray inside the threshold.

snake.toolkit.plotting._get_axis_properties(array_bg: numpy.typing.NDArray, cuts: tuple[int, ...], width_inches: float, cbar: bool = True, arr_pad: int = 4, tight_crop: bool = True) tuple[numpy.typing.NDArray, numpy.typing.NDArray, tuple[tuple[slice, slice], ...], tuple[tuple[Any, Any, Any], ...]][source]#

Generate mplt toolkit axes dividers for a 3D array.

Parameters:
  • array_bg (3D array) – The 3D array to display.

  • cuts (tuple) – The cuts to performs to create 3 2D array to display.

  • width_inches (float) – The width of the figure in inches.

  • cbar (bool) – Display the colorbar.

  • arr_pad (int) – Padding to add to the bounding box.

  • tight_crop (bool, default True) – If True, crop the image to their bounding box, to remove empty space.

Returns:

  • hdiv (np.ndarray) – The horizontal division.

  • vdiv (np.ndarray) – The vertical division.

  • bbox (tuple) – The bounding box of the 2D arrays cuts.

  • slices (tuple) – The slices to take from the 3D array.

snake.toolkit.plotting._get_hdiv_vdiv(array_bg: numpy.typing.NDArray, bbox: tuple[tuple[slice]], slices: tuple[slice], width_inches: float, cbar: bool = False) tuple[numpy.typing.NDArray, numpy.typing.NDArray][source]#
snake.toolkit.plotting.get_mask_cuts_mask(mask: numpy.typing.NDArray) tuple[int, ...][source]#

Get the optimal cut that expose maximum number of voxel in mask.

snake.toolkit.plotting.plot_frames_activ(background: numpy.typing.NDArray, z_score: numpy.typing.NDArray, roi: numpy.typing.NDArray | None, ax: matplotlib.pyplot.Axes, slices: tuple[Any, ...], bbox: tuple[Any, ...], z_thresh: float = 3, z_max: float = 11, bg_cmap: str = 'gray') tuple[matplotlib.pyplot.Axes, matplotlib.image.AxesImage][source]#

Plot activation maps and background.

Parameters:
  • background (3D array)

  • z_score (3D array)

  • roi (3D array)

  • ax (plt.Axes)

  • slices (tuple)

  • bbox (tuple)

  • z_thresh (float)

  • z_max (float)

  • bg_cmap (str)

snake.toolkit.plotting.axis3dcut(background: numpy.typing.NDArray[numpy.float32], z_score: numpy.typing.NDArray[numpy.float32] | None, gt_roi: numpy.typing.NDArray | None = None, width_inches: float = 7, cbar: bool = True, cuts: tuple[int, ...] | tuple[float, ...] | None = None, bbox: tuple[tuple[Any, Any], ...] | None = None, slices: tuple[tuple[Any, Any, Any], ...] | None = None, bg_cmap: str = 'gray', ax: matplotlib.pyplot.Axes | None = None, vmin_vmax: tuple[float] = None, z_thresh: float = 3, z_max: float = 11, tight_crop: bool = True) tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes, tuple[int, ...]][source]#

Display a 3D image with zscore and ground truth ROI.

This function is used to display a 3D brain image with optional overlay for the z-score and the ground truth ROI outline.

Parameters:
  • background (3D array) – The background image to display.

  • z_score (3D array, optional) – The z-score activation map to display, thresholded at z_thresh.

  • gt_roi (3D array, optional) – The ground truth ROI to display. If None, no ROI is displayed.

  • width_inches (float, optional) – The width of the figure in inches.

  • cbar (bool, optional) – Display the colorbar.

  • cuts (tuple, optional) – The cuts to performs to create 3 2D array to display. If None, the cuts are computed, such that the ROI is maximally exposed.

  • bbox (tuple, optional) – The bounding box to display.

  • slices (tuple, optional) – The slices to display.

  • bg_cmap (str, optional) – The colormap for the background image.

  • ax (plt.Axes, optional) – The axes to use to display the image.

  • vmin_vmax (tuple, optional) – The vmin and vmax to use for the background image.

  • z_thresh (float, optional) – The threshold to use for the z-score.

  • z_max (float, optional) – The maximum value for the z-score.

  • tight_crop (bool, optional) – If True, crop the image to their bounding box, to remove empty space.

Returns:

  • fig (plt.Figure) – The figure.

  • ax (plt.Axes) – The axes.