art#
Utilities for artistic visualizations created from scPortrait datasets.
Artistic visualizations created from scPortrait datasets.
- scportrait.art.create_h5sc_collage(master_png: str | PathLike[str], h5sc_path: str | PathLike[str], colors: ndarray, *, grid_width: int, n_samples_per_color: int = 200, crop_size: int = 200, channel_indices: slice = slice(2, 6, None), dataset_key: str = 'obsm/single_cell_images', edge_fraction_threshold: float | None = 0.2, random_seed: int | None = 492755, max_cell_uses: int = 1, master_batch_size: int = 128, tile_batch_size: int = 10000, output_path: str | PathLike[str] | None = None) Any#
Create a photomosaic from colorized h5sc single-cell images.
- Parameters:
master_png – PNG image to recreate as a collage.
h5sc_path – An h5sc file or a directory containing
*.h5scor*.h5files.colors – RGB colors of shape
(n_colors, 3)in the 0–255 range.grid_width – Number of mosaic tiles across the output.
n_samples_per_color – Unique cells sampled per color and input h5 file.
crop_size – Side length of each centered square crop in pixels.
channel_indices – Channels combined into each colorized tile.
dataset_key – HDF5 dataset containing images shaped
(cell, channel, y, x). Defaults to the standardized scPortrait h5sc location.edge_fraction_threshold – Discard tiles with a greater nonzero edge fraction. Set to
Noneto keep every tile.random_seed – Seed used for reproducible cell sampling; set to
Nonefor random sampling.max_cell_uses – Maximum number of times a colorized channel/cell tile may appear in the mosaic.
master_batch_size – Number of master cells processed per MPS calculation batch.
tile_batch_size – Number of source tiles processed per MPS calculation batch.
output_path – Optional path where the completed collage is saved.
- Returns:
The image result returned by
phomo.Mosaic.build.
Example
```python from scportrait.art import create_h5sc_collage
- result = create_h5sc_collage(
master_png=”master.png”, h5sc_path=”cells/”, colors=[[179, 38, 42], [47, 85, 154]], grid_width=60, output_path=”mosaic.png”,
)#