### Install development environment Source: https://github.com/bayer-group/tiffslide/blob/main/docs/README.md Sets up a virtual environment and installs necessary dependencies for running benchmarks. ```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 ``` -------------------------------- ### Setup development environment without Conda Source: https://github.com/bayer-group/tiffslide/blob/main/README.md Commands to clone the repository and install dependencies in editable mode using a virtual environment. ```bash git clone https://github.com/bayer-science-for-a-better-life/tiffslide.git cd tiffslide python -m venv venv && source venv/bin/activate && python -m pip install -U pip pip install -e .[dev] ``` -------------------------------- ### Setup development environment with Conda Source: https://github.com/bayer-group/tiffslide/blob/main/README.md Commands to clone the repository and create a development environment using conda. ```bash git clone https://github.com/bayer-science-for-a-better-life/tiffslide.git cd tiffslide conda env create -f environment.devenv.yml conda activate tiffslide ``` -------------------------------- ### Install tiffslide Source: https://github.com/bayer-group/tiffslide/blob/main/README.md Install the package using pip or conda. ```bash pip install tiffslide ``` ```bash conda install -c conda-forge tiffslide ``` -------------------------------- ### Download benchmark test files Source: https://github.com/bayer-group/tiffslide/blob/main/docs/README.md Creates local directories and downloads sample slide files from OpenSlide and AWS S3. ```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 ``` -------------------------------- ### OpenSeadragon Initialization Source: https://github.com/bayer-group/tiffslide/blob/main/examples/deepzoom/templates/index.html Initializes the OpenSeadragon viewer with specific tile sources and performance settings. ```javascript /* NOTE, this is a stripped down version of: https://github.com/openslide/openslide-python/blob/ee6f01b77897a76af81575e31cd8de43a25a69e0/examples/deepzoom/templates/slide-fullpage.html */ document.addEventListener("DOMContentLoaded", function(event) { var viewer = new OpenSeadragon({ id: "openseadragon-viewer", tileSources: "{{ slide_url }}", prefixUrl: "{{ url_for('static', filename='openseadragon-2.4.2/images/') }}", showNavigator: true, animationTime: 0.5, blendTime: 0.1, constrainDuringPan: true, maxZoomPixelRatio: 2, minZoomLevel: 1, visibilityRatio: 1, zoomPerScroll: 2, timeout: 120000, }); viewer.addHandler("open", function() { viewer.source.minLevel = 8; }); }); ``` -------------------------------- ### Generate benchmark plots Source: https://github.com/bayer-group/tiffslide/blob/main/docs/README.md Executes the benchmark script using the path to the downloaded test data. ```shell OPENSLIDE_TESTDATA_DIR=/path/to/tiffslide_benchmark_files/ python docs/generate_benchmark_plots.py ``` -------------------------------- ### Use tiffslide as a drop-in replacement Source: https://github.com/bayer-group/tiffslide/blob/main/README.md Initialize TiffSlide directly or use it as a drop-in replacement for the openslide module. ```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') ``` -------------------------------- ### Read regions as numpy arrays Source: https://github.com/bayer-group/tiffslide/blob/main/README.md Retrieve image regions directly as numpy arrays by setting the as_array parameter to True. ```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) ``` -------------------------------- ### Access cloud files with fsspec Source: https://github.com/bayer-group/tiffslide/blob/main/README.md Access whole slide images from cloud storage providers like S3 or GCS using fsspec integration. ```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)) # read from fsspec urlpaths directly, using your AWS_PROFILE 'aws' slide = TiffSlide("s3://my-bucket/file.svs", storage_options={'profile': 'aws'}) thumb = slide.get_thumbnail((200, 200)) # read via fsspec from google cloud and use fsspec's caching mechanism to cache locally slide = TiffSlide("simplecache::gcs://my-bucket/file.svs", storage_options={'project': 'my-project'}) region = slide.read_region((300, 400), 0, (512, 512)) ``` -------------------------------- ### CSS Viewer Styling Source: https://github.com/bayer-group/tiffslide/blob/main/examples/deepzoom/templates/index.html Defines the layout for the viewer container to occupy the full viewport height. ```css {{ filename }} body { display: flex; height: 100vh; margin: 0; } #openseadragon-viewer { flex: 1; background: black; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.