diff --git a/Modules/Pharmacokinetics/autoload/Models/mitkPharmacokineticModelsActivator.cpp b/Modules/Pharmacokinetics/autoload/Models/mitkPharmacokineticModelsActivator.cpp index b3c4088926..bc00163e87 100644 --- a/Modules/Pharmacokinetics/autoload/Models/mitkPharmacokineticModelsActivator.cpp +++ b/Modules/Pharmacokinetics/autoload/Models/mitkPharmacokineticModelsActivator.cpp @@ -1,77 +1,75 @@ /*============================================================================ 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 #include #include //MR perfusion models #include "mitkDescriptivePharmacokineticBrixModelFactory.h" #include "mitkExtendedToftsModelFactory.h" #include "mitkStandardToftsModelFactory.h" #include "mitkTwoCompartmentExchangeModelFactory.h" -#include "mitkNumericTwoCompartmentExchangeModelFactory.h" //PET perfusion models #include "mitkOneTissueCompartmentModelFactory.h" #include "mitkExtendedOneTissueCompartmentModelFactory.h" #include "mitkTwoTissueCompartmentModelFactory.h" #include "mitkTwoTissueCompartmentFDGModelFactory.h" #include "mitkNumericTwoTissueCompartmentModelFactory.h" namespace mitk { /* * This is the module activator for the IO aspects of the "pharmacokinetics" module. */ class PharmacokineticModelsActivator : public us::ModuleActivator { public: template void RegisterProvider(us::ModuleContext* context) { auto provider = new TProvider(); provider->RegisterService(context); m_RegisteredProviders.push_back(std::unique_ptr(provider)); } void Load(us::ModuleContext* context) override { m_RegisteredProviders.clear(); RegisterProvider >(context); RegisterProvider >(context); RegisterProvider >(context); RegisterProvider >(context); - RegisterProvider >(context); RegisterProvider >(context); RegisterProvider >(context); RegisterProvider >(context); RegisterProvider >(context); RegisterProvider >(context); } void Unload(us::ModuleContext* ) override { } private: std::vector > m_RegisteredProviders; }; } US_EXPORT_MODULE_ACTIVATOR(mitk::PharmacokineticModelsActivator) diff --git a/Modules/Pharmacokinetics/files.cmake b/Modules/Pharmacokinetics/files.cmake index 6af6b8dd1c..03cd41d8ca 100644 --- a/Modules/Pharmacokinetics/files.cmake +++ b/Modules/Pharmacokinetics/files.cmake @@ -1,61 +1,58 @@ file(GLOB_RECURSE H_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include/*") set(CPP_FILES Common/mitkAterialInputFunctionGenerator.cpp Common/mitkAIFParametrizerHelper.cpp Common/mitkConcentrationCurveGenerator.cpp Common/mitkDescriptionParameterImageGeneratorBase.cpp Common/mitkPixelBasedDescriptionParameterImageGenerator.cpp DescriptionParameters/mitkCurveDescriptionParameterBase.cpp DescriptionParameters/mitkAreaUnderTheCurveDescriptionParameter.cpp DescriptionParameters/mitkAreaUnderFirstMomentDescriptionParameter.cpp DescriptionParameters/mitkMeanResidenceTimeDescriptionParameter.cpp DescriptionParameters/mitkTimeToPeakCurveDescriptionParameter.cpp DescriptionParameters/mitkMaximumCurveDescriptionParameter.cpp Functors/mitkCurveParameterFunctor.cpp Models/mitkAIFBasedModelBase.cpp Models/mitkDescriptivePharmacokineticBrixModel.cpp Models/mitkDescriptivePharmacokineticBrixModelFactory.cpp Models/mitkDescriptivePharmacokineticBrixModelValueBasedParameterizer.cpp Models/mitkDescriptivePharmacokineticBrixModelParameterizer.cpp Models/mitkTwoCompartmentExchangeModel.cpp Models/mitkTwoCompartmentExchangeModelFactory.cpp Models/mitkTwoCompartmentExchangeModelParameterizer.cpp - Models/mitkNumericTwoCompartmentExchangeModel.cpp - Models/mitkNumericTwoCompartmentExchangeModelFactory.cpp - Models/mitkNumericTwoCompartmentExchangeModelParameterizer.cpp Models/mitkExtendedToftsModel.cpp Models/mitkExtendedToftsModelFactory.cpp Models/mitkExtendedToftsModelParameterizer.cpp Models/mitkStandardToftsModel.cpp Models/mitkStandardToftsModelFactory.cpp Models/mitkStandardToftsModelParameterizer.cpp Models/mitkOneTissueCompartmentModel.cpp Models/mitkOneTissueCompartmentModelFactory.cpp Models/mitkOneTissueCompartmentModelParameterizer.cpp Models/mitkExtendedOneTissueCompartmentModel.cpp Models/mitkExtendedOneTissueCompartmentModelFactory.cpp Models/mitkExtendedOneTissueCompartmentModelParameterizer.cpp Models/mitkTwoTissueCompartmentModel.cpp Models/mitkTwoTissueCompartmentModelFactory.cpp Models/mitkTwoTissueCompartmentModelParameterizer.cpp Models/mitkTwoTissueCompartmentFDGModel.cpp Models/mitkTwoTissueCompartmentFDGModelFactory.cpp Models/mitkTwoTissueCompartmentFDGModelParameterizer.cpp Models/mitkNumericTwoTissueCompartmentModel.cpp Models/mitkNumericTwoTissueCompartmentModelFactory.cpp Models/mitkNumericTwoTissueCompartmentModelParameterizer.cpp SimulationFramework/mitkImageGenerationHelper.cpp ) set(HXX_FILES mitkDICOMSegmentationConstants.h ) set(MOC_H_FILES ) diff --git a/Modules/Pharmacokinetics/include/mitkNumericTwoCompartmentExchangeModel.h b/Modules/Pharmacokinetics/include/mitkNumericTwoCompartmentExchangeModel.h deleted file mode 100644 index b8bcc20432..0000000000 --- a/Modules/Pharmacokinetics/include/mitkNumericTwoCompartmentExchangeModel.h +++ /dev/null @@ -1,128 +0,0 @@ -/*============================================================================ - -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 mitkNumericTwoCompartmentExchangeModel_h -#define mitkNumericTwoCompartmentExchangeModel_h - -#include "mitkAIFBasedModelBase.h" -#include "MitkPharmacokineticsExports.h" - - -namespace mitk -{ - /** @class NumericTwoCompartmentExchangeModel - * @brief Implementation of the numeric model function of the 2 Compartment Exchange model, using an Aterial Input Function - * The Model calculates the measured Concentration-Time-Curve from the mass balance equations of the 2-tissue compartent Model - * - * vp * dCp(t)/dt = F * (CA(t) - Cp(t)) - PS * (Cp(t) - Ci(t)) - * ve * dCi(t)/dt = PS * (Cp(t) - Ci(t)) - * - * with concentration curve Cp(t) of the Blood Plasma p and Ce(t) of the Extracellular Extravascular Space(EES)(interstitial volume). CA(t) is the aterial concentration, i.e. the AIF - * Cp(t) and Ce(t) are found numerical via Runge-Kutta methode, implemented in Boosts numeric library ODEINT. Here we use a runge_kutta_cash_karp54 stepper with - * adaptive step size and error controll. - * From the resulting curves Cp(t) and Ce(t) the measured concentration Ctotal(t) is found vial - * - * Ctotal(t) = vp * Cp(t) + ve * Ce(t) - * - * where vp=Vp/VT and ve=Ve/VT are the portion of Plasma/EES volume Vp/Ve of the total volume VT respectively. - * The parameters PS, F, vp and ve are subject to the fitting routine*/ - - class MITKPHARMACOKINETICS_EXPORT NumericTwoCompartmentExchangeModel : public AIFBasedModelBase - { - - public: - typedef NumericTwoCompartmentExchangeModel 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(NumericTwoCompartmentExchangeModel, ModelBase); - - typedef std::vector state_type; - - - static const std::string MODEL_DISPLAY_NAME; - - static const std::string NAME_PARAMETER_F; - static const std::string NAME_PARAMETER_PS; - static const std::string NAME_PARAMETER_ve; - static const std::string NAME_PARAMETER_vp; - static const std::string NAME_STATIC_PARAMETER_ODEINTStepSize; - - static const std::string UNIT_PARAMETER_F; - static const std::string UNIT_PARAMETER_PS; - static const std::string UNIT_PARAMETER_ve; - static const std::string UNIT_PARAMETER_vp; - - static const unsigned int POSITION_PARAMETER_F; - static const unsigned int POSITION_PARAMETER_PS; - static const unsigned int POSITION_PARAMETER_ve; - static const unsigned int POSITION_PARAMETER_vp; - - static const unsigned int NUMBER_OF_PARAMETERS; - - std::string GetModelDisplayName() const override; - - std::string GetModelType() const override; - - itkGetConstReferenceMacro(ODEINTStepSize, double); - itkSetMacro(ODEINTStepSize, double); - - - ParameterNamesType GetParameterNames() const override; - ParametersSizeType GetNumberOfParameters() const override; - - ParamterUnitMapType GetParameterUnits() const override; - - ParameterNamesType GetStaticParameterNames() const override; - ParametersSizeType GetNumberOfStaticParameters() const override; - - - protected: - NumericTwoCompartmentExchangeModel(); - ~NumericTwoCompartmentExchangeModel() 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; - - void PrintSelf(std::ostream& os, ::itk::Indent indent) const override; - - private: - - - - //No copy constructor allowed - NumericTwoCompartmentExchangeModel(const Self& source); - void operator=(const Self&); //purposely not implemented - - double m_ODEINTStepSize; - - - - }; -} - -#endif diff --git a/Modules/Pharmacokinetics/include/mitkNumericTwoCompartmentExchangeModelFactory.h b/Modules/Pharmacokinetics/include/mitkNumericTwoCompartmentExchangeModelFactory.h deleted file mode 100644 index f94e55ef59..0000000000 --- a/Modules/Pharmacokinetics/include/mitkNumericTwoCompartmentExchangeModelFactory.h +++ /dev/null @@ -1,46 +0,0 @@ -/*============================================================================ - -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 mitkNumericTwoCompartmentExchangeModelFactory_h -#define mitkNumericTwoCompartmentExchangeModelFactory_h - -#include "mitkTwoCompartmentExchangeModelFactoryBase.h" -#include "mitkNumericTwoCompartmentExchangeModelParameterizer.h" - -namespace mitk -{ - - class MITKPHARMACOKINETICS_EXPORT NumericTwoCompartmentExchangeModelFactory : public - mitk::TwoCompartmentExchangeModelFactoryBase - { - public: - mitkClassMacro(NumericTwoCompartmentExchangeModelFactory, - TwoCompartmentExchangeModelFactoryBase); - itkFactorylessNewMacro(Self); - - protected: - - ModelParameterizerBase::Pointer DoCreateParameterizer(const modelFit::ModelFitInfo* fit) const override; - - NumericTwoCompartmentExchangeModelFactory(); - - ~NumericTwoCompartmentExchangeModelFactory() override; - - private: - - //No copy constructor allowed - NumericTwoCompartmentExchangeModelFactory(const Self& source); - void operator=(const Self&); //purposely not implemented - - }; - -} -#endif diff --git a/Modules/Pharmacokinetics/include/mitkNumericTwoCompartmentExchangeModelParameterizer.h b/Modules/Pharmacokinetics/include/mitkNumericTwoCompartmentExchangeModelParameterizer.h deleted file mode 100644 index 076952c6c3..0000000000 --- a/Modules/Pharmacokinetics/include/mitkNumericTwoCompartmentExchangeModelParameterizer.h +++ /dev/null @@ -1,77 +0,0 @@ -/*============================================================================ - -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 mitkNumericTwoCompartmentExchangeModelParameterizer_h -#define mitkNumericTwoCompartmentExchangeModelParameterizer_h - -#include "mitkAIFBasedModelParameterizerBase.h" -#include "mitkNumericTwoCompartmentExchangeModel.h" - -#include "MitkPharmacokineticsExports.h" - -namespace mitk -{ - - class MITKPHARMACOKINETICS_EXPORT NumericTwoCompartmentExchangeModelParameterizer : public - mitk::AIFBasedModelParameterizerBase - { - public: - typedef NumericTwoCompartmentExchangeModelParameterizer Self; - typedef mitk::AIFBasedModelParameterizerBase Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - itkTypeMacro(NumericTwoCompartmentExchangeModelParameterizer, - mitk::AIFBasedModelParameterizerBase); - itkFactorylessNewMacro(Self); - - typedef Superclass::ModelBaseType ModelBaseType; - typedef Superclass::ModelBasePointer ModelBasePointer; - - typedef Superclass::ModelType ModelType; - typedef ModelType::Pointer ModelPointer; - - typedef Superclass::StaticParameterValueType StaticParameterValueType; - typedef Superclass::StaticParameterValuesType StaticParameterValuesType; - typedef Superclass::StaticParameterMapType StaticParameterMapType; - - typedef Superclass::IndexType IndexType; - - itkSetMacro(ODEINTStepSize, double); - itkGetConstReferenceMacro(ODEINTStepSize, double); - - /** Returns the global static parameters for the model. - * @remark this default implementation assumes only AIF and its timegrid as static parameters. - * Reimplement in derived classes to change this behavior.*/ - StaticParameterMapType GetGlobalStaticParameters() const override; - - - /** This function returns the default parameterization (e.g. initial parametrization for fitting) - defined by the model developer for for the given model.*/ - ParametersType GetDefaultInitialParameterization() const override; - - protected: - - double m_ODEINTStepSize; - - NumericTwoCompartmentExchangeModelParameterizer(); - - ~NumericTwoCompartmentExchangeModelParameterizer() override; - - private: - - //No copy constructor allowed - NumericTwoCompartmentExchangeModelParameterizer(const Self& source); - void operator=(const Self&); //purposely not implemented - }; -} -#endif diff --git a/Modules/Pharmacokinetics/include/mitkTwoCompartmentExchangeModelDifferentialEquations.h b/Modules/Pharmacokinetics/include/mitkTwoCompartmentExchangeModelDifferentialEquations.h deleted file mode 100644 index f9e4b461fa..0000000000 --- a/Modules/Pharmacokinetics/include/mitkTwoCompartmentExchangeModelDifferentialEquations.h +++ /dev/null @@ -1,114 +0,0 @@ -/*============================================================================ - -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 mitkTwoCompartmentExchangeModelDifferentialEquations_h -#define mitkTwoCompartmentExchangeModelDifferentialEquations_h - -#include "mitkNumericTwoCompartmentExchangeModel.h" - -namespace mitk{ -/** @class TwoCompartmentExchangeModelDifferentialEquations - * @brief Helper Class for NumericTwoCompartmentExchangeModel: Defines the differential equations (Mass Balance Equations) in the 2 Compartment Exchange model. - * The 2 Compartment Exchange model is defined via the mass balance equations - * vp * dCp(t)/dt = F * (CA(t) - Cp(t)) - PS * (Cp(t) - Ce(t)) - * ve * dCe(t)/dt = PS * (Cp(t) - Ce(t)) - * Boost ODEINT performs a stepwise numeric integration (e.g. via Runge-Kutta method) of the initial value problem - * x' = dx/dt = f(x,t) - * It needs an operator () (a functor) that calculates dx/dt = dxdt for a given x and t. - * Parameters are F, PS, ve and vp and the time dependent Ca(t) =AIF, that is interpolated to the current step t -*/ - -class TwoCompartmentExchangeModelDifferentialEquations -{ -public: - - typedef std::vector< double > AIFType; - - /** @brief Functor for differential equation of Physiological Pharmacokinetic Brix Model - * Takes current state x = x(t) and time t and calculates the corresponding dxdt = dx/dt - */ - void operator() (const mitk::NumericTwoCompartmentExchangeModel::state_type &x, mitk::NumericTwoCompartmentExchangeModel::state_type &dxdt, const double t) - { - double Ca_t = InterpolateAIFToCurrentTimeStep(t); - -// dxdt[0] = -(this->FVP + this->PSVP)*x[0] - this->PSVP*x[1]+this->FVP*Ca_t; - dxdt[0] = (1/this->vp) * ( this->F*(Ca_t - x[0]) - this->PS*(x[0] - x[1]) ); - dxdt[1] = (1/this->ve) * this->PS * (x[0] - x[1]); - - } - - TwoCompartmentExchangeModelDifferentialEquations() : F(0), PS(0), ve(0), vp(0), m_AIF(0), m_AIFTimeGrid(0) - { - } - - /** @brief Initialize class with parameters F/Vp, PS/Vp, fi and fp that are free fit parameters*/ - void initialize(double Fp, double ps, double fi, double fp) - { - this->F = Fp; - this->PS = ps; - this->ve = fi; - this->vp = fp; - } - - - void setAIF(AIFType &aif) - { - this->m_AIF = aif; - } - - - void setAIFTimeGrid(AIFType &grid) - { - this->m_AIFTimeGrid = grid; - } - -private: - - double F; - double PS; - double ve; - double vp; - - AIFType m_AIF; - AIFType m_AIFTimeGrid; - - - /** @brief Internal routine to interpolate the AIF to the current time point t used for integration - * The numerical integration of ODEINT is performed on an adaptive timegrid (adaptive step size dt) different from the time grid of the AIF and model function. - * Thus, the AIF value Ca(t) has to be interpolated from the set AIF - */ - double InterpolateAIFToCurrentTimeStep(double t) - { - double lastValue = m_AIF[0]; - double lastTime = std::numeric_limits::min(); - - AIFType::const_iterator posITime = m_AIFTimeGrid.begin(); - AIFType::const_iterator posValue = m_AIF.begin(); - - while(t > *posITime) - { - lastValue = *posValue; - lastTime = *posITime; - ++posValue; - ++posITime; - } - double weightLast = 1 - (t - lastTime)/(*posITime - lastTime); - double weightNext = 1- (*posITime - t)/(*posITime - lastTime); - double result = weightLast * lastValue + weightNext * (*posValue); - - return result; - } - -}; -} - -#endif diff --git a/Modules/Pharmacokinetics/src/Models/mitkNumericTwoCompartmentExchangeModel.cpp b/Modules/Pharmacokinetics/src/Models/mitkNumericTwoCompartmentExchangeModel.cpp deleted file mode 100644 index 2d95cd5e57..0000000000 --- a/Modules/Pharmacokinetics/src/Models/mitkNumericTwoCompartmentExchangeModel.cpp +++ /dev/null @@ -1,286 +0,0 @@ -/*============================================================================ - -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 "mitkNumericTwoCompartmentExchangeModel.h" -#include "mitkAIFParametrizerHelper.h" -#include "mitkTimeGridHelper.h" -#include "mitkTwoCompartmentExchangeModelDifferentialEquations.h" -#include -#include -#include - -const std::string mitk::NumericTwoCompartmentExchangeModel::MODEL_DISPLAY_NAME = - "Numeric Two Compartment Exchange Model"; - -const std::string mitk::NumericTwoCompartmentExchangeModel::NAME_PARAMETER_F = "F"; -const std::string mitk::NumericTwoCompartmentExchangeModel::NAME_PARAMETER_PS = "PS"; -const std::string mitk::NumericTwoCompartmentExchangeModel::NAME_PARAMETER_ve = "ve"; -const std::string mitk::NumericTwoCompartmentExchangeModel::NAME_PARAMETER_vp = "vp"; - -const std::string mitk::NumericTwoCompartmentExchangeModel::UNIT_PARAMETER_F = "ml/min/100ml"; -const std::string mitk::NumericTwoCompartmentExchangeModel::UNIT_PARAMETER_PS = "ml/min/100ml"; -const std::string mitk::NumericTwoCompartmentExchangeModel::UNIT_PARAMETER_ve = "ml/ml"; -const std::string mitk::NumericTwoCompartmentExchangeModel::UNIT_PARAMETER_vp = "ml/ml"; - -const unsigned int mitk::NumericTwoCompartmentExchangeModel::POSITION_PARAMETER_F = 0; -const unsigned int mitk::NumericTwoCompartmentExchangeModel::POSITION_PARAMETER_PS = 1; -const unsigned int mitk::NumericTwoCompartmentExchangeModel::POSITION_PARAMETER_ve = 2; -const unsigned int mitk::NumericTwoCompartmentExchangeModel::POSITION_PARAMETER_vp = 3; - -const unsigned int mitk::NumericTwoCompartmentExchangeModel::NUMBER_OF_PARAMETERS = 4; - -const std::string mitk::NumericTwoCompartmentExchangeModel::NAME_STATIC_PARAMETER_ODEINTStepSize = "ODEIntStepSize"; - - -std::string mitk::NumericTwoCompartmentExchangeModel::GetModelDisplayName() const -{ - return MODEL_DISPLAY_NAME; -}; - -std::string mitk::NumericTwoCompartmentExchangeModel::GetModelType() const -{ - return "Perfusion.MR"; -}; - - -mitk::NumericTwoCompartmentExchangeModel::NumericTwoCompartmentExchangeModel() -{ - -} - -mitk::NumericTwoCompartmentExchangeModel::~NumericTwoCompartmentExchangeModel() -{ - -} - -mitk::NumericTwoCompartmentExchangeModel::ParameterNamesType mitk::NumericTwoCompartmentExchangeModel::GetStaticParameterNames() const -{ - ParameterNamesType result; - - result.push_back(NAME_STATIC_PARAMETER_AIF); - result.push_back(NAME_STATIC_PARAMETER_AIFTimeGrid); - result.push_back(NAME_STATIC_PARAMETER_ODEINTStepSize); - - return result; -} - -mitk::NumericTwoCompartmentExchangeModel::ParametersSizeType mitk::NumericTwoCompartmentExchangeModel::GetNumberOfStaticParameters() -const -{ - return 3; -} - - -void mitk::NumericTwoCompartmentExchangeModel::SetStaticParameter(const ParameterNameType& name, - const StaticParameterValuesType& values) -{ - if (name == NAME_STATIC_PARAMETER_AIF) - { - AterialInputFunctionType aif = mitk::convertParameterToArray(values); - - SetAterialInputFunctionValues(aif); - } - - if (name == NAME_STATIC_PARAMETER_AIFTimeGrid) - { - TimeGridType timegrid = mitk::convertParameterToArray(values); - - SetAterialInputFunctionTimeGrid(timegrid); - } - - if (name == NAME_STATIC_PARAMETER_ODEINTStepSize) - { - SetODEINTStepSize(values[0]); - } -}; - -mitk::NumericTwoCompartmentExchangeModel::StaticParameterValuesType mitk::NumericTwoCompartmentExchangeModel::GetStaticParameterValue( - const ParameterNameType& name) const -{ - StaticParameterValuesType result; - - if (name == NAME_STATIC_PARAMETER_AIF) - { - result = mitk::convertArrayToParameter(this->m_AterialInputFunctionValues); - } - - if (name == NAME_STATIC_PARAMETER_AIFTimeGrid) - { - result = mitk::convertArrayToParameter(this->m_AterialInputFunctionTimeGrid); - } - if (name == NAME_STATIC_PARAMETER_ODEINTStepSize) - { - result.push_back(GetODEINTStepSize()); - } - - return result; -}; - - -mitk::NumericTwoCompartmentExchangeModel::ParameterNamesType -mitk::NumericTwoCompartmentExchangeModel::GetParameterNames() const -{ - ParameterNamesType result; - - result.push_back(NAME_PARAMETER_F); - result.push_back(NAME_PARAMETER_PS); - result.push_back(NAME_PARAMETER_ve); - result.push_back(NAME_PARAMETER_vp); - - return result; -} - -mitk::NumericTwoCompartmentExchangeModel::ParametersSizeType -mitk::NumericTwoCompartmentExchangeModel::GetNumberOfParameters() const -{ - return NUMBER_OF_PARAMETERS; -} - - -mitk::NumericTwoCompartmentExchangeModel::ParamterUnitMapType -mitk::NumericTwoCompartmentExchangeModel::GetParameterUnits() const -{ - ParamterUnitMapType result; - - result.insert(std::make_pair(NAME_PARAMETER_F, UNIT_PARAMETER_F)); - result.insert(std::make_pair(NAME_PARAMETER_PS, UNIT_PARAMETER_PS)); - 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::NumericTwoCompartmentExchangeModel::ModelResultType -mitk::NumericTwoCompartmentExchangeModel::ComputeModelfunction(const ParametersType& parameters) -const -{ - typedef itk::Array ConcentrationCurveType; - typedef std::vector ConcentrationVectorType; - - 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(); - - /** @brief Boost::numeric::odeint works with type std::vector thus, aif and grid are converted to ModelParameters( of type std::vector) - */ - mitk::TwoCompartmentExchangeModelDifferentialEquations::AIFType aif = mitk::convertArrayToParameter( - aterialInputFunction); - mitk::TwoCompartmentExchangeModelDifferentialEquations::AIFType grid = - mitk::convertArrayToParameter(m_TimeGrid); - - mitk::TwoCompartmentExchangeModelDifferentialEquations::AIFType aifODE = aif; - aifODE.push_back(aif[timeSteps - 1]); - mitk::TwoCompartmentExchangeModelDifferentialEquations::AIFType gridODE = grid; - gridODE.push_back(grid[timeSteps - 1] + (grid[timeSteps - 1] - grid[timeSteps - 2])); - - - - //Model Parameters - double F = (double) parameters[POSITION_PARAMETER_F] / 6000.0; - double PS = (double) parameters[POSITION_PARAMETER_PS] / 6000.0; - double ve = (double) parameters[POSITION_PARAMETER_ve]; - double vp = (double) parameters[POSITION_PARAMETER_vp]; - - - /** @brief Initialize class TwoCompartmentExchangeModelDifferentialEquations defining the differential equations. AIF and Grid must be set so that at step t the aterial Concentration Ca(t) can be interpolated from AIF*/ - mitk::TwoCompartmentExchangeModelDifferentialEquations ode; - ode.initialize(F, PS, ve, vp); - ode.setAIF(aifODE); - ode.setAIFTimeGrid(gridODE); - - state_type x(2); - x[0] = 0.0; - x[1] = 0.0; - typedef boost::numeric::odeint::runge_kutta_cash_karp54 error_stepper_type; - //typedef boost::numeric::odeint::runge_kutta4< state_type > stepper_type; - - /** @brief Results of odeeint x[0] and x[1]*/ - ConcentrationVectorType Cp; - ConcentrationVectorType Ce; - ConcentrationVectorType odeTimeGrid; - - error_stepper_type stepper; - - - /** @brief Stepsize. Should be adapted by stepper (runge_kutta_cash_karp54) */ -// const double dt = 0.05; - const double dt = this->m_ODEINTStepSize; - - - /** @brief perform Step t -> t+dt to calculate approximate value x(t+dt)*/ - for (double t = 0.0; t < this->m_TimeGrid(this->m_TimeGrid.GetSize() - 1) - 2*dt; t += dt) - { - stepper.do_step(ode, x, t, dt); - Cp.push_back(x[0]); - Ce.push_back(x[1]); - odeTimeGrid.push_back(t); - } - - /** @brief transfom result of Differential equations back to itk::Array and interpolate to m_TimeGrid (they are calculated on a different grid defined by stepsize of odeint)*/ - ConcentrationCurveType plasmaConcentration = mitk::convertParameterToArray(Cp); - ConcentrationCurveType EESConcentration = mitk::convertParameterToArray(Ce); - ConcentrationCurveType rungeKuttaTimeGrid = mitk::convertParameterToArray(odeTimeGrid); - - mitk::ModelBase::ModelResultType C_Plasma = mitk::InterpolateSignalToNewTimeGrid(plasmaConcentration, rungeKuttaTimeGrid, m_TimeGrid); - mitk::ModelBase::ModelResultType C_EES = mitk::InterpolateSignalToNewTimeGrid(EESConcentration, rungeKuttaTimeGrid, m_TimeGrid); - - - //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 CePos = C_EES.begin(); - - mitk::ModelBase::ModelResultType::const_iterator t = this->m_TimeGrid.begin(); - mitk::ModelBase::ModelResultType::const_iterator Cin = aterialInputFunction.begin(); - - - - for (mitk::ModelBase::ModelResultType::const_iterator CpPos = C_Plasma.begin(); - CpPos != C_Plasma.end(); ++CpPos, ++CePos, ++signalPos, ++t, ++Cin) - { - *signalPos = vp * (*CpPos) + ve * (*CePos); - - } - - return signal; - -} - - - - -itk::LightObject::Pointer mitk::NumericTwoCompartmentExchangeModel::InternalClone() const -{ - NumericTwoCompartmentExchangeModel::Pointer newClone = NumericTwoCompartmentExchangeModel::New(); - - newClone->SetTimeGrid(this->m_TimeGrid); - - return newClone.GetPointer(); -} - -void mitk::NumericTwoCompartmentExchangeModel::PrintSelf(std::ostream& os, - ::itk::Indent indent) const -{ - Superclass::PrintSelf(os, indent); - - -} - - diff --git a/Modules/Pharmacokinetics/src/Models/mitkNumericTwoCompartmentExchangeModelFactory.cpp b/Modules/Pharmacokinetics/src/Models/mitkNumericTwoCompartmentExchangeModelFactory.cpp deleted file mode 100644 index ef04fa136a..0000000000 --- a/Modules/Pharmacokinetics/src/Models/mitkNumericTwoCompartmentExchangeModelFactory.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/*============================================================================ - -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 "mitkNumericTwoCompartmentExchangeModelFactory.h" - - -#include "mitkNumericTwoCompartmentExchangeModelParameterizer.h" -#include "mitkAIFParametrizerHelper.h" - -mitk::NumericTwoCompartmentExchangeModelFactory::NumericTwoCompartmentExchangeModelFactory() -{ -}; - -mitk::NumericTwoCompartmentExchangeModelFactory::~NumericTwoCompartmentExchangeModelFactory() -{ -}; - -mitk::ModelParameterizerBase::Pointer -mitk::NumericTwoCompartmentExchangeModelFactory::DoCreateParameterizer( - const modelFit::ModelFitInfo* fit) -const -{ - mitk::ModelParameterizerBase::Pointer result; - - ModelParameterizerType::Pointer modelParameterizer = - ModelParameterizerType::New(); - - modelFit::StaticParameterMap::ValueType aif = fit->staticParamMap.Get( - ModelType::NAME_STATIC_PARAMETER_AIF); - - modelParameterizer->SetAIF(mitk::convertParameterToArray(aif)); - - modelFit::StaticParameterMap::ValueType aifGrid = fit->staticParamMap.Get( - ModelType::NAME_STATIC_PARAMETER_AIFTimeGrid); - modelParameterizer->SetAIFTimeGrid(mitk::convertParameterToArray(aifGrid)); - - modelFit::StaticParameterMap::ValueType odeStepSize = fit->staticParamMap.Get( - ModelType::NAME_STATIC_PARAMETER_ODEINTStepSize); - modelParameterizer->SetODEINTStepSize(odeStepSize[0]); - - - result = modelParameterizer.GetPointer(); - - return result; -}; diff --git a/Modules/Pharmacokinetics/src/Models/mitkNumericTwoCompartmentExchangeModelParameterizer.cpp b/Modules/Pharmacokinetics/src/Models/mitkNumericTwoCompartmentExchangeModelParameterizer.cpp deleted file mode 100644 index 25910af578..0000000000 --- a/Modules/Pharmacokinetics/src/Models/mitkNumericTwoCompartmentExchangeModelParameterizer.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/*============================================================================ - -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 "mitkNumericTwoCompartmentExchangeModelParameterizer.h" - -mitk::NumericTwoCompartmentExchangeModelParameterizer::ParametersType -mitk::NumericTwoCompartmentExchangeModelParameterizer::GetDefaultInitialParameterization() const -{ - ParametersType initialParameters; - initialParameters.SetSize(4); - initialParameters[mitk::NumericTwoCompartmentExchangeModel::POSITION_PARAMETER_PS] = 5.0; - initialParameters[mitk::NumericTwoCompartmentExchangeModel::POSITION_PARAMETER_F] = 20.0; - initialParameters[mitk::NumericTwoCompartmentExchangeModel::POSITION_PARAMETER_ve] = 0.1; - initialParameters[mitk::NumericTwoCompartmentExchangeModel::POSITION_PARAMETER_vp] = 0.04; - - return initialParameters; -}; - -mitk::NumericTwoCompartmentExchangeModelParameterizer::NumericTwoCompartmentExchangeModelParameterizer() -{ -}; - -mitk::NumericTwoCompartmentExchangeModelParameterizer::~NumericTwoCompartmentExchangeModelParameterizer() -{ -}; - -mitk::NumericTwoCompartmentExchangeModelParameterizer::StaticParameterMapType mitk::NumericTwoCompartmentExchangeModelParameterizer::GetGlobalStaticParameters() const -{ - StaticParameterMapType result; - StaticParameterValuesType valuesAIF = mitk::convertArrayToParameter(this->m_AIF); - StaticParameterValuesType valuesAIFGrid = mitk::convertArrayToParameter(this->m_AIFTimeGrid); - StaticParameterValuesType values; - values.push_back(m_ODEINTStepSize); - - result.insert(std::make_pair(ModelType::NAME_STATIC_PARAMETER_AIF, valuesAIF)); - result.insert(std::make_pair(ModelType::NAME_STATIC_PARAMETER_AIFTimeGrid, valuesAIFGrid)); - result.insert(std::make_pair(ModelType::NAME_STATIC_PARAMETER_ODEINTStepSize, values)); - - return result; -};