diff --git a/Modules/Pharmacokinetics/include/mitkExtendedToftsModel.h b/Modules/Pharmacokinetics/include/mitkExtendedToftsModel.h index 64f03b7aff..551c38524b 100644 --- a/Modules/Pharmacokinetics/include/mitkExtendedToftsModel.h +++ b/Modules/Pharmacokinetics/include/mitkExtendedToftsModel.h @@ -1,106 +1,116 @@ /*============================================================================ 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 mitkExtendedToftsModel_h #define mitkExtendedToftsModel_h #include "mitkAIFBasedModelBase.h" #include "MitkPharmacokineticsExports.h" namespace mitk { /** @class ExtendedToftsModel * @brief Implementation of the Model function of the Tofts pharmacokinetic model, using an Aterial Input Function * The Model calculates the Concentration-Time-Curve as a convolution of the plasma curve Cp (the AIF) and a tissue specific * residue function (in this case an exponential: R(t) = ktrans * exp(-ktrans/ve * (t)) ). * C(t) = vp * Cp(t) + conv(Cp(t),R(t)) * The parameters ktrans, ve and ve are subject to the fitting routine*/ class MITKPHARMACOKINETICS_EXPORT ExtendedToftsModel : public AIFBasedModelBase { public: typedef ExtendedToftsModel Self; typedef AIFBasedModelBase Superclass; typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; /** Method for creation through the object factory. */ itkFactorylessNewMacro(Self); itkCloneMacro(Self); /** Run-time type information (and related methods). */ itkTypeMacro(ExtendedToftsModel, ModelBase); - static const std::string MODEL_DISPLAY_NAME; - static const std::string NAME_PARAMETER_Ktrans; static const std::string NAME_PARAMETER_ve; static const std::string NAME_PARAMETER_vp; static const std::string UNIT_PARAMETER_Ktrans; static const std::string UNIT_PARAMETER_ve; static const std::string UNIT_PARAMETER_vp; static const unsigned int POSITION_PARAMETER_Ktrans; static const unsigned int POSITION_PARAMETER_ve; static const unsigned int POSITION_PARAMETER_vp; static const unsigned int NUMBER_OF_PARAMETERS; + static const std::string NAME_DERIVED_PARAMETER_kep; + + static const unsigned int NUMBER_OF_DERIVED_PARAMETERS; + + static const std::string UNIT_DERIVED_PARAMETER_kep; + + static const std::string MODEL_DISPLAY_NAME; + + static const std::string MODEL_TYPE; + + static const std::string FUNCTION_STRING; + std::string GetModelDisplayName() const override; std::string GetModelType() const override; ParameterNamesType GetParameterNames() const override; ParametersSizeType GetNumberOfParameters() const override; ParamterUnitMapType GetParameterUnits() const override; ParameterNamesType GetDerivedParameterNames() const override; ParametersSizeType GetNumberOfDerivedParameters() const override; ParamterUnitMapType GetDerivedParameterUnits() const override; protected: ExtendedToftsModel(); ~ExtendedToftsModel() 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; DerivedParameterMapType ComputeDerivedParameters(const mitk::ModelBase::ParametersType& parameters) const override; void PrintSelf(std::ostream& os, ::itk::Indent indent) const override; private: //No copy constructor allowed ExtendedToftsModel(const Self& source); void operator=(const Self&); //purposely not implemented }; } #endif diff --git a/Modules/Pharmacokinetics/src/Models/mitkExtendedToftsModel.cpp b/Modules/Pharmacokinetics/src/Models/mitkExtendedToftsModel.cpp index dedc6d3917..c17d27f0a8 100644 --- a/Modules/Pharmacokinetics/src/Models/mitkExtendedToftsModel.cpp +++ b/Modules/Pharmacokinetics/src/Models/mitkExtendedToftsModel.cpp @@ -1,182 +1,192 @@ /*============================================================================ 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 "mitkExtendedToftsModel.h" #include "mitkConvolutionHelper.h" #include #include const std::string mitk::ExtendedToftsModel::MODEL_DISPLAY_NAME = "Extended Tofts Model"; -const std::string mitk::ExtendedToftsModel::NAME_PARAMETER_Ktrans = "KTrans"; -const std::string mitk::ExtendedToftsModel::NAME_PARAMETER_ve = "ve"; -const std::string mitk::ExtendedToftsModel::NAME_PARAMETER_vp = "vp"; +const std::string mitk::ExtendedToftsModel::NAME_PARAMETER_Ktrans = "K^trans"; +const std::string mitk::ExtendedToftsModel::NAME_PARAMETER_ve = "v_e"; +const std::string mitk::ExtendedToftsModel::NAME_PARAMETER_vp = "v_p"; const std::string mitk::ExtendedToftsModel::UNIT_PARAMETER_Ktrans = "ml/min/100ml"; const std::string mitk::ExtendedToftsModel::UNIT_PARAMETER_ve = "ml/ml"; const std::string mitk::ExtendedToftsModel::UNIT_PARAMETER_vp = "ml/ml"; const unsigned int mitk::ExtendedToftsModel::POSITION_PARAMETER_Ktrans = 0; const unsigned int mitk::ExtendedToftsModel::POSITION_PARAMETER_ve = 1; const unsigned int mitk::ExtendedToftsModel::POSITION_PARAMETER_vp = 2; const unsigned int mitk::ExtendedToftsModel::NUMBER_OF_PARAMETERS = 3; +const std::string mitk::ExtendedToftsModel::NAME_DERIVED_PARAMETER_kep = "k_{e->p}"; + +const unsigned int mitk::ExtendedToftsModel::NUMBER_OF_DERIVED_PARAMETERS = 1; + +const std::string mitk::ExtendedToftsModel::UNIT_DERIVED_PARAMETER_kep = "1/min"; + +const std::string mitk::ExtendedToftsModel::MODEL_TYPE = "Perfusion.MR"; + +const std::string mitk::ExtendedToftsModel::FUNCTION_STRING = ""; + std::string mitk::ExtendedToftsModel::GetModelDisplayName() const { return MODEL_DISPLAY_NAME; }; std::string mitk::ExtendedToftsModel::GetModelType() const { - return "Perfusion.MR"; + return MODEL_TYPE; }; mitk::ExtendedToftsModel::ExtendedToftsModel() { } mitk::ExtendedToftsModel::~ExtendedToftsModel() { } mitk::ExtendedToftsModel::ParameterNamesType mitk::ExtendedToftsModel::GetParameterNames() const { ParameterNamesType result; result.push_back(NAME_PARAMETER_Ktrans); result.push_back(NAME_PARAMETER_ve); result.push_back(NAME_PARAMETER_vp); return result; } mitk::ExtendedToftsModel::ParametersSizeType mitk::ExtendedToftsModel::GetNumberOfParameters() const { return NUMBER_OF_PARAMETERS; } mitk::ExtendedToftsModel::ParamterUnitMapType mitk::ExtendedToftsModel::GetParameterUnits() const { ParamterUnitMapType result; result.insert(std::make_pair(NAME_PARAMETER_Ktrans, UNIT_PARAMETER_Ktrans)); result.insert(std::make_pair(NAME_PARAMETER_vp, UNIT_PARAMETER_vp)); result.insert(std::make_pair(NAME_PARAMETER_ve, UNIT_PARAMETER_ve)); return result; }; mitk::ExtendedToftsModel::ParameterNamesType mitk::ExtendedToftsModel::GetDerivedParameterNames() const { ParameterNamesType result; - result.push_back("kep"); + result.push_back(NAME_DERIVED_PARAMETER_kep); return result; }; mitk::ExtendedToftsModel::ParametersSizeType mitk::ExtendedToftsModel::GetNumberOfDerivedParameters() const { - return 1; + return NUMBER_OF_DERIVED_PARAMETERS; }; mitk::ExtendedToftsModel::ParamterUnitMapType mitk::ExtendedToftsModel::GetDerivedParameterUnits() const { ParamterUnitMapType result; - result.insert(std::make_pair("kep", "1/min")); + result.insert(std::make_pair(NAME_DERIVED_PARAMETER_kep, UNIT_DERIVED_PARAMETER_kep)); return result; }; mitk::ExtendedToftsModel::ModelResultType mitk::ExtendedToftsModel::ComputeModelfunction( const ParametersType& parameters) const { if (this->m_TimeGrid.GetSize() == 0) { itkExceptionMacro("No Time Grid Set! Cannot Calculate Signal"); } AterialInputFunctionType aterialInputFunction; aterialInputFunction = GetAterialInputFunction(this->m_TimeGrid); unsigned int timeSteps = this->m_TimeGrid.GetSize(); //Model Parameters double ktrans = parameters[POSITION_PARAMETER_Ktrans] / 6000.0; double ve = parameters[POSITION_PARAMETER_ve]; double vp = parameters[POSITION_PARAMETER_vp]; if (ve == 0.0) { itkExceptionMacro("ve is 0! Cannot calculate signal"); } double lambda = ktrans / ve; mitk::ModelBase::ModelResultType convolution = mitk::convoluteAIFWithExponential(this->m_TimeGrid, aterialInputFunction, lambda); //Signal that will be returned by ComputeModelFunction mitk::ModelBase::ModelResultType signal(timeSteps); signal.fill(0.0); mitk::ModelBase::ModelResultType::iterator signalPos = signal.begin(); mitk::ModelBase::ModelResultType::const_iterator res = convolution.begin(); for (AterialInputFunctionType::iterator Cp = aterialInputFunction.begin(); Cp != aterialInputFunction.end(); ++res, ++signalPos, ++Cp) { *signalPos = (*Cp) * vp + ktrans * (*res); } return signal; } mitk::ModelBase::DerivedParameterMapType mitk::ExtendedToftsModel::ComputeDerivedParameters( const mitk::ModelBase::ParametersType& parameters) const { DerivedParameterMapType result; double kep = parameters[POSITION_PARAMETER_Ktrans] / parameters[POSITION_PARAMETER_ve]; - result.insert(std::make_pair("kep", kep)); + result.insert(std::make_pair(NAME_DERIVED_PARAMETER_kep, kep)); return result; }; itk::LightObject::Pointer mitk::ExtendedToftsModel::InternalClone() const { ExtendedToftsModel::Pointer newClone = ExtendedToftsModel::New(); newClone->SetTimeGrid(this->m_TimeGrid); return newClone.GetPointer(); }; void mitk::ExtendedToftsModel::PrintSelf(std::ostream& os, ::itk::Indent indent) const { Superclass::PrintSelf(os, indent); };