Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef __cmtkSplineWarpMultiChannelRegistrationFunctional_h_included_
00034 #define __cmtkSplineWarpMultiChannelRegistrationFunctional_h_included_
00035
00036 #include <cmtkconfig.h>
00037
00038 #include <Registration/cmtkMultiChannelRMIRegistrationFunctional.h>
00039 #include <Registration/cmtkTemplateMultiChannelRegistrationFunctional.h>
00040 #include <Registration/cmtkAffineMultiChannelRegistrationFunctional.h>
00041
00042 #include <Base/cmtkSplineWarpXform.h>
00043
00044 #include <System/cmtkThreads.h>
00045 #include <System/cmtkMutexLock.h>
00046
00047 #include <list>
00048
00049 namespace
00050 cmtk
00051 {
00052
00055
00057 template<class MetricFunctionalClass>
00058 class SplineWarpMultiChannelIntensityCorrectionRegistrationFunctional;
00059
00061 template<class TMetricFunctional = MultiChannelRMIRegistrationFunctional<> >
00062 class SplineWarpMultiChannelRegistrationFunctional :
00064 public TemplateMultiChannelRegistrationFunctional<SplineWarpXform, TMetricFunctional >
00065 {
00066 public:
00068 typedef SplineWarpMultiChannelRegistrationFunctional Self;
00069
00071 typedef SmartPointer<Self> SmartPtr;
00072
00074 typedef TemplateMultiChannelRegistrationFunctional<SplineWarpXform, TMetricFunctional > Superclass;
00075
00077 typedef typename Superclass::MetricData MetricData;
00078
00080 SplineWarpMultiChannelRegistrationFunctional();
00081
00083 template<class TAffineMetricFunctional>
00084 SplineWarpMultiChannelRegistrationFunctional
00085 ( AffineMultiChannelRegistrationFunctional<TAffineMetricFunctional>& affineFunctional );
00086
00088 virtual void SetInitialAffineTransformation( const AffineXform& initialAffine )
00089 {
00090 this->m_InitialAffineTransformation = initialAffine;
00091 }
00092
00094 void SetAdaptiveFixEntropyThreshold( const bool flag )
00095 {
00096 this->m_AdaptiveFixEntropyThreshold = flag;
00097 }
00098
00100 void SetAdaptiveFixThreshFactor( const float factor )
00101 {
00102 this->m_AdaptiveFixThreshFactor = factor;
00103 }
00104
00106 void ClearFixedCoordinateDimensions()
00107 {
00108 this->m_FixedCoordinateDimensions.clear();
00109 }
00110
00112 void AddFixedCoordinateDimension( const int dim )
00113 {
00114 this->m_FixedCoordinateDimensions.push_back( dim );
00115 }
00116
00118 void SetJacobianConstraintWeight( const float weight )
00119 {
00120 this->m_JacobianConstraintWeight = weight;
00121 }
00122
00124 virtual void InitTransformation( const Vector3D& domain, const Types::Coordinate gridSpacing, const bool exact );
00125
00127 virtual void RefineTransformation();
00128
00130 virtual void ClearAllChannels()
00131 {
00132 this->ClearReformattedFloatingChannels();
00133 Superclass::ClearAllChannels();
00134 }
00135
00137 virtual typename Self::ReturnType Evaluate();
00138
00140 virtual typename Self::ReturnType EvaluateWithGradient( CoordinateVector& v, CoordinateVector& g, const Types::Coordinate step = 1 );
00141
00142 protected:
00144 virtual void NewReferenceChannelGeometry()
00145 {
00146 this->UpdateTransformationData();
00147 }
00148
00149 private:
00151 AffineXform m_InitialAffineTransformation;
00152
00154 virtual void UpdateTransformationData();
00155
00157 std::vector< std::vector<float> > m_ReformattedFloatingChannels;
00158
00160 virtual void AllocateReformattedFloatingChannels();
00161
00163 virtual void ClearReformattedFloatingChannels();
00164
00166 typename Self::ReturnType EvaluateIncremental( const SplineWarpXform* warp, MetricData& metricData, const DataGrid::RegionType& region );
00167
00169 virtual void ContinueMetricStoreReformatted( MetricData& metricData, const size_t rindex, const Vector3D& fvector );
00170
00172 virtual void BacktraceMetric( MetricData& metricData, const DataGrid::RegionType& voi );
00173
00175 std::vector<Types::Coordinate> m_StepScaleVector;
00176
00178 std::vector<DataGrid::RegionType> m_VolumeOfInfluenceVector;
00179
00181 bool m_AdaptiveFixEntropyThreshold;
00182
00184 float m_AdaptiveFixThreshFactor;
00185
00187 std::list<int> m_FixedCoordinateDimensions;
00188
00190 float m_JacobianConstraintWeight;
00191
00193 virtual void UpdateTransformationFixedControlPoints();
00194
00196 bool m_UpdateTransformationFixedControlPointsRequired;
00197
00199 const size_t m_NumberOfThreads;
00200
00202 static void EvaluateThreadFunction( void* args, const size_t taskIdx, const size_t taskCnt, const size_t threadIdx, const size_t );
00203
00205 MutexLock m_MetricDataMutex;
00206
00208 std::vector<SplineWarpXform::SmartPtr> m_ThreadTransformations;
00209
00211 class EvaluateGradientThreadParameters :
00213 public ThreadParameters<Self>
00214 {
00215 public:
00217 Types::Coordinate m_Step;
00218
00220 Types::Coordinate* m_Gradient;
00221
00223 const CoordinateVector* m_ParameterVector;
00224
00226 typename Self::ReturnType m_MetricBaseValue;
00227 };
00228
00230 static void EvaluateWithGradientThreadFunction( void* args, const size_t taskIdx, const size_t taskCnt, const size_t threadIdx, const size_t );
00231
00233 template<class MetricFunctionalClass> friend class SplineWarpMultiChannelIntensityCorrectionRegistrationFunctional;
00234 };
00235
00237
00238 }
00239
00240 #include "cmtkSplineWarpMultiChannelRegistrationFunctional.txx"
00241 #include "cmtkSplineWarpMultiChannelRegistrationFunctionalThreadFunctions.txx"
00242
00243 #endif // #ifndef __cmtkSplineWarpMultiChannelRegistrationFunctional_h_included_