Metadata-Version: 2.5
Name: histolytics
Version: 0.3.0
Summary: Panoptic Segmentation and WSI Spatial Analysis
Project-URL: Homepage, https://hautaniemilab.github.io/histolytics/
Project-URL: Documentation, https://hautaniemilab.github.io/histolytics/
Project-URL: Repository, https://github.com/HautaniemiLab/histolytics
Project-URL: Changelog, https://github.com/HautaniemiLab/histolytics/blob/main/CHANGELOG.md
Author-email: Oskari Lehtonen <oskari.lehtonen@helsinki.fi>
License: BSD 3-Clause License
        
        Copyright (c) 2024-2025, HautaniemiLab
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        * Redistributions of source code must retain the above copyright notice, this
          list of conditions and the following disclaimer.
        
        * Redistributions in binary form must reproduce the above copyright notice,
          this list of conditions and the following disclaimer in the documentation
          and/or other materials provided with the distribution.
        
        * Neither the name of the copyright holder nor the names of its
          contributors may be used to endorse or promote products derived from
          this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License-File: LICENSE
Keywords: computer vision,geospatial,panoptic segmentation,spatial analysis,whole slide image
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Requires-Dist: esda>=2.7.0
Requires-Dist: geopandas<2.0.0,>=1.0.1
Requires-Dist: h3>=4.2.2
Requires-Dist: libpysal<5.0.0,>=4.13.0
Requires-Dist: mapclassify>=2.8.1
Requires-Dist: matplotlib>=3.10.3
Requires-Dist: networkx>=3.4.2
Requires-Dist: numba<0.61.0,>=0.60.0
Requires-Dist: numpy<2.0,>=1.24.4
Requires-Dist: opencv-python<5.0,>=4.8
Requires-Dist: pandarallel>=1.6.5
Requires-Dist: pandas<2.4.0dev0,>=2.0
Requires-Dist: psutil
Requires-Dist: pyarrow<17.0.0,>=16.1.0
Requires-Dist: pyproj>=3.3.0
Requires-Dist: quadbin>=0.2.2
Requires-Dist: rasterio<2.0.0,>=1.4.3
Requires-Dist: scikit-image<0.26,>=0.25.0
Requires-Dist: scikit-learn<2.0.0,>=1.4
Requires-Dist: scipy<2.0,>=1.14
Requires-Dist: shapely>=2.0.1
Requires-Dist: tqdm<5.0.0,>=4.64.0
Provides-Extra: all
Requires-Dist: albumentations>=2.0.6; extra == 'all'
Requires-Dist: cellseg-models-pytorch>=0.1.30; extra == 'all'
Requires-Dist: cucim-cu12>=25.6.0; extra == 'all'
Requires-Dist: cuml-cu12>=25.6.0; extra == 'all'
Requires-Dist: cupy-cuda12x>=12.0.0; extra == 'all'
Requires-Dist: datasets>=3.6.0; extra == 'all'
Requires-Dist: huggingface-hub; extra == 'all'
Requires-Dist: pillow>=10.1; extra == 'all'
Requires-Dist: safetensors; extra == 'all'
Requires-Dist: torch<3.0,>=2.9.1; extra == 'all'
Requires-Dist: torchdata>=0.11.0; extra == 'all'
Provides-Extra: cucim
Requires-Dist: albumentations>=2.0.6; extra == 'cucim'
Requires-Dist: cellseg-models-pytorch>=0.1.30; extra == 'cucim'
Requires-Dist: cucim-cu12>=25.6.0; extra == 'cucim'
Requires-Dist: cupy-cuda12x>=12.0.0; extra == 'cucim'
Requires-Dist: datasets>=3.6.0; extra == 'cucim'
Requires-Dist: huggingface-hub; extra == 'cucim'
Requires-Dist: pillow>=10.1; extra == 'cucim'
Requires-Dist: safetensors; extra == 'cucim'
Requires-Dist: torch<3.0,>=2.9.1; extra == 'cucim'
Requires-Dist: torchdata>=0.11.0; extra == 'cucim'
Provides-Extra: cuda-analysis
Requires-Dist: cucim-cu12>=25.6.0; extra == 'cuda-analysis'
Requires-Dist: cuml-cu12>=25.6.0; extra == 'cuda-analysis'
Requires-Dist: cupy-cuda12x>=12.0.0; extra == 'cuda-analysis'
Provides-Extra: segmentation
Requires-Dist: albumentations>=2.0.6; extra == 'segmentation'
Requires-Dist: cellseg-models-pytorch>=0.1.30; extra == 'segmentation'
Requires-Dist: datasets>=3.6.0; extra == 'segmentation'
Requires-Dist: huggingface-hub; extra == 'segmentation'
Requires-Dist: pillow>=10.1; extra == 'segmentation'
Requires-Dist: safetensors; extra == 'segmentation'
Requires-Dist: torch<3.0,>=2.9.1; extra == 'segmentation'
Requires-Dist: torchdata>=0.11.0; extra == 'segmentation'
Description-Content-Type: text/markdown

