42 #ifndef SVK_KINETIC_MODEL_COST_FUNCTION_H
43 #define SVK_KINETIC_MODEL_COST_FUNCTION_H
45 #include <itkParticleSwarmOptimizer.h>
74 this->numTimePoints = 0;
102 double cost = GetResidual( parameters );
113 this->numSignals = numSignals;
114 this->signalVector.resize(numSignals);
115 this->modelSignalVector.resize(numSignals);
124 return this->numSignals;
131 void SetSignal(
float* signal,
int signalIndex,
string signalName)
133 map<string, float*> signalMap;
134 signalMap[signalName] = signal;
135 if (signalIndex > this->signalVector.size() ) {
136 cout <<
"ERROR, signal index is out of range" << endl;
139 this->signalVector[signalIndex] = signalMap;
148 return &(this->signalVector);
158 return (this->signalVector[ signalIndex ].begin()->second)[timePt];
167 return this->signalVector[ signalIndex ].begin()->first;
176 return (this->signalVector[ signalIndex ]).begin()->second;
186 this->numTimePoints = numTimePoints;
187 if ( this->numSignals == 0 ) {
188 cout <<
"ERROR, numSignals not yet initialized" << endl;
191 for (
int i = 0; i < this->numSignals; i++ ) {
192 float* model =
new float [this->numTimePoints];
193 string modelSignalName = this->GetSignalName(i);
194 cout <<
"NAME: " << modelSignalName << endl;
195 this->SetModelSignal( model, i, modelSignalName);
212 void SetModelSignal(
float* modelSignal,
int modelSignalIndex,
string modelSignalName)
214 map<string, float*> modelSignalMap;
215 modelSignalMap[modelSignalName] = modelSignal;
216 if ( modelSignalIndex > this->modelSignalVector.size() ) {
217 cout <<
"ERROR, signal index is out of range" << endl;
220 this->modelSignalVector[modelSignalIndex] = modelSignalMap;
229 return (this->modelSignalVector[ modelSignalIndex ].begin()->second)[timePt];
238 return (this->modelSignalVector[ modelSignalIndex ]).begin()->second;
254 int numOutputPorts = this->GetNumberOfSignals() + this->GetNumberOfParameters();
255 return numOutputPorts;
269 virtual void GetKineticModel(
const ParametersType& parameters )
const = 0;
275 virtual unsigned int GetNumberOfParameters(
void)
const = 0;
281 virtual void InitNumberOfSignals(
void) = 0;
287 virtual void InitOutputDescriptionVector(vector<string>* outputDescriptionVector )
const = 0;
293 virtual void InitParamBounds(
float* lowerBounds,
float* upperBounds ) = 0;
299 virtual void InitParamInitialPosition( ParametersType* initialPosition ) = 0;
305 virtual void GetParamFinalScaledPosition( ParametersType* finalPosition ) = 0;
320 this->GetKineticModel( parameters );
322 for (
int t = 0; t < this->numTimePoints; t++ ) {
323 for (
int sigNumber = 0; sigNumber < this->GetNumberOfSignals(); sigNumber++ ) {
324 residual += ( this->GetSignalAtTime(sigNumber, t) - this->GetModelSignal(sigNumber)[t] )
325 * ( this->GetSignalAtTime(sigNumber, t) - this->GetModelSignal(sigNumber)[t] );
350 #endif// SVK_KINETIC_MODEL_COST_FUNCTION_H
MeasureType GetValue(const ParametersType ¶meters) const
Definition: svkKineticModelCostFunction.h:100
Definition: svkKineticModelCostFunction.h:53
float * GetModelSignal(int modelSignalIndex) const
Definition: svkKineticModelCostFunction.h:236
string GetSignalName(int signalIndex) const
Definition: svkKineticModelCostFunction.h:165
itk::SingleValuedCostFunction Superclass
Definition: svkKineticModelCostFunction.h:59
float GetSignalAtTime(int signalIndex, int timePt) const
Definition: svkKineticModelCostFunction.h:155
void SetTR(float TR)
Definition: svkKineticModelCostFunction.h:203
itk::SmartPointer< const Self > ConstPointer
Definition: svkKineticModelCostFunction.h:61
int numSignals
Definition: svkKineticModelCostFunction.h:341
float GetModelSignalAtTime(int modelSignalIndex, int timePt) const
Definition: svkKineticModelCostFunction.h:227
MeasureType GetResidual(const ParametersType ¶meters) const
Definition: svkKineticModelCostFunction.h:317
~svkKineticModelCostFunction()
Definition: svkKineticModelCostFunction.h:82
void SetSignal(float *signal, int signalIndex, string signalName)
Definition: svkKineticModelCostFunction.h:131
vector< map< string, float * > > * GetSignals()
Definition: svkKineticModelCostFunction.h:146
float * GetSignal(int signalIndex) const
Definition: svkKineticModelCostFunction.h:174
Superclass::DerivativeType DerivativeType
Definition: svkKineticModelCostFunction.h:65
itk::SmartPointer< Self > Pointer
Definition: svkKineticModelCostFunction.h:60
void SetModelSignal(float *modelSignal, int modelSignalIndex, string modelSignalName)
Definition: svkKineticModelCostFunction.h:212
unsigned int GetNumberOfOutputPorts(void) const
Definition: svkKineticModelCostFunction.h:252
void SetNumberOfSignals(int numSignals)
Definition: svkKineticModelCostFunction.h:111
float TR
Definition: svkKineticModelCostFunction.h:342
Superclass::ParametersType ParametersType
Definition: svkKineticModelCostFunction.h:64
vector< map< string, float * > > modelSignalVector
Definition: svkKineticModelCostFunction.h:339
svkKineticModelCostFunction()
Definition: svkKineticModelCostFunction.h:72
int GetNumberOfSignals() const
Definition: svkKineticModelCostFunction.h:122
vector< map< string, float * > > signalVector
Definition: svkKineticModelCostFunction.h:335
Superclass::MeasureType MeasureType
Definition: svkKineticModelCostFunction.h:66
void GetDerivative(const ParametersType &, DerivativeType &) const
Definition: svkKineticModelCostFunction.h:90
svkKineticModelCostFunction Self
Definition: svkKineticModelCostFunction.h:58
int numTimePoints
Definition: svkKineticModelCostFunction.h:340
void SetNumTimePoints(int numTimePoints)
Definition: svkKineticModelCostFunction.h:184