QuickstartΒΆ

  1. Install ryomen with pip install ryomen -U

  2. Load a large microscopy image, create the slicer, and initialize an array to store the outputs

from skimage.io import imread
from ryomen import Slicer
import numpy as np

huge_tilescan = imread('my_huge_tilescan.tif')   # shape is [C, X, Y] -> [3, 1000, 1000]
output = np.zeros_like(huge_tilescan)

slices = Slicer(
    image=huge_tilescan,   # your image
    crop_size=(512, 512),  # sliced up into 512x512 tiles
    overlap=(64, 64),      # with 64px of overlap
    pad=True,              # padded with reflection
    batch_size=1           # batched one at a time
)
  1. Iterate over the slices

  2. Perform some expensive function on the slices

  3. slot the data from the expensive function into the output array

expensive_fn = lambda x: x + 1  # might be a ML model, huge filter, etc...

for crop, source, destination in slices:
    crop = expensive_fn(crop)
    
    # Take the non-overlapping data from crop and
    # put it in the output array
    output[destination] = crop[source]