Metadata-Version: 2.4
Name: histolytics
Version: 0.2.5
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
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Requires-Dist: albumentations>=2.0.6
Requires-Dist: cellseg-models-pytorch>=0.1.30
Requires-Dist: cucim-cu12>=25.6.0
Requires-Dist: cuml-cu12>=25.6.0
Requires-Dist: datasets>=3.6.0
Requires-Dist: esda>=2.7.0
Requires-Dist: geopandas>=1.0.1
Requires-Dist: h3>=4.2.2
Requires-Dist: libpysal>=4.13.0
Requires-Dist: mapclassify>=2.8.1
Requires-Dist: matplotlib>=3.10.3
Requires-Dist: networkx>=3.4.2
Requires-Dist: pandarallel>=1.6.5
Requires-Dist: quadbin>=0.2.2
Requires-Dist: scikit-image>=0.25.0
Requires-Dist: torchdata>=0.11.0
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/%F0%9F%A4%97%20HF-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
```

## 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

```bibtex
@article{2025histolytics,
  title={Histolytics: A Panoptic Spatial Analysis Framework for Interpretable Histopathology},
  author={Oskari Lehtonen, Niko Nordlund, Shams Salloum, Ilkka Kalliala, Anni Virtanen, Sampsa Hautaniemi},
  journal={XX},
  volume={XX},
  number={XX},
  pages={XX},
  year={2025},
  publisher={XX}
}
```
