Medical Imaging Interaction Toolkit  2018.4.99-b5518f0d
Medical Imaging Interaction Toolkit
mitkPUImpurityLoss.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkPUImpurityLoss_h
14 #define mitkPUImpurityLoss_h
15 
16 #include <vigra/multi_array.hxx>
17 #include <vigra/random_forest.hxx>
18 #include <mitkAdditionalRFData.h>
19 
20 namespace mitk
21 {
22 
23  template<class LabelType = double>
24  class PURFProblemSpec : vigra::ProblemSpec<LabelType>
25  {
26  public:
27  vigra::ArrayVector<double> kappa_; // if classes have different importance
28  };
29 
30 
31  template <class TLossFunction = vigra::GiniCriterion, class TLabelContainer = vigra::MultiArrayView<2, int>, class TWeightContainer = vigra::MultiArrayView<2, double> >
33  {
34  public:
35  typedef TLabelContainer LabelContainerType;
36  typedef TWeightContainer WeightContainerType;
37 
38  template <class T>
39  PUImpurityLoss(TLabelContainer const &labels,
40  vigra::ProblemSpec<T> const &ext,
42 
43  void Reset();
44 
45  void UpdatePUCounts();
46 
47  template <class TDataIterator>
48  double Increment(TDataIterator begin, TDataIterator end);
49 
50  template <class TDataIterator>
51  double Decrement(TDataIterator begin, TDataIterator end);
52 
53  template <class TArray>
54  double Init(TArray initCounts);
55 
56  vigra::ArrayVector<double> const& Response();
57 
58  void UsePointWeights(bool useWeights);
59  bool IsUsingPointWeights();
60 
61  void SetPointWeights(TWeightContainer weight);
62  WeightContainerType GetPointWeights();
63 
64  private:
65  bool m_UsePointWeights;
66  TWeightContainer m_PointWeights;
67 
68  //Variable of origin
69  TLabelContainer const& m_Labels;
70  vigra::ArrayVector<double> m_Counts;
71  vigra::ArrayVector<double> m_PUCounts;
72  vigra::ArrayVector<double> m_Kappa;
73  vigra::ArrayVector<double> m_ClassWeights;
74  double m_TotalCount;
75  double m_PUTotalCount;
76  int m_ClassCount;
77  TLossFunction m_LossFunction;
78  };
79 
80 }
81 
82 #include <../src/Splitter/mitkPUImpurityLoss.cpp>
83 
84 #endif //mitkImpurityLoss_h
vigra::ArrayVector< double > kappa_
DataCollection - Class to facilitate loading/accessing structured data.
TLabelContainer LabelContainerType
TWeightContainer WeightContainerType