segmetrics.regional
- class segmetrics.regional.AdjustedRandIndex(*args, correspondance_function: Literal['min', 'max'] = 'max', **kwargs)
Bases:
RegionalImageMeasureDefines 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 values of the performance measure (or an intermediate representation thereof) for the given segmentation results based on the previously set expected result.
Intermediate representations are useful, for example, if the measure must take multiple images of a dataset into account and cannot be computed by a mean value across those images. If an intermediate representation is returned, the final performance values can be obtained by feeding the list of intermediate representations obtained for all images into the
postprocess()method.- Parameters:
actual – An image containing uniquely labeled object masks corresponding to the segmentation results.
- Returns:
A list of float values representing the performance measure or an intermediate representation thereof (arbitrary data type).
- class segmetrics.regional.AggregatedJaccardCoefficient(**kwargs)
Bases:
AsymmetricMeasureMixin,MeasureDefines the Aggregated Jaccard Coefficient proposed in Kumar et al. (2017).
In the original publication, the measure is called Aggregated Jaccard Index. Here, it is instead named Aggregated Jaccard Coefficient for consistency with the
JaccardCoefficientandJaccardIndexmeasures.Loosely citing the original publication, the measure computes an “aggregated intersection cardinality numerator, and an aggregated union cardinality denominator for all ground truth and segmented objects under consideration”.
References:
N. Kumar et al. “A dataset and a technique for generalized nuclear segmentation for computational pathology,” IEEE Transactions on Medical Imaging, vol. 36, no. 7, pp. 1550-1560, 2017.
- class segmetrics.regional.Dice(*args, correspondance_function: Literal['min', 'max'] = 'max', **kwargs)
Bases:
RegionalImageMeasureDefines 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 values of the performance measure (or an intermediate representation thereof) for the given segmentation results based on the previously set expected result.
Intermediate representations are useful, for example, if the measure must take multiple images of a dataset into account and cannot be computed by a mean value across those images. If an intermediate representation is returned, the final performance values can be obtained by feeding the list of intermediate representations obtained for all images into the
postprocess()method.- Parameters:
actual – An image containing uniquely labeled object masks corresponding to the segmentation results.
- Returns:
A list of float values representing the performance measure or an intermediate representation thereof (arbitrary data type).
- class segmetrics.regional.ISBIScore(min_ref_size: int = 1, **kwargs)
Bases:
AsymmetricMeasureMixin,MeasureDefines 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_sizepixels are skipped. It is reasonable to set this value to2so 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 to1by 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 values of the performance measure (or an intermediate representation thereof) for the given segmentation results based on the previously set expected result.
Intermediate representations are useful, for example, if the measure must take multiple images of a dataset into account and cannot be computed by a mean value across those images. If an intermediate representation is returned, the final performance values can be obtained by feeding the list of intermediate representations obtained for all images into the
postprocess()method.- Parameters:
actual – An image containing uniquely labeled object masks corresponding to the segmentation results.
- Returns:
A list of float values representing the performance measure or an intermediate representation thereof (arbitrary data type).
- class segmetrics.regional.JaccardCoefficient(*args, correspondance_function: Literal['min', 'max'] = 'max', **kwargs)
Bases:
RegionalImageMeasureDefines 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 values of the performance measure (or an intermediate representation thereof) for the given segmentation results based on the previously set expected result.
Intermediate representations are useful, for example, if the measure must take multiple images of a dataset into account and cannot be computed by a mean value across those images. If an intermediate representation is returned, the final performance values can be obtained by feeding the list of intermediate representations obtained for all images into the
postprocess()method.- Parameters:
actual – An image containing uniquely labeled object masks corresponding to the segmentation results.
- Returns:
A list of float values representing the performance measure or an intermediate representation thereof (arbitrary data type).
- class segmetrics.regional.JaccardIndex(*args, correspondance_function: Literal['min', 'max'] = 'max', **kwargs)
Bases:
RandIndexDefines 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 values of the performance measure (or an intermediate representation thereof) for the given segmentation results based on the previously set expected result.
Intermediate representations are useful, for example, if the measure must take multiple images of a dataset into account and cannot be computed by a mean value across those images. If an intermediate representation is returned, the final performance values can be obtained by feeding the list of intermediate representations obtained for all images into the
postprocess()method.- Parameters:
actual – An image containing uniquely labeled object masks corresponding to the segmentation results.
- Returns:
A list of float values representing the performance measure or an intermediate representation thereof (arbitrary data type).
- class segmetrics.regional.RandIndex(*args, correspondance_function: Literal['min', 'max'] = 'max', **kwargs)
Bases:
RegionalImageMeasureDefines 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 values of the performance measure (or an intermediate representation thereof) for the given segmentation results based on the previously set expected result.
Intermediate representations are useful, for example, if the measure must take multiple images of a dataset into account and cannot be computed by a mean value across those images. If an intermediate representation is returned, the final performance values can be obtained by feeding the list of intermediate representations obtained for all images into the
postprocess()method.- Parameters:
actual – An image containing uniquely labeled object masks corresponding to the segmentation results.
- Returns:
A list of float values representing the performance measure or an intermediate representation thereof (arbitrary data type).
- class segmetrics.regional.RegionalImageMeasure(*args, correspondance_function: Literal['min', 'max'] = 'max', **kwargs)
Bases:
ImageMeasureMixin,MeasureDefines an image-level performance measure which is based on the regions of binary volumes (images).