linumpy.imaging.visualization#
Volume visualization utilities.
Consolidated from linum_screenshot_omezarr.py and linum_screenshot_omezarr_annotated.py.
Functions#
|
Save orthogonal (XY, XZ, YZ) views of a volume as a figure. |
|
Try to estimate number of input slices from OME-Zarr metadata. |
|
Add Z-slice index labels on the side of a coronal/sagittal view. |
|
Save anatomically-labelled orthogonal views with Z-slice index annotations. |
Module Contents#
- linumpy.imaging.visualization.save_orthogonal_views(image, out_path, z_slice=None, x_slice=None, y_slice=None, cmap='magma', percentile_max=99.9)[source]#
Save orthogonal (XY, XZ, YZ) views of a volume as a figure.
- Parameters:
image (array-like) – 3D volume (Z, Y, X) - as returned by read_omezarr.
out_path (str) – Output figure path (e.g. ‘view.png’).
z_slice (int or None) – Slice indices. Default: center of each axis.
x_slice (int or None) – Slice indices. Default: center of each axis.
y_slice (int or None) – Slice indices. Default: center of each axis.
cmap (str) – Colormap (default ‘magma’).
percentile_max (float) – Values above this percentile are clipped for display.
- Return type:
None
- linumpy.imaging.visualization.estimate_n_slices_from_zarr(zarr_path)[source]#
Try to estimate number of input slices from OME-Zarr metadata.
Checks custom metadata fields, multiscales metadata, sibling slice files in the directory, and falls back to a heuristic estimate.
- linumpy.imaging.visualization.add_z_slice_labels(ax, n_input_slices, img_height, font_size=7, label_every=1, show_lines=False, side='left', slice_ids=None)[source]#
Add Z-slice index labels on the side of a coronal/sagittal view.
- Parameters:
ax (matplotlib axis) – The axis to annotate.
n_input_slices (int) – Number of input slices stacked (e.g. 64 physical slices).
img_height (int) – Height of the displayed image in pixels (Z dimension).
font_size (int) – Font size for labels.
label_every (int) – Label every Nth slice.
show_lines (bool) – Draw horizontal lines at slice boundaries.
side (str) – ‘left’ or ‘right’ for label placement.
slice_ids (list of str or None) – Actual slice IDs (e.g. [‘05’, ‘12’]). If None, uses sequential numbers.
- Return type:
None
- linumpy.imaging.visualization.save_annotated_views(image, out_path, n_input_slices=None, x_slice=None, y_slice=None, font_size=7, label_every=1, show_lines=False, slice_ids=None, zarr_path=None, orientation=None, voxel_size=None, crop_to_tissue=False)[source]#
Save anatomically-labelled orthogonal views with Z-slice index annotations.
- Parameters:
image (array-like) – 3D volume (Z, Y, X).
out_path (str) – Output figure path.
n_input_slices (int or None) – Number of input slices. Auto-detected if zarr_path provided.
x_slice (int or None) – Slice indices. Default: center.
y_slice (int or None) – Slice indices. Default: center.
font_size (int) – Font size for slice labels.
label_every (int) – Label every Nth slice.
show_lines (bool) – Draw horizontal lines at slice boundaries.
slice_ids (list of str or None) – Actual slice IDs to display.
zarr_path (str or None) – If provided, try to auto-detect n_input_slices from metadata.
orientation (str or None) – 3-letter RAS orientation code (e.g.
'RIA'). When provided, panel titles and axis labels use anatomical names (Axial/Coronal/Sagittal) derived from this code instead of the generic'Coronal (ZY)'/'Sagittal (ZX)'defaults.voxel_size (list or None) – Voxel size as [z, y, x] in any consistent unit (e.g. millimetres from
read_omezarr). Used to set the correct physical aspect ratio so that cross-sections look geometrically correct. If None, aspect=’equal’ (1 pixel = 1 pixel, which distorts anisotropic volumes).crop_to_tissue (bool) – When True, crop the volume to the non-zero bounding box (with a small margin) before rendering. This removes empty space caused by motor drift and canvas inflation, making the tissue fill the panels.
- Return type:
None