Skip to content
Snippets Groups Projects

Simple 3d slicer

1 file
+ 12
2
Compare changes
  • Side-by-side
  • Inline
+ 12
2
"""
Provides a collection of visualization functions.
"""
from typing import List, Optional, Union
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap
from matplotlib import colormaps
@@ -203,8 +204,17 @@ def grid_pred(in_targ_preds, num_images=7, cmap_im="gray", cmap_segm="viridis",
return fig
def slices(vol, axis = 0, position = None, n_slices = 5, cmap = "viridis", img_height = 4, img_width = 4, show = False, show_title = True, interpolation = None):
""" Displays one or several slices from a 3d volume.
def slices(vol: Union[np.ndarray, torch.Tensor],
axis: int = 0,
position: Optional[Union[str, int, List[int]]] = None,
n_slices: int = 5,
cmap: str = "viridis",
img_height: int = 4,
img_width: int = 4,
show: bool = False,
show_title: bool = True,
interpolation: Optional[str] = None) -> plt.Figure:
""" Displays one or several slices from a 3d volume.
By default if `position` is None, slices plots `n_slices` linearly spaced slices.
If `position` is given as a string or integer, slices will plot an overview with `n_slices` figures around that position.
Loading