segmetrics.regional

class segmetrics.regional.AdjustedRandIndex(*args, correspondance_function: Literal['min', 'max'] = 'max', **kwargs)

Bases: RegionalImageMeasure

Defines the adjusted Rand index.

See: http://scikit-learn.org/stable/modules/generated/sklearn.metrics.adjusted_rand_score.html

compute(actual: None) List[float]

Computes the performance measure for the given segmentation results based on the previously set expected result.

Parameters:

actual – An image containing uniquely labeled object masks corresponding to the segmentation results.

default_name() str

Returns the default name of this measure.

class segmetrics.regional.Dice(*args, correspondance_function: Literal['min', 'max'] = 'max', **kwargs)

Bases: RegionalImageMeasure

Defines the Dice coefficient.

Let \(R\) be the set of all image pixels corresponding to the ground truth segmentation, and \(S\) the set of those corresponding to the segmentation result. Then, the Dice coefficient is defined as

\[\mathrm{DC} =\frac {2 \cdot \left|R \cap S\right|} {\left|R\right| + \left|S\right|}\]

and attains values between \(0\) and \(1\). Higher values correspond to better segmentation performance. Dice corresponds to the pixel-based F1 score (harmonic mean of precision and recall).

compute(actual: None) List[float]

Computes the performance measure for the given segmentation results based on the previously set expected result.

Parameters:

actual – An image containing uniquely labeled object masks corresponding to the segmentation results.

class segmetrics.regional.ISBIScore(min_ref_size: int = 1, **kwargs)

Bases: AsymmetricMeasureMixin, Measure

Defines the SEG performance measure (used in the ISBI Cell Tracking Challenge).

The SEG measure is based on the Jaccard coefficient \(J = \left|R \cap S\right| / \left|R \cup S\right|\) of the sets of pixels of matching objects \(R\) and \(S\), where \(R\) denotes the set of pixels belonging to a reference object and \(S\) denotes the set of pixels belonging to its matching segmented object. A ground truth object \(R\) and a segmented object \(S\) are considered matching if and only if \(\left|R \cap S\right| > 0.5 \cdot \left|R\right|\). Note that for each reference object, there can be at most one segmented object which satisfies the detection test. See: http://public.celltrackingchallenge.net/documents/SEG.pdf

Parameters:

min_ref_size – Ground truth objects smaller than min_ref_size pixels are skipped. It is reasonable to set this value to 2 so that objects of a single pixel in size are skipped, since such objects obviously correspond to misannotations which distort the performance evaluation. However, for compatibility to the official implementation, the value is set to 1 by default so all ground truth objects are included.

References:

  • M. Maska et al., “A benchmark for comparison of cell tracking algorithms,” Bioinformatics, vol. 30, no. 11, pp. 1609–1617, 2014.

compute(actual: None) List[float]

Computes the performance measure for the given segmentation results based on the previously set expected result.

Parameters:

actual – An image containing uniquely labeled object masks corresponding to the segmentation results.

default_name() str

Returns the default name of this measure.

class segmetrics.regional.JaccardCoefficient(*args, correspondance_function: Literal['min', 'max'] = 'max', **kwargs)

Bases: RegionalImageMeasure

Defines the Jaccard coefficient.

Let \(R\) be the set of all image pixels corresponding to the ground truth segmentation, and \(S\) the set of those corresponding to the segmentation result. Then, the Jaccard coefficient is defined as the intersection over the union,

\[\mathrm{JC} = \frac {\left|R \cap S\right|} {\left|R \cup S\right|},\]

and attains values between \(0\) and \(1\). Higher values correspond to better segmentation performance.

The Jaccard coefficient equals \(\mathrm{JC} = \mathrm{DC} / \left(2 - \mathrm{DC}\right)\), where \(\mathrm{DC}\) is the Dice coefficient. Note that this equation only holds for individual \(\mathrm{JC}\) and \(\mathrm{DC}\) values, but not for sums or mean values thereof.

compute(actual: None) List[float]

Computes the performance measure for the given segmentation results based on the previously set expected result.

Parameters:

actual – An image containing uniquely labeled object masks corresponding to the segmentation results.

default_name() str

Returns the default name of this measure.

class segmetrics.regional.JaccardIndex(*args, correspondance_function: Literal['min', 'max'] = 'max', **kwargs)

Bases: RandIndex

Defines the Jaccard index, not to be confused with the Jaccard coefficient.

Let \(R\) be the set of all image pixels corresponding to the ground truth segmentation, and \(S\) the set of those corresponding to the segmentation result. Moreover, let \(a, b, c, d\) be the quantities of the events

\[\begin{split}&\text{(a) } R_i = R_j \text{ and } S_i = S_j \quad &\text{(b) } R_i \neq R_j \text{ and } S_i = S_j \\ &\text{(c) } R_i = R_j \text{ and } S_i \neq S_j \quad &\text{(d) } R_i \neq R_j \text{ and } S_i \neq S_j\end{split}\]

for \(i\) and \(j\) ranging over all pair of pixels in \(R\) and \(S\). Then, the Jaccard index is defined as

\[\mathrm{JI} = \frac{a + d}{b + c + d}.\]

The Jaccard index is not upper-bounded. Higher values correspond to better segmentation performance.

References:

  • L. Coelho, A. Shariff, and R. Murphy, “Nuclear segmentation in microscope cell images: A hand-segmented dataset and comparison of algorithms,” in Proc. Int. Symp. Biomed. Imag., 2009, pp. 518–521.

compute(actual: None) List[float]

Computes the performance measure for the given segmentation results based on the previously set expected result.

Parameters:

actual – An image containing uniquely labeled object masks corresponding to the segmentation results.

default_name() str

Returns the default name of this measure.

class segmetrics.regional.RandIndex(*args, correspondance_function: Literal['min', 'max'] = 'max', **kwargs)

Bases: RegionalImageMeasure

Defines the Rand index.

Let \(R\) be the set of all image pixels corresponding to the ground truth segmentation, and \(S\) the set of those corresponding to the segmentation result. Moreover, let \(a, b, c, d\) be the quantities of the events

\[\begin{split}&\text{(a) } R_i = R_j \text{ and } S_i = S_j \quad &\text{(b) } R_i \neq R_j \text{ and } S_i = S_j \\ &\text{(c) } R_i = R_j \text{ and } S_i \neq S_j \quad &\text{(d) } R_i \neq R_j \text{ and } S_i \neq S_j\end{split}\]

for \(i\) and \(j\) ranging over all pair of pixels in \(R\) and \(S\). Then, the Rand index is defined as

\[\mathrm{RI} = \frac{a + d}{a + b + c + d}.\]

The Rand index attains values between \(0\) and \(1\). Larger values correspond to better segmentation performance. The Rand index corresponds to the pixel-based accuracy score.

References:

  • L. Coelho, A. Shariff, and R. Murphy, “Nuclear segmentation in microscope cell images: A hand-segmented dataset and comparison of algorithms,” in Proc. Int. Symp. Biomed. Imag., 2009, pp. 518–521.

compute(actual: None) List[float]

Computes the performance measure for the given segmentation results based on the previously set expected result.

Parameters:

actual – An image containing uniquely labeled object masks corresponding to the segmentation results.

compute_parts(actual: None) Tuple[float, float, float, float]

Computes the values \(a\), \(b\), \(c\), \(d\).

default_name() str

Returns the default name of this measure.

class segmetrics.regional.RegionalImageMeasure(*args, correspondance_function: Literal['min', 'max'] = 'max', **kwargs)

Bases: ImageMeasureMixin, Measure

Defines an image-level performance measure which is based on the regions of binary volumes (images).