20 #ifndef MIRTK_RegistrationEnergy_H 21 #define MIRTK_RegistrationEnergy_H 23 #include "mirtk/ObjectiveFunction.h" 25 #include "mirtk/Array.h" 26 #include "mirtk/EnergyTerm.h" 27 #include "mirtk/FastDelegate.h" 28 #include "mirtk/EventDelegate.h" 29 #include "mirtk/Transformation.h" 58 Array<EnergyTerm *> _Term;
61 mirtkPublicAttributeMacro(PreUpdateFunctionType, PreUpdateFunction);
72 mirtkPublicAttributeMacro(
bool, NormalizeGradients);
80 mirtkPublicAttributeMacro(
bool, ExcludeConstraints);
87 mirtkPublicAttributeMacro(
double, Preconditioning);
164 virtual bool Set(
const char *,
const char *);
183 virtual void Put(
const double *x);
193 virtual void Get(
double *x)
const;
198 virtual double Get(
int)
const;
221 virtual double Step(
double *dx);
224 virtual void Update(
bool =
true);
287 void Gradient(
double *dx,
double step = .0,
bool *sgn_chg =
nullptr);
300 void GradientStep(
const double *dx,
double &min,
double &max)
const;
314 virtual double Evaluate(
double *dx = NULL,
double step = .0,
bool *sgn_chg = NULL);
324 virtual void WriteDataSets(
const char *,
const char *,
bool =
true)
const;
327 virtual void WriteGradient(
const char *,
const char *)
const;
338 return static_cast<int>(_Term.size());
344 #endif // MIRTK_RegistrationEnergy_H virtual void WriteGradient(const char *, const char *) const
Write gradient of data fidelity terms w.r.t each transformed input.
bool Empty() const
Whether energy function has no terms.
int NumberOfActiveTerms() const
Number of energy terms with non-zero weight.
EnergyTerm * Term(int)
Get the n-th energy term.
void Add(EnergyTerm *)
Add energy term and take over ownership of the object.
virtual void DataFidelityGradient(double *dx, double step=.0, bool *sgn_chg=nullptr)
RegistrationEnergy()
Constructor.
virtual void Get(double *x) const
int NumberOfDataTerms() const
Number of data terms, i.e., with base type DataFidelity.
void Clear()
Delete previously added energy terms.
bool IsSparsityConstraint(int) const
Whether the n-th energy term is a sparsity term.
double GradientNorm(const double *) const
double InitialValue()
Query/evaluate initial value of registration energy.
virtual double Evaluate(double *dx=NULL, double step=.0, bool *sgn_chg=NULL)
virtual double Step(double *dx)
Array< Pair< string, string > > ParameterList
Ordered list of parameter name/value pairs.
virtual ~RegistrationEnergy()
Destructor.
virtual bool Set(const char *, const char *)
Set parameter value from string.
virtual ParameterList Parameter() const
Get parameter as key/value as string map.
virtual void Update(bool=true)
Update internal state after change of parameters.
bool IsConstraint(int) const
Whether the n-th energy term is a penalty term.
virtual void WriteDataSets(const char *, const char *, bool=true) const
Write input of data fidelity terms.
void Gradient(double *dx, double step=.0, bool *sgn_chg=nullptr)
bool IsActive(int) const
Whether the n-th energy term has non-zero weight.
virtual void Initialize()
Initialize energy terms once input and parameters have been set.
double Value()
Evaluate registration energy.
virtual void AddConstraintGradient(double *dx, double step=.0, bool *sgn_chg=nullptr)
virtual int NumberOfDOFs() const
FastDelegate1< bool > PreUpdateFunctionType
Type of pre-update function delegate.
void GradientStep(const double *dx, double &min, double &max) const
int NumberOfTerms() const
Number of energy terms.
virtual ParameterList Parameter() const
Get parameter name/value pairs.
void Sub(EnergyTerm *)
Remove energy term and revoke ownership of the object.
virtual void Put(const double *x)
int NumberOfConstraints() const
Number of penalty terms, i.e., with base type TransformationConstraint.
void NormalizeGradient(double *dx)
bool IsDataTerm(int) const
Whether the n-th energy term is a data term.