-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbisNonLinearImageRegistration.h
158 lines (111 loc) · 5.07 KB
/
bisNonLinearImageRegistration.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/* License
_This file is Copyright 2018 by the Image Processing and Analysis Group (BioImage Suite Team). Dept. of Radiology & Biomedical Imaging, Yale School of Medicine._ It is released under the terms of the GPL v2.
----
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
See also http: www.gnu.org/licenses/gpl.html
If this software is modified please retain this statement and add a notice
that it had been modified (and by whom).
Endlicense */
#ifndef _bis_NonLinearImageRegistration_h
#define _bis_NonLinearImageRegistration_h
#include "bisUtil.h"
#include "bisAbstractImageRegistration.h"
#include "bisComboTransformation.h"
#include "bisGridTransformation.h"
/**
* Implements nonlinear (tensor b-spline) image registration
*/
class bisNonLinearImageRegistration : public bisAbstractImageRegistration,bisGridTransformationOptimizable {
public:
/** Constructor
* @param n value to set the name of the object
*/
bisNonLinearImageRegistration(std::string n="nonlineareg");
/** Destructor */
virtual ~bisNonLinearImageRegistration();
// Set Parameters and Run
virtual void run(bisJSONParameterList* plist);
/** Set Initial transformation
* @param tr the initial transformation
*/
void setInitialTransformation(std::shared_ptr<bisAbstractTransformation> tr);
// Optimizer Stuff
virtual float computeValue(std::vector<float>& position);
virtual float computeGradient(std::vector<float>& position,std::vector<float>& gradient);
// bisGridTransformationOptimizable interface
virtual float computeValueFunctionPiece(bisAbstractTransformation* tr,int bounds[6],int cp);
/** Get Output Transformation
* @returns the output combo transformation (shared pointer)
*/
std::shared_ptr<bisComboTransformation> getOutputTransformation() { return this->internalTransformation; }
// Enhance this to add last similarity and last smoothness
virtual void generateFeedback(std::string input);
/**
* Essentially a print function for now
* @param input string to print */
virtual void generateFeedback2(std::string input);
protected:
/** the current combo transformation */
std::shared_ptr<bisComboTransformation> internalTransformation;
/** the currently being optimize gridtransformation, this is added to internalTransformation when the current level is done */
std::shared_ptr<bisGridTransformation> currentGridTransformation;
/** A temp image to reslice in part into during optimization */
std::unique_ptr<bisSimpleImage<short> > part_temp_target;
/** Check Params for validity
* @param plist the parameter list to check
*/
virtual int checkInputParameters(bisJSONParameterList* plist);
/** Initialize Multi Resolution Level and the Grid Transformation
* @param lv the level
* @param numlevels the number of levels
*/
virtual void initializeLevelAndGrid(int lv,int numlevels);
/** Approximate Transformation with Grid
* @param dispfield the displacement field
* @param newgrd the grid to fit
* @param fast whther to do a fast or slow fitting
*/
virtual void approximateDisplacementField(bisSimpleImage<float>* dispfield,bisGridTransformation* newgrd,int fast=0);
/** Compute a displacement field to fit later given a current transformation
* @param old the input transformation
* @returns the displacement field
*/
bisSimpleImage<float>* computeDisplacementField(bisAbstractTransformation* old);
#ifndef DOXYGEN_SKIP
double totaltime;
#endif
/** append mode -- if > 0 then append grids instead of fitting them */
int append_mode;
/** The current control point spacing */
float current_cps[3];
/** The current grid dimensions */
int current_dim[3];
/** The current value of the regularization weight */
float lambda;
/** The current value of the windowsize for gradient computation */
float windowsize;
/** Last similarity **/
float lastSimilarity;
/** Last smoothness **/
float lastSmoothness;
/** The initial Transformation */
std::shared_ptr<bisAbstractTransformation > initialTransformation;
/** A flag to signify whether we have an initial transformation */
int hasInitialTransformation;
private:
/** Copy constructor disabled to maintain shared/unique ptr safety */
bisNonLinearImageRegistration(const bisNonLinearImageRegistration&);
/** Assignment disabled to maintain shared/unique ptr safety */
void operator=(const bisNonLinearImageRegistration&);
};
#endif