segmetrics.measure
- class segmetrics.measure.AsymmetricMeasureMixin(*args, **kwargs)
Bases:
MeasureProtocolDefines an asymmetric performance measure.
Symmetric performance measures are guaranteed to yield the same results when the actual and the expected segmentation masks are swapped. Asymmetric performance measures can yield different results when the results are swapped.
- reversed(**kwargs) Measure
Returns a measure for comparing the underlying asymmetric performance measure measure in the opposite direction (i.e. swapping the actual and the expected segmentation masks).
Keyword arguments are passed through to
ReverseMeasureAdapter.- Returns:
This measure decorated by
ReverseMeasureAdapter.
- symmetric(**kwargs) Measure
Returns a bidirectional variant of the underlying asymmetric performance measure. The underlying performance measure is used for computation of performance values in both direction (i.e. with the original segmentation masks, and, in addition, with actual and expected segmentation masks swapped).
Keyword arguments are passed through to
SymmetricMeasureAdapter.- Returns:
This measure decorated by
SymmetricMeasureAdapter.
- class segmetrics.measure.ImageMeasureMixin(*args, correspondance_function: Literal['min', 'max'], **kwargs)
Bases:
MeasureProtocolDefines an image-level performance measure.
The computation of such measures only regards the union of the individual objects, not the individual objects themselves.
- Parameters:
correspondance_function – Determines how the object correspondances between the segmented and the ground truth objects are determined when using the
object_based()method. The correspondances are established by choosing the segmented object for each ground truth object, for which the obtained scores are either minimal (min) or maximal (max).
- object_based(**kwargs) Measure
Returns measure for comparing the individual objects (as opposed to only considering the union thereof).
Keyword arguments are passed through to
ObjectMeasureAdapter.- Returns:
This measure decorated by
ObjectMeasureAdapter.
- class segmetrics.measure.Measure(aggregation: Literal['sum', 'mean', 'geometric-mean', 'object-mean'] = 'mean')
Bases:
MeasureProtocolDefines a performance measure.
- Parameters:
aggregation – Controls whether the results of this performance measure are aggregated by summation (
sum), by averaging (mean), by using the geometric mean (geometric-mean), or by computing the proportion with respect to the number of annotated objects (object-mean).
- property aggregation: Literal['sum', 'mean', 'geometric-mean', 'object-mean']
Indicates whether the results of this performance measure are aggregated by summation (
sum), by averaging (mean), by using the geometric mean (geometric-mean), or by computing the proportion with respect to the number of annotated objects (object-mean).
- compute(actual: None) List[Any]
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.measure.MeasureProtocol(*args, **kwargs)
Bases:
ProtocolType protocol of performance measures.
- property aggregation: Literal['sum', 'mean', 'geometric-mean', 'object-mean']
Indicates whether the results of this performance measure are aggregated by summation (
sum), by averaging (mean), by using the geometric mean (geometric-mean), or by computing the proportion with respect to the number of annotated objects (object-mean).
- compute(actual: None) List[Any]
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.measure.ObjectMeasureAdapter(measure: MeasureProtocol, correspondance_function: Callable[[List[float]], float], **kwargs)
Bases:
AsymmetricMeasureMixin,MeasureAdapter to use image-level measures on a per-object level.
Computes the underlying image-level measure on a per-object level. Object correspondances between the segmented and the ground truth objects are established by choosing the segmented object for each ground truth object, for which the obtained scores are either minimal or maximal.
- Parameters:
measure – The underlying image-level measure.
correspondance_function – Determines the object correspondances by reducing a sequence of scores to a single score value.
- 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).
- default_name()
Returns the default name of this measure.
- class segmetrics.measure.ReverseMeasureAdapter(measure: MeasureProtocol, **kwargs)
Bases:
Measure- 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.measure.SymmetricMeasureAdapter(measure1: MeasureProtocol, measure2: MeasureProtocol, **kwargs)
Bases:
Measure- 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).