### Install Development Environment Source: https://github.com/bayer-science-for-a-better-life/tiffslide/blob/main/docs/README.md Commands to clone the repository, set up a virtual environment, and install necessary dependencies for development and benchmarking. ```shell git clone https://github.com/bayer-science-for-a-better-life/tiffslide.git cd tiffslide python -m venv venv source venv/bin/activate pip install --upgrade pip pip install -e ".[dev]" pip install -r docs/requirements.bench.txt ``` -------------------------------- ### Install tiffslide via pip Source: https://github.com/bayer-science-for-a-better-life/tiffslide/blob/main/README.md Install tiffslide using pip. ```bash pip install tiffslide ``` -------------------------------- ### Install tiffslide via conda Source: https://github.com/bayer-science-for-a-better-life/tiffslide/blob/main/README.md Install tiffslide using conda. ```bash conda install -c conda-forge tiffslide ``` -------------------------------- ### HTML and JavaScript for Deep Zoom Viewer Source: https://github.com/bayer-science-for-a-better-life/tiffslide/blob/main/examples/deepzoom/templates/index.html This snippet includes the basic HTML structure and JavaScript code to initialize and configure an OpenSeadragon viewer for deep zoom. ```html Deep Zoom Viewer
``` -------------------------------- ### Access files in the cloud Source: https://github.com/bayer-science-for-a-better-life/tiffslide/blob/main/README.md Example of accessing whole slide images from cloud storage using tiffslide and filesystem_spec. ```python import fsspec from tiffslide import TiffSlide # read from any io buffer with fsspec.open("s3://my-bucket/file.svs") as f: slide = TiffSlide(f) thumb = slide.get_thumbnail((200, 200)) ``` -------------------------------- ### Reading from fsspec urlpaths Source: https://github.com/bayer-science-for-a-better-life/tiffslide/blob/main/README.md Examples of reading TIFF slides directly from S3 and Google Cloud Storage using fsspec. ```python slide = TiffSlide("s3://my-bucket/file.svs", storage_options={'profile': 'aws'}) thumb = slide.get_thumbnail((200, 200)) ``` ```python slide = TiffSlide("simplecache::gcs://my-bucket/file.svs", storage_options={'project': 'my-project'}) region = slide.read_region((300, 400), 0, (512, 512)) ``` -------------------------------- ### Reading numpy arrays instead of PIL images Source: https://github.com/bayer-science-for-a-better-life/tiffslide/blob/main/README.md Example demonstrating how to read a region directly as a NumPy array. ```python import numpy as np from tiffslide import TiffSlide slide = TiffSlide("myfile.svs") arr = slide.read_region((100, 200), 0, (256, 256), as_array=True) assert isinstance(arr, np.ndarray) ``` -------------------------------- ### Download Benchmark Files Source: https://github.com/bayer-science-for-a-better-life/tiffslide/blob/main/docs/README.md Commands to create a directory and download various test image files from different sources for benchmarking. ```shell mkdir -p tiffslide_benchmark_files cd tiffslide_benchmark_files mkdir -p Aperio && curl -L https://openslide.cs.cmu.edu/download/openslide-testdata/Aperio/CMU-2.svs -o Aperio/CMU-2.svs mkdir -p Generic-TIFF && curl -L https://openslide.cs.cmu.edu/download/openslide-testdata/Generic-TIFF/CMU-1.tiff -o Generic-TIFF/CMU-1.tiff mkdir -p Hamamatsu && curl -L https://openslide.cs.cmu.edu/download/openslide-testdata/Hamamatsu/OS-3.ndpi -o Hamamatsu/OS-3.ndpi # mkdir -p Ventana && curl -L https://openslide.cs.cmu.edu/download/openslide-testdata/Ventana/OS-2.bif -o Ventana/OS-2.bif mkdir -p Leica && curl -L https://openslide.cs.cmu.edu/download/openslide-testdata/Leica/Leica-2.scn -o Leica/Leica-2.scn mkdir -p Aperio-JP2K && aws s3 cp --no-sign-request s3://tcga-2-open/2aa283f3-732c-4879-8d37-1fec3ccf5bdc/TCGA-05-4395-01Z-00-DX1.20205276-ca16-46b2-914a-fe5e576a5cf9.svs Aperio-JP2K/TCGA-05-4395-01Z-00-DX1.20205276-ca16-46b2-914a-fe5e576a5cf9.svs pwd ``` -------------------------------- ### Usage as a drop-in replacement Source: https://github.com/bayer-science-for-a-better-life/tiffslide/blob/main/README.md Demonstrates using tiffslide directly or via its drop-in behavior mimicking openslide-python. ```python # directly from tiffslide import TiffSlide slide = TiffSlide('path/to/my/file.svs') # or via its drop-in behavior import tiffslide as openslide slide = openslide.OpenSlide('path/to/my/file.svs') ``` -------------------------------- ### Generate Benchmarks Source: https://github.com/bayer-science-for-a-better-life/tiffslide/blob/main/docs/README.md Command to run the benchmark generation script, specifying the directory containing the downloaded test files. ```shell OPENSLIDE_TESTDATA_DIR=/path/to/tiffslide_benchmark_files/ python docs/generate_benchmark_plots.py ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.