Metadata-Version: 2.1
Name: bipl
Version: 0.3.9
Summary: Openslide/libtiff/GDAL ndarray-like interface and lazy parallel tile-based processing
Project-URL: homepage, https://github.com/arquolo/bipl
Project-URL: repository, https://github.com
Author-email: Paul Maevskikh <arquolo@gmail.com>
Maintainer-email: Paul Maevskikh <arquolo@gmail.com>
License: MIT License
        
        Copyright (c) 2019 Paul Maevskikh
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: aperio,batch,bigtiff,gdal,geotiff,hamamatsu,images,lazy,libtiff,medical,mrxs,ndpi,openslide,osgeo,parallel,pathology,processing,pyramid,slide,svs,tiff,tile,whole-slide,wsi
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.9
Requires-Dist: glow~=0.12.7
Requires-Dist: imagecodecs
Requires-Dist: lxml
Requires-Dist: numpy~=1.21
Requires-Dist: opencv-python-headless~=4.0
Requires-Dist: pydantic~=1.2
Requires-Dist: tqdm
Provides-Extra: dev
Requires-Dist: bipl[dev-core]; extra == 'dev'
Requires-Dist: flake8-alphabetize; extra == 'dev'
Requires-Dist: typing-extensions~=4.6; extra == 'dev'
Provides-Extra: dev-core
Requires-Dist: flake8-pie; extra == 'dev-core'
Requires-Dist: flake8-pyi; extra == 'dev-core'
Requires-Dist: flake8-pyproject; extra == 'dev-core'
Requires-Dist: flake8-simplify; extra == 'dev-core'
Requires-Dist: flake8~=6.0.0; extra == 'dev-core'
Requires-Dist: isort; extra == 'dev-core'
Requires-Dist: mypy~=1.3.0; extra == 'dev-core'
Requires-Dist: pytest~=7.3; extra == 'dev-core'
Requires-Dist: ruff~=0.0.270; extra == 'dev-core'
Requires-Dist: yapf~=0.33.0; extra == 'dev-core'
Provides-Extra: dev-wemake
Requires-Dist: bipl[dev-core]; extra == 'dev-wemake'
Requires-Dist: wemake-python-styleguide~=0.15.0; extra == 'dev-wemake'
Provides-Extra: gdal
Requires-Dist: gdal~=3.0; extra == 'gdal'
Description-Content-Type: text/markdown

# BIPL is a Big Image Python Library

Library to read big pyramidal images like in formats like BigTiff, Aperio SVS, Leica MRXS.

## `bipl.Slide` - ndarray-like reader for multiscale images (svs, tiff, etc...)
<details>

```python
import numpy as np
from bipl import Slide

slide = Slide.open('test.svs')
shape: tuple[int, ...] = slide.shape
pools: tuple[int, ...] = slide.pools
spacing: float = slide.spacing  # X um per pixel
image: np.ndarray = slide[:2048, :2048]  # Get numpy.ndarray of 2048x2048 from 1:1 level

mini = slide.pool(4)  # 1:4 scale, shape is 4x smaller then full resolution
image: np.ndarray = mini[:512, :512]  # Same view as `image`, but lower resolution
```
</details>

## `bipl.Mosaic` - apply function for each tile of big image on desired scale.
<details>

```python
import numpy as np
from bipl import Mosaic, Slide

m = Mosaic(step=512, overlap=0)  # Read at [0:512], [512:1024], ...

# Open slide at 1:1 scale
s = Slide.open('test.svs')

# Get view at 1:4 scale of slide. `s4.shape` = `s.shape` / 4.
# If `test.svs` has some pyramid in it (i.e. 1:1, 1:4, 1:16), it will be used to speed up reads.
s4 = s.pool(4)

# Get iterator over tiles.
# Reads will be at [0:512], [512:1024] ... @ 1:4 scale
# or [0:2048], [2048:4096], ... @ 1:1, each downscaled to 512px
tiles = m.iterate(s4)

# Read only subset of tiles according to binary mask (1s are read, 0s are not).
# `mask.shape` * `scale` = `s4.shape`, `scale` >= 1
tiles = tiles.select(mask, scale)

# Read all data, trigger I/O. All the previous calls do not trigger any disk reads beyond metadata.
images: list[np.ndarray] = [*tiles]
```
</details>

## Installation

```bash
pip install bipl
```
bipl is compatible with: Python 3.9+.
Tested on ArchLinux, Ubuntu 18.04/20.04/22.04, Windows 10/11.