<div align="center">

![Logo](imgs/histolytics_logo.png)

**A Python library for scalable panoptic spatial analysis of histological WSIs**

[![Github Test](https://img.shields.io/github/actions/workflow/status/HautaniemiLab/histolytics/tests.yml?label=tests)](https://github.com/HautaniemiLab/histolytics/blob/main/.github/workflows/tests.yml) [![License](https://img.shields.io/github/license/HautaniemiLab/histolytics)](https://github.com/HautaniemiLab/histolytics/blob/main/LICENSE) [![Python - Version](https://img.shields.io/pypi/pyversions/histolytics)](https://www.python.org/)
[![Package - Version](https://img.shields.io/pypi/v/histolytics)](https://pypi.org/project/histolytics/) [![Model Checkpoints](https://img.shields.io/badge/HF-Model%20Hub-yellow)](https://huggingface.co/histolytics-hub)
</div>

## Introduction

**histolytics** is a spatial analysis library for histological whole slide images (WSI). Built upon [`torch`](https://pytorch.org/), [`geopandas`](https://geopandas.org/en/stable/index.html) and [`libpysal`](https://pysal.org/libpysal/), the library provides a comprehensive and scalable framework for **panoptic segmentation** and **interpretable panoptic spatial analysis** of routine histopathology slides.


## Panoptic Segmentation Features
- Fast WSI-level panoptic segmentation. See [example](https://hautaniemilab.github.io/histolytics/user_guide/seg/panoptic_segmentation/).
- Low memory-footprint segmentation results with [`__geo_interface__`](https://gist.github.com/sgillies/2217756)-specification.
- Multiple vectorized segmentation output formats (geojson/feather/parquet).
- Several panoptic segmentation model architectures for histological WSIs with flexible backbone support: See [example](https://hautaniemilab.github.io/histolytics/user_guide/seg/backbones/)
- Pre-trained models in model-hub. See: [histolytics-hub](https://huggingface.co/histolytics-hub)

## Spatial Analysis Features
- Fast Spatial Querying of WSI-scale panoptic segmentation maps. See [example](https://hautaniemilab.github.io/histolytics/user_guide/spatial/querying/)
- Spatial indexing/partitioning for localized spatial statistics and analysis. See [example](https://hautaniemilab.github.io/histolytics/user_guide/spatial/partitioning/)
- Graph-based neighborhood analysis for local cell neighborhoods. See [example](https://hautaniemilab.github.io/histolytics/user_guide/spatial/nhoods/)
- Plotting utilities for spatial data visualization. See [example](https://hautaniemilab.github.io/histolytics/user_guide/spatial/legendgram/)
- Spatial clustering and cluster centrography metrics. See [example](https://hautaniemilab.github.io/histolytics/user_guide/spatial/clustering/)
- Large set of morphological, intensity, chromatin distribution, and textural features at nuclear level. See [example](https://hautaniemilab.github.io/histolytics/user_guide/spatial/nuclear_features/)
- Large set of collagen fiber and intensity based features to characterize stroma and ECM. See [example](https://hautaniemilab.github.io/histolytics/user_guide/spatial/stromal_features/)

## Example Workflows
- Immuno-oncology Profiling:
  - [Spatial Statistics of TILs](https://hautaniemilab.github.io/histolytics/user_guide/workflows/TIL_workflow/).
  - [Profiling TLS and Lymphoid Aggregates](https://hautaniemilab.github.io/histolytics/user_guide/workflows/tls_lymphoid_aggregate/).
- Nuclear Pleomorphism:
  - [Nuclear Morphology Analysis](https://hautaniemilab.github.io/histolytics/user_guide/workflows/nuclear_morphology/).
  - [Nuclear Chromatin Distribution Analysis](https://hautaniemilab.github.io/histolytics/user_guide/workflows/chromatin_patterns/).
- TME Characterization:
  - [Collagen Fiber Disorder Analysis](https://hautaniemilab.github.io/histolytics/user_guide/workflows/collagen_orientation/).
  - [Characterization of Desmoplastic Stroma](https://hautaniemilab.github.io/histolytics/user_guide/workflows/clustering_desmoplasia/).
- Nuclei Neighborhoods:
  - [Tumor Cell Accessibility](https://hautaniemilab.github.io/histolytics/user_guide/workflows/tumor_cell_accessibility/).


## Installation

```shell
pip install 'histolytics[all]'               # Recommended full installation (Linux)
pip install histolytics                      # CPU spatial/image analysis
pip install 'histolytics[segmentation]'       # Models and segmentation workflows
pip install 'histolytics[cucim]'              # Retained cuCIM WSI backend (Linux)
pip install 'histolytics[cuda-analysis]'      # Existing CUDA analysis (Linux)
```

These groups apply to Histolytics 0.3.0 and later. Histolytics 0.2.5 retains
its previous installation requirements. Existing model users must select
`segmentation` or `all`; to retain all prior capabilities on Linux, install
`histolytics[all]`. See the
[installation guide](https://hautaniemilab.github.io/histolytics/installation/) for
source installation, reader prerequisites, and CPU Torch setup.

## Models

- Panoptic [HoVer-Net](https://www.sciencedirect.com/science/article/abs/pii/S1361841519301045)
- Panoptic [Cellpose](https://www.nature.com/articles/s41592-020-01018-x)
- Panoptic [Stardist](https://arxiv.org/abs/1806.03535)
- Panoptic [CellVit-SAM](https://arxiv.org/abs/2306.15350)
- Panoptic [CPP-Net](https://arxiv.org/abs/2102.06867)

## Contributing

We welcome contributions! To get started:

1. Fork the repository and create your branch from `main`.
2. Make your changes with clear commit messages.
3. Ensure all tests pass and add new tests as needed.
4. Submit a pull request describing your changes.

See [contributing guide](https://github.com/HautaniemiLab/histolytics/blob/main/CONTRIBUTING.md) for detailed guidelines.

## Citation

If you use histolytics in your research, please cite:

Lehtonen, O., Nordlund, N., Salloum, S., Kalliala, I., Virtanen, A., & Hautaniemi, S. (2025). **Histolytics: A panoptic spatial analysis framework for interpretable histopathology.** *Computational and Structural Biotechnology Journal*, 27, 5135–5147. [https://doi.org/10.1016/j.csbj.2025.11.022](https://doi.org/10.1016/j.csbj.2025.11.022)

```bibtex
@article{2025histolytics,
  title={{Histolytics}: A panoptic spatial analysis framework for interpretable histopathology},
  author={Lehtonen, Oskari and Nordlund, Niko and Salloum, Shams and Kalliala, Ilkka and Virtanen, Anni and Hautaniemi, Sampsa},
  journal={Computational and Structural Biotechnology Journal},
  volume={27},
  pages={5135--5147},
  year={2025},
  doi={10.1016/j.csbj.2025.11.022},
  url={https://doi.org/10.1016/j.csbj.2025.11.022},
  publisher={Elsevier}
}
```
