Skip to main content

Panoptic Quality (PQ) computation for binary masks.

Project description

panoptica

Python Versions Stable Version Documentation Status tests codecov License

Computing instance-wise segmentation quality metrics for 2D and 3D semantic- and instance segmentation maps.

Use Cases & Tutorials | Documentation

Features

The package provides three core modules:

  1. Instance Approximator: instance approximation algorithms to extract instances from semantic segmentation maps/model outputs.
  2. Instance Matcher: matches predicted instances with reference instances.
  3. Instance Evaluator: computes segmentation and detection quality metrics for pairs of predicted - and reference segmentation maps.

workflow_figure

Installation

With a Python 3.10+ environment, you can install panoptica from pypi.org

pip install panoptica

Or, alternatively, from conda:

conda install -c conda-forge panoptica

Available Metrics

[!NOTE] Panoptica supports a large range of metrics.
An overview of the supported metrics and their formulas can be found here: panoptica/metrics.md

Use Cases & Tutorials

Minimal example

A minimal example of using panoptica could look e.g. like this (here with Matched Instances as Input):

from panoptica import InputType, Panoptica_Evaluator
from panoptica.metrics import Metric

from auxiliary.io import read_image # feel free to use any other way to read nifti files

ref_masks = read_image("reference.nii.gz")
pred_masks = read_image("prediction.nii.gz")

evaluator = Panoptica_Evaluator(
    expected_input=InputType.MATCHED_INSTANCE,
    decision_metric=Metric.IOU,
    decision_threshold=0.5,
)

result = evaluator.evaluate(pred_masks, ref_masks)["ungrouped"]

[!TIP] We provide Jupyter Notebook tutorials showcasing various use cases.
You can explore them here: BrainLesion/tutorials/panoptica

Semantic Segmentation Input

semantic_figure

Although an instance-wise evaluation is highly relevant and desirable for many biomedical segmentation problems, they are still addressed as semantic segmentation problems due to the lack of appropriate instance labels.

This tutorial leverages all three modules of panoptica: instance approximation, -matching and -evaluation.

nbviewer Open In Colab

Unmatched Instances Input

unmatched_instance_figure

It is a common issue that instance segmentation outputs feature good outlines but mismatched instance labels. For this case, the matcher module can be utilized to match instances and the evaluator to report metrics.

nbviewer Open In Colab

Matched Instances Input

matched_instance_figure

nbviewer Open In Colab

If your predicted instances already match the reference instances, you can directly compute metrics using the evaluator module.

Matching Algorithm Example

nbviewer Open In Colab

Using Configs (saving and loading)

You can construct Panoptica_Evaluator (among many others) objects and save their arguments, so you can save project-specific configurations and use them later. It uses ruamel.yaml in a readable way.

nbviewer Open In Colab

Using Panoptica Aggregator

Using our Panoptica Aggregator, you can evaluate your data while the Aggregator takes care of writing the results into a .tsv file (threading-safe). This allows you to focus only on the important part, that is loading and iterating over your data. From the aggregator, you can immediately get a Panoptica Statistics object that yield you the statistics over your metrics as well as create nice figures for you.

Tutorial: TBD

Documentation

We provide a readthedocs documentation of our codebase here

Citation

[!IMPORTANT] If you use panoptica in your research, please cite it to support the development!

Kofler, F., Möller, H., Buchner, J. A., de la Rosa, E., Ezhov, I., Rosier, M., Mekki, I., Shit, S., Negwer, M., Al-Maskari, R., Ertürk, A., Vinayahalingam, S., Isensee, F., Pati, S., Rueckert, D., Kirschke, J. S., Ehrlich, S. K., Reinke, A., Menze, B., Wiestler, B., & Piraud, M. (2023). Panoptica -- instance-wise evaluation of 3D semantic and instance segmentation maps. arXiv preprint arXiv:2312.02608.

@misc{kofler2023panoptica,
      title={Panoptica -- instance-wise evaluation of 3D semantic and instance segmentation maps}, 
      author={Florian Kofler and Hendrik Möller and Josef A. Buchner and Ezequiel de la Rosa and Ivan Ezhov and Marcel Rosier and Isra Mekki and Suprosanna Shit and Moritz Negwer and Rami Al-Maskari and Ali Ertürk and Shankeeth Vinayahalingam and Fabian Isensee and Sarthak Pati and Daniel Rueckert and Jan S. Kirschke and Stefan K. Ehrlich and Annika Reinke and Bjoern Menze and Benedikt Wiestler and Marie Piraud},
      year={2023},
      eprint={2312.02608},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

Contributing

We welcome all kinds of contributions from the community!

Some guides on extending panoptica can be found in panoptica/extending_panoptica.md

Reporting Bugs, Feature Requests and Questions

Please open a new issue here.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

panoptica-1.5.1.tar.gz (67.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

panoptica-1.5.1-py3-none-any.whl (88.9 kB view details)

Uploaded Python 3

File details

Details for the file panoptica-1.5.1.tar.gz.

File metadata

  • Download URL: panoptica-1.5.1.tar.gz
  • Upload date:
  • Size: 67.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.6

File hashes

Hashes for panoptica-1.5.1.tar.gz
Algorithm Hash digest
SHA256 a74f57d3d457e4673f45cca57f08f9380a99e16b8f9c5fb3ba906f7f8ac7fabb
MD5 98ee017b76ba4618143265a500be60b6
BLAKE2b-256 25d6665c65d5e9631c734cdfd457d4f2f8d0917dbc94a9c17158d2f717c51c85

See more details on using hashes here.

File details

Details for the file panoptica-1.5.1-py3-none-any.whl.

File metadata

  • Download URL: panoptica-1.5.1-py3-none-any.whl
  • Upload date:
  • Size: 88.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.6

File hashes

Hashes for panoptica-1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eaa25ef265a8fdc20dbbb1698e8e3cf45c2b3358a790b5aafb1ec41702e928c4
MD5 e1f40d390942aa421e3cba225557d87f
BLAKE2b-256 9fa0ad31c36cc63b2e8fad2023d1ff8b3bf42d50d83ea846c7686bf6f4e2050a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page