diff --git a/Modules/Pharmacokinetics/include/mitkAIFBasedModelBase.h b/Modules/Pharmacokinetics/include/mitkAIFBasedModelBase.h index 057a7817c6..0a9a18b411 100644 --- a/Modules/Pharmacokinetics/include/mitkAIFBasedModelBase.h +++ b/Modules/Pharmacokinetics/include/mitkAIFBasedModelBase.h @@ -1,114 +1,124 @@ /*============================================================================ 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 mitkAIFBasedModelBase_h #define mitkAIFBasedModelBase_h #include "MitkPharmacokineticsExports.h" #include "mitkModelBase.h" #include "itkArray2D.h" namespace mitk { /** \class AIFBasedModelBase * \brief Base Class for all physiological perfusion models using an Aterial Input Function * All AIF based models come with an array of AIF values and the corresponding TimeGrid ( AIF(t)) * This class provides functions for setting the AIF Values and optionally a specific AIF TimeGrid. * It also provides a method for interpolation of the AIF source array to a specified Timegrid that differs from * AIFTimeGrid. The AIF must be set with an itk::Array. If no AIFTimeGrid is specified with the Setter, it is assumed * that the AIFTimeGrid is the same as the ModelTimegrid (e.g. AIF is derived from data set to be fitted). In this * case, AIFvalues must have the same length as ModelTimeGrid, otherwise an exception is generated*/ class MITKPHARMACOKINETICS_EXPORT AIFBasedModelBase : public mitk::ModelBase { public: typedef AIFBasedModelBase Self; typedef ModelBase Superclass; typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; /** Run-time type information (and related methods). */ itkTypeMacro(PhysiologciModelBase, AIFBasedModelBase); static const std::string NAME_STATIC_PARAMETER_AIF; static const std::string NAME_STATIC_PARAMETER_AIFTimeGrid; static const std::string UNIT_STATIC_PARAMETER_AIF; static const std::string UNIT_STATIC_PARAMETER_AIFTimeGrid; + static const unsigned int NUMBER_OF_STATIC_PARAMETERS; + + 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; + /** Typedef for Aterial InputFunction AIF(t)*/ typedef itk::Array AterialInputFunctionType; itkGetConstReferenceMacro(AterialInputFunctionValues, AterialInputFunctionType); itkGetConstReferenceMacro(AterialInputFunctionTimeGrid, TimeGridType); itkSetMacro(AterialInputFunctionValues, AterialInputFunctionType); itkSetMacro(AterialInputFunctionTimeGrid, TimeGridType); std::string GetXAxisName() const override; std::string GetXAxisUnit() const override; std::string GetYAxisName() const override; std::string GetYAxisUnit() const override; /** Returns the TimeGrid used for the AIF. Either the externally set AIF time grid * or the time grid of the model if nothing is set.*/ const TimeGridType& GetCurrentAterialInputFunctionTimeGrid() const; /** Returns the Aterial Input function matching currentTimeGrid * The original values are interpolated to the passed TimeGrid * if currentTimeGrid.Size() = 0 , the Original AIF will be returned*/ const AterialInputFunctionType GetAterialInputFunction(TimeGridType currentTimeGrid) const; ParameterNamesType GetStaticParameterNames() const override; ParametersSizeType GetNumberOfStaticParameters() const override; ParamterUnitMapType GetStaticParameterUnits() const override; protected: AIFBasedModelBase(); ~AIFBasedModelBase() override; /** Reimplementation that checks if AIF and timegrid settings are valid. * @param [out] error Set internally to indicate the error reason if method returns false. Is used by GetSignal() for the * exception comment. * @return Returns true if the model is valid and can compute a signal. Otherwise it returns false.*/ bool ValidateModel(std::string& error) const override; void PrintSelf(std::ostream& os, ::itk::Indent indent) const override; void SetStaticParameter(const ParameterNameType& name, const StaticParameterValuesType& values) override; StaticParameterValuesType GetStaticParameterValue(const ParameterNameType& name) const override; TimeGridType m_AterialInputFunctionTimeGrid; AterialInputFunctionType m_AterialInputFunctionValues; private: //No copy constructor allowed AIFBasedModelBase(const Self& source); void operator=(const Self&); //purposely not implemented }; } #endif diff --git a/Modules/Pharmacokinetics/src/Models/mitkAIFBasedModelBase.cpp b/Modules/Pharmacokinetics/src/Models/mitkAIFBasedModelBase.cpp index b746b38fec..78fe64e9b3 100644 --- a/Modules/Pharmacokinetics/src/Models/mitkAIFBasedModelBase.cpp +++ b/Modules/Pharmacokinetics/src/Models/mitkAIFBasedModelBase.cpp @@ -1,183 +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 "mitkAIFBasedModelBase.h" #include "mitkTimeGridHelper.h" #include "mitkAIFParametrizerHelper.h" #include "itkArray2D.h" +const unsigned int mitk::AIFBasedModelBase::NUMBER_OF_STATIC_PARAMETERS = 2; -const std::string mitk::AIFBasedModelBase::NAME_STATIC_PARAMETER_AIF = "Aterial Input Function"; +const std::string mitk::AIFBasedModelBase::NAME_STATIC_PARAMETER_AIF = "Arterial Input Function"; const std::string mitk::AIFBasedModelBase::NAME_STATIC_PARAMETER_AIFTimeGrid = - "Aterial Input Function Timegrid"; + "Arterial Input Function Timegrid"; //Assumed AIF is always extracted from concentration image -const std::string mitk::AIFBasedModelBase::UNIT_STATIC_PARAMETER_AIF = "C"; +const std::string mitk::AIFBasedModelBase::UNIT_STATIC_PARAMETER_AIF = "mM"; const std::string mitk::AIFBasedModelBase::UNIT_STATIC_PARAMETER_AIFTimeGrid = "s"; +const std::string mitk::AIFBasedModelBase::X_AXIS_NAME = "Time"; + +const std::string mitk::AIFBasedModelBase::X_AXIS_UNIT = "s"; + +const std::string mitk::AIFBasedModelBase::Y_AXIS_NAME = "Concentration"; + +const std::string mitk::AIFBasedModelBase::Y_AXIS_UNIT = "mM"; + std::string mitk::AIFBasedModelBase::GetXAxisName() const { - return "Time"; + return X_AXIS_NAME; }; std::string mitk::AIFBasedModelBase::GetXAxisUnit() const { - return "s"; + return X_AXIS_UNIT; } std::string mitk::AIFBasedModelBase::GetYAxisName() const { - return ""; + return Y_AXIS_NAME; }; std::string mitk::AIFBasedModelBase::GetYAxisUnit() const { - return ""; + return Y_AXIS_UNIT; } mitk::AIFBasedModelBase::AIFBasedModelBase() { } mitk::AIFBasedModelBase::~AIFBasedModelBase() { } const mitk::AIFBasedModelBase::TimeGridType& mitk::AIFBasedModelBase::GetCurrentAterialInputFunctionTimeGrid() const { if (!m_AterialInputFunctionTimeGrid.empty()) { return m_AterialInputFunctionTimeGrid; } else { return m_TimeGrid; } }; const mitk::AIFBasedModelBase::AterialInputFunctionType mitk::AIFBasedModelBase::GetAterialInputFunction(TimeGridType CurrentTimeGrid) const { if (CurrentTimeGrid.GetSize() == 0) { return this->m_AterialInputFunctionValues; } else { return mitk::InterpolateSignalToNewTimeGrid(m_AterialInputFunctionValues, GetCurrentAterialInputFunctionTimeGrid(), CurrentTimeGrid); } } mitk::AIFBasedModelBase::ParameterNamesType mitk::AIFBasedModelBase::GetStaticParameterNames() const { ParameterNamesType result; result.push_back(NAME_STATIC_PARAMETER_AIF); result.push_back(NAME_STATIC_PARAMETER_AIFTimeGrid); return result; } mitk::AIFBasedModelBase::ParametersSizeType mitk::AIFBasedModelBase::GetNumberOfStaticParameters() const { - return 2; + return NUMBER_OF_STATIC_PARAMETERS; } mitk::AIFBasedModelBase::ParamterUnitMapType mitk::AIFBasedModelBase::GetStaticParameterUnits() const { ParamterUnitMapType result; result.insert(std::make_pair(NAME_STATIC_PARAMETER_AIF, UNIT_STATIC_PARAMETER_AIF)); result.insert(std::make_pair(NAME_STATIC_PARAMETER_AIFTimeGrid, UNIT_STATIC_PARAMETER_AIFTimeGrid)); return result; }; void mitk::AIFBasedModelBase::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); } }; mitk::AIFBasedModelBase::StaticParameterValuesType mitk::AIFBasedModelBase::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); } return result; }; bool mitk::AIFBasedModelBase::ValidateModel(std::string& error) const { bool result = Superclass::ValidateModel(error); if (result) { if (m_AterialInputFunctionTimeGrid.empty()) { if (this->m_TimeGrid.GetSize() != m_AterialInputFunctionValues.GetSize()) { result = false; error = "Number of elements of Model Time Grid does not match number of elements in Aterial Input Function! Set valid aif or aif time grid."; } } else { if (m_AterialInputFunctionTimeGrid.GetSize() != m_AterialInputFunctionValues.GetSize()) { result = false; error = "Number of elements of Aterial Input Function Time Grid does not match number of elements of Aterial Input Function Values! Set valid curve"; } } } return result; }; void mitk::AIFBasedModelBase::PrintSelf(std::ostream& os, ::itk::Indent indent) const { Superclass::PrintSelf(os, indent); - os << indent << "Aterial Input Function: " << m_AterialInputFunctionValues; - os << indent << "Aterial Input Function Time Grid: " << m_AterialInputFunctionTimeGrid; + os << indent << "Arterial Input Function: " << m_AterialInputFunctionValues; + os << indent << "Arterial Input Function Time Grid: " << m_AterialInputFunctionTimeGrid; };