00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "freImageClassificationSOMetricMonitor.h"
00024
00025 #include "itkNumericTraits.h"
00026
00027 namespace FREE
00028 {
00029
00033 ImageClassificationSOMetricResult::
00034 ImageClassificationSOMetricResult()
00035 {
00036 this->Reset();
00037 };
00038
00039 void
00040 ImageClassificationSOMetricResult::
00041 Reset()
00042 {
00043 m_TP = 0;
00044 m_FP = 0;
00045 m_TN = 0;
00046 m_FN = 0;
00047 m_Duration = 0;
00048 };
00049
00053 ImageClassificationSOMetricMonitor::
00054 ImageClassificationSOMetricMonitor()
00055 {};
00056
00057 ImageClassificationSOMetricMonitor::
00058 ~ImageClassificationSOMetricMonitor()
00059 {
00060 };
00061
00062 void
00063 ImageClassificationSOMetricMonitor::
00064 InsertEvaluationResults(const ResultType& results)
00065 {
00066 m_TPs.push_back(results.GetTP());
00067 m_FPs.push_back(results.GetFP());
00068 m_TNs.push_back(results.GetTN());
00069 m_FNs.push_back(results.GetFN());
00070 m_Durations.push_back(results.GetDuration());
00071 };
00072
00073 void
00074 ImageClassificationSOMetricMonitor::
00075 CopyAdaptationResults(const ResultIndexType& index, ResultType& results) const
00076 {
00077 results.SetTP(m_TPs[index]);
00078 results.SetFP(m_FPs[index]);
00079 results.SetTN(m_TNs[index]);
00080 results.SetFN(m_FNs[index]);
00081 results.SetDuration(m_Durations[index]);
00082 };
00083
00084 void
00085 ImageClassificationSOMetricMonitor::
00086 EnlistResultsToStatistic(const ResultType& results, StatisticEntry& entry)
00087 {
00088 double sensitivity = double(results.GetTP())/double(results.GetTP()+results.GetFN());
00089 double specificity = double(results.GetTN())/double(results.GetFP()+results.GetTN());
00090 double ppv = double(results.GetTP())/double(results.GetTP()+results.GetFP());
00091 double npv = double(results.GetTN())/double(results.GetTN()+results.GetFN());
00092
00093 if (results.GetTP()+results.GetFN()==0) sensitivity = -1.0;
00094 if (results.GetFP()+results.GetTN()==0) specificity = -1.0;
00095 if (results.GetTP()+results.GetFP()==0) ppv = -1.0;
00096 if (results.GetTN()+results.GetFN()==0) npv = -1.0;
00097
00098 entry.AddValue(Convert::ToStr(sensitivity),2);
00099 entry.AddValue(Convert::ToStr(specificity),3);
00100 entry.AddValue(Convert::ToStr(ppv),4);
00101 entry.AddValue(Convert::ToStr(npv),5);
00102 entry.AddValue(Convert::ToStr(results.GetDuration()),6);
00103 };
00104
00105 void
00106 ImageClassificationSOMetricMonitor::
00107 EnlistDictionaryEntries(StatisticDictionary& dictionary)
00108 {
00109 dictionary.AddValueDefinition(this->GetNameOfClass(),"Sensitivity", "The sensitivity is the proportion of true positives of all pixels belonging to the class");
00110 dictionary.AddValueDefinition(this->GetNameOfClass(),"Specitvity", "The specificity is the proportion of true negatives of all pixels not belonging to the class");
00111 dictionary.AddValueDefinition(this->GetNameOfClass(),"Positive predictive value", "The proportion of classified pixels who are correctly classified");
00112 dictionary.AddValueDefinition(this->GetNameOfClass(),"Negative predictive value", "The proportion of non classified pixels who are correctly classified");
00113 dictionary.AddValueDefinition(this->GetNameOfClass(),"Duration", "Duration of the registration in 1/10 sec");
00114 };
00115
00116
00117 }