scilpy.viz package
scilpy.viz.chord_chart module
scilpy.viz.gradient_sampling module
scilpy.viz.scene_utils module
scilpy.viz.screenshot module
- scilpy.viz.screenshot.compose_image(img_scene, img_size, slice_number, corner_position=(0, 0), transparency_scene=None, image_alpha=1.0, labelmap_scene=None, labelmap_overlay_alpha=0.7, overlays_scene=None, overlays_alpha=0.7, overlays_colors=None, peaks_overlay_scene=None, peaks_overlay_alpha=0.7, display_slice_number=False, display_lr=False, lr_labels=['L', 'R'], canvas=None)[source]
Compose an image with the given scenes, with transparency, overlays, labelmap and annotations. If no canvas for the image is given, it will be automatically created with sizings to fit.
- Parameters:
img_scene (np.ndarray) – Image scene data.
img_size (array-like) – Image size (pixels) (width, height).
slice_number (int) – Number of the current slice.
corner_position (array-like) – Image corner (pixels) (left, top).
transparency_scene (np.ndarray, optional) – Transaprency scene data.
image_alpha (float) – Alpha value for the image in range [0, 1].
labelmap_scene (np.ndarray, optional) – Labelmap scene data.
labelmap_alpha (float) – Alpha value for labelmap overlay in range [0, 1].
overlays_scene (np.ndarray, optional) – Overlays scene data.
overlays_alpha (float) – Alpha value for the overlays in range [0, 1].
overlays_colors (list, optional) – Colors for the overlays as a list of 3 integers in range [0, 255].
peaks_overlay_scene (np.ndarray, optional) – Peaks overlay scene data.
peaks_overlay_alpha (float) – Alpha value for peaks overlay in range [0, 1].
display_slice_number (bool) – If true, displays the slice number in the upper left corner.
display_lr (bool or int) – If 1 or -1, annotates the left and right sides on the image. -1 flips left and right positions.
lr_labels (list) – Labels used to annotate the left and right sides of the image.
canvas (PIL.Image, optional) – Base canvas into which to paste the scene.
- Returns:
canvas – Canvas containing the pasted scene.
- Return type:
PIL.Image
- scilpy.viz.screenshot.compose_mosaic(img_scene_container, cell_size, rows, cols, slice_numbers, overlap_factor=None, transparency_scene_container=None, image_alpha=1.0, labelmap_scene_container=None, labelmap_overlay_alpha=0.7, overlays_scene_container=None, overlays_alpha=0.7, overlays_colors=None, display_slice_number=False, display_lr=False, lr_labels=['L', 'R'])[source]
Create the mosaic canvas for given number of rows and columns, and the requested cell size and overlap values.
- Parameters:
img_scene_container (list) – Image scene data container.
cell_size (array-like) – Cell size (pixels) (width, height).
rows (int) – Row count.
cols (int) – Column count.
overlap_factor (array-like) – Overlap factor (horizontal, vertical).
transparency_scene_container (iterable) – Transaprency scene data container.
image_alpha (float) – Alpha value for the image in range [0, 1].
labelmap_scene_container (iterable) – Labelmap scene data container.
overlays_scene_container (iterable) – Overlays scene data container.
overlays_alpha (float) – Alpha value for the overlays in range [0, 1].
overlays_colors (list, optional) – Color for the overlays as a list of 3 integers in range [0, 255].
display_slice_number (bool) – If true, displays the slice number in the upper left corner.
display_lr (bool or int) – If 1 or -1, annotates the left and right sides on the image. -1 flips left and right positions.
lr_labels (list) – Labels used to annotate the left and right sides of the image.
- Returns:
mosaic – Canvas containing the mosaic scene.
- Return type:
PIL.Image
- scilpy.viz.screenshot.screenshot_contour(bin_img, orientation, slice_ids, size, bg_opacity=0.0)[source]
Take a screenshot of the given binary image countour with the appropriate slice data at the provided slice indices.
- Parameters:
bin_img (nib.Nifti1Image) – Binary volume image.
orientation (str) – Slicing axis name.
slice_ids (array-like) – Slice indices.
size (array-like) – Size of the screenshot image (pixels).
bg_opacity (float) – Background opacity in range [0, 1].
- Returns:
snapshots – Scene screenshots generator.
- Return type:
generator
- scilpy.viz.screenshot.screenshot_peaks(img, orientation, slice_ids, size, mask_img=None)[source]
Take a screenshot of the given peaks image at the provided slice indices.
- Parameters:
img (nib.Nifti1Image) – Peaks volume image.
orientation (str) – Slicing axis name.
slice_ids (array-like) – Slice indices.
size (array-like) – Size of the screenshot image (pixels).
- Returns:
snapshots – Scene screenshots generator.
- Return type:
generator
- scilpy.viz.screenshot.screenshot_volume(img, orientation, slice_ids, size, labelmap=None)[source]
Take a screenshot of the given volume at the provided slice indices.
- Parameters:
img (nib.Nifti1Image) – Volume image.
orientation (str) – Slicing axis name.
slice_ids (array-like) – Slice indices.
size (array-like) – Size of the screenshot image (pixels).
- Returns:
snapshots – Scene screenshots generator.
- Return type:
generator
scilpy.viz.utils module
- scilpy.viz.utils.affine_from_offset(orientation, offset)[source]
Create an affine matrix from a scalar offset in given orientation, in RPS coordinates for imaging.
- Parameters:
orientation (str) – Name of the axis to visualize. Choices are axial, coronal and sagittal.
offset (float) – The offset of the texture image.
- Returns:
affine – The affine transformation.
- Return type:
np.ndarray
- scilpy.viz.utils.check_mosaic_layout(img_count, rows, cols)[source]
Check whether a mosaic can be built given the image count and the requested number of rows and columns. Raise a ValueError if it cannot be built.
- Parameters:
img_count (int) – Image count to be arranged in the mosaic.
rows (int) – Row count.
cols (int) – Column count.
- scilpy.viz.utils.compute_cell_topleft_pos(idx, cols, offset_h, offset_v)[source]
Compute the top-left position of a cell to be drawn in a mosaic.
- Parameters:
idx (int) – Cell index in the mosaic.
cols (int) – Column count.
offset_h – Horizontal offset (pixels).
offset_v – Vertical offset (pixels).
- Returns:
top_pos (int) – Top position (pixels).
left_pos (int) – Left position (pixels).