snake.toolkit.plotting
#
Plotting utilities for the project.
Module Contents#
Functions#
Get a cool-warm colorbar, with gray inside the threshold. |
|
Generate mplt toolkit axes dividers for a 3D array. |
|
Get the optimal cut that expose maximum number of voxel in mask. |
|
Plot activation maps and background. |
|
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.
- 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.