# Statistics Framework Resolve Decision Rules Duplicates

Jim Miller
2011-05-31
The statistics library was refactored in 2007 and has been available under the Review directory since that time. ITKv4 has adoped the refactored statistics library and has removed the original statistics library. Remnants of the old statistics library were still visible in ITK as a few of the classes in the new statistics library were named using a convention that would not clash with the old statistics framework, e.g. MaximumDecisionRule2. In an effort to complete the transition to the new statistics framework, these duplicate classes have been resolved into single class definitions. Classes from the old statistics framework have been removed and classes from the new statistics framework have been renamed to officially take their place. Along with these changes, the documentation and API has been revised.

For users of the old statistics framework, there are two main changes: (1) itk::DecisionRuleBase has been renamed itk::Statistics::DecisionRule, and (2) the subclasses of DecisionRule are now in the itk::Statistics namespace, i.e. itk::MaximumDecisionRule is now referred to as itk::Statistics::MaximumDecisionRule.

For users of the new statistics framework, there are two main changes: (1) decision rule classes have been renamed to supplant the names from the old statistics library, i.e. itk::Statistics::MaximumDecisionRule2 is now itk::Statistics::MaximumDecisionRule (this affect header inclusion and class references), and (2) the API to MaximumRatioDecisionRule has been modified to make it consistent with ITK conventions. With the latter, ther has been a change that prior probabilities are assumed to be doubles not floats, to make prior probabilities consistent in type with the likelihood functions. Finally, typedefs have been created to define class ids and probability value types.
#include "itkMaximumDecisionRule2.h"

int main(int, char*[]) { typedef itk::Statistics::MaximumDecisionRule2 DecisionRuleType; DecisionRuleType::Pointer decisionRule = DecisionRuleType::New();

return 0; }
#include "itkMaximumDecisionRule.h"

int main(int, char*[]) { typedef itk::Statistics::MaximumDecisionRule DecisionRuleType; DecisionRuleType::Pointer decisionRule = DecisionRuleType::New();

return 0; }
#include "itkMaximumRatioDecisionRule2.h"

int main(int, char*[]) { typedef itk::Statistics::MaximumRatioDecisionRule2 DecisionRuleType; DecisionRuleType::Pointer decisionRule = DecisionRuleType::New();

std::vector&lt; double > discriminantScores; discriminantScores.push_back( 0.1 ); discriminantScores.push_back( 0.3 ); discriminantScores.push_back( 0.6 );

DecisionRuleType::APrioriVectorType aPrioris; aPrioris.push_back( 0.1 ); aPrioris.push_back( 0.8 ); aPrioris.push_back( 0.1 );

decisionRule->SetAPriori( aPrioris ); unsigned int cid = decisionRule->Evaluate( discriminantScores );

return 0; }
#include "itkMaximumRatioDecisionRule.h"

