Single-cell image mosaic#
This example delegates h5sc tile preparation, edge filtering, and Apple-GPU photomosaic matching to scportrait.art.create_h5sc_collage. Make sure to install the required optional dependencies via pip install scportrait[art]
[1]:
from pathlib import Path
import numpy as np
import scportrait
from scportrait.art import create_h5sc_collage
/Users/niklas/mamba/envs/260831_scp_art/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
from .autonotebook import tqdm as notebook_tqdm
[2]:
datasets = scportrait.data.autophagosome_h5sc()
[10]:
h5sc_path = Path(datasets[1])
master_png = Path("../../_static/scPortrait_logo_text.png")
output_png = Path("scPortrait_mosaic.png")
# RGB triplets
colors = np.array(
[
[215, 25, 32],
[255, 209, 5],
[59, 77, 129],
# Add black for background
[0, 0, 0],
],
dtype=np.float32,
)
[24]:
result = create_h5sc_collage(
master_png=master_png,
h5sc_path=h5sc_path,
colors=colors,
grid_width=50,
n_samples_per_color=7,
crop_size=128,
channel_indices=slice(2, 6),
edge_fraction_threshold=0.20,
random_seed=492755,
max_cell_uses=9, # Maximum uses of each colorized channel/cell tile
master_batch_size=128,
tile_batch_size=10_000,
output_path=output_png,
)
result.show()
Building mosaic: 100%|██████████| 500/500 [00:00<00:00, 25805.07it/s]
[ ]: