The segmentation game – for napari

License PyPI Python Version tests codecov napari hub DOI

Gamified image segmentation quality estimation

img.png


Usage

The Segmentation Game allows to quantitatively compare segmentation results to a given ground truth annotation. This allows fine-tuning parameters of image processing workflows to get optimal segmentation quality. It also allows comparing different segmentation algorithms and identify which algorithm performs best objectively.

The game can be found in napari’s Tools > Games > The Segmentation Game menu.

Ground Truth Annotation

Before you can start playing the game, some annotated cells/nuclei are necessary to later compute segmentation quality from. Depending on the used metric, it might be sufficient to annotate a hand full of objects. Use napari’s annotation tools as shown below. Use the + and - keys on your keyboard to increase and decrease the label number that is currently drawn. Note: Avoid label gaps. The labels must be continuously subsequent. If there are pixels annotated with value 2, there must be pixels annotated with value 1.

Parameter tuning

If you work with one of napari’s segmentation plugins that produce labels layers, you can tune their parameters and see how this influences segmentation quality.

Segmentation algorithm comparison

If you aim at comparing different segmentation algorithms, you can collect their results in label layers in the napari viewer. You can then select the segmentation result from the corresponding pulldown and save quantitative comparison results in the Highscore table.

Metrics

Currently, these metrics are implemented:

  • Jaccard Index (sparse): The Jaccard Index is a measure of overlap. It lies between 0 (no overlap) and 1 (perfect overlap). For each annotated ground truth label, the maximum overlap of any segmented label is determined. The mean overlap of all annotated labels serves as metric result.
  • Jaccard Index (binary): The annotated ground truth labels and the segmentation result are first binarized considering all annotated pixels as positive and all other labels as negative. Afterwards, the overlap between the two binary images is computed. This allows comparing binary segmentation algorithms, such as thresholding techniques.
  • Jaccard Index (binary, sparse): The annotated ground truth image can contain values 1 (negative, false) and 2 (positive, true) and the segmentation result image will be binarized (0: False, otherwise: True). This allows comparing object/no-object annotations with label images.

Related plugins

If you aim at automatically optimizing segmentation quality, there are also napari plugins available with this capability:

Installation

You can install the-segmentation-game via pip:

pip install the-segmentation-game

Contributing

Contributions – especially new image segmentation quality metrics – are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the BSD-3 license, “the-segmentation-game” is free and open source software

Issues

If you encounter any problems, please open a thread on image.sc along with a detailed description.

GitHub

View Github