medpy.metric.binary.obj_fpr#

medpy.metric.binary.obj_fpr(result, reference, connectivity=1)[source]#

The false positive rate of distinct binary object detection.

The false positive rates gives a percentage measure of how many distinct binary objects in the second array do not exists in the first array. A partial overlap (of minimum one voxel) is here considered sufficient.

In cases where two distinct binary object in the second array overlap with a single distinct object in the first array, only one is considered to have been detected successfully and the other is added to the count of false positives.

Parameters:
resultarray_like

Input data containing objects. Can be any type but will be converted into binary: background where 0, object everywhere else.

referencearray_like

Input data containing objects. Can be any type but will be converted into binary: background where 0, object everywhere else.

connectivityint

The neighbourhood/connectivity considered when determining what accounts for a distinct binary object. This value is passed to scipy.ndimage.generate_binary_structure and should usually be \(> 1\). The decision on the connectivity is important, as it can influence the results strongly. If in doubt, leave it as it is.

Returns:
tprfloat

A percentage measure of how many distinct binary objects in results have no corresponding binary object in reference. It has the range \([0, 1]\), where a \(0\) denotes an ideal score.

Raises:
RuntimeError

If the second array is empty.

See also

obj_tpr

Notes

This is not a real metric, as it is directed. Whatever array is considered as reference should be passed second. A perfect score of \(0\) tells that there are no distinct binary objects in the second array that do not exists also in the reference array, but does not reveal anything about objects in the reference array also existing in the second array (use obj_tpr for this).

Examples

>>> arr2 = numpy.asarray([[1,0,0],[1,0,1],[0,0,1]])
>>> arr1 = numpy.asarray([[0,0,1],[1,0,1],[0,0,1]])
>>> arr2
array([[1, 0, 0],
       [1, 0, 1],
       [0, 0, 1]])
>>> arr1
array([[0, 0, 1],
       [1, 0, 1],
       [0, 0, 1]])
>>> obj_fpr(arr1, arr2)
0.0
>>> obj_fpr(arr2, arr1)
0.0

Example of directedness:

>>> arr2 = numpy.asarray([1,0,1,0,1])
>>> arr1 = numpy.asarray([1,0,1,0,0])
>>> obj_fpr(arr1, arr2)
0.0
>>> obj_fpr(arr2, arr1)
0.3333333333333333

Examples of multiple overlap treatment:

>>> arr2 = numpy.asarray([1,0,1,0,1,1,1])
>>> arr1 = numpy.asarray([1,1,1,0,1,0,1])
>>> obj_fpr(arr1, arr2)
0.3333333333333333
>>> obj_fpr(arr2, arr1)
0.3333333333333333
>>> arr2 = numpy.asarray([1,0,1,1,1,0,1])
>>> arr1 = numpy.asarray([1,1,1,0,1,1,1])
>>> obj_fpr(arr1, arr2)
0.0
>>> obj_fpr(arr2, arr1)
0.3333333333333333
>>> arr2 = numpy.asarray([[1,0,1,0,0],
                          [1,0,0,0,0],
                          [1,0,1,1,1],
                          [0,0,0,0,0],
                          [1,0,1,0,0]])
>>> arr1 = numpy.asarray([[1,1,1,0,0],
                          [0,0,0,0,0],
                          [1,1,1,0,1],
                          [0,0,0,0,0],
                          [1,1,1,0,0]])
>>> obj_fpr(arr1, arr2)
0.0
>>> obj_fpr(arr2, arr1)
0.2