Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

Review/Statistics/itkExpectationMaximizationMixtureModelEstimator.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkExpectationMaximizationMixtureModelEstimator.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-05-02 05:43:55 $
00007   Version:   $Revision: 1.1 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkExpectationMaximizationMixtureModelEstimator_h
00018 #define __itkExpectationMaximizationMixtureModelEstimator_h
00019 
00020 #include "itkMembershipFunctionBase.h"
00021 #include "itkMixtureModelComponentBase.h"
00022 #include "itkGaussianMembershipFunction.h"
00023 
00024 namespace itk { 
00025 namespace Statistics {
00026 
00053 template< class TSample >
00054 class ITK_EXPORT ExpectationMaximizationMixtureModelEstimator : public Object
00055 {
00056 public:
00058   typedef ExpectationMaximizationMixtureModelEstimator Self;
00059   typedef Object                                       Superclass;
00060   typedef SmartPointer< Self >                         Pointer;
00061   typedef SmartPointer<const Self>                     ConstPointer;
00062 
00064   itkTypeMacro(ExpectationMaximizationMixtureModelEstimator,
00065                Object);
00066   itkNewMacro(Self);
00068 
00070   typedef TSample                                 SampleType;
00071   typedef typename TSample::MeasurementType       MeasurementType;
00072   typedef typename TSample::MeasurementVectorType MeasurementVectorType;
00073 
00074 
00077   typedef GaussianMembershipFunction< MeasurementVectorType > 
00078                                                    GaussianMembershipFunctionType;
00079 
00080   typedef typename GaussianMembershipFunctionType::Pointer 
00081                                                    GaussianMembershipFunctionPointer;
00082 
00083   typedef MembershipFunctionBase< MeasurementVectorType > MembershipFunctionType;
00084   typedef typename MembershipFunctionType::ConstPointer   MembershipFunctionPointer;
00085   typedef std::vector< MembershipFunctionPointer >        MembershipFunctionVectorType;
00086   typedef SimpleDataObjectDecorator<
00087     MembershipFunctionVectorType >                        MembershipFunctionVectorObjectType;
00088   typedef typename 
00089     MembershipFunctionVectorObjectType::Pointer           MembershipFunctionVectorObjectPointer;
00090 
00092   typedef MixtureModelComponentBase< TSample > ComponentType;
00093 
00095   typedef std::vector< ComponentType* > ComponentVectorType;
00096 
00098   typedef MembershipFunctionBase< MeasurementVectorType > 
00099   ComponentMembershipFunctionType;
00100 
00102   typedef Array< double > ProportionVectorType;
00103 
00105   void SetSample(const TSample* sample);
00106 
00108   const TSample* GetSample() const;
00109 
00112   void SetInitialProportions(ProportionVectorType &propotion);
00113   const ProportionVectorType& GetInitialProportions() const;
00115 
00117   const ProportionVectorType& GetProportions() const;
00118 
00120   typedef SimpleDataObjectDecorator<
00121   ProportionVectorType>                 MembershipFunctionsWeightsArrayObjectType;
00122   typedef typename 
00123     MembershipFunctionsWeightsArrayObjectType::Pointer   MembershipFunctionsWeightsArrayPointer;
00124 
00126   const MembershipFunctionsWeightsArrayObjectType * GetMembershipFunctionsWeightsArray() const;
00127 
00132   void SetMaximumIteration(int numberOfIterations);
00133   int GetMaximumIteration() const;
00135 
00137   int GetCurrentIteration() 
00138     { 
00139     return m_CurrentIteration;
00140     }
00141 
00143   int AddComponent(ComponentType* component);
00144 
00146   unsigned int GetNumberOfComponents() const;
00147 
00149   void Update();
00150 
00152   enum TERMINATION_CODE { CONVERGED = 0, NOT_CONVERGED = 1 };
00153 
00155   TERMINATION_CODE GetTerminationCode() const;
00156 
00159   ComponentMembershipFunctionType* GetComponentMembershipFunction(int componentIndex) const;
00160 
00163   const MembershipFunctionVectorObjectType * GetOutput() const; 
00164 
00165 protected:
00166   ExpectationMaximizationMixtureModelEstimator();
00167   virtual ~ExpectationMaximizationMixtureModelEstimator() {}
00168   void PrintSelf(std::ostream& os, Indent indent) const;
00169 
00170   bool CalculateDensities();
00171   double CalculateExpectation() const;
00172   bool UpdateComponentParameters();
00173   bool UpdateProportions();
00174 
00176   void GenerateData();
00177 
00178 private:
00180   const TSample* m_Sample;
00181 
00182   int m_MaxIteration;
00183   int m_CurrentIteration;
00184 
00185   TERMINATION_CODE            m_TerminationCode;
00186   ComponentVectorType         m_ComponentVector;
00187   ProportionVectorType        m_InitialProportions;
00188   ProportionVectorType        m_Proportions;
00189 
00190   MembershipFunctionVectorObjectPointer   m_MembershipFunctionsObject;
00191   MembershipFunctionsWeightsArrayPointer  m_MembershipFunctionsWeightArrayObject;
00192 }; // end of class
00193 
00194 
00195 } // end of namespace Statistics 
00196 } // end of namespace itk
00197 
00198 
00199 #ifndef ITK_MANUAL_INSTANTIATION
00200 #include "itkExpectationMaximizationMixtureModelEstimator.txx"
00201 #endif
00202 
00203 #endif
00204 

Generated at Fri Apr 16 18:17:10 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000