ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkExpectationMaximizationMixtureModelEstimator.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkExpectationMaximizationMixtureModelEstimator_h
19 #define itkExpectationMaximizationMixtureModelEstimator_h
20 
24 
25 namespace itk
26 {
27 namespace Statistics
28 {
60 template< typename TSample >
61 class ITK_TEMPLATE_EXPORT ExpectationMaximizationMixtureModelEstimator:public Object
62 {
63 public:
66  using Superclass = Object;
69 
72  Object);
73  itkNewMacro(Self);
75 
77  using SampleType = TSample;
78  using MeasurementType = typename TSample::MeasurementType;
79  using MeasurementVectorType = typename TSample::MeasurementVectorType;
80 
84 
86 
89  using MembershipFunctionVectorType = std::vector< MembershipFunctionPointer >;
92 
95 
97  using ComponentVectorType = std::vector< ComponentType * >;
98 
101 
104 
106  void SetSample(const TSample *sample);
107 
109  const TSample * GetSample() const;
110 
113  void SetInitialProportions(ProportionVectorType & propotion);
114 
115  const ProportionVectorType & GetInitialProportions() const;
116 
118  const ProportionVectorType & GetProportions() const;
119 
123 
125  const MembershipFunctionsWeightsArrayObjectType * GetMembershipFunctionsWeightsArray() const;
126 
131  void SetMaximumIteration(int numberOfIterations);
132 
133  int GetMaximumIteration() const;
134 
137  {
138  return m_CurrentIteration;
139  }
140 
142  int AddComponent(ComponentType *component);
143 
145  unsigned int GetNumberOfComponents() const;
146 
148  void Update();
149 
151  enum TERMINATION_CODE { CONVERGED = 0, NOT_CONVERGED = 1 };
152 
154  TERMINATION_CODE GetTerminationCode() const;
155 
158  ComponentMembershipFunctionType * GetComponentMembershipFunction(int componentIndex) const;
159 
162  const MembershipFunctionVectorObjectType * GetOutput() const;
163 
164 protected:
166  ~ExpectationMaximizationMixtureModelEstimator() override = default;
167  void PrintSelf(std::ostream & os, Indent indent) const override;
168 
169  bool CalculateDensities();
170 
171  double CalculateExpectation() const;
172 
173  bool UpdateComponentParameters();
174 
175  bool UpdateProportions();
176 
178  void GenerateData();
179 
180 private:
182  const TSample *m_Sample;
183 
184  int m_MaxIteration{100};
185  int m_CurrentIteration{0};
186 
191 
194 }; // end of class
195 } // end of namespace Statistics
196 } // end of namespace itk
197 
198 #ifndef ITK_MANUAL_INSTANTIATION
199 #include "itkExpectationMaximizationMixtureModelEstimator.hxx"
200 #endif
201 
202 #endif
Light weight base class for most itk classes.
typename MembershipFunctionVectorObjectType::Pointer MembershipFunctionVectorObjectPointer
Decorates any &quot;simple&quot; data type (data types without smart pointers) with a DataObject API...
GaussianMembershipFunction models class membership through a multivariate Gaussian function...
MembershipFunctionBase defines common interfaces for membership functions.
typename MembershipFunctionsWeightsArrayObjectType::Pointer MembershipFunctionsWeightsArrayPointer
Control indentation during Print() invocation.
Definition: itkIndent.h:49
base class for distribution modules that supports analytical way to update the distribution parameter...
This class generates the parameter estimates for a mixture model using expectation maximization strat...
Base class for most ITK classes.
Definition: itkObject.h:60