Skip to content

Commit

Permalink
Adding references to pairwise_measures
Browse files Browse the repository at this point in the history
  • Loading branch information
Carole Sudre authored and Carole Sudre committed Sep 26, 2024
1 parent b3a3715 commit 907aa49
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion MetricsReloaded/metrics/pairwise_measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ def youden_index(self):
YI = Specificity + Sensitivity - 1
Youden, W.J, Index for rating diagnostic tests - 1950 Cancer 3 - 32,35
:return: Youden index
"""
return self.specificity() + self.sensitivity() - 1
Expand All @@ -441,6 +443,8 @@ def sensitivity(self):
Sens = \dfrac{TP}{\sharp Ref}
Yerushalmy J., Statistical Problems in assessing Methods of Medical Diagnosis with Special reference to X-Ray Techniques, 1947, Public Health Reports, pp1432-1449
This measure is not defined for empty reference. Will raise a warning and return a nan value
:return: sensitivity
Expand All @@ -458,6 +462,8 @@ def specificity(self):
Spec = \dfrac{TN}{\sharp {1-Ref}}
Yerushalmy J., Statistical Problems in assessing Methods of Medical Diagnosis with Special reference to X-Ray Techniques, 1947, Public Health Reports, pp1432-1449
This measure is not defined when there is no reference negative. This will
raise a warning and return a nan
Expand Down Expand Up @@ -503,6 +509,8 @@ def false_positive_rate(self):
FPR = \dfrac{FP}{\sharp \bar{Ref}}
Burke D, Brundage J, Redfield R., Measurement of the False positive rate in a screening Program for Human Immunodeficiency Virus Infections - 1988 - The New England Journal of Medicine 319 (15) 961-964
:return: false positive rate
"""
return self.fp() / self.n_neg_ref()
Expand Down Expand Up @@ -542,6 +550,8 @@ def matthews_correlation_coefficient(self):
"""
Calculates and returns the MCC for the binary case
Matthews, B.W. Comparison of the predicted and observed secondary structure of T4 phage lysozyme. Biochimica et Biophysica Acta - Protein Structure - 1975 405 442-451
.. math::
MCC = \dfrac{TP * TN - FP * FN}{(TP+FP)*(TP+FN)*(TN+FP)*(TN+FN)}
Expand Down Expand Up @@ -586,6 +596,8 @@ def cohens_kappa(self):
:math:`p_e = ` expected chance matching and :math:`p_o = `observed accuracy
Cohen, J. A coefficient of agreement for nominal scales - Educational and Psychological Measurement (1960) 20 37-46
:return: CK
"""
p_e = self.expected_matching_ck()
Expand Down Expand Up @@ -634,6 +646,8 @@ def positive_predictive_values(self):
Not defined when no positives in the prediction - returns nan if both
reference and prediction empty. Returns 0 if only prediction empty
Fletcher, R.H and Fletcher S.W (2005) - Clinical Epidemiology, the essentials p45
:return: PPV
"""
if self.flag_empty_pred:
Expand Down Expand Up @@ -755,6 +769,8 @@ def negative_predictive_values(self):
This function calculates the negative predictive value ratio between
the number of true negatives and the total number of negative elements
Fletcher, R.H and Fletcher S.W (2005) - Clinical Epidemiology, the essentials p45
:return: NPV
"""
if self.tn() + self.fn() == 0:
Expand Down Expand Up @@ -791,6 +807,10 @@ def fppi(self):
"""
This function returns the average number of false positives per
image, assuming that the cases are collated on the last axis of the array
Bram Van Ginneken, Samuel G Armato III, Bartjan de Hoop, Saskia van Amelsvoort-van de Vorst, Thomas Duindam, Meindert Niemeijer, Keelin Murphy, Arnold Schilham, Alessandra Retico, Maria Evelina Fantacci, et al. Comparing and combining algorithms for computer-aided detection of pulmonary nodules in computed tomography scans: the anode09 study. Medical image analysis, 14(6):707–722, 2010.
Andriy I Bandos, Howard E Rockette, Tao Song, and David Gur. Area under the free-response roc curve (froc) and a related summary index. Biometrics, 65(1):247–256, 2009.
"""
sum_per_image = np.sum(
np.reshape(self.__fp_map(), -1, self.ref.shape[-1]), axis=0
Expand All @@ -802,6 +822,8 @@ def intersection_over_reference(self):
This function calculates the ratio of the intersection of prediction and
reference over reference.
Pavel Matula, Martin Maška, Dmitry V Sorokin, Petr Matula, Carlos Ortiz-de Solórzano, and Michal Kozubek. Cell tracking accuracy measurement based on comparison of acyclic oriented graphs. PloS one, 10(12):e0144959, 2015.
:return: IoR
"""
if self.flag_empty_ref:
Expand All @@ -815,6 +837,8 @@ def intersection_over_union(self):
reference over union - This is also the definition of
jaccard coefficient
Murphy, A.H. The Finley Affair: a signal event in the history of forecast verification - Weather and Forecasting (1996) 11
:return: IoU
"""
if self.flag_empty_pred and self.flag_empty_ref:
Expand Down Expand Up @@ -1094,13 +1118,16 @@ def measured_distance(self):

def measured_average_distance(self):
"""
This function returns only the average distance when calculating the
This function returns only the average symmetric surface distance when calculating the
distances between prediction and reference
.. math::
ASSD(A,B) = \dfrac{\sum_{a\inA}d(a,B) + \sum_{b\inB}d(b,A)}{|A|+ |B|}
Heimann, T., et al. (2009), Comparison and evaluation of methods for liver segmentation from CT datasets. IEEE Trans Med Imaging. 28(8): p. 1251-65.
Varduhi Yeghiazaryan and Irina Voiculescu. An overview of current evaluation methods used in medical image segmentation. Department of Computer Science, University of Oxford, 2015.
:return: assd
"""
return self.measured_distance()[1]
Expand Down

0 comments on commit 907aa49

Please sign in to comment.