freSingleValuedVnlSOMetricAdaptor.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: freSingleValuedVnlSOMetricAdaptor.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 
00023 #ifndef __freSingleValuedVnlSOMetricAdaptor_h
00024 #define __freSingleValuedVnlSOMetricAdaptor_h
00025 
00026 #include "freSetupOptimizationMetric.h"
00027 #include "vnl/vnl_cost_function.h"
00028 
00029 #include "itkEventObject.h"
00030 #include "itkCommand.h"
00031 
00032 
00033 namespace FREE
00034 {
00035   
00046 class SingleValuedVnlSOMetricAdaptor : 
00047     public vnl_cost_function
00048 {
00049 public:
00050 
00052   typedef   vnl_vector<double>     InternalParametersType;
00053 
00055   typedef   double                 InternalMeasureType;
00056 
00058   typedef   vnl_vector<double>     InternalDerivativeType;
00059 
00061   typedef SetupOptimizationMetric::ParametersType ParametersType;
00062 
00064         typedef itk::Array<double>                                                               DerivativeType;
00065 
00067   typedef SetupOptimizationMetric::MeasureType           MeasureType;
00068 
00069         typedef SetupOptimizationMetric::DecomposedMeasureType           DecomposedMeasureType;
00070 
00072         typedef itk::Array<double>             ScalesType;
00073 
00075         typedef itk::Array<double>             MetricScalesType;
00076 
00077         virtual const char* GetNameOfClass() const { return "SingleValuedVnlSOMetricAdaptor";};
00078 
00080   SingleValuedVnlSOMetricAdaptor(unsigned int spaceDimension);
00081 
00083   void SetCostFunction( SetupOptimizationMetric * costFunction )
00084   { m_CostFunction = costFunction; }
00085 
00087   const SetupOptimizationMetric * GetCostFunction( void ) const
00088   { return m_CostFunction; }
00089 
00090 
00092   virtual InternalMeasureType f( const InternalParametersType & inparameters );
00093     
00095   virtual void gradf(const InternalParametersType   & inparameters,
00096                      InternalDerivativeType   & gradient );
00097     
00099   virtual void compute(const InternalParametersType   & x,
00100                        InternalMeasureType      * f, 
00101                        InternalDerivativeType   * g   );
00102     
00104   void ConvertExternalToInternalGradient(
00105     const DerivativeType         & input,
00106     InternalDerivativeType & output ) const;
00107 
00109   void SetScales(const ScalesType & scales);
00110 
00119    void SetNegateCostFunction( bool value );
00120    bool GetNegateCostFunction() const;
00121    void NegateCostFunctionOn() { m_NegateCostFunction = true; }
00122    void NegateCostFunctionOff() { m_NegateCostFunction = false; }
00123  
00128   unsigned long AddObserver(const itk::EventObject & event, itk::Command * command) const;
00129 
00134   const MeasureType & GetCachedValue() const;
00135   const DecomposedMeasureType & GetCachedDecomposedValue() const;
00136   const DerivativeType & GetCachedDerivative() const;
00137   const ParametersType & GetCachedCurrentParameters() const;
00138   
00139 protected:
00140 
00143         void ReportIteration( const itk::EventObject & event ) const;
00144 
00145         virtual ParametersType ConvertInternalToParameter(const InternalParametersType & inparameters);
00146         virtual InternalParametersType ConvertParameterToInternal(const ParametersType & parameters);
00147 
00148   SetupOptimizationMetric::Pointer                                      m_CostFunction;
00149   bool                                m_ScalesInitialized;
00150   ScalesType                          m_Scales;
00151   bool                                m_NegateCostFunction;
00152         itk::Object::Pointer                     m_Reporter;
00153   
00154   mutable MeasureType                 m_CachedValue;
00155   mutable DecomposedMeasureType       m_CachedDecomposedValue;
00156   mutable DerivativeType              m_CachedDerivative;
00157   mutable ParametersType              m_CachedCurrentParameters;
00158 
00159 };  // end of Class CostFunction
00160 
00161     
00162 } // end namespace itk
00163 
00164 
00165 #endif
00166 
00167 
00168 

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