freSetupOptimizationMetric.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   F.R.E.E. - flexible registration evaluation engine
00004   Version:   v.1.0.0
00005   Date:      $Date: 2006/09/01 12:00:00 $
00006   Module:    $RCSfile: freSetupOptimizationMetric.h,v $
00007   Language:  C++
00008 
00009 
00010 
00011   Copyright (c) 2007 Ralf o Floca (Department of Medical Informatics,
00012   Institute for Medical Biometry and Informatics, University of Heidelberg,
00013   Germany). All rights reserved.
00014   See FREECopyright.txt or http://www.mi.med.uni-hd.de/free/copyright.htm
00015   for details.
00016 
00017      This software is distributed WITHOUT ANY WARRANTY; without even 
00018      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00019      PURPOSE.  See the above copyright notices for more information.
00020 
00021 =========================================================================*/
00022 #ifndef __freSetupOptimizationMetric_h
00023 #define __freSetupOptimizationMetric_h
00024 
00025 #include "freElementals.h"
00026 #include "freSetupTransform.h"
00027 #include "freAdaptationList.h"
00028 #include "freRegistrationEvents.h"
00029 #include "freSetupOptimizationObserverEvents.h"
00030 
00031 #include "itkCostFunction.h"
00032 #include "itkArray.h"
00033 #include "itkObjectFactory.h"
00034 #include "itkNumericTraits.h"
00035 
00036 namespace FREE
00037 {
00038 
00045 class ITK_EXPORT SetupOptimizationMetric : 
00046   public itk::CostFunction 
00047 {
00048 public:
00050   typedef SetupOptimizationMetric           Self;
00051   typedef itk::CostFunction            Superclass;
00052   typedef itk::SmartPointer<Self>           Pointer;
00053   typedef itk::SmartPointer<const Self>     ConstPointer;
00054  
00056   itkTypeMacro( SetupOptimizationMetric, CostFunction );
00057  
00060   typedef Superclass::ParametersType         ParametersType;
00061 
00064   typedef double                                                                 MeasureType;
00065   typedef itk::Array<double>                 DecomposedMeasureType;
00066   typedef itk::Array<double>                 DerivativeType;
00067   
00068         typedef itk::Array<double>                                                               MetricScalesType;
00069 
00070   typedef SetupTransform                     TransformType;
00071   typedef TransformType::Pointer                                         TransformPointer;
00072 
00073         itkSetMacro( Delta, double);
00074   itkGetMacro( Delta, double);
00075 
00076   itkSetMacro( MetricScales, MetricScalesType );
00077   itkGetConstReferenceMacro( MetricScales, MetricScalesType );
00078 
00081   virtual MeasureType GetValue( const ParametersType & parameters ) const;
00082   virtual DecomposedMeasureType GetDecomposedValue( const ParametersType & parameters ) const;
00083 
00085         DecomposedMeasureType GetCurrentDecomposedValue() const;
00087         MeasureType GetCurrentValue() const;
00089         ParametersType GetCurrentParameters() const;
00090 
00092   virtual void GetDerivative( const ParametersType & parameters,
00093                       DerivativeType  & derivative ) const;
00094 
00096   virtual void GetValueAndDerivative( const ParametersType & parameters,
00097     MeasureType& Value, DerivativeType& Derivative ) const;
00098 
00102   virtual unsigned int GetNumberOfValues(void) const  = 0;
00103 
00106   virtual unsigned int GetNumberOfParameters(void) const;
00107 
00109   itkSetObjectMacro( Transform, TransformType );
00111   itkGetConstObjectMacro( Transform, TransformType );
00112 
00115   Adaptation::AdaptationList* GetAdaptationList() const;
00116   void SetAdaptationList(Adaptation::AdaptationList* pAdaptations);
00117 
00118   virtual Statistics& GetMetricStatistic() const {return m_MetricStatistic;};
00119 
00120   virtual void Initialize();
00121 
00129   ProgressEventBase::Pointer fnOnEvaluationProgress;
00130 
00136   ProgressEventBase::Pointer fnOnEvaluationDone;
00137 
00143   ProgressEventBase::Pointer fnOnNextAdaptation;
00144 
00149   ProgressEventBase::Pointer fnOnEvaluationFailed;
00150 
00151 protected:
00152   SetupOptimizationMetric();
00153   virtual ~SetupOptimizationMetric();
00154 
00155   TransformPointer m_Transform;
00156   Adaptation::AdaptationList::Pointer m_smpAdaptations;
00157 
00158   IterationEvent<SetupOptimizationMetric>::Pointer m_IterationEvent;
00159 
00160   virtual DecomposedMeasureType ComputeDecomposedValue( const ParametersType & parameters ) const = 0;
00161 
00162   virtual void ComputeDecomposedValueAndDerivative( const ParametersType & parameters,
00163                                                                                                                                                                                                                 DecomposedMeasureType& Value,
00164                                                                                                                                                                                                                 DerivativeType& Derivative) const;
00165 
00166         MeasureType ComposeValue(const DecomposedMeasureType& values) const;
00167 
00168         MetricScalesType m_MetricScales;
00169 
00170         mutable DecomposedMeasureType m_CachedValues;
00171         mutable DerivativeType m_CachedDerivative;
00172         mutable ParametersType m_CachedParameters;
00173 
00174   void EnlistLastRegistrationEvaluation() const;
00177   mutable Statistics m_MetricStatistic;
00178 
00179         double m_Delta;
00180 
00181 private:
00182   SetupOptimizationMetric(const Self&); //purposely not implemented
00183   void operator=(const Self&); //purposely not implemented
00184 };
00185 
00186 
00187 } // end namespace FREE
00188 
00189 
00190 #endif
00191 
00192 
00193 

Generated at Sat Oct 13 17:27:29 2007 for f.r.e.e. - Flexible Registration and Evaluation Engine by doxygen 1.5.3 written by Dimitri van Heesch, © 1997-2000