{ "cells": [ { "cell_type": "markdown", "metadata": { "collapsed": true, "pycharm": { "name": "#%% md\n" } }, "source": [ "\n", "Quickstart\n", "==========\n", "\n", "1) Install ryomen with `pip install ryomen -U`\n", "\n", "2) Load a large microscopy image, create the slicer, and initialize an array to store the outputs" ] }, { "cell_type": "code", "execution_count": null, "outputs": [], "source": [ "from skimage.io import imread\n", "from ryomen import Slicer\n", "import numpy as np\n", "\n", "huge_tilescan = imread('my_huge_tilescan.tif') # shape is [C, X, Y] -> [3, 1000, 1000]\n", "output = np.zeros_like(huge_tilescan)\n", "\n", "slices = Slicer(\n", " image=huge_tilescan, # your image\n", " crop_size=(512, 512), # sliced up into 512x512 tiles\n", " overlap=(64, 64), # with 64px of overlap\n", " pad=True, # padded with reflection\n", " batch_size=1 # batched one at a time\n", ")" ], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } } }, { "cell_type": "markdown", "source": [ "3) Iterate over the slices\n", "4) Perform some expensive function on the slices\n", "5) slot the data from the expensive function into the output array" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": null, "outputs": [], "source": [ "expensive_fn = lambda x: x + 1 # might be a ML model, huge filter, etc...\n", "\n", "for crop, source, destination in slices:\n", " crop = expensive_fn(crop)\n", " \n", " # Take the non-overlapping data from crop and\n", " # put it in the output array\n", " output[destination] = crop[source] " ], "metadata": { "collapsed": false } } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 0 }