scallops.visualize.composite.montage_plot

scallops.visualize.composite.montage_plot(image, percentile_min=0.0, percentile_max=99.0, pad_min=100, pad_max=3000, figsize=None, thresholds=None, row_labels=None, col_labels=None, crop=None, display_t=False, cmap=None)

Plot an image montage, which is a composite view of multiple images arranged in a grid.

A montage provides a compact visualization of multiple images, often used in scientific and medical imaging to compare variations or features across different samples or channels.

Parameters:
  • image (DataArray | Experiment) – XArray with dimensions (t, c, z, y, x) or (i, t, c, z, y, x).

  • percentile_min (Sequence[float] | float) – Lower percentile used to calculate contrasting thresholds. If a list, different percentiles per channel.Default is 0.0. If a number, the same percentile is applied for all channels.

  • percentile_max (Sequence[float] | float) – Upper percentile used to calculate contrasting thresholds. If a list, different percentiles per channel. Default is 99.0. If a number, the same percentile is applied for all channels.

  • pad_min (Sequence[float] | float) – vmin = tmin - pad_min and vmax = tmax + pad_max. If vectors, different pads per channel. Otherwise, apply the same pad.

  • pad_max (Sequence[float] | float) – vmax = tmax + pad_max. If vectors, different pads per channel. Otherwise, apply the same pad.

  • figsize (tuple[int, int] | None) – Figure size.

  • thresholds (dict[int, tuple[float, float]]) – Optional dictionary that maps channel to a tuple of (tmin, tmax) instead of computing thresholds using percentiles and pad.

  • row_labels (str | Sequence[str] | None) – Image attribute to show along rows (e.g., well_row) or a list of labels.

  • col_labels (str | Sequence[str] | None) – Image attribute to show along columns (e.g., well_row) or a list of labels.

  • crop (int | tuple[int, int, int, int] | None) – Pixel size for cropping each panel at the center (e.g., crop=300 means only show 300x300 at the center) or tuple of (x, y, width, height).

  • display_t (bool | None) – Use the T dimension in rows

  • cmap (None | Sequence[str, str | Colormap] | str | Colormap) – Sequence of colormaps or registered colormap name used to map scalar data to colors.

Example:
# Generate synthetic data for testing
import numpy as np
import xarray as xr
from scallops.visualize import montage_plot

image_data = np.random.rand(t, c, z, y, x)
image = xr.DataArray(image_data, dims=("t", "c", "z", "y", "x"))

# Plot the image montage
montage_plot(
    image.isel(t=0, z=0),
    percentile_min=0,
    percentile_max=1,
    pad_min=0.01,
    pad_max=0.99,
    figsize=(12, 8),
)
plt.show()