MetricDistortion.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2013-2015 Imperial College London
5  * Copyright 2013-2015 Andreas Schuh
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifndef MIRTK_MetricDistortion_H
21 #define MIRTK_MetricDistortion_H
22 
23 #include "mirtk/SurfaceConstraint.h"
24 
25 #include "mirtk/Array.h"
26 
27 
28 namespace mirtk {
29 
30 
31 /**
32  * Metric distortion constraint
33  *
34  * Fischl et al.. Cortical Surface-Based Analysis II: Inflation, Flattening,
35  * and a Surface-Based Coordinate System. NeuroImage, 9(2), 195–207 (1999).
36  *
37  * Additional to the formulation in the NeuroImage paper of Fischl et al.,
38  * this implementation contains a slight modification found in the implementation
39  * of FreeSurfer's mris_inflate tool. The normal component of the force term
40  * is removed from the gradient vector.
41  */
43 {
44  mirtkEnergyTermMacro(MetricDistortion, EM_MetricDistortion);
45 
46  // ---------------------------------------------------------------------------
47  // Types
48 
49 public:
50 
51  struct NodeDistances
52  {
53  double _Distance0; ///< Initial node distance
54  double _Distance; ///< Current node distance
55  };
56 
57  /// Array of computed distances to neighboring nodes
58  typedef Array<NodeDistances> DistancesArray;
59 
60  // ---------------------------------------------------------------------------
61  // Attributes
62 
63  /// Radius of node neighborhood (i.e., maximum edge-connectivity)
64  mirtkPublicAttributeMacro(int, Radius);
65 
66  /// Area of initial surface mesh
67  mirtkAttributeMacro(double, InitialArea);
68 
69  /// For each node, the initial and current distances to their neighboring nodes
70  mirtkAttributeMacro(Array<DistancesArray>, Distances);
71 
72  /// Copy attributes of this class from another instance
73  void CopyAttributes(const MetricDistortion &);
74 
75  // ---------------------------------------------------------------------------
76  // Construction/Destruction
77 
78 public:
79 
80  /// Constructor
81  MetricDistortion(const char * = "", double = 1.0);
82 
83  /// Copy constructor
85 
86  /// Assignment operator
88 
89  /// Destructor
90  virtual ~MetricDistortion();
91 
92  // ---------------------------------------------------------------------------
93  // Configuration
94 
95 protected:
96 
97  /// Set parameter value from string
98  virtual bool SetWithoutPrefix(const char *, const char *);
99 
100 public:
101 
102  // Import other overloads
104 
105  /// Get parameter name/value pairs
106  virtual ParameterList Parameter() const;
107 
108  // ---------------------------------------------------------------------------
109  // Evaluation
110 
111  /// Initialize internal force term once input and parameters have been set
112  virtual void Initialize();
113 
114  /// Reinitialize internal force term after change of input topology
115  virtual void Reinitialize();
116 
117  /// Update internal force data structures
118  virtual void Update(bool);
119 
120 protected:
121 
122  /// Common (re-)initialization steps of this internal force term
123  /// \note Must be a non-virtual function!
124  void Init();
125 
126  /// Compute penalty for current transformation estimate
127  virtual double Evaluate();
128 
129  /// Compute internal force w.r.t. transformation parameters
130  virtual void EvaluateGradient(double *, double, double);
131 
132 };
133 
134 
135 } // namespace mirtk
136 
137 #endif // MIRTK_MetricDistortion_H
Minimize metric distortion.
Definition: EnergyMeasure.h:80
mirtkAttributeMacro(double, InitialArea)
Area of initial surface mesh.
MetricDistortion & operator=(const MetricDistortion &)
Assignment operator.
void CopyAttributes(const MetricDistortion &)
Copy attributes of this class from another instance.
Array< NodeDistances > DistancesArray
Array of computed distances to neighboring nodes.
virtual double Evaluate()
Compute penalty for current transformation estimate.
virtual ~MetricDistortion()
Destructor.
Array< Pair< string, string > > ParameterList
Ordered list of parameter name/value pairs.
Definition: Object.h:38
virtual ParameterList Parameter() const
Get parameter name/value pairs.
Definition: IOConfig.h:41
mirtkPublicAttributeMacro(int, Radius)
Radius of node neighborhood (i.e., maximum edge-connectivity)
virtual bool SetWithoutPrefix(const char *, const char *)
Set parameter value from string.
virtual void EvaluateGradient(double *, double, double)
Compute internal force w.r.t. transformation parameters.
virtual void Initialize()
Initialize internal force term once input and parameters have been set.
MetricDistortion(const char *="", double=1.0)
Constructor.
virtual void Update(bool)
Update internal force data structures.
virtual ParameterList Parameter() const
Get parameter key/value as string map.
virtual void Reinitialize()
Reinitialize internal force term after change of input topology.