Metadata-Version: 2.1
Name: prismtoolbox
Version: 0.0.2
Summary: Toolbox for histopathology image analysis
Home-page: https://gustaveroussy.github.io/prismtoolbox
License: BSD-3-Clause
Author: Loïc Le Bescond
Author-email: loic.le.bescond@centralesupelec.fr
Requires-Python: >=3.9,<3.12
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Provides-Extra: emb
Provides-Extra: seg
Requires-Dist: cellpose (>=3.0.7,<4.0.0) ; extra == "seg"
Requires-Dist: dask[dataframe] (>=2024.3.1,<2025.0.0) ; extra == "emb"
Requires-Dist: h5py (>=3.10.0,<4.0.0)
Requires-Dist: huggingface-hub (>=0.22.1,<0.23.0) ; extra == "emb"
Requires-Dist: ipywidgets (>=8.1.2,<9.0.0) ; extra == "seg"
Requires-Dist: matplotlib (>=3.8.3,<4.0.0)
Requires-Dist: opencv-python (>=4.8.1.78,<5.0.0.0)
Requires-Dist: openslide-python (>=1.3.1,<2.0.0)
Requires-Dist: pandas (>=2.2.1,<3.0.0)
Requires-Dist: scikit-learn (>=1.4.1.post1,<2.0.0) ; extra == "emb"
Requires-Dist: scipy (>=1.12.0,<2.0.0)
Requires-Dist: shapely (>=2.0.3,<3.0.0)
Requires-Dist: tiffslide (>=2.3.0,<3.0.0)
Requires-Dist: timm (>=0.9.16,<0.10.0) ; extra == "emb"
Requires-Dist: torch (>=2.2.2,<3.0.0) ; extra == "emb" or extra == "seg"
Requires-Dist: torchvision (>=0.17.2,<0.18.0) ; extra == "emb" or extra == "seg"
Requires-Dist: tqdm (>=4.66.2,<5.0.0) ; extra == "emb"
Requires-Dist: transformers (>=4.38.2,<5.0.0) ; extra == "emb"
Requires-Dist: umap-learn[plot] (>=0.5.5,<0.6.0) ; extra == "emb"
Requires-Dist: uuid (>=1.30,<2.0)
Project-URL: Documentation, https://gustaveroussy.github.io/prismtoolbox
Project-URL: Repository, https://github.com/gustaveroussy/prismtoolbox
Description-Content-Type: text/markdown

# PrismToolBox

PrismToolBox is a comprehensive toolkit designed to streamline the process of working with digital pathology images. It provides a set of utilities and functionalities that simplify tasks such as reading slides, extracting patches, and embedding slides. It also provides useful functions to import/export data on [QuPath](https://qupath.github.io/).

The toolkit is still under development, and some features may not be fully implemented. If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request.

## Features

- **Slide Reading**: Supports multiple backends for reading slides, including OpenSlide and TiffSlide.
- **Patch Extraction**: Extracts patches from slides at various magnification levels.
- **Slide Embedding**: Uses pre-trained models to generate embeddings from patches, facilitating downstream tasks like clustering or classification (in progress).
- **Nuclei segmentation**: Extracts nuclei using [cellpose](https://cellpose.readthedocs.io/en/latest/index.html) for H&E and [SOP](https://github.com/loic-lb/Unsupervised-Nuclei-Segmentation-using-Spatial-Organization-Priors) for IHC brighfield images.

## Installation

To install PrismToolBox, run the following command in your terminal:

```bash
pip install prismtoolbox
```

To install PrismToolBox embedding and nuclei utilitaries, please run the following command:

```bash
pip install 'prismtoolbox[emb, seg]'
```

## Usage

Here's a basic example of how to use PrismToolBox:

```python
from prismtoolbox import WSI

# Initialize the reader
WSI_object = WSI(slide_path="path_to_your_slide", engine="openslide")

# Extract tissue contours
params_detect_tissue = {"seg_level": 4, "window_avg": 30, "window_eng": 5, "thresh": 90, "area_min": 1.5e3}

WSI_object.detect_tissue(**params_detect_tissue)

# Extract patches and save them as jpg images
params_patches = {"patch_size": 256, "patch_level": 0,"mode": "contours", "contours_mode": "four_pt_hard"}

WSI_object.extract_patches(**params_patches)
WSI_object.save_patches("path_to_folder", file_format="jpg")
```

For more detailed usage instructions and examples, please refer to the [documentation](https://gustaveroussy.github.io/prismtoolbox/).

## Contributing

Contributions to PrismToolBox are welcome! Please open an issue or submit a pull request to propose changes or additions.

## License

PrismToolBox is licensed under the BSD 3-Clause License. See [LICENSE](./LICENSE) for more information.

