ITK  5.2.0
Insight Toolkit
itkExpectationMaximizationMixtureModelEstimator.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 
21 #include <ITKStatisticsExport.h>
25 
26 namespace itk
27 {
28 namespace Statistics
29 {
35 {
36 public:
41  {
42  CONVERGED = 0,
43  NOT_CONVERGED = 1
44  };
45 };
46 // Define how to print enumeration
47 extern ITKStatistics_EXPORT std::ostream &
49 
84 
85 template <typename TSample>
86 class ITK_TEMPLATE_EXPORT ExpectationMaximizationMixtureModelEstimator : public Object
87 {
88 public:
91  using Superclass = Object;
94 
97  itkNewMacro(Self);
99 
101  using SampleType = TSample;
102  using MeasurementType = typename TSample::MeasurementType;
103  using MeasurementVectorType = typename TSample::MeasurementVectorType;
104 
108 
110 
113  using MembershipFunctionVectorType = std::vector<MembershipFunctionPointer>;
116 
119 
121  using ComponentVectorType = std::vector<ComponentType *>;
122 
125 
128 
130  void
131  SetSample(const TSample * sample);
132 
134  const TSample *
135  GetSample() const;
136 
139  void
140  SetInitialProportions(ProportionVectorType & proportions);
141 
142  const ProportionVectorType &
143  GetInitialProportions() const;
144 
146  const ProportionVectorType &
147  GetProportions() const;
148 
152 
155  GetMembershipFunctionsWeightsArray() const;
156 
161  void
162  SetMaximumIteration(int numberOfIterations);
163 
164  int
165  GetMaximumIteration() const;
166 
168  int
170  {
171  return m_CurrentIteration;
172  }
173 
175  int
176  AddComponent(ComponentType * component);
177 
179  unsigned int
180  GetNumberOfComponents() const;
181 
183  void
184  Update();
185 
187 #if !defined(ITK_LEGACY_REMOVE)
188 
189  static constexpr TERMINATION_CODE_ENUM CONVERGED = TERMINATION_CODE_ENUM::CONVERGED;
190  static constexpr TERMINATION_CODE_ENUM NOT_CONVERGED = TERMINATION_CODE_ENUM::NOT_CONVERGED;
191 #endif
192 
195  GetTerminationCode() const;
196 
200  GetComponentMembershipFunction(int componentIndex) const;
201 
205  GetOutput() const;
206 
207 protected:
209  ~ExpectationMaximizationMixtureModelEstimator() override = default;
210  void
211  PrintSelf(std::ostream & os, Indent indent) const override;
212 
213  bool
214  CalculateDensities();
215 
216  double
217  CalculateExpectation() const;
218 
219  bool
220  UpdateComponentParameters();
221 
222  bool
223  UpdateProportions();
224 
226  void
227  GenerateData();
228 
229 private:
231  const TSample * m_Sample;
232 
233  int m_MaxIteration{ 100 };
234  int m_CurrentIteration{ 0 };
235 
236  TERMINATION_CODE_ENUM m_TerminationCode{ TERMINATION_CODE_ENUM::NOT_CONVERGED };
240 
243 }; // end of class
244 } // end of namespace Statistics
245 } // end of namespace itk
246 
247 #ifndef ITK_MANUAL_INSTANTIATION
248 # include "itkExpectationMaximizationMixtureModelEstimator.hxx"
249 #endif
250 
251 #endif
itk::Statistics::ExpectationMaximizationMixtureModelEstimator::m_ComponentVector
ComponentVectorType m_ComponentVector
Definition: itkExpectationMaximizationMixtureModelEstimator.h:237
itk::Statistics::MixtureModelComponentBase
base class for distribution modules that supports analytical way to update the distribution parameter...
Definition: itkMixtureModelComponentBase.h:57
itk::SimpleDataObjectDecorator
Decorates any "simple" data type (data types without smart pointers) with a DataObject API.
Definition: itkSimpleDataObjectDecorator.h:66
itk::uint8_t
::uint8_t uint8_t
Definition: itkIntTypes.h:29
itk::Statistics::ExpectationMaximizationMixtureModelEstimator::m_MembershipFunctionsObject
MembershipFunctionVectorObjectPointer m_MembershipFunctionsObject
Definition: itkExpectationMaximizationMixtureModelEstimator.h:241
itkGaussianMembershipFunction.h
itk::Statistics::ExpectationMaximizationMixtureModelEstimator::m_Proportions
ProportionVectorType m_Proportions
Definition: itkExpectationMaximizationMixtureModelEstimator.h:239
itk::Statistics::MembershipFunctionBase
MembershipFunctionBase defines common interfaces for membership functions.
Definition: itkMembershipFunctionBase.h:58
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::Statistics::operator<<
ITKStatistics_EXPORT std::ostream & operator<<(std::ostream &out, const ExpectationMaximizationMixtureModelEstimatorEnums::TERMINATION_CODE value)
itk::Statistics::ExpectationMaximizationMixtureModelEstimator::MembershipFunctionsWeightsArrayPointer
typename MembershipFunctionsWeightsArrayObjectType::Pointer MembershipFunctionsWeightsArrayPointer
Definition: itkExpectationMaximizationMixtureModelEstimator.h:151
itk::Statistics::ExpectationMaximizationMixtureModelEstimator::m_Sample
const TSample * m_Sample
Definition: itkExpectationMaximizationMixtureModelEstimator.h:231
itk::Statistics::ExpectationMaximizationMixtureModelEstimator
This class generates the parameter estimates for a mixture model using expectation maximization strat...
Definition: itkExpectationMaximizationMixtureModelEstimator.h:86
itk::Statistics::ExpectationMaximizationMixtureModelEstimator::SampleType
TSample SampleType
Definition: itkExpectationMaximizationMixtureModelEstimator.h:101
itkMixtureModelComponentBase.h
itk::Statistics::ExpectationMaximizationMixtureModelEstimatorEnums::TERMINATION_CODE
TERMINATION_CODE
Definition: itkExpectationMaximizationMixtureModelEstimator.h:40
itk::Statistics::ExpectationMaximizationMixtureModelEstimator::MembershipFunctionVectorType
std::vector< MembershipFunctionPointer > MembershipFunctionVectorType
Definition: itkExpectationMaximizationMixtureModelEstimator.h:113
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::Statistics::ExpectationMaximizationMixtureModelEstimator::m_MembershipFunctionsWeightArrayObject
MembershipFunctionsWeightsArrayPointer m_MembershipFunctionsWeightArrayObject
Definition: itkExpectationMaximizationMixtureModelEstimator.h:242
itk::Statistics::ExpectationMaximizationMixtureModelEstimator::GetCurrentIteration
int GetCurrentIteration()
Definition: itkExpectationMaximizationMixtureModelEstimator.h:169
itk::Statistics::ExpectationMaximizationMixtureModelEstimator::m_InitialProportions
ProportionVectorType m_InitialProportions
Definition: itkExpectationMaximizationMixtureModelEstimator.h:238
itk::Statistics::ExpectationMaximizationMixtureModelEstimator::MembershipFunctionPointer
typename MembershipFunctionType::ConstPointer MembershipFunctionPointer
Definition: itkExpectationMaximizationMixtureModelEstimator.h:112
itk::Statistics::ExpectationMaximizationMixtureModelEstimatorEnums::TERMINATION_CODE::CONVERGED
itk::Statistics::ExpectationMaximizationMixtureModelEstimatorEnums
Contains all enum classes used by ExpectationMaximizationMixtureModelEstimator class.
Definition: itkExpectationMaximizationMixtureModelEstimator.h:34
TERMINATION_CODE
itk::Statistics::ExpectationMaximizationMixtureModelEstimator::MembershipFunctionVectorObjectPointer
typename MembershipFunctionVectorObjectType::Pointer MembershipFunctionVectorObjectPointer
Definition: itkExpectationMaximizationMixtureModelEstimator.h:115
itk::Statistics::GaussianMembershipFunction
GaussianMembershipFunction models class membership through a multivariate Gaussian function.
Definition: itkGaussianMembershipFunction.h:56
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::Statistics::ExpectationMaximizationMixtureModelEstimator::MeasurementType
typename TSample::MeasurementType MeasurementType
Definition: itkExpectationMaximizationMixtureModelEstimator.h:102
itk::Array< double >
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:62
itk::Statistics::ExpectationMaximizationMixtureModelEstimator::GaussianMembershipFunctionPointer
typename GaussianMembershipFunctionType::Pointer GaussianMembershipFunctionPointer
Definition: itkExpectationMaximizationMixtureModelEstimator.h:109
itkSimpleDataObjectDecorator.h
itk::Statistics::ExpectationMaximizationMixtureModelEstimator::ComponentVectorType
std::vector< ComponentType * > ComponentVectorType
Definition: itkExpectationMaximizationMixtureModelEstimator.h:121
itk::Statistics::ExpectationMaximizationMixtureModelEstimator::MeasurementVectorType
typename TSample::MeasurementVectorType MeasurementVectorType
Definition: itkExpectationMaximizationMixtureModelEstimator.h:103
itk::Statistics::ExpectationMaximizationMixtureModelEstimatorEnums::TERMINATION_CODE::NOT_CONVERGED