diff --git a/Modules/ModelFit/include/mitkExponentialDecayModel.h b/Modules/ModelFit/include/mitkExponentialDecayModel.h index b7e4d991c7..60797f420b 100644 --- a/Modules/ModelFit/include/mitkExponentialDecayModel.h +++ b/Modules/ModelFit/include/mitkExponentialDecayModel.h @@ -1,144 +1,142 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef mitkExponentialDecayModel_h #define mitkExponentialDecayModel_h #include "mitkModelBase.h" #include "MitkModelFitExports.h" namespace mitk { /** @class ExponentialDecayModel * @brief Simple model of exponential decay in the form of: * y(x) = y-intercept * exp(-x/lambda) with lambda being the decay constant. */ class MITKMODELFIT_EXPORT ExponentialDecayModel : public mitk::ModelBase { public: typedef ExponentialDecayModel Self; typedef mitk::ModelBase Superclass; typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; typedef Superclass::ParameterNameType ParameterNameType; typedef Superclass::ParametersSizeType ParametersSizeType; /** Method for creation through the object factory. */ itkFactorylessNewMacro(Self); itkCloneMacro(Self); /** Run-time type information (and related methods). */ itkTypeMacro(ExponentialDecayModel, ModelBase); static const std::string NAME_PARAMETER_y0; static const std::string NAME_PARAMETER_lambda; static const unsigned int NUMBER_OF_PARAMETERS; static const std::string UNIT_PARAMETER_y0; static const std::string UNIT_PARAMETER_lambda; static const unsigned int POSITION_PARAMETER_y0; static const unsigned int POSITION_PARAMETER_lambda; static const std::string NAME_DERIVED_PARAMETER_k; static const unsigned int NUMBER_OF_DERIVED_PARAMETERS; static const std::string UNIT_DERIVED_PARAMETER_k; static const unsigned int NUMBER_OF_STATIC_PARAMETERS; static const std::string MODEL_DISPLAY_NAME; static const std::string MODEL_TYPE; static const std::string FUNCTION_STRING; static const std::string X_NAME; static const std::string X_AXIS_NAME; static const std::string X_AXIS_UNIT; static const std::string Y_AXIS_NAME; static const std::string Y_AXIS_UNIT; ParameterNamesType GetParameterNames() const override; ParametersSizeType GetNumberOfParameters() const override; ParamterUnitMapType GetParameterUnits() const override; ParameterNamesType GetDerivedParameterNames() const override; ParametersSizeType GetNumberOfDerivedParameters() const override; ParamterUnitMapType GetDerivedParameterUnits() const override; ParameterNamesType GetStaticParameterNames() const override; ParametersSizeType GetNumberOfStaticParameters() const override; - ParamterUnitMapType GetStaticParameterUnits() const override; - std::string GetModelDisplayName() const override; std::string GetModelType() const override; FunctionStringType GetFunctionString() const override; std::string GetXName() const override; std::string GetXAxisName() const override; std::string GetXAxisUnit() const override; std::string GetYAxisName() const override; std::string GetYAxisUnit() const override; mitk::ModelBase::DerivedParameterMapType ComputeDerivedParameters( const mitk::ModelBase::ParametersType ¶meters) const; protected: ExponentialDecayModel() {}; ~ExponentialDecayModel() override {}; /** * Actual implementation of the clone method. This method should be reimplemeted * in subclasses to clone the extra required parameters. */ itk::LightObject::Pointer InternalClone() const override; ModelResultType ComputeModelfunction(const ParametersType& parameters) const override; void SetStaticParameter(const ParameterNameType& name, const StaticParameterValuesType& values) override; StaticParameterValuesType GetStaticParameterValue(const ParameterNameType& name) const override; private: //No copy constructor allowed ExponentialDecayModel(const Self& source); void operator=(const Self&); //purposely not implemented }; } #endif diff --git a/Modules/ModelFit/src/Models/mitkExponentialDecayModel.cpp b/Modules/ModelFit/src/Models/mitkExponentialDecayModel.cpp index 025fea430c..ca96684b30 100644 --- a/Modules/ModelFit/src/Models/mitkExponentialDecayModel.cpp +++ b/Modules/ModelFit/src/Models/mitkExponentialDecayModel.cpp @@ -1,217 +1,208 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "mitkExponentialDecayModel.h" #include "mitkNumericConstants.h" const std::string mitk::ExponentialDecayModel::NAME_PARAMETER_y0 = "y-intercept"; const std::string mitk::ExponentialDecayModel::NAME_PARAMETER_lambda = "lambda"; const unsigned int mitk::ExponentialDecayModel::NUMBER_OF_PARAMETERS = 2; const std::string mitk::ExponentialDecayModel::UNIT_PARAMETER_y0 = "[unit of y]"; const std::string mitk::ExponentialDecayModel::UNIT_PARAMETER_lambda = "[unit of x]"; const unsigned int mitk::ExponentialDecayModel::POSITION_PARAMETER_y0 = 0; const unsigned int mitk::ExponentialDecayModel::POSITION_PARAMETER_lambda = 1; const std::string mitk::ExponentialDecayModel::NAME_DERIVED_PARAMETER_k = "rate"; const unsigned int mitk::ExponentialDecayModel::NUMBER_OF_DERIVED_PARAMETERS = 1; const std::string mitk::ExponentialDecayModel::UNIT_DERIVED_PARAMETER_k = "1/[unit of x]"; const unsigned int mitk::ExponentialDecayModel::NUMBER_OF_STATIC_PARAMETERS = 0; const std::string mitk::ExponentialDecayModel::MODEL_DISPLAY_NAME = "Exponential Decay Model"; const std::string mitk::ExponentialDecayModel::MODEL_TYPE = "Generic"; const std::string mitk::ExponentialDecayModel::FUNCTION_STRING = "y(x) = y-intercept * exp(-x/lambda)"; const std::string mitk::ExponentialDecayModel::X_NAME = "x"; const std::string mitk::ExponentialDecayModel::X_AXIS_NAME = "X"; const std::string mitk::ExponentialDecayModel::X_AXIS_UNIT = "unit of x"; const std::string mitk::ExponentialDecayModel::Y_AXIS_NAME = "Y"; const std::string mitk::ExponentialDecayModel::Y_AXIS_UNIT = "unit of y"; std::string mitk::ExponentialDecayModel::GetModelDisplayName() const { return MODEL_DISPLAY_NAME; }; std::string mitk::ExponentialDecayModel::GetModelType() const { return MODEL_TYPE; }; mitk::ExponentialDecayModel::FunctionStringType mitk::ExponentialDecayModel::GetFunctionString() const { return FUNCTION_STRING; }; std::string mitk::ExponentialDecayModel::GetXName() const { return X_NAME; }; std::string mitk::ExponentialDecayModel::GetXAxisName() const { return X_AXIS_NAME; }; std::string mitk::ExponentialDecayModel::GetXAxisUnit() const { return X_AXIS_UNIT; } std::string mitk::ExponentialDecayModel::GetYAxisName() const { return Y_AXIS_NAME; }; std::string mitk::ExponentialDecayModel::GetYAxisUnit() const { return Y_AXIS_UNIT; } mitk::ExponentialDecayModel::ParameterNamesType mitk::ExponentialDecayModel::GetParameterNames() const { ParameterNamesType result; result.push_back(NAME_PARAMETER_y0); result.push_back(NAME_PARAMETER_lambda); return result; }; mitk::ExponentialDecayModel::ParamterUnitMapType mitk::ExponentialDecayModel::GetParameterUnits() const { ParamterUnitMapType result; result.insert(std::make_pair(NAME_PARAMETER_y0, UNIT_PARAMETER_y0)); result.insert(std::make_pair(NAME_PARAMETER_lambda, UNIT_PARAMETER_lambda)); return result; } mitk::ExponentialDecayModel::ParametersSizeType mitk::ExponentialDecayModel::GetNumberOfParameters() const { return NUMBER_OF_PARAMETERS; }; mitk::ExponentialDecayModel::ParameterNamesType mitk::ExponentialDecayModel::GetDerivedParameterNames() const { ParameterNamesType result; result.push_back(NAME_DERIVED_PARAMETER_k); return result; }; mitk::ExponentialDecayModel::ParametersSizeType mitk::ExponentialDecayModel::GetNumberOfDerivedParameters() const { return NUMBER_OF_DERIVED_PARAMETERS; }; mitk::ExponentialDecayModel::ParamterUnitMapType mitk::ExponentialDecayModel::GetDerivedParameterUnits() const { ParamterUnitMapType result; result.insert(std::make_pair(NAME_DERIVED_PARAMETER_k, UNIT_DERIVED_PARAMETER_k)); return result; }; mitk::ExponentialDecayModel::ModelResultType mitk::ExponentialDecayModel::ComputeModelfunction(const ParametersType& parameters) const { double y0 = parameters[POSITION_PARAMETER_y0]; double lambda = parameters[POSITION_PARAMETER_lambda]; ModelResultType signal(m_TimeGrid.GetSize()); ModelResultType::iterator signalPos = signal.begin(); for (const auto& gridPos : m_TimeGrid) { *signalPos = y0 * exp(-1.0 * gridPos/ lambda); ++signalPos; } return signal; }; mitk::ExponentialDecayModel::ParameterNamesType mitk::ExponentialDecayModel::GetStaticParameterNames() const { ParameterNamesType result; return result; } mitk::ExponentialDecayModel::ParametersSizeType mitk::ExponentialDecayModel::GetNumberOfStaticParameters() const { return NUMBER_OF_STATIC_PARAMETERS; } -mitk::ExponentialDecayModel::ParamterUnitMapType mitk::ExponentialDecayModel::GetStaticParameterUnits() const -{ - ParamterUnitMapType result; - - //do nothing - - return result; -}; - void mitk::ExponentialDecayModel::SetStaticParameter(const ParameterNameType& /*name*/, const StaticParameterValuesType& /*values*/) { //do nothing }; mitk::ExponentialDecayModel::StaticParameterValuesType mitk::ExponentialDecayModel::GetStaticParameterValue( const ParameterNameType& /*name*/) const { StaticParameterValuesType result; //do nothing return result; }; mitk::ModelBase::DerivedParameterMapType mitk::ExponentialDecayModel::ComputeDerivedParameters( const mitk::ModelBase::ParametersType ¶meters) const { DerivedParameterMapType result; //Model Parameters double lambda = parameters[POSITION_PARAMETER_lambda]; double k = 1.0 / (lambda + mitk::eps); result.insert(std::make_pair(NAME_DERIVED_PARAMETER_k, k)); return result; }; itk::LightObject::Pointer mitk::ExponentialDecayModel::InternalClone() const { ExponentialDecayModel::Pointer newClone = ExponentialDecayModel::New(); newClone->SetTimeGrid(this->m_TimeGrid); return newClone.GetPointer(); };