12 #ifndef REGISTRATION_H
13 #define REGISTRATION_H
18 #include <Eigen/Dense>
75 int valueGrad(
const Eigen::VectorXd& params,
double& val,
76 Eigen::VectorXd&
grad);
88 int grad(
const Eigen::VectorXd& params, Eigen::VectorXd& grad);
98 int value(
const Eigen::VectorXd& params,
double& val);
117 void setBins(
size_t nbins,
size_t krad);
190 vector<double> m_gradHjoint;
191 vector<double> m_gradHmove;
197 double m_rangemove[2];
198 double m_rangefix[2];
239 int valueGrad(
const Eigen::VectorXd& params,
double& val,
240 Eigen::VectorXd&
grad);
252 int grad(
const Eigen::VectorXd& params, Eigen::VectorXd& grad);
262 int value(
const Eigen::VectorXd& params,
double& val);
351 int valueGrad(
const Eigen::VectorXd& params,
double& val,
352 Eigen::VectorXd&
grad);
364 int grad(
const Eigen::VectorXd& params, Eigen::VectorXd& grad);
374 int value(
const Eigen::VectorXd& params,
double& val);
401 size_t nparam() {
return m_deform ? m_deform->elements() : 0; };
421 size_t m_krad,
size_t nbins,
double space,
int dir);
452 int metric(
double& val, VectorXd& grad);
459 int metric(
double& val);
559 double m_rangefix[2];
599 int valueGrad(
const Eigen::VectorXd& params,
double& val,
600 Eigen::VectorXd&
grad);
612 int grad(
const Eigen::VectorXd& params, Eigen::VectorXd& grad);
622 int value(
const Eigen::VectorXd& params,
double& val);
654 size_t nparam() {
return m_deform ? m_deform->elements() : 0; };
663 void setBins(
size_t nbins,
size_t krad);
722 int metric(
double& val, VectorXd& grad);
729 int metric(
double& val);
826 double m_rangemove[2];
831 double m_rangefix[2];
965 ptr<MRImage>
motionCorrect(ptr<const MRImage> input,
size_t ref);
980 Rigid3DTrans
corReg3D(ptr<const MRImage> fixed, ptr<const MRImage> moving,
981 const std::vector<double>& sigmas);
1000 ptr<const MRImage> moving,
const std::vector<double>& sigmas,
1001 size_t nbins = 128,
size_t binradius = 4, std::string metric =
"MI",
1002 double stopx = 0.001);
1028 ptr<MRImage>
infoDistCor(ptr<const MRImage> fixed, ptr<const MRImage> moving,
1029 bool otsu,
int dir,
double bspace,
double jac,
double tps,
1030 const std::vector<double>& sigmas,
1031 size_t nbins = 128,
size_t binradius = 4,
string metric =
"MI",
1032 size_t hist = 8,
double stopx = 1e-5,
double beta = 0.5);
1045 int cor3DDerivTest(
double step,
double tol, ptr<const MRImage> in1,
1046 ptr<const MRImage> in2);
1060 ptr<const MRImage> in1, ptr<const MRImage> in2);
1076 shared_ptr<const MRImage> in1, shared_ptr<const MRImage> in2,
1077 double regj = 0,
double regt = 0);
1090 stream <<
"Rigid3DTrans ";
1092 stream <<
"(In RAS)\n";
1094 stream <<
"(In Index)\n";
1096 stream <<
"Rotation: ";
1097 for(
size_t ii=0; ii<2; ii++)
1098 stream << rigid.
rotation[ii] <<
", ";
1099 stream << rigid.
rotation[2] <<
"\n";
1101 stream <<
"Center: ";
1102 for(
size_t ii=0; ii<2; ii++)
1103 stream << rigid.
center[ii] <<
", ";
1104 stream << rigid.
center[2] <<
"\n";
1106 stream <<
"Shift : ";
1107 for(
size_t ii=0; ii<2; ii++)
1108 stream << rigid.
shift[ii] <<
", ";
1109 stream << rigid.
shift[2] <<
"\n";
1117 #endif //REGISTRATION_H
size_t nparam()
Returns the number of parameters that are being estimated.
bool ras_coord
Indicates the stored transform is relative to physical coordintes rather than index coordinates...
double m_tps_reg
Thin-plate spline regularization weight.
The distortion correction MI Computer is used to compute the mutual information and gradient of mutua...
RigidInfoComp(bool mindiff)
Constructor for the rigid correlation class. Note that rigid rotation is assumed to be about the cent...
size_t nparam()
Returns the number of parameters (knots)
int value(const Eigen::VectorXd ¶ms, double &val)
Computes the correlation.
void toIndexCoords(ptr< const MRImage > in, bool forcegridcenter)
Converts from world coordinates to index coordinates based on the orientation stored in input image...
void setRotation(const Matrix3d &rot)
Constructs rotation vector from rotation matrix.
void setFixed(ptr< const MRImage > fixed)
Set the fixed image for registration/comparison.
int grad(const Eigen::VectorXd ¶ms, Eigen::VectorXd &grad)
Computes the gradient of the correlation. Note that this function just calls valueGrad because comput...
ptr< const MRImage > getMoving()
Return the current moving image.
ptr< const MRImage > getFixed()
Return the current fixed image.
void toRASCoords(ptr< const MRImage > in)
Converts to world coordinates based on the orientation stored in input image.
bool m_compdiff
Compute the difference of images (negate MI and NMI)
int value(const Eigen::VectorXd ¶ms, double &val)
Computes the correlation.
void setFixed(ptr< const MRImage > fixed)
Set the fixed image for registration/comparison.
int grad(const Eigen::VectorXd ¶ms, Eigen::VectorXd &grad)
Computes the gradient of the correlation. Note that this function just calls valueGrad because comput...
bool m_compdiff
Compute the difference of images (negate MI and NMI)
Metric m_metric
Metric to use.
ptr< const MRImage > getMoving()
Return the current moving image.
int grad(const Eigen::VectorXd ¶ms, Eigen::VectorXd &grad)
Computes the gradient of the correlation. Note that this function just calls valueGrad because comput...
ptr< const MRImage > getFixed()
Return the current fixed image.
Metric m_metric
Metric to use.
int value(const Eigen::VectorXd ¶ms, double &val)
Computes the correlation.
The Rigid Corr Computer is used to compute the correlation and gradient of correlation between two im...
int value(const Eigen::VectorXd ¶ms, double &val)
Computes the correlation.
Metric m_metric
Metric to use.
Matrix3d rotMatrix()
Constructs and returns rotation Matrix.
The Rigid MI Computer is used to compute the mutual information and gradient of mutual information be...
void setBins(size_t nbins, size_t krad)
Reallocates histograms and if m_fixed has been set, regenerates histogram estimate of fixed pdf...
ptr< MRImage > motionCorrect(ptr< const MRImage > input, size_t ref)
Performs motion correction on a set of volumes. Each 3D volume is extracted and linearly registered w...
void setMoving(ptr< const MRImage > moving, int dir=-1)
Set the moving image for comparison, note that setting this triggers a derivative computation and so ...
double m_jac_reg
Jacobian regularization weight.
std::ostream & operator<<(std::ostream &os, const Matrix< D1, D2 > &b)
int valueGrad(const Eigen::VectorXd ¶ms, double &val, Eigen::VectorXd &grad)
Computes the gradient and value of the correlation.
int grad(const Eigen::VectorXd ¶ms, Eigen::VectorXd &grad)
Computes the gradient of the correlation. Note that this function just calls valueGrad because comput...
ptr< const MRImage > getMoving()
Return the current moving image.
ptr< const MRImage > getMoving()
Return the current moving image.
ProbDistCorrInfoComp(bool mindiff)
Constructor for the distortion correction class.
ptr< MRImage > getDeform()
Returns the current deformation.
void setFixed(ptr< const MRImage > fixed)
Set the fixed image for registration/comparison.
Rigid3DTrans informationReg3D(ptr< const MRImage > fixed, ptr< const MRImage > moving, const std::vector< double > &sigmas, size_t nbins=128, size_t binradius=4, std::string metric="MI", double stopx=0.001)
Performs information-based registration between two 3D volumes. note that the two volumes should have...
bool m_compdiff
Negative of correlation (which will make it work with most optimizers)
int valueGrad(const Eigen::VectorXd ¶ms, double &val, Eigen::VectorXd &grad)
Computes the gradient and value of the correlation.
void setMoving(ptr< const MRImage > moving)
Set the moving image for comparison, note that setting this triggers a derivative computation and so ...
ptr< const MRImage > getFixed()
Return the current fixed image.
ptr< const MRImage > getFixed()
Return the current fixed image.
std::shared_ptr< T > ptr
Make the shared_ptr name shorter...
ptr< MRImage > getDeform()
Returns the current deformation.
RigidCorrComp(bool mindiff)
Constructor for the rigid correlation class. Note that rigid rotation is assumed to be about the cent...
double m_jac_reg
Jacobian regularization weight.
size_t nparam()
Returns the number of parameters (knots)
int cor3DDerivTest(double step, double tol, ptr< const MRImage > in1, ptr< const MRImage > in2)
This function checks the validity of the derivative functions used to optimize between-image corrlati...
double m_tps_reg
Thin-plate spline regularization weight.
void setMoving(ptr< const MRImage > moving)
Set the moving image for comparison, note that setting this triggers a derivative computation and so ...
void initialize(ptr< const MRImage > fixed, ptr< const MRImage > moving, size_t m_krad, size_t nbins, double space, int dir)
Initializes the computer. This is much simipler to keep track of properly than several initialize fun...
int m_dir
Phase encode (distortion) dimensions.
void invert()
Inverts rigid transform, where:
int valueGrad(const Eigen::VectorXd ¶ms, double &val, Eigen::VectorXd &grad)
Computes the gradient and value of the correlation.
DistCorrInfoComp(bool mindiff)
Constructor for the distortion correction class.
bool m_compdiff
Compute the difference of images (negate MI and NMI)
The distortion correction MI Computer is used to compute the mutual information and gradient of mutua...
void initializeKnots(double space)
Initializes knot spacing and if m_fixed has been set, then initializes the m_deform image...
size_t nparam()
Returns the number of parameters that are being estimated.
int information3DDerivTest(double step, double tol, ptr< const MRImage > in1, ptr< const MRImage > in2)
This function checks the validity of the derivative functions used to optimize between-image corrlati...
int distcorDerivTest(double step, double tol, shared_ptr< const MRImage > in1, shared_ptr< const MRImage > in2, double regj=0, double regt=0)
This function checks the validity of the derivative functions used to optimize between-image corrlati...
void setBins(size_t nbins, size_t krad)
Reallocates histograms and if m_fixed has been set, regenerates histogram estimate of fixed pdf...
int valueGrad(const Eigen::VectorXd ¶ms, double &val, Eigen::VectorXd &grad)
Computes the gradient and value of the correlation.
Rigid3DTrans corReg3D(ptr< const MRImage > fixed, ptr< const MRImage > moving, const std::vector< double > &sigmas)
Performs correlation based registration between two 3D volumes. note that the two volumes should have...
Struct for holding information about a rigid transform. Note that rotation R = Rx*Ry*Rz, where Rx, Ry, and Rz are the rotations about x, y and z aaxes, and the angles are stored (in radians) in the rotation member.
Metric
Information-based Metric to use.
ptr< MRImage > infoDistCor(ptr< const MRImage > fixed, ptr< const MRImage > moving, bool otsu, int dir, double bspace, double jac, double tps, const std::vector< double > &sigmas, size_t nbins=128, size_t binradius=4, string metric="MI", size_t hist=8, double stopx=1e-5, double beta=0.5)
Information based registration between two 3D volumes. note that the two volumes should have identica...