diff --git a/Modules/Pharmacokinetics/include/mitkNumericTwoTissueCompartmentModel.h b/Modules/Pharmacokinetics/include/mitkNumericTwoTissueCompartmentModel.h index 0364852861..74181746b5 100644 --- a/Modules/Pharmacokinetics/include/mitkNumericTwoTissueCompartmentModel.h +++ b/Modules/Pharmacokinetics/include/mitkNumericTwoTissueCompartmentModel.h @@ -1,97 +1,103 @@ /*============================================================================ 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 mitkNumericTwoTissueCompartmentModel_h #define mitkNumericTwoTissueCompartmentModel_h #include "mitkAIFBasedModelBase.h" #include "MitkPharmacokineticsExports.h" namespace mitk { class MITKPHARMACOKINETICS_EXPORT NumericTwoTissueCompartmentModel : public AIFBasedModelBase { public: typedef NumericTwoTissueCompartmentModel 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(NumericTwoTissueCompartmentModel, ModelBase); typedef std::vector state_type; /** Model Specifications */ static const std::string MODEL_DISPLAY_NAME; static const std::string NAME_PARAMETER_K1; static const std::string NAME_PARAMETER_k2; static const std::string NAME_PARAMETER_k3; static const std::string NAME_PARAMETER_k4; - static const std::string NAME_PARAMETER_VB; + static const std::string NAME_PARAMETER_vb; static const std::string UNIT_PARAMETER_K1; static const std::string UNIT_PARAMETER_k2; static const std::string UNIT_PARAMETER_k3; static const std::string UNIT_PARAMETER_k4; - static const std::string UNIT_PARAMETER_VB; + static const std::string UNIT_PARAMETER_vb; static const unsigned int POSITION_PARAMETER_K1; static const unsigned int POSITION_PARAMETER_k2; static const unsigned int POSITION_PARAMETER_k3; static const unsigned int POSITION_PARAMETER_k4; - static const unsigned int POSITION_PARAMETER_VB; + static const unsigned int POSITION_PARAMETER_vb; static const unsigned int NUMBER_OF_PARAMETERS; + static const unsigned int NUMBER_OF_DERIVED_PARAMETERS; + + static const std::string MODEL_TYPE; + + std::string GetModelDisplayName() const override; std::string GetModelType() const override; ParameterNamesType GetParameterNames() const override; ParametersSizeType GetNumberOfParameters() const override; + ParametersSizeType GetNumberOfDerivedParameters() const override; ParamterUnitMapType GetParameterUnits() const override; protected: NumericTwoTissueCompartmentModel(); ~NumericTwoTissueCompartmentModel() 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 PrintSelf(std::ostream& os, ::itk::Indent indent) const override; private: //No copy constructor allowed NumericTwoTissueCompartmentModel(const Self& source); void operator=(const Self&); //purposely not implemented }; } #endif diff --git a/Modules/Pharmacokinetics/include/mitkTwoTissueCompartmentModel.h b/Modules/Pharmacokinetics/include/mitkTwoTissueCompartmentModel.h index a20c922009..8d07cfeed2 100644 --- a/Modules/Pharmacokinetics/include/mitkTwoTissueCompartmentModel.h +++ b/Modules/Pharmacokinetics/include/mitkTwoTissueCompartmentModel.h @@ -1,94 +1,101 @@ /*============================================================================ 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 mitkTwoTissueCompartmentModel_h #define mitkTwoTissueCompartmentModel_h #include "mitkAIFBasedModelBase.h" #include "MitkPharmacokineticsExports.h" namespace mitk { class MITKPHARMACOKINETICS_EXPORT TwoTissueCompartmentModel : public AIFBasedModelBase { public: typedef TwoTissueCompartmentModel 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(TwoTissueCompartmentModel, ModelBase); /** Model Specifications */ - static const std::string MODEL_DISPLAY_NAME; static const std::string NAME_PARAMETER_K1; static const std::string NAME_PARAMETER_k2; static const std::string NAME_PARAMETER_k3; static const std::string NAME_PARAMETER_k4; - static const std::string NAME_PARAMETER_VB; + static const std::string NAME_PARAMETER_vb; static const std::string UNIT_PARAMETER_K1; static const std::string UNIT_PARAMETER_k2; static const std::string UNIT_PARAMETER_k3; static const std::string UNIT_PARAMETER_k4; - static const std::string UNIT_PARAMETER_VB; + static const std::string UNIT_PARAMETER_vb; static const unsigned int POSITION_PARAMETER_K1; static const unsigned int POSITION_PARAMETER_k2; static const unsigned int POSITION_PARAMETER_k3; static const unsigned int POSITION_PARAMETER_k4; - static const unsigned int POSITION_PARAMETER_VB; + static const unsigned int POSITION_PARAMETER_vb; static const unsigned int NUMBER_OF_PARAMETERS; + static const unsigned int NUMBER_OF_DERIVED_PARAMETERS; + + static const std::string MODEL_DISPLAY_NAME; + + static const std::string MODEL_TYPE; + std::string GetModelDisplayName() const override; std::string GetModelType() const override; ParameterNamesType GetParameterNames() const override; ParametersSizeType GetNumberOfParameters() const override; + ParametersSizeType GetNumberOfDerivedParameters() const override; + ParamterUnitMapType GetParameterUnits() const override; protected: TwoTissueCompartmentModel(); ~TwoTissueCompartmentModel() 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 PrintSelf(std::ostream& os, ::itk::Indent indent) const override; private: //No copy constructor allowed TwoTissueCompartmentModel(const Self& source); void operator=(const Self&); //purposely not implemented }; } #endif diff --git a/Modules/Pharmacokinetics/include/mitkTwoTissueCompartmentModelFactoryBase.h b/Modules/Pharmacokinetics/include/mitkTwoTissueCompartmentModelFactoryBase.h index 2430ab8a15..ad8047cf3b 100644 --- a/Modules/Pharmacokinetics/include/mitkTwoTissueCompartmentModelFactoryBase.h +++ b/Modules/Pharmacokinetics/include/mitkTwoTissueCompartmentModelFactoryBase.h @@ -1,81 +1,81 @@ /*============================================================================ 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 mitkTwoTissueCompartmentModelFactoryBase_h #define mitkTwoTissueCompartmentModelFactoryBase_h #include "mitkConcreteAIFBasedModelFactory.h" #include "mitkAIFBasedModelParameterizerBase.h" #include "mitkSimpleBarrierConstraintChecker.h" namespace mitk { template class TwoTissueCompartmentModelFactoryBase : public mitk::ConcreteAIFBasedModelFactory< TModelParameterizer > { public: mitkClassMacro(TwoTissueCompartmentModelFactoryBase, ConcreteAIFBasedModelFactory< TModelParameterizer >); itkFactorylessNewMacro(Self); typedef typename Superclass::ModelType ModelType; typedef typename Superclass::ModelParameterizerType ModelParameterizerType; typedef typename Superclass::ParametersType ParametersType; ConstraintCheckerBase::Pointer CreateDefaultConstraints() const override { SimpleBarrierConstraintChecker::Pointer constraints = SimpleBarrierConstraintChecker::New(); /**@todo Mit Charlie klaren ob es eine sinnvolle default Einstellung gibt.*/ constraints->SetLowerBarrier(ModelType::POSITION_PARAMETER_K1, 0, 0); constraints->SetLowerBarrier(ModelType::POSITION_PARAMETER_k2, 0, 0); constraints->SetLowerBarrier(ModelType::POSITION_PARAMETER_k3, 0, 0); constraints->SetLowerBarrier(ModelType::POSITION_PARAMETER_k4, 0, 0); - constraints->SetLowerBarrier(ModelType::POSITION_PARAMETER_VB, 0, 0); - constraints->SetUpperBarrier(ModelType::POSITION_PARAMETER_VB, 1, 0); + constraints->SetLowerBarrier(ModelType::POSITION_PARAMETER_vb, 0, 0); + constraints->SetUpperBarrier(ModelType::POSITION_PARAMETER_vb, 1, 0); constraints->SetUpperBarrier(ModelType::POSITION_PARAMETER_K1, 1.0, 0); constraints->SetUpperBarrier(ModelType::POSITION_PARAMETER_k2, 1.0, 0); constraints->SetUpperBarrier(ModelType::POSITION_PARAMETER_k3, 1.0, 0); constraints->SetUpperBarrier(ModelType::POSITION_PARAMETER_k4, 1.0, 0); return constraints.GetPointer(); }; ParametersType GetDefaultInitialParameterization() const override { typename ModelParameterizerType::Pointer modelParameterizer = ModelParameterizerType::New(); return modelParameterizer->GetDefaultInitialParameterization(); }; protected: TwoTissueCompartmentModelFactoryBase() { }; ~TwoTissueCompartmentModelFactoryBase() override { }; private: //No copy constructor allowed TwoTissueCompartmentModelFactoryBase(const Self& source); void operator=(const Self&); //purposely not implemented }; } #endif diff --git a/Modules/Pharmacokinetics/src/Models/mitkNumericTwoTissueCompartmentModel.cpp b/Modules/Pharmacokinetics/src/Models/mitkNumericTwoTissueCompartmentModel.cpp index bb7226a2d9..4807a457ff 100644 --- a/Modules/Pharmacokinetics/src/Models/mitkNumericTwoTissueCompartmentModel.cpp +++ b/Modules/Pharmacokinetics/src/Models/mitkNumericTwoTissueCompartmentModel.cpp @@ -1,216 +1,224 @@ /*============================================================================ 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 "mitkNumericTwoTissueCompartmentModel.h" #include "mitkAIFParametrizerHelper.h" #include "mitkTimeGridHelper.h" #include "mitkTwoTissueCompartmentModelDifferentialEquations.h" #include #include #include -const std::string mitk::NumericTwoTissueCompartmentModel::MODEL_DISPLAY_NAME = - "Numeric Two Tissue Compartment Model"; +const std::string mitk::NumericTwoTissueCompartmentModel::MODEL_DISPLAY_NAME = "Numeric Two Tissue Compartment Model"; -const std::string mitk::NumericTwoTissueCompartmentModel::NAME_PARAMETER_K1 = "K1"; -const std::string mitk::NumericTwoTissueCompartmentModel::NAME_PARAMETER_k2 = "k2"; -const std::string mitk::NumericTwoTissueCompartmentModel::NAME_PARAMETER_k3 = "k3"; -const std::string mitk::NumericTwoTissueCompartmentModel::NAME_PARAMETER_k4 = "k4"; -const std::string mitk::NumericTwoTissueCompartmentModel::NAME_PARAMETER_VB = "V_B"; +const std::string mitk::NumericTwoTissueCompartmentModel::NAME_PARAMETER_K1 = "K_1"; +const std::string mitk::NumericTwoTissueCompartmentModel::NAME_PARAMETER_k2 = "k_2"; +const std::string mitk::NumericTwoTissueCompartmentModel::NAME_PARAMETER_k3 = "k_3"; +const std::string mitk::NumericTwoTissueCompartmentModel::NAME_PARAMETER_k4 = "k_4"; +const std::string mitk::NumericTwoTissueCompartmentModel::NAME_PARAMETER_vb = "v_b"; const std::string mitk::NumericTwoTissueCompartmentModel::UNIT_PARAMETER_K1 = "1/min"; const std::string mitk::NumericTwoTissueCompartmentModel::UNIT_PARAMETER_k2 = "1/min"; const std::string mitk::NumericTwoTissueCompartmentModel::UNIT_PARAMETER_k3 = "1/min"; const std::string mitk::NumericTwoTissueCompartmentModel::UNIT_PARAMETER_k4 = "1/min"; -const std::string mitk::NumericTwoTissueCompartmentModel::UNIT_PARAMETER_VB = "ml/ml"; +const std::string mitk::NumericTwoTissueCompartmentModel::UNIT_PARAMETER_vb = "ml/ml"; const unsigned int mitk::NumericTwoTissueCompartmentModel::POSITION_PARAMETER_K1 = 0; const unsigned int mitk::NumericTwoTissueCompartmentModel::POSITION_PARAMETER_k2 = 1; const unsigned int mitk::NumericTwoTissueCompartmentModel::POSITION_PARAMETER_k3 = 2; const unsigned int mitk::NumericTwoTissueCompartmentModel::POSITION_PARAMETER_k4 = 3; -const unsigned int mitk::NumericTwoTissueCompartmentModel::POSITION_PARAMETER_VB = 4; +const unsigned int mitk::NumericTwoTissueCompartmentModel::POSITION_PARAMETER_vb = 4; const unsigned int mitk::NumericTwoTissueCompartmentModel::NUMBER_OF_PARAMETERS = 5; +const unsigned int mitk::NumericTwoTissueCompartmentModel::NUMBER_OF_DERIVED_PARAMETERS = 0; + +const std::string mitk::NumericTwoTissueCompartmentModel::MODEL_TYPE = "Dynamic.PET"; std::string mitk::NumericTwoTissueCompartmentModel::GetModelDisplayName() const { return MODEL_DISPLAY_NAME; }; std::string mitk::NumericTwoTissueCompartmentModel::GetModelType() const { - return "Dynamic.PET"; + return MODEL_TYPE; }; mitk::NumericTwoTissueCompartmentModel::NumericTwoTissueCompartmentModel() { } mitk::NumericTwoTissueCompartmentModel::~NumericTwoTissueCompartmentModel() { } mitk::NumericTwoTissueCompartmentModel::ParameterNamesType mitk::NumericTwoTissueCompartmentModel::GetParameterNames() const { ParameterNamesType result; result.push_back(NAME_PARAMETER_K1); result.push_back(NAME_PARAMETER_k2); result.push_back(NAME_PARAMETER_k3); result.push_back(NAME_PARAMETER_k4); - result.push_back(NAME_PARAMETER_VB); + result.push_back(NAME_PARAMETER_vb); return result; } mitk::NumericTwoTissueCompartmentModel::ParametersSizeType mitk::NumericTwoTissueCompartmentModel::GetNumberOfParameters() const { return NUMBER_OF_PARAMETERS; } +mitk::NumericTwoTissueCompartmentModel::ParametersSizeType +mitk::NumericTwoTissueCompartmentModel::GetNumberOfDerivedParameters() const +{ + return NUMBER_OF_DERIVED_PARAMETERS; +} + mitk::NumericTwoTissueCompartmentModel::ParamterUnitMapType mitk::NumericTwoTissueCompartmentModel::GetParameterUnits() const { ParamterUnitMapType result; result.insert(std::make_pair(NAME_PARAMETER_K1, UNIT_PARAMETER_K1)); result.insert(std::make_pair(NAME_PARAMETER_k2, UNIT_PARAMETER_k2)); result.insert(std::make_pair(NAME_PARAMETER_k3, UNIT_PARAMETER_k3)); result.insert(std::make_pair(NAME_PARAMETER_k4, UNIT_PARAMETER_k4)); - result.insert(std::make_pair(NAME_PARAMETER_VB, UNIT_PARAMETER_VB)); + result.insert(std::make_pair(NAME_PARAMETER_vb, UNIT_PARAMETER_vb)); return result; }; mitk::NumericTwoTissueCompartmentModel::ModelResultType mitk::NumericTwoTissueCompartmentModel::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::TwoTissueCompartmentModelDifferentialEquations::AIFType aif = mitk::convertArrayToParameter( aterialInputFunction); mitk::TwoTissueCompartmentModelDifferentialEquations::AIFType grid = mitk::convertArrayToParameter( m_TimeGrid); mitk::TwoTissueCompartmentModelDifferentialEquations::AIFType aifODE = aif; aifODE.push_back(aif[timeSteps - 1]); mitk::TwoTissueCompartmentModelDifferentialEquations::AIFType gridODE = grid; gridODE.push_back(grid[timeSteps - 1] + (grid[timeSteps - 1] - grid[timeSteps - 2])); //Model Parameters double K1 = (double)parameters[POSITION_PARAMETER_K1] / 60.0; double k2 = (double)parameters[POSITION_PARAMETER_k2] / 60.0; double k3 = (double)parameters[POSITION_PARAMETER_k3] / 60.0; double k4 = (double)parameters[POSITION_PARAMETER_k4] / 60.0; - double VB = parameters[POSITION_PARAMETER_VB]; + double vb = parameters[POSITION_PARAMETER_vb]; /** @brief Initialize class TwpTissueCompartmentModelDifferentialEquations 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::TwoTissueCompartmentModelDifferentialEquations ode; ode.initialize(K1, k2, k3, k4); 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 C1; ConcentrationVectorType C2; ConcentrationVectorType odeTimeGrid; error_stepper_type stepper; /** @brief Stepsize. Should be adapted by stepper (runge_kutta_cash_karp54) */ const double dt = 0.1; /** @brief perform Step t -> t+dt to calculate approximate value x(t+dt)*/ double T = this->m_TimeGrid(timeSteps - 1) + (grid[timeSteps - 1] - grid[timeSteps - 2]); for (double t = 0.0; t < T; t += dt) { stepper.do_step(ode, x, t, dt); C1.push_back(x[0]); C2.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 ConcentrationCompartment1 = mitk::convertParameterToArray(C1); ConcentrationCurveType ConcentrationCompartment2 = mitk::convertParameterToArray(C2); ConcentrationCurveType rungeKuttaTimeGrid = mitk::convertParameterToArray(odeTimeGrid); mitk::ModelBase::ModelResultType C_1 = mitk::InterpolateSignalToNewTimeGrid( ConcentrationCompartment1, rungeKuttaTimeGrid, m_TimeGrid); mitk::ModelBase::ModelResultType C_2 = mitk::InterpolateSignalToNewTimeGrid( ConcentrationCompartment2, 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 C1Pos = C_1.begin(); mitk::ModelBase::ModelResultType::const_iterator C2Pos = C_2.begin(); for (AterialInputFunctionType::const_iterator aifpos = aterialInputFunction.begin(); aifpos != aterialInputFunction.end(); ++aifpos, ++C1Pos, ++C2Pos, ++signalPos) { - *signalPos = VB * (*aifpos) + (1 - VB) * (*C1Pos + *C2Pos); + *signalPos = vb * (*aifpos) + (1 - vb) * (*C1Pos + *C2Pos); } return signal; } itk::LightObject::Pointer mitk::NumericTwoTissueCompartmentModel::InternalClone() const { NumericTwoTissueCompartmentModel::Pointer newClone = NumericTwoTissueCompartmentModel::New(); newClone->SetTimeGrid(this->m_TimeGrid); return newClone.GetPointer(); } void mitk::NumericTwoTissueCompartmentModel::PrintSelf(std::ostream& os, ::itk::Indent indent) const { Superclass::PrintSelf(os, indent); } diff --git a/Modules/Pharmacokinetics/src/Models/mitkNumericTwoTissueCompartmentModelParameterizer.cpp b/Modules/Pharmacokinetics/src/Models/mitkNumericTwoTissueCompartmentModelParameterizer.cpp index 32bc61366e..a1c6b1de07 100644 --- a/Modules/Pharmacokinetics/src/Models/mitkNumericTwoTissueCompartmentModelParameterizer.cpp +++ b/Modules/Pharmacokinetics/src/Models/mitkNumericTwoTissueCompartmentModelParameterizer.cpp @@ -1,35 +1,35 @@ /*============================================================================ 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 "mitkNumericTwoTissueCompartmentModelParameterizer.h" mitk::NumericTwoTissueCompartmentModelParameterizer::ParametersType mitk::NumericTwoTissueCompartmentModelParameterizer::GetDefaultInitialParameterization() const { ParametersType initialParameters; initialParameters.SetSize(5); initialParameters[mitk::NumericTwoTissueCompartmentModel::POSITION_PARAMETER_K1] = 0.23; initialParameters[mitk::NumericTwoTissueCompartmentModel::POSITION_PARAMETER_k2] = 0.4; initialParameters[mitk::NumericTwoTissueCompartmentModel::POSITION_PARAMETER_k3] = 0.13; initialParameters[mitk::NumericTwoTissueCompartmentModel::POSITION_PARAMETER_k4] = 0.15; - initialParameters[mitk::NumericTwoTissueCompartmentModel::POSITION_PARAMETER_VB] = 0.03; + initialParameters[mitk::NumericTwoTissueCompartmentModel::POSITION_PARAMETER_vb] = 0.03; return initialParameters; }; mitk::NumericTwoTissueCompartmentModelParameterizer::NumericTwoTissueCompartmentModelParameterizer() { }; mitk::NumericTwoTissueCompartmentModelParameterizer::~NumericTwoTissueCompartmentModelParameterizer() { }; diff --git a/Modules/Pharmacokinetics/src/Models/mitkTwoTissueCompartmentModel.cpp b/Modules/Pharmacokinetics/src/Models/mitkTwoTissueCompartmentModel.cpp index a00a006665..6d960cb46d 100644 --- a/Modules/Pharmacokinetics/src/Models/mitkTwoTissueCompartmentModel.cpp +++ b/Modules/Pharmacokinetics/src/Models/mitkTwoTissueCompartmentModel.cpp @@ -1,170 +1,180 @@ /*============================================================================ 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 "mitkTwoTissueCompartmentModel.h" #include "mitkConvolutionHelper.h" #include const std::string mitk::TwoTissueCompartmentModel::MODEL_DISPLAY_NAME = "Two Tissue Compartment Model"; -const std::string mitk::TwoTissueCompartmentModel::NAME_PARAMETER_K1 = "K1"; -const std::string mitk::TwoTissueCompartmentModel::NAME_PARAMETER_k2 = "k2"; -const std::string mitk::TwoTissueCompartmentModel::NAME_PARAMETER_k3 = "k3"; -const std::string mitk::TwoTissueCompartmentModel::NAME_PARAMETER_k4 = "k4"; -const std::string mitk::TwoTissueCompartmentModel::NAME_PARAMETER_VB = "V_B"; +const std::string mitk::TwoTissueCompartmentModel::NAME_PARAMETER_K1 = "K_1"; +const std::string mitk::TwoTissueCompartmentModel::NAME_PARAMETER_k2 = "k_2"; +const std::string mitk::TwoTissueCompartmentModel::NAME_PARAMETER_k3 = "k_3"; +const std::string mitk::TwoTissueCompartmentModel::NAME_PARAMETER_k4 = "k_4"; +const std::string mitk::TwoTissueCompartmentModel::NAME_PARAMETER_vb = "v_b"; const std::string mitk::TwoTissueCompartmentModel::UNIT_PARAMETER_K1 = "1/min"; const std::string mitk::TwoTissueCompartmentModel::UNIT_PARAMETER_k2 = "1/min"; const std::string mitk::TwoTissueCompartmentModel::UNIT_PARAMETER_k3 = "1/min"; const std::string mitk::TwoTissueCompartmentModel::UNIT_PARAMETER_k4 = "1/min"; -const std::string mitk::TwoTissueCompartmentModel::UNIT_PARAMETER_VB = "ml/ml"; +const std::string mitk::TwoTissueCompartmentModel::UNIT_PARAMETER_vb = "ml/ml"; const unsigned int mitk::TwoTissueCompartmentModel::POSITION_PARAMETER_K1 = 0; const unsigned int mitk::TwoTissueCompartmentModel::POSITION_PARAMETER_k2 = 1; const unsigned int mitk::TwoTissueCompartmentModel::POSITION_PARAMETER_k3 = 2; const unsigned int mitk::TwoTissueCompartmentModel::POSITION_PARAMETER_k4 = 3; -const unsigned int mitk::TwoTissueCompartmentModel::POSITION_PARAMETER_VB = 4; +const unsigned int mitk::TwoTissueCompartmentModel::POSITION_PARAMETER_vb = 4; const unsigned int mitk::TwoTissueCompartmentModel::NUMBER_OF_PARAMETERS = 5; +const unsigned int mitk::TwoTissueCompartmentModel::NUMBER_OF_DERIVED_PARAMETERS = 0; + +const std::string mitk::TwoTissueCompartmentModel::MODEL_TYPE = "Dynamic.PET"; + inline double square(double a) { return a * a; } std::string mitk::TwoTissueCompartmentModel::GetModelDisplayName() const { return MODEL_DISPLAY_NAME; }; std::string mitk::TwoTissueCompartmentModel::GetModelType() const { - return "Dynamic.PET"; + return MODEL_TYPE; }; mitk::TwoTissueCompartmentModel::TwoTissueCompartmentModel() { } mitk::TwoTissueCompartmentModel::~TwoTissueCompartmentModel() { } mitk::TwoTissueCompartmentModel::ParameterNamesType mitk::TwoTissueCompartmentModel::GetParameterNames() const { ParameterNamesType result; result.push_back(NAME_PARAMETER_K1); result.push_back(NAME_PARAMETER_k2); result.push_back(NAME_PARAMETER_k3); result.push_back(NAME_PARAMETER_k4); - result.push_back(NAME_PARAMETER_VB); + result.push_back(NAME_PARAMETER_vb); return result; } mitk::TwoTissueCompartmentModel::ParametersSizeType mitk::TwoTissueCompartmentModel::GetNumberOfParameters() const { return NUMBER_OF_PARAMETERS; } +mitk::TwoTissueCompartmentModel::ParametersSizeType +mitk::TwoTissueCompartmentModel::GetNumberOfDerivedParameters() const +{ + return NUMBER_OF_DERIVED_PARAMETERS; +} + mitk::TwoTissueCompartmentModel::ParamterUnitMapType mitk::TwoTissueCompartmentModel::GetParameterUnits() const { ParamterUnitMapType result; result.insert(std::make_pair(NAME_PARAMETER_K1, UNIT_PARAMETER_K1)); result.insert(std::make_pair(NAME_PARAMETER_k2, UNIT_PARAMETER_k2)); result.insert(std::make_pair(NAME_PARAMETER_k3, UNIT_PARAMETER_k3)); result.insert(std::make_pair(NAME_PARAMETER_k4, UNIT_PARAMETER_k4)); - result.insert(std::make_pair(NAME_PARAMETER_VB, UNIT_PARAMETER_VB)); + result.insert(std::make_pair(NAME_PARAMETER_vb, UNIT_PARAMETER_vb)); return result; }; mitk::TwoTissueCompartmentModel::ModelResultType mitk::TwoTissueCompartmentModel::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 k1 = (double)parameters[POSITION_PARAMETER_K1] / 60.0; + double K1 = (double)parameters[POSITION_PARAMETER_K1] / 60.0; double k2 = (double)parameters[POSITION_PARAMETER_k2] / 60.0; double k3 = (double)parameters[POSITION_PARAMETER_k3] / 60.0; double k4 = (double)parameters[POSITION_PARAMETER_k4] / 60.0; - double VB = parameters[POSITION_PARAMETER_VB]; + double vb = parameters[POSITION_PARAMETER_vb]; double alpha1 = 0.5 * ((k2 + k3 + k4) - sqrt(square(k2 + k3 + k4) - 4 * k2 * k4)); double alpha2 = 0.5 * ((k2 + k3 + k4) + sqrt(square(k2 + k3 + k4) - 4 * k2 * k4)); mitk::ModelBase::ModelResultType exp1 = mitk::convoluteAIFWithExponential(this->m_TimeGrid, aterialInputFunction, alpha1); mitk::ModelBase::ModelResultType exp2 = mitk::convoluteAIFWithExponential(this->m_TimeGrid, aterialInputFunction, alpha2); //Signal that will be returned by ComputeModelFunction mitk::ModelBase::ModelResultType signal(timeSteps); signal.fill(0.0); mitk::ModelBase::ModelResultType::const_iterator exp1Pos = exp1.begin(); mitk::ModelBase::ModelResultType::const_iterator exp2Pos = exp2.begin(); AterialInputFunctionType::const_iterator aifPos = aterialInputFunction.begin(); for (mitk::ModelBase::ModelResultType::iterator signalPos = signal.begin(); signalPos != signal.end(); ++exp1Pos, ++exp2Pos, ++signalPos, ++aifPos) { - double Ci = k1 / (alpha2 - alpha1) * ((k4 - alpha1 + k3) * (*exp1Pos) + (alpha2 - k4 - k3) * + double Ci = K1 / (alpha2 - alpha1) * ((k4 - alpha1 + k3) * (*exp1Pos) + (alpha2 - k4 - k3) * (*exp2Pos)); - *signalPos = VB * (*aifPos) + (1 - VB) * Ci; + *signalPos = vb * (*aifPos) + (1 - vb) * Ci; } return signal; } itk::LightObject::Pointer mitk::TwoTissueCompartmentModel::InternalClone() const { TwoTissueCompartmentModel::Pointer newClone = TwoTissueCompartmentModel::New(); newClone->SetTimeGrid(this->m_TimeGrid); return newClone.GetPointer(); } void mitk::TwoTissueCompartmentModel::PrintSelf(std::ostream& os, ::itk::Indent indent) const { Superclass::PrintSelf(os, indent); } diff --git a/Modules/Pharmacokinetics/src/Models/mitkTwoTissueCompartmentModelParameterizer.cpp b/Modules/Pharmacokinetics/src/Models/mitkTwoTissueCompartmentModelParameterizer.cpp index e724bb2d1e..7ddb0abd61 100644 --- a/Modules/Pharmacokinetics/src/Models/mitkTwoTissueCompartmentModelParameterizer.cpp +++ b/Modules/Pharmacokinetics/src/Models/mitkTwoTissueCompartmentModelParameterizer.cpp @@ -1,35 +1,35 @@ /*============================================================================ 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 "mitkTwoTissueCompartmentModelParameterizer.h" mitk::TwoTissueCompartmentModelParameterizer::ParametersType mitk::TwoTissueCompartmentModelParameterizer::GetDefaultInitialParameterization() const { ParametersType initialParameters; initialParameters.SetSize(5); initialParameters[mitk::TwoTissueCompartmentModel::POSITION_PARAMETER_K1] = 0.5; initialParameters[mitk::TwoTissueCompartmentModel::POSITION_PARAMETER_k2] = 0.5; initialParameters[mitk::TwoTissueCompartmentModel::POSITION_PARAMETER_k3] = 0.5; initialParameters[mitk::TwoTissueCompartmentModel::POSITION_PARAMETER_k4] = 0.5; - initialParameters[mitk::TwoTissueCompartmentModel::POSITION_PARAMETER_VB] = 0.5; + initialParameters[mitk::TwoTissueCompartmentModel::POSITION_PARAMETER_vb] = 0.5; return initialParameters; }; mitk::TwoTissueCompartmentModelParameterizer::TwoTissueCompartmentModelParameterizer() { }; mitk::TwoTissueCompartmentModelParameterizer::~TwoTissueCompartmentModelParameterizer() { }; diff --git a/Plugins/org.mitk.gui.qt.pharmacokinetics.simulation/src/internal/PerfusionDataSimulationView.cpp b/Plugins/org.mitk.gui.qt.pharmacokinetics.simulation/src/internal/PerfusionDataSimulationView.cpp index 3bdf80080f..92eac84425 100644 --- a/Plugins/org.mitk.gui.qt.pharmacokinetics.simulation/src/internal/PerfusionDataSimulationView.cpp +++ b/Plugins/org.mitk.gui.qt.pharmacokinetics.simulation/src/internal/PerfusionDataSimulationView.cpp @@ -1,1000 +1,1000 @@ /*============================================================================ 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 "mitkWorkbenchUtil.h" #include "PerfusionDataSimulationView.h" #include "itkUnaryFunctorImageFilter.h" #include #include "mitkImageCast.h" #include "mitkImageTimeSelector.h" #include "mitkITKImageImport.h" #include "mitkGaussianNoiseFunctor.h" #include "mitkTwoCompartmentExchangeModel.h" #include "mitkTwoCompartmentExchangeModelParameterizer.h" #include "mitkTwoCompartmentExchangeModelFactory.h" #include "mitkNumericTwoCompartmentExchangeModel.h" #include "mitkNumericTwoCompartmentExchangeModelParameterizer.h" #include "mitkNumericTwoCompartmentExchangeModelFactory.h" #include "mitkExtendedToftsModel.h" #include "mitkExtendedToftsModelFactory.h" #include "mitkExtendedToftsModelParameterizer.h" #include "mitkTwoTissueCompartmentModel.h" #include "mitkTwoTissueCompartmentModelParameterizer.h" #include "mitkTwoTissueCompartmentModelFactory.h" #include "mitkOneTissueCompartmentModel.h" #include "mitkOneTissueCompartmentModelParameterizer.h" #include "mitkOneTissueCompartmentModelFactory.h" #include "mitkModelSignalImageGenerator.h" #include #include #include #include #include "mitkSimpleFunctorBase.h" #include "mitkArbitraryTimeGeometry.h" #include #include const std::string PerfusionDataSimulationView::VIEW_ID = "org.mitk.views.pharmacokinetics.simulation"; inline double convertToDouble(const std::string& data) { std::istringstream stepStream(data); stepStream.imbue(std::locale("C")); double value = 0.0; if (!(stepStream >> value) || !(stepStream.eof())) { mitkThrow() << "Cannot convert string to double. String: " << data; } return value; } inline double FindeMaxConcentration(std::vector Concentration) { double maximum = Concentration[0]; for (std::vector::size_type i =0; isetFocus(); } void PerfusionDataSimulationView::CreateQtPartControl(QWidget* parent) { m_Controls.setupUi(parent); m_Controls.GenerateBtn->setEnabled(false); m_Controls.groupBox_TM->hide(); m_Controls.groupBox_2CXM->hide(); m_Controls.groupBox_2TCM->hide(); m_Controls.groupBox_1TCM->hide(); m_Controls.groupBox_CNR->hide(); this->InitModelComboBox(); /** #2 @todo Reduce code ? */ m_Controls.comboBox_F->SetDataStorage(this->GetDataStorage()); m_Controls.comboBox_F->SetPredicate(m_IsNotABinaryImagePredicate); m_Controls.comboBox_PS->SetDataStorage(this->GetDataStorage()); m_Controls.comboBox_PS->SetPredicate(m_IsNotABinaryImagePredicate); m_Controls.comboBox_fp->SetDataStorage(this->GetDataStorage()); m_Controls.comboBox_fp->SetPredicate(m_IsNotABinaryImagePredicate); m_Controls.comboBox_fi->SetDataStorage(this->GetDataStorage()); m_Controls.comboBox_fi->SetPredicate(m_IsNotABinaryImagePredicate); m_Controls.comboBox_Ktrans->SetDataStorage(this->GetDataStorage()); m_Controls.comboBox_Ktrans->SetPredicate(m_IsNotABinaryImagePredicate); m_Controls.comboBox_vp->SetDataStorage(this->GetDataStorage()); m_Controls.comboBox_vp->SetPredicate(m_IsNotABinaryImagePredicate); m_Controls.comboBox_ve->SetDataStorage(this->GetDataStorage()); m_Controls.comboBox_ve->SetPredicate(m_IsNotABinaryImagePredicate); m_Controls.comboBox_K1->SetDataStorage(this->GetDataStorage()); m_Controls.comboBox_K1->SetPredicate(m_IsNotABinaryImagePredicate); m_Controls.comboBox_K2->SetDataStorage(this->GetDataStorage()); m_Controls.comboBox_K2->SetPredicate(m_IsNotABinaryImagePredicate); m_Controls.comboBox_K3->SetDataStorage(this->GetDataStorage()); m_Controls.comboBox_K3->SetPredicate(m_IsNotABinaryImagePredicate); m_Controls.comboBox_K4->SetDataStorage(this->GetDataStorage()); m_Controls.comboBox_K4->SetPredicate(m_IsNotABinaryImagePredicate); m_Controls.comboBox_VB->SetDataStorage(this->GetDataStorage()); m_Controls.comboBox_VB->SetPredicate(m_IsNotABinaryImagePredicate); m_Controls.comboBox_k1->SetDataStorage(this->GetDataStorage()); m_Controls.comboBox_k1->SetPredicate(m_IsNotABinaryImagePredicate); m_Controls.comboBox_k2->SetDataStorage(this->GetDataStorage()); m_Controls.comboBox_k2->SetPredicate(m_IsNotABinaryImagePredicate); connect(m_Controls.AifFileBtn, SIGNAL(clicked()), this, SLOT(LoadAIFFile())); connect(m_Controls.ModelSelection, SIGNAL(currentIndexChanged(int)), this, SLOT(OnModellSet(int))); connect(m_Controls.GenerateBtn, SIGNAL(clicked()), this, SLOT(OnGenerateDataButtonClicked())); connect(m_Controls.comboBox_F, SIGNAL(currentIndexChanged(int)), this, SLOT(OnSimulationConfigurationChanged())); connect(m_Controls.comboBox_PS, SIGNAL(currentIndexChanged(int)), this, SLOT(OnSimulationConfigurationChanged())); connect(m_Controls.comboBox_fp, SIGNAL(currentIndexChanged(int)), this, SLOT(OnSimulationConfigurationChanged())); connect(m_Controls.comboBox_fi, SIGNAL(currentIndexChanged(int)), this, SLOT(OnSimulationConfigurationChanged())); connect(m_Controls.comboBox_VB, SIGNAL(currentIndexChanged(int)), this, SLOT(OnSimulationConfigurationChanged())); connect(m_Controls.comboBox_K1, SIGNAL(currentIndexChanged(int)), this, SLOT(OnSimulationConfigurationChanged())); connect(m_Controls.comboBox_K2, SIGNAL(currentIndexChanged(int)), this, SLOT(OnSimulationConfigurationChanged())); connect(m_Controls.comboBox_K3, SIGNAL(currentIndexChanged(int)), this, SLOT(OnSimulationConfigurationChanged())); connect(m_Controls.comboBox_K4, SIGNAL(currentIndexChanged(int)), this, SLOT(OnSimulationConfigurationChanged())); connect(m_Controls.comboBox_k1, SIGNAL(currentIndexChanged(int)), this, SLOT(OnSimulationConfigurationChanged())); connect(m_Controls.comboBox_k2, SIGNAL(currentIndexChanged(int)), this, SLOT(OnSimulationConfigurationChanged())); connect(m_Controls.comboBox_Ktrans, SIGNAL(currentIndexChanged(int)), this, SLOT(OnSimulationConfigurationChanged())); connect(m_Controls.comboBox_vp, SIGNAL(currentIndexChanged(int)), this, SLOT(OnSimulationConfigurationChanged())); connect(m_Controls.comboBox_ve, SIGNAL(currentIndexChanged(int)), this, SLOT(OnSimulationConfigurationChanged())); connect(m_Controls.CNRSpinBox, SIGNAL(valueChanged(double)),this, SLOT(OnSimulationConfigurationChanged())); connect(m_Controls.NoiseCheckBox, SIGNAL(stateChanged(int)),this, SLOT(OnSimulationConfigurationChanged())); // UpdateDataSelection(); } void PerfusionDataSimulationView::UpdateDataSelection() { } //void PerfusionDataSimulationView::OnSelectionChanged(berry::IWorkbenchPart::Pointer /*source*/, // const QList& selectedNodes) //{ // UpdateDataSelection(); // m_Controls.GenerateBtn->setEnabled(CheckModelSettings()); //} void PerfusionDataSimulationView::OnSimulationConfigurationChanged() { // UpdateDataSelection(); m_Controls.groupBox_CNR->setVisible(m_Controls.NoiseCheckBox->isChecked()); this->m_CNR = m_Controls.CNRSpinBox->value(); m_Controls.GenerateBtn->setEnabled( CheckModelSettings() ); } void PerfusionDataSimulationView::OnModellSet(int index) { m_selectedModelFactory = nullptr; if (index > 0) { if (static_cast(index) <= m_FactoryStack.size() ) { m_selectedModelFactory = m_FactoryStack[index - 1]; } else { MITK_WARN << "Invalid model index. Index outside of the factory stack. Factory stack size: "<< m_FactoryStack.size() << "; invalid index: "<< index; } } bool isToftsFactory = dynamic_cast(m_selectedModelFactory.GetPointer()) != nullptr; bool is2CXMFactory = dynamic_cast(m_selectedModelFactory.GetPointer()) != nullptr || dynamic_cast(m_selectedModelFactory.GetPointer()) != nullptr; bool is2TCMFactory = dynamic_cast(m_selectedModelFactory.GetPointer()) != nullptr; bool is1TCMFactory = dynamic_cast(m_selectedModelFactory.GetPointer()) != nullptr; m_Controls.groupBox_TM->setVisible(isToftsFactory); m_Controls.groupBox_2CXM->setVisible(is2CXMFactory ); m_Controls.groupBox_2TCM->setVisible(is2TCMFactory ); m_Controls.groupBox_1TCM->setVisible(is1TCMFactory ); m_Controls.GenerateBtn->setEnabled( CheckModelSettings() ); // UpdateDataSelection(); } bool PerfusionDataSimulationView::CheckModelSettings() { bool ok = true; if(m_selectedModelFactory.IsNull()) { return false; } if(this->m_AterialInputFunction.GetSize() == 0 || this->m_TimeGrid.GetSize() == 0) { return false; } bool isToftsFactory = dynamic_cast(m_selectedModelFactory.GetPointer()) != nullptr; bool is2CXMFactory = dynamic_cast(m_selectedModelFactory.GetPointer()) != nullptr || dynamic_cast(m_selectedModelFactory.GetPointer()) != nullptr; bool is2TCMFactory = dynamic_cast(m_selectedModelFactory.GetPointer()) != nullptr; bool is1TCMFactory = dynamic_cast(m_selectedModelFactory.GetPointer()) != nullptr; if(isToftsFactory) { ok = ok && m_Controls.comboBox_Ktrans->GetSelectedNode().IsNotNull(); ok = ok && m_Controls.comboBox_vp->GetSelectedNode().IsNotNull(); ok = ok && m_Controls.comboBox_ve->GetSelectedNode().IsNotNull(); } else if(is2CXMFactory) { ok = ok && m_Controls.comboBox_F->GetSelectedNode().IsNotNull(); ok = ok && m_Controls.comboBox_PS->GetSelectedNode().IsNotNull(); ok = ok && m_Controls.comboBox_fp->GetSelectedNode().IsNotNull(); ok = ok && m_Controls.comboBox_fi->GetSelectedNode().IsNotNull(); } else if(is2TCMFactory) { ok = ok && m_Controls.comboBox_K1->GetSelectedNode().IsNotNull(); ok = ok && m_Controls.comboBox_K2->GetSelectedNode().IsNotNull(); ok = ok && m_Controls.comboBox_K3->GetSelectedNode().IsNotNull(); ok = ok && m_Controls.comboBox_K4->GetSelectedNode().IsNotNull(); ok = ok && m_Controls.comboBox_VB->GetSelectedNode().IsNotNull(); } else if(is1TCMFactory) { ok = ok && m_Controls.comboBox_k1->GetSelectedNode().IsNotNull(); ok = ok && m_Controls.comboBox_k2->GetSelectedNode().IsNotNull(); } else { return false; } if(m_Controls.NoiseCheckBox->isChecked()) { if(m_CNR !=0 && m_MaxConcentration !=0) { this->m_Sigma = m_MaxConcentration/m_CNR; } if(m_Sigma==0) { return false; } } return ok; } void PerfusionDataSimulationView::InitModelComboBox() const { this->m_Controls.ModelSelection->clear(); this->m_Controls.ModelSelection->addItem(tr("No model selected")); for (ModelFactoryStackType::const_iterator pos = m_FactoryStack.begin(); pos != m_FactoryStack.end(); ++pos) { this->m_Controls.ModelSelection->addItem(QString::fromStdString((*pos)->GetClassID())); } this->m_Controls.ModelSelection->setCurrentIndex(0); }; void PerfusionDataSimulationView::LoadAIFFile() { QFileDialog dialog; dialog.setNameFilter(tr("Images (*.csv")); QString fileName = dialog.getOpenFileName(); m_Controls.AifFilePath->setText( fileName ); std::string aifFilePath = fileName.toStdString(); //Read Input typedef boost::tokenizer< boost::escaped_list_separator > Tokenizer; ///////////////////////////////////////////////////////////////////////////////////////////////// //AIF Data std::vector inputFunction; std::vector inputGrid; std::ifstream in1(aifFilePath.c_str()); if(!in1.is_open()) { m_Controls.errorMessageLabel->setText("Could not open AIF File!"); } std::vector< std::string > vec1; std::string line1; while (getline(in1,line1)) { Tokenizer tok(line1); vec1.assign(tok.begin(),tok.end()); // if (vec1.size() < 3) continue; inputGrid.push_back(convertToDouble(vec1[0])); inputFunction.push_back(convertToDouble(vec1[1])); } this->m_MaxConcentration = FindeMaxConcentration(inputFunction); itk::Array aif; itk::Array grid; aif.SetSize(inputFunction.size()); grid.SetSize(inputGrid.size()); aif.fill(0.0); grid.fill(0.0); itk::Array::iterator aifPos = aif.begin(); for(std::vector::const_iterator pos = inputFunction.begin(); pos != inputFunction.end(); ++pos, ++aifPos) { *aifPos = *pos; } itk::Array::iterator gridPos = grid.begin(); for(std::vector::const_iterator pos = inputGrid.begin(); pos != inputGrid.end(); ++pos, ++gridPos) { *gridPos = *pos; } this->m_AterialInputFunction = aif; this->m_TimeGrid = grid; m_Controls.GenerateBtn->setEnabled( CheckModelSettings() ); // UpdateDataSelection(); } /** @todo #2 Same function for Numeric and analytic version of FillParameterMap2CXM */ void PerfusionDataSimulationView::FillParameterMap2CXM() { ParameterMapType stack; mitk::DataNode::Pointer m_selectedNode = m_Controls.comboBox_F->GetSelectedNode(); mitk::Image::Pointer m_selectedImage = dynamic_cast(m_selectedNode->GetData()); stack.insert(std::make_pair(mitk::TwoCompartmentExchangeModel::NAME_PARAMETER_F,m_selectedImage)); m_selectedNode = m_Controls.comboBox_PS->GetSelectedNode(); m_selectedImage = dynamic_cast(m_selectedNode->GetData()); stack.insert(std::make_pair(mitk::TwoCompartmentExchangeModel::NAME_PARAMETER_PS,m_selectedImage)); m_selectedNode = m_Controls.comboBox_fp->GetSelectedNode(); m_selectedImage = dynamic_cast(m_selectedNode->GetData()); stack.insert(std::make_pair(mitk::TwoCompartmentExchangeModel::NAME_PARAMETER_vp,m_selectedImage)); m_selectedNode = m_Controls.comboBox_fi->GetSelectedNode(); m_selectedImage = dynamic_cast(m_selectedNode->GetData()); stack.insert(std::make_pair(mitk::TwoCompartmentExchangeModel::NAME_PARAMETER_ve,m_selectedImage)); this->m_ParameterImageMap = stack; } void PerfusionDataSimulationView::FillParameterMapNumeric2CXM() { ParameterMapType stack; mitk::DataNode::Pointer m_selectedNode = m_Controls.comboBox_F->GetSelectedNode(); mitk::Image::Pointer m_selectedImage = dynamic_cast(m_selectedNode->GetData()); stack.insert(std::make_pair(mitk::NumericTwoCompartmentExchangeModel::NAME_PARAMETER_F,m_selectedImage)); m_selectedNode = m_Controls.comboBox_PS->GetSelectedNode(); m_selectedImage = dynamic_cast(m_selectedNode->GetData()); stack.insert(std::make_pair(mitk::NumericTwoCompartmentExchangeModel::NAME_PARAMETER_PS,m_selectedImage)); m_selectedNode = m_Controls.comboBox_fp->GetSelectedNode(); m_selectedImage = dynamic_cast(m_selectedNode->GetData()); stack.insert(std::make_pair(mitk::NumericTwoCompartmentExchangeModel::NAME_PARAMETER_vp,m_selectedImage)); m_selectedNode = m_Controls.comboBox_fi->GetSelectedNode(); m_selectedImage = dynamic_cast(m_selectedNode->GetData()); stack.insert(std::make_pair(mitk::NumericTwoCompartmentExchangeModel::NAME_PARAMETER_ve,m_selectedImage)); this->m_ParameterImageMap = stack; } void PerfusionDataSimulationView::FillParameterMapETM() { ParameterMapType stack; mitk::DataNode::Pointer m_selectedNode = m_Controls.comboBox_Ktrans->GetSelectedNode(); mitk::Image::Pointer m_selectedImage = dynamic_cast(m_selectedNode->GetData()); stack.insert(std::make_pair(mitk::ExtendedToftsModel::NAME_PARAMETER_Ktrans,m_selectedImage)); m_selectedNode = m_Controls.comboBox_vp->GetSelectedNode(); m_selectedImage = dynamic_cast(m_selectedNode->GetData()); stack.insert(std::make_pair(mitk::ExtendedToftsModel::NAME_PARAMETER_vp,m_selectedImage)); m_selectedNode = m_Controls.comboBox_ve->GetSelectedNode(); m_selectedImage = dynamic_cast(m_selectedNode->GetData()); stack.insert(std::make_pair(mitk::ExtendedToftsModel::NAME_PARAMETER_ve,m_selectedImage)); this->m_ParameterImageMap = stack; } void PerfusionDataSimulationView::FillParameterMap2TCM() { ParameterMapType stack; mitk::DataNode::Pointer m_selectedNode = m_Controls.comboBox_K1->GetSelectedNode(); mitk::Image::Pointer m_selectedImage = dynamic_cast(m_selectedNode->GetData()); stack.insert(std::make_pair(mitk::TwoTissueCompartmentModel::NAME_PARAMETER_K1,m_selectedImage)); m_selectedNode = m_Controls.comboBox_K2->GetSelectedNode(); m_selectedImage = dynamic_cast(m_selectedNode->GetData()); stack.insert(std::make_pair(mitk::TwoTissueCompartmentModel::NAME_PARAMETER_k2,m_selectedImage)); m_selectedNode = m_Controls.comboBox_K3->GetSelectedNode(); m_selectedImage = dynamic_cast(m_selectedNode->GetData()); stack.insert(std::make_pair(mitk::TwoTissueCompartmentModel::NAME_PARAMETER_k3,m_selectedImage)); m_selectedNode = m_Controls.comboBox_K4->GetSelectedNode(); m_selectedImage = dynamic_cast(m_selectedNode->GetData()); stack.insert(std::make_pair(mitk::TwoTissueCompartmentModel::NAME_PARAMETER_k4,m_selectedImage)); m_selectedNode = m_Controls.comboBox_VB->GetSelectedNode(); m_selectedImage = dynamic_cast(m_selectedNode->GetData()); - stack.insert(std::make_pair(mitk::TwoTissueCompartmentModel::NAME_PARAMETER_VB,m_selectedImage)); + stack.insert(std::make_pair(mitk::TwoTissueCompartmentModel::NAME_PARAMETER_vb,m_selectedImage)); this->m_ParameterImageMap = stack; } void PerfusionDataSimulationView::FillParameterMap1TCM() { ParameterMapType stack; mitk::DataNode::Pointer m_selectedNode = m_Controls.comboBox_k1->GetSelectedNode(); mitk::Image::Pointer m_selectedImage = dynamic_cast(m_selectedNode->GetData()); stack.insert(std::make_pair(mitk::OneTissueCompartmentModel::NAME_PARAMETER_K1,m_selectedImage)); m_selectedNode = m_Controls.comboBox_k2->GetSelectedNode(); m_selectedImage = dynamic_cast(m_selectedNode->GetData()); stack.insert(std::make_pair(mitk::OneTissueCompartmentModel::NAME_PARAMETER_k2,m_selectedImage)); this->m_ParameterImageMap = stack; } void PerfusionDataSimulationView::OnGenerateDataButtonClicked() { mitk::Image::Pointer m_DynamicImage = mitk::Image::New(); bool isToftsFactory = dynamic_cast(m_selectedModelFactory.GetPointer()) != nullptr; bool isPhysBrixFactory = dynamic_cast(m_selectedModelFactory.GetPointer()) != nullptr; bool isNumPhysBrixFactory = dynamic_cast(m_selectedModelFactory.GetPointer()) != nullptr; bool is2TCMFactory = dynamic_cast(m_selectedModelFactory.GetPointer()) != nullptr; bool is1TCMFactory = dynamic_cast(m_selectedModelFactory.GetPointer()) != nullptr; if(isToftsFactory) { this->FillParameterMapETM(); m_DynamicImage = this->GenerateETModelData(); } if (isPhysBrixFactory) { this->FillParameterMap2CXM(); m_DynamicImage = this->Generate2CXModelData(); } if (isNumPhysBrixFactory) { this->FillParameterMapNumeric2CXM(); m_DynamicImage = this->GenerateNumeric2CXModelData(); } if (is2TCMFactory) { this->FillParameterMap2TCM(); m_DynamicImage = this->Generate2TCModelData(); } if (is1TCMFactory) { this->FillParameterMap1TCM(); m_DynamicImage = this->Generate1TCModelData(); } mitk::DataNode::Pointer resultNode = mitk::DataNode::New(); std::string nameOfResultImage = "SimulationData_"; nameOfResultImage.append(m_selectedModelFactory->GetModelDisplayName()); resultNode->SetProperty("name", mitk::StringProperty::New(nameOfResultImage) ); resultNode->SetData(m_DynamicImage); // set data of new node this->GetDataStorage()->Add(resultNode); } mitk::Image::Pointer PerfusionDataSimulationView::Generate2CXModelData() { mitk::ModelSignalImageGenerator::Pointer generator = mitk::ModelSignalImageGenerator::New(); mitk::TwoCompartmentExchangeModelParameterizer::Pointer modelParameterizer = mitk::TwoCompartmentExchangeModelParameterizer::New(); /** @todo #2 necessary? Generator need to have a map with Parameters in order of Model in order to pass vector parameters correctly to Model. * I wanted to make it independend from the order the images are passed on */ for(ParameterMapType::const_iterator pos = this->m_ParameterImageMap.begin(); pos != this->m_ParameterImageMap.end(); ++pos) { if(pos->first == mitk::TwoCompartmentExchangeModel::NAME_PARAMETER_F) { generator->SetParameterInputImage(mitk::TwoCompartmentExchangeModel::POSITION_PARAMETER_F, pos->second); } if(pos->first == mitk::TwoCompartmentExchangeModel::NAME_PARAMETER_PS) { generator->SetParameterInputImage(mitk::TwoCompartmentExchangeModel::POSITION_PARAMETER_PS, pos->second); } if(pos->first == mitk::TwoCompartmentExchangeModel::NAME_PARAMETER_ve) { generator->SetParameterInputImage(mitk::TwoCompartmentExchangeModel::POSITION_PARAMETER_ve, pos->second); } if(pos->first == mitk::TwoCompartmentExchangeModel::NAME_PARAMETER_vp) { generator->SetParameterInputImage(mitk::TwoCompartmentExchangeModel::POSITION_PARAMETER_vp, pos->second); } } modelParameterizer->SetAIF(this->m_AterialInputFunction); modelParameterizer->SetAIFTimeGrid(this->m_TimeGrid); modelParameterizer->SetDefaultTimeGrid(this->m_TimeGrid); generator->SetParameterizer(modelParameterizer); mitk::Image::Pointer generatedImage = generator->GetGeneratedImage(); mitk::Image::Pointer resultImage = mitk::Image::New(); if(m_Controls.NoiseCheckBox->isChecked()) { typedef itk::Image ImageType; mitk::Image::Pointer tempImage = mitk::Image::New(); tempImage->Initialize(generatedImage); mitk::ArbitraryTimeGeometry* timeGeometry = dynamic_cast (generatedImage->GetTimeGeometry()); tempImage->SetTimeGeometry(timeGeometry); ImageType::Pointer itkImage = ImageType::New(); mitk::ImageTimeSelector::Pointer imageTimeSelector = mitk::ImageTimeSelector::New(); imageTimeSelector->SetInput(generatedImage); for(unsigned int i = 0; i< generatedImage->GetTimeSteps(); ++i) { imageTimeSelector->SetTimeNr(i); imageTimeSelector->UpdateLargestPossibleRegion(); mitk::Image::Pointer mitkInputImage = imageTimeSelector->GetOutput(); mitk::CastToItkImage(mitkInputImage, itkImage ); typedef mitk::GaussianNoiseFunctor NoiseFunctorType; typedef itk::UnaryFunctorImageFilter NoiseFilterType; NoiseFilterType::Pointer noiseFilter = NoiseFilterType::New(); NoiseFunctorType noiseFunctor; noiseFunctor.SetMean(0.0); noiseFunctor.SetSigma(this->m_Sigma); noiseFilter->SetFunctor(noiseFunctor); noiseFilter->SetInput(itkImage); mitk::Image::Pointer outputImage = mitk::ImportItkImage(noiseFilter->GetOutput())->Clone(); mitk::ImageReadAccessor accessor(outputImage); tempImage->SetVolume(accessor.GetData(), i); } resultImage = tempImage->Clone(); } else { resultImage = generatedImage; } return resultImage; } /** @todo #2 Synergie? Function implementation for every Model to complicated? */ mitk::Image::Pointer PerfusionDataSimulationView::GenerateNumeric2CXModelData() { mitk::ModelSignalImageGenerator::Pointer generator = mitk::ModelSignalImageGenerator::New(); mitk::NumericTwoCompartmentExchangeModelParameterizer::Pointer modelParameterizer = mitk::NumericTwoCompartmentExchangeModelParameterizer::New(); for(ParameterMapType::const_iterator pos = this->m_ParameterImageMap.begin(); pos != this->m_ParameterImageMap.end(); ++pos) { if(pos->first == mitk::NumericTwoCompartmentExchangeModel::NAME_PARAMETER_F) { generator->SetParameterInputImage(mitk::NumericTwoCompartmentExchangeModel::POSITION_PARAMETER_F, pos->second); } if(pos->first == mitk::NumericTwoCompartmentExchangeModel::NAME_PARAMETER_PS) { generator->SetParameterInputImage(mitk::NumericTwoCompartmentExchangeModel::POSITION_PARAMETER_PS, pos->second); } if(pos->first == mitk::NumericTwoCompartmentExchangeModel::NAME_PARAMETER_ve) { generator->SetParameterInputImage(mitk::NumericTwoCompartmentExchangeModel::POSITION_PARAMETER_ve, pos->second); } if(pos->first == mitk::NumericTwoCompartmentExchangeModel::NAME_PARAMETER_vp) { generator->SetParameterInputImage(mitk::NumericTwoCompartmentExchangeModel::POSITION_PARAMETER_vp, pos->second); } } modelParameterizer->SetAIF(this->m_AterialInputFunction); modelParameterizer->SetAIFTimeGrid(this->m_TimeGrid); modelParameterizer->SetDefaultTimeGrid(this->m_TimeGrid); modelParameterizer->SetODEINTStepSize(0.05); generator->SetParameterizer(modelParameterizer); mitk::Image::Pointer generatedImage = generator->GetGeneratedImage(); mitk::Image::Pointer resultImage = mitk::Image::New(); if(m_Controls.NoiseCheckBox->isChecked()) { typedef itk::Image ImageType; mitk::Image::Pointer tempImage = mitk::Image::New(); tempImage->Initialize(generatedImage); mitk::ArbitraryTimeGeometry* timeGeometry = dynamic_cast (generatedImage->GetTimeGeometry()); tempImage->SetTimeGeometry(timeGeometry); ImageType::Pointer itkImage = ImageType::New(); mitk::ImageTimeSelector::Pointer imageTimeSelector = mitk::ImageTimeSelector::New(); imageTimeSelector->SetInput(generatedImage); for(unsigned int i = 0; i< generatedImage->GetTimeSteps(); ++i) { imageTimeSelector->SetTimeNr(i); imageTimeSelector->UpdateLargestPossibleRegion(); mitk::Image::Pointer mitkInputImage = imageTimeSelector->GetOutput(); mitk::CastToItkImage(mitkInputImage, itkImage ); typedef mitk::GaussianNoiseFunctor NoiseFunctorType; typedef itk::UnaryFunctorImageFilter NoiseFilterType; NoiseFilterType::Pointer noiseFilter = NoiseFilterType::New(); NoiseFunctorType noiseFunctor; noiseFunctor.SetMean(0.0); noiseFunctor.SetSigma(this->m_Sigma); noiseFilter->SetFunctor(noiseFunctor); noiseFilter->SetInput(itkImage); mitk::Image::Pointer outputImage = mitk::ImportItkImage(noiseFilter->GetOutput())->Clone(); mitk::ImageReadAccessor accessor(outputImage); tempImage->SetVolume(accessor.GetData(), i); } resultImage = tempImage->Clone(); } else { resultImage = generatedImage; } return resultImage; } mitk::Image::Pointer PerfusionDataSimulationView::GenerateETModelData() { mitk::ModelSignalImageGenerator::Pointer generator = mitk::ModelSignalImageGenerator::New(); mitk::ExtendedToftsModelParameterizer::Pointer modelParameterizer = mitk::ExtendedToftsModelParameterizer::New(); for(ParameterMapType::const_iterator pos = this->m_ParameterImageMap.begin(); pos != this->m_ParameterImageMap.end(); ++pos) { if(pos->first == mitk::ExtendedToftsModel::NAME_PARAMETER_Ktrans) { generator->SetParameterInputImage(mitk::ExtendedToftsModel::POSITION_PARAMETER_Ktrans, pos->second); } if(pos->first == mitk::ExtendedToftsModel::NAME_PARAMETER_vp) { generator->SetParameterInputImage(mitk::ExtendedToftsModel::POSITION_PARAMETER_vp, pos->second); } if(pos->first == mitk::ExtendedToftsModel::NAME_PARAMETER_ve) { generator->SetParameterInputImage(mitk::ExtendedToftsModel::POSITION_PARAMETER_ve, pos->second); } } modelParameterizer->SetAIF(this->m_AterialInputFunction); modelParameterizer->SetAIFTimeGrid(this->m_TimeGrid); modelParameterizer->SetDefaultTimeGrid(this->m_TimeGrid); generator->SetParameterizer(modelParameterizer); mitk::Image::Pointer generatedImage = generator->GetGeneratedImage(); mitk::Image::Pointer resultImage = mitk::Image::New(); if(m_Controls.NoiseCheckBox->isChecked()) { typedef itk::Image ImageType; mitk::Image::Pointer tempImage = mitk::Image::New(); tempImage->Initialize(generatedImage); mitk::ArbitraryTimeGeometry* timeGeometry = dynamic_cast (generatedImage->GetTimeGeometry()); tempImage->SetTimeGeometry(timeGeometry); ImageType::Pointer itkImage = ImageType::New(); mitk::ImageTimeSelector::Pointer imageTimeSelector = mitk::ImageTimeSelector::New(); imageTimeSelector->SetInput(generatedImage); for(unsigned int i = 0; i< generatedImage->GetTimeSteps(); ++i) { imageTimeSelector->SetTimeNr(i); imageTimeSelector->UpdateLargestPossibleRegion(); mitk::Image::Pointer mitkInputImage = imageTimeSelector->GetOutput(); mitk::CastToItkImage(mitkInputImage, itkImage ); typedef mitk::GaussianNoiseFunctor NoiseFunctorType; typedef itk::UnaryFunctorImageFilter NoiseFilterType; NoiseFilterType::Pointer noiseFilter = NoiseFilterType::New(); NoiseFunctorType noiseFunctor; noiseFunctor.SetMean(0.0); noiseFunctor.SetSigma(this->m_Sigma); noiseFilter->SetFunctor(noiseFunctor); noiseFilter->SetInput(itkImage); mitk::Image::Pointer outputImage = mitk::ImportItkImage(noiseFilter->GetOutput())->Clone(); mitk::ImageReadAccessor accessor(outputImage); tempImage->SetVolume(accessor.GetData(), i); } resultImage = tempImage->Clone(); } else { resultImage = generatedImage; } return resultImage; } mitk::Image::Pointer PerfusionDataSimulationView::Generate2TCModelData() { mitk::ModelSignalImageGenerator::Pointer generator = mitk::ModelSignalImageGenerator::New(); mitk::TwoTissueCompartmentModelParameterizer::Pointer modelParameterizer = mitk::TwoTissueCompartmentModelParameterizer::New(); for(ParameterMapType::const_iterator pos = this->m_ParameterImageMap.begin(); pos != this->m_ParameterImageMap.end(); ++pos) { if(pos->first == mitk::TwoTissueCompartmentModel::NAME_PARAMETER_K1) { generator->SetParameterInputImage(mitk::TwoTissueCompartmentModel::POSITION_PARAMETER_K1, pos->second); } if(pos->first == mitk::TwoTissueCompartmentModel::NAME_PARAMETER_k2) { generator->SetParameterInputImage(mitk::TwoTissueCompartmentModel::POSITION_PARAMETER_k2, pos->second); } if(pos->first == mitk::TwoTissueCompartmentModel::NAME_PARAMETER_k3) { generator->SetParameterInputImage(mitk::TwoTissueCompartmentModel::POSITION_PARAMETER_k3, pos->second); } if(pos->first == mitk::TwoTissueCompartmentModel::NAME_PARAMETER_k4) { generator->SetParameterInputImage(mitk::TwoTissueCompartmentModel::POSITION_PARAMETER_k4, pos->second); } - if(pos->first == mitk::TwoTissueCompartmentModel::NAME_PARAMETER_VB) + if(pos->first == mitk::TwoTissueCompartmentModel::NAME_PARAMETER_vb) { - generator->SetParameterInputImage(mitk::TwoTissueCompartmentModel::POSITION_PARAMETER_VB, pos->second); + generator->SetParameterInputImage(mitk::TwoTissueCompartmentModel::POSITION_PARAMETER_vb, pos->second); } } modelParameterizer->SetAIF(this->m_AterialInputFunction); modelParameterizer->SetAIFTimeGrid(this->m_TimeGrid); modelParameterizer->SetDefaultTimeGrid(this->m_TimeGrid); generator->SetParameterizer(modelParameterizer); mitk::Image::Pointer generatedImage = generator->GetGeneratedImage(); mitk::Image::Pointer resultImage = mitk::Image::New(); if(m_Controls.NoiseCheckBox->isChecked()) { typedef itk::Image ImageType; mitk::Image::Pointer tempImage = mitk::Image::New(); tempImage->Initialize(generatedImage); mitk::ArbitraryTimeGeometry* timeGeometry = dynamic_cast (generatedImage->GetTimeGeometry()); tempImage->SetTimeGeometry(timeGeometry); ImageType::Pointer itkImage = ImageType::New(); mitk::ImageTimeSelector::Pointer imageTimeSelector = mitk::ImageTimeSelector::New(); imageTimeSelector->SetInput(generatedImage); for(unsigned int i = 0; i< generatedImage->GetTimeSteps(); ++i) { imageTimeSelector->SetTimeNr(i); imageTimeSelector->UpdateLargestPossibleRegion(); mitk::Image::Pointer mitkInputImage = imageTimeSelector->GetOutput(); mitk::CastToItkImage(mitkInputImage, itkImage ); typedef mitk::GaussianNoiseFunctor NoiseFunctorType; typedef itk::UnaryFunctorImageFilter NoiseFilterType; NoiseFilterType::Pointer noiseFilter = NoiseFilterType::New(); NoiseFunctorType noiseFunctor; noiseFunctor.SetMean(0.0); noiseFunctor.SetSigma(this->m_Sigma); noiseFilter->SetFunctor(noiseFunctor); noiseFilter->SetInput(itkImage); mitk::Image::Pointer outputImage = mitk::ImportItkImage(noiseFilter->GetOutput())->Clone(); mitk::ImageReadAccessor accessor(outputImage); tempImage->SetVolume(accessor.GetData(), i); } resultImage = tempImage->Clone(); } else { resultImage = generatedImage; } return resultImage; } mitk::Image::Pointer PerfusionDataSimulationView::Generate1TCModelData() { mitk::ModelSignalImageGenerator::Pointer generator = mitk::ModelSignalImageGenerator::New(); mitk::OneTissueCompartmentModelParameterizer::Pointer modelParameterizer = mitk::OneTissueCompartmentModelParameterizer::New(); for(ParameterMapType::const_iterator pos = this->m_ParameterImageMap.begin(); pos != this->m_ParameterImageMap.end(); ++pos) { if(pos->first == mitk::OneTissueCompartmentModel::NAME_PARAMETER_K1) { generator->SetParameterInputImage(mitk::OneTissueCompartmentModel::POSITION_PARAMETER_K1, pos->second); } if(pos->first == mitk::OneTissueCompartmentModel::NAME_PARAMETER_k2) { generator->SetParameterInputImage(mitk::OneTissueCompartmentModel::POSITION_PARAMETER_k2, pos->second); } } modelParameterizer->SetAIF(this->m_AterialInputFunction); modelParameterizer->SetAIFTimeGrid(this->m_TimeGrid); modelParameterizer->SetDefaultTimeGrid(this->m_TimeGrid); generator->SetParameterizer(modelParameterizer); mitk::Image::Pointer generatedImage = generator->GetGeneratedImage(); mitk::Image::Pointer resultImage = mitk::Image::New(); if(m_Controls.NoiseCheckBox->isChecked()) { typedef itk::Image ImageType; mitk::Image::Pointer tempImage = mitk::Image::New(); tempImage->Initialize(generatedImage); mitk::ArbitraryTimeGeometry* timeGeometry = dynamic_cast (generatedImage->GetTimeGeometry()); tempImage->SetTimeGeometry(timeGeometry); ImageType::Pointer itkImage = ImageType::New(); mitk::ImageTimeSelector::Pointer imageTimeSelector = mitk::ImageTimeSelector::New(); imageTimeSelector->SetInput(generatedImage); for(unsigned int i = 0; i< generatedImage->GetTimeSteps(); ++i) { imageTimeSelector->SetTimeNr(i); imageTimeSelector->UpdateLargestPossibleRegion(); mitk::Image::Pointer mitkInputImage = imageTimeSelector->GetOutput(); mitk::CastToItkImage(mitkInputImage, itkImage ); typedef mitk::GaussianNoiseFunctor NoiseFunctorType; typedef itk::UnaryFunctorImageFilter NoiseFilterType; NoiseFilterType::Pointer noiseFilter = NoiseFilterType::New(); NoiseFunctorType noiseFunctor; noiseFunctor.SetMean(0.0); noiseFunctor.SetSigma(this->m_Sigma); noiseFilter->SetFunctor(noiseFunctor); noiseFilter->SetInput(itkImage); mitk::Image::Pointer outputImage = mitk::ImportItkImage(noiseFilter->GetOutput())->Clone(); mitk::ImageReadAccessor accessor(outputImage); tempImage->SetVolume(accessor.GetData(), i); } resultImage = tempImage->Clone(); } else { resultImage = generatedImage; } return resultImage; } PerfusionDataSimulationView::PerfusionDataSimulationView() { m_Sigma = 0; m_CNR=0; m_MaxConcentration=0; m_selectedModelFactory = nullptr; mitk::ModelFactoryBase::Pointer factory = mitk::ExtendedToftsModelFactory::New().GetPointer(); m_FactoryStack.push_back(factory); factory = mitk::TwoCompartmentExchangeModelFactory::New().GetPointer(); m_FactoryStack.push_back(factory); factory = mitk::NumericTwoCompartmentExchangeModelFactory::New().GetPointer(); m_FactoryStack.push_back(factory); factory = mitk::TwoTissueCompartmentModelFactory::New().GetPointer(); m_FactoryStack.push_back(factory); factory = mitk::OneTissueCompartmentModelFactory::New().GetPointer(); m_FactoryStack.push_back(factory); m_IsNotABinaryImagePredicate = mitk::NodePredicateAnd::New( mitk::TNodePredicateDataType::New(), mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("binary", mitk::BoolProperty::New(true))), mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("helper object"))).GetPointer(); }