00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __freAccuracySOMetricController_h
00023 #define __freAccuracySOMetricController_h
00024
00025 #include "freSetupOptimizationMultiThreadMetricControllerBase.h"
00026
00027 #include "freAccuracySOMetric.h"
00028
00029 namespace FREE
00030 {
00031
00041 freControllerIDMacro(AccuracySOMetricControllerBase, "AccuracySOMetricBase");
00042 template <class TControlledMetric>
00043 class AccuracySOMetricControllerBase : public SetupOptimizationMultiThreadMetricControllerBase<TControlledMetric>
00044 {
00045 public:
00046 DeclareParameterMacro(UseField);
00047 DeclareParameterMacro(ComputeAdaptationMean);
00048 DeclareParameterMacro(ResultField);
00049 DeclareParameterMacro(ReferenceField);
00050 DeclareParameterMacro(ReferencePoints);
00051 DeclareParameterMacro(MovingPoints);
00052
00053 typedef TControlledMetric ComponentType;
00054 typedef SetupOptimizationMultiThreadMetricControllerBase<ComponentType> Superclass;
00055
00056 itkTypeMacro(AccuracySOMetricControllerBase, SetupOptimizationMultiThreadMetricControllerBase);
00057
00058 protected:
00059 AccuracySOMetricControllerBase()
00060 {
00061
00062 this->UpdateControllerID(ControllerID::AccuracySOMetricControllerBase);
00063 this->m_Description = "Base class for accuracy registration metric.";
00064 };
00065
00066 virtual void GenerateProfile(CtrlProfile::ControllerProfile& profile,
00067 const SessionComponentCache* pComponentCache,
00068 bool bRegardOldSetup) const
00069 {
00070 Superclass::GenerateProfile(profile,pComponentCache,bRegardOldSetup);
00071
00072
00073 profile.Parameters().AddParameter(Superclass::cParam_MetricScales,CtrlProfile::Parameter::PVTDouble,Superclass::cParamDsc_MetricScales,9,"1.0");
00074 profile.Parameters().AddParameter(cParam_UseField,CtrlProfile::Parameter::PVTBool,cParamDsc_UseField,1,"true");
00075 profile.Parameters().AddParameter(cParam_ComputeAdaptationMean,CtrlProfile::Parameter::PVTBool,cParamDsc_ComputeAdaptationMean,1,"true");
00076 profile.Parameters().AddParameter(cParam_ReferenceField,CtrlProfile::Parameter::PVTIDPath,cParamDsc_ReferenceField,1,"");
00077 profile.Parameters().AddParameter(cParam_ResultField,CtrlProfile::Parameter::PVTIDPath,cParamDsc_ResultField,1,"");
00078 profile.Parameters().AddParameter(cParam_ReferencePoints,Parameter::PVTIDPath,cParamDsc_ReferencePoints,1,"");
00079 profile.Parameters().AddParameter(cParam_MovingPoints,CtrlProfile::Parameter::PVTIDPath,cParamDsc_MovingPoints,1,"");
00080 };
00081
00082 virtual void ActualizeMainComponent(ComponentType* pMainComponent,
00083 SessionComponentCache* pComponentCache,
00084 SessionInfo* pSessionInfo,
00085 const unsigned int& iActLevel) const
00086 {
00087 Superclass::ActualizeMainComponent(pMainComponent, pComponentCache,
00088 pSessionInfo, iActLevel);
00089
00090 bool bUseField;
00091 bool bComputeAdaptationMean;
00092 std::string sTempPath;
00093 IDPath referenceFieldPath;
00094 IDPath resultFieldPath;
00095 IDPath referencePointsPath;
00096 IDPath movingPointsPath;
00097
00098 try
00099 {
00100 SessionAccessor::GetParameterValue(pComponentCache,cParam_UseField,bUseField);
00101 SessionAccessor::GetParameterValue(pComponentCache,cParam_ComputeAdaptationMean,bComputeAdaptationMean);
00102 SessionAccessor::GetParameterValue(pComponentCache,cParam_ReferenceField,sTempPath);
00103 referenceFieldPath = sTempPath;
00104 SessionAccessor::GetParameterValue(pComponentCache,cParam_ResultField,sTempPath);
00105 resultFieldPath = sTempPath;
00106 SessionAccessor::GetParameterValue(pComponentCache,cParam_ReferencePoints,sTempPath);
00107 referencePointsPath = sTempPath;
00108 SessionAccessor::GetParameterValue(pComponentCache,cParam_MovingPoints,sTempPath);
00109 movingPointsPath = sTempPath;
00110 }
00111 catchAllNPassMacro("Error while retrieving parameter values.");
00112
00113 pMainComponent->SetUseField(bUseField);
00114 pMainComponent->SetComputeAdaptationMean(bComputeAdaptationMean);
00115 pMainComponent->SetReferenceFieldPath(referenceFieldPath);
00116 pMainComponent->SetReferencePointsPath(referencePointsPath);
00117 pMainComponent->SetMovingPointsPath(movingPointsPath);
00118 pMainComponent->SetResultFieldPath(resultFieldPath);
00119 };
00120
00121 void
00122 SetStatisticEntryMainComponent(StatisticEntry& rStatisticEntry,
00123 ComponentType* pMainComponent,
00124 SessionComponentCache* pMainComponentCache,
00125 SessionInfo* pSessionInfo,
00126 StatisticDictionary& rDictionary) const
00127 {
00128 typename ComponentType::DecomposedMeasureType values = pMainComponent->GetCurrentDecomposedValue();
00129
00130 std::string sIDPath = pMainComponentCache->GetIDPath();
00131 StatisticValueDefinition* pEntry = rDictionary.GetValueDefinitionByName(sIDPath,"mean error");
00132
00133 if (!pEntry)
00134 {
00135 if (pMainComponent->GetComputeAdaptationMean())
00136 {
00137 pEntry = rDictionary.AddValueDefinition(sIDPath,"mean adaptation error", "mean of all mean error of all adaptations.");
00138 rDictionary.AddValueDefinition(sIDPath,"std dev error", "mean standard deviation of all adaptations.");
00139 }
00140 else
00141 {
00142 pEntry = rDictionary.AddValueDefinition(sIDPath,"mean error", "mean error of the processed setup.");
00143 rDictionary.AddValueDefinition(sIDPath,"std dev image error", "standard deviation of the error of the processed setup.");
00144 }
00145 rDictionary.AddValueDefinition(sIDPath,"min adaptation error", "minimum error of the processed setup.");
00146 rDictionary.AddValueDefinition(sIDPath,"max adaptation error", "maximum error of the processed setup.");
00147 rDictionary.AddValueDefinition(sIDPath,"failure", "number of failed processings.");
00148 rDictionary.AddValueDefinition(sIDPath,"unevaluated points", "number of reference points that could not be evaluated.");
00149 rDictionary.AddValueDefinition(sIDPath,"mean duration", "mean duration of processing the setup (tenth of a second).");
00150 rDictionary.AddValueDefinition(sIDPath,"std duration", "standard deviation of processing the setup (tenth of a second).");
00151 rDictionary.AddValueDefinition(sIDPath,"min duration", "minimum duration of processing the setup (tenth of a second).");
00152 rDictionary.AddValueDefinition(sIDPath,"max duration", "maximum duration of processing the setup (tenth of a second).");
00153 }
00154
00155 for (unsigned int i = 0; i<values.Size(); i++)
00156 {
00157 rStatisticEntry.AddValue(Convert::ToStr(values[i]),pEntry->GetRefID()+i);
00158 }
00159 };
00160
00161 };
00162
00163 template <class TControlledMetric>
00164 const char* const AccuracySOMetricControllerBase<TControlledMetric>::cParam_UseField = "UseField";
00165 template <class TControlledMetric>
00166 const char* const AccuracySOMetricControllerBase<TControlledMetric>::cParamDsc_UseField = "Indicates if the metric should use a reference field or reference points to evaluate accuracy of the registrations.";
00167
00168 template <class TControlledMetric>
00169 const char* const AccuracySOMetricControllerBase<TControlledMetric>::cParam_ComputeAdaptationMean = "ComputeAdaptationMean";
00170 template <class TControlledMetric>
00171 const char* const AccuracySOMetricControllerBase<TControlledMetric>::cParamDsc_ComputeAdaptationMean = "Indicates how the mean error and standard deviation is calculated. If true, the mean error is the mean of mean errors of all adaptations and std dev is the mean of all std deviations. If false, the mean error is the mean of all point errors or field errors and std dev is his deviation. Both options are equal for the mean error, if all adaptation have the same point count/field size, otherwiese the first option will be biased towards adaptions with larger point count/field size.";
00172
00173 template <class TControlledMetric>
00174 const char* const AccuracySOMetricControllerBase<TControlledMetric>::cParam_ReferenceField = "ReferenceField";
00175 template <class TControlledMetric>
00176 const char* const AccuracySOMetricControllerBase<TControlledMetric>::cParamDsc_ReferenceField = "IDPath of the reference field within the session of the adapted setups used as test basis. Only required of UseField is true.";
00177
00178 template <class TControlledMetric>
00179 const char* const AccuracySOMetricControllerBase<TControlledMetric>::cParam_ResultField = "ResultField";
00180 template <class TControlledMetric>
00181 const char* const AccuracySOMetricControllerBase<TControlledMetric>::cParamDsc_ResultField = "IDPath of the result field of the processed session of the adapted setups used as test basis. This path is always required.";
00182
00183 template <class TControlledMetric>
00184 const char* const AccuracySOMetricControllerBase<TControlledMetric>::cParam_ReferencePoints = "ReferencePoints";
00185 template <class TControlledMetric>
00186 const char* const AccuracySOMetricControllerBase<TControlledMetric>::cParamDsc_ReferencePoints = "IDPath of the reference points within the session of the adapted setups used as test basis. Only required of UseField is false.";
00187
00188 template <class TControlledMetric>
00189 const char* const AccuracySOMetricControllerBase<TControlledMetric>::cParam_MovingPoints = "MovingPoints";
00190 template <class TControlledMetric>
00191 const char* const AccuracySOMetricControllerBase<TControlledMetric>::cParamDsc_MovingPoints = "IDPath of the reference field within the session of the adapted setups used as test basis. Only required of UseField is false.";
00192
00201 freControllerIDMacro(Accuracy2DSOMetricController, "Accuracy 2D SO Metric");
00202 class Accuracy2DSOMetricController : public AccuracySOMetricControllerBase< AccuracySOMetric<2> >
00203 {
00204 public:
00205 typedef AccuracySOMetric<2> ComponentType;
00206 typedef AccuracySOMetricControllerBase<ComponentType> Superclass;
00207
00208 itkTypeMacro(Accuracy2DSOMetricController, AccuracySOMetricControllerBase);
00209
00210 Accuracy2DSOMetricController();
00211
00212 };
00213
00222 freControllerIDMacro(Accuracy3DSOMetricController, "Accuracy 3D SO Metric");
00223 class Accuracy3DSOMetricController : public AccuracySOMetricControllerBase< AccuracySOMetric<3> >
00224 {
00225 public:
00226 typedef AccuracySOMetric<3> ComponentType;
00227 typedef AccuracySOMetricControllerBase<ComponentType> Superclass;
00228
00229 itkTypeMacro(Accuracy3DSOMetricController, AccuracySOMetricControllerBase);
00230
00231 Accuracy3DSOMetricController();
00232
00233 };
00234
00235 }
00236
00237 #endif