int main(int, char*[]) { typedef itk::Statistics::MaximumRatioDecisionRule DecisionRuleType; DecisionRuleType::Pointer decisionRule = DecisionRuleType::New();

DecisionRuleType::MembershipVectorType discriminantScores; discriminantScores.push_back( 0.1 ); discriminantScores.push_back( 0.3 ); discriminantScores.push_back( 0.6 );

DecisionRuleType::PriorProbabilityVectorType aPrioris; aPrioris.push_back( 0.1 ); aPrioris.push_back( 0.8 ); aPrioris.push_back( 0.1 );

decisionRule->SetPriorProbabilities( aPrioris ); DecisionRuleType::ClassIdentifierType cid = decisionRule->Evaluate( discriminantScores );

return 0; }
http://review.source.kitware.com/#change,1740
Examples/Statistics/CMakeLists.txt Examples/Statistics/MaximumDecisionRule.cxx Examples/Statistics/MaximumDecisionRule2.cxx Examples/Statistics/MaximumRatioDecisionRule.cxx Examples/Statistics/MaximumRatioDecisionRule2.cxx Examples/Statistics/MinimumDecisionRule.cxx Examples/Statistics/MinimumDecisionRule2.cxx Modules/Numerics/Statistics/include/itkDecisionRule.h Modules/Numerics/Statistics/include/itkDecisionRuleBase.h Modules/Numerics/Statistics/include/itkMaximumDecisionRule.h Modules/Numerics/Statistics/include/itkMaximumDecisionRule2.h Modules/Numerics/Statistics/include/itkMaximumRatioDecisionRule.h Modules/Numerics/Statistics/include/itkMaximumRatioDecisionRule2.h Modules/Numerics/Statistics/include/itkMinimumDecisionRule.h Modules/Numerics/Statistics/include/itkMinimumDecisionRule2.h Modules/Numerics/Statistics/src/itkMaximumRatioDecisionRule.cxx Modules/Numerics/Statistics/test/CMakeLists.txt Modules/Numerics/Statistics/test/itkDecisionRuleBackwardCompatibilityTest.cxx Modules/Segmentation/MarkovRandomFieldsClassifiers/test/itkMRFImageFilterTest.cxx Examples/Segmentation/GibbsPriorImageFilter1.cxx Examples/Statistics/BayesianPluginClassifier.cxx Examples/Statistics/KdTreeBasedKMeansClustering.cxx Examples/Statistics/ScalarImageMarkovRandomField1.cxx Modules/Nonunit/IntegratedTest/test/itkCommonPrintTest.cxx Modules/Nonunit/IntegratedTest/test/itkMaximumDecisionRuleTest.cxx Modules/Nonunit/IntegratedTest/test/itkMaximumRatioDecisionRuleTest.cxx Modules/Nonunit/IntegratedTest/test/itkMinimumDecisionRuleTest.cxx Modules/Nonunit/IntegratedTest/test/itkStatisticsPrintTest.cxx Modules/Numerics/Statistics/src/CMakeLists.txt Modules/Numerics/Statistics/src/itkDecisionRule.cxx Modules/Numerics/Statistics/src/itkDecisionRuleBase.cxx Modules/Numerics/Statistics/src/itkMaximumDecisionRule.cxx Modules/Numerics/Statistics/src/itkMaximumDecisionRule2.cxx Modules/Numerics/Statistics/src/itkMaximumRatioDecisionRule2.cxx Modules/Numerics/Statistics/src/itkMinimumDecisionRule.cxx Modules/Numerics/Statistics/src/itkMinimumDecisionRule2.cxx Modules/Numerics/Statistics/test/itkDecisionRuleBackwardCompatibility.cxx Modules/Numerics/Statistics/test/itkDecisionRuleTest.cxx Modules/Numerics/Statistics/test/itkMaximumDecisionRuleTest.cxx Modules/Numerics/Statistics/test/itkMaximumRatioDecisionRuleTest.cxx Modules/Numerics/Statistics/test/itkMinimumDecisionRuleTest.cxx Modules/Numerics/Statistics/test/itkStatisticsHeaderTest.cxx Modules/Segmentation/Classifiers/include/itkBayesianClassifierImageFilter.h Modules/Segmentation/Classifiers/include/itkBayesianClassifierImageFilter.txx Modules/Segmentation/Classifiers/include/itkClassifierBase.h Modules/Segmentation/Classifiers/include/itkScalarImageKmeansImageFilter.h Modules/Segmentation/Classifiers/test/itkImageClassifierFilterTest.cxx Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest1.cxx Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest2.cxx Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest3.cxx Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest4.cxx Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest5.cxx Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest6.cxx Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest7.cxx Modules/Segmentation/Classifiers/test/itkSupervisedImageClassifierTest.cxx Modules/Segmentation/MarkovRandomFieldsClassifiers/test/itkGibbsTest.cxx
itk::DecisionRuleBase
itk::Statistics::DecisionRule
itk::Statistics::MaximumDecisionRule2
itk::Statistics::MaximumDecisionRule
itk::Statistics::MinimumDecisionRule2
itk::Statistics::MinimumDecisionRule
itk::Statistics::MaximumRatioDecisionRule2
itk::Statistics::MaximumRatioDecisionRule
#include "itkDecisionRuleBase.h"
#include "itkDecisionRule.h"
#include "itkMaximumDecisionRule2.h"
#include "itkMaximumDecisionRule.h"
#include "itkMinimumDecisionRule2.h"
#include "itkMinimumDecisionRule.h"
#include "itkMaximumRatioDecisionRule2.h"
#include "itkMaximumRatioDecisionRule.h"
SetAPrioris
SetPriorProbabilities
::APrioriVectorType
::PriorProbabilityVectorType