Medical Imaging Interaction Toolkit  2023.04.00
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);
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
mitk::PUImpurityLoss::WeightContainerType
TWeightContainer WeightContainerType
Definition: mitkPUImpurityLoss.h:36
mitkAdditionalRFData.h
mitk::PUImpurityLoss::Decrement
double Decrement(TDataIterator begin, TDataIterator end)
mitk::PURFProblemSpec
Definition: mitkPUImpurityLoss.h:24
mitk::PUImpurityLoss::Init
double Init(TArray initCounts)
mitk::PURFProblemSpec::kappa_
vigra::ArrayVector< double > kappa_
Definition: mitkPUImpurityLoss.h:27
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitk::PUImpurityLoss::UpdatePUCounts
void UpdatePUCounts()
mitk::PUImpurityLoss
Definition: mitkPUImpurityLoss.h:32
mitk::AdditionalRFDataAbstract
Definition: mitkAdditionalRFData.h:21
mitk::PUImpurityLoss::UsePointWeights
void UsePointWeights(bool useWeights)
mitk::PUImpurityLoss::PUImpurityLoss
PUImpurityLoss(TLabelContainer const &labels, vigra::ProblemSpec< T > const &ext, AdditionalRFDataAbstract *data)
mitk::PUImpurityLoss::SetPointWeights
void SetPointWeights(TWeightContainer weight)
mitk::PUImpurityLoss::Increment
double Increment(TDataIterator begin, TDataIterator end)
mitk::PUImpurityLoss::Response
vigra::ArrayVector< double > const & Response()
mitk::PUImpurityLoss::IsUsingPointWeights
bool IsUsingPointWeights()
mitk::PUImpurityLoss::Reset
void Reset()
mitk::PUImpurityLoss::LabelContainerType
TLabelContainer LabelContainerType
Definition: mitkPUImpurityLoss.h:35
mitk::PUImpurityLoss::GetPointWeights
WeightContainerType GetPointWeights()