Developer documentation
Version 3.0.3-105-gd3941f44
rigid.h
Go to the documentation of this file.
1/* Copyright (c) 2008-2022 the MRtrix3 contributors.
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 *
7 * Covered Software is provided under this License on an "as is"
8 * basis, without warranty of any kind, either expressed, implied, or
9 * statutory, including, without limitation, warranties that the
10 * Covered Software is free of defects, merchantable, fit for a
11 * particular purpose or non-infringing.
12 * See the Mozilla Public License v. 2.0 for more details.
13 *
14 * For more details, see http://www.mrtrix.org/.
15 */
16
17#ifndef __registration_transform_rigid_h__
18#define __registration_transform_rigid_h__
19
21#include "types.h"
22#include "math/math.h"
23
24using namespace MR::Math;
25
26namespace MR
27{
28 namespace Registration
29 {
30 namespace Transform
31 {
32
34 public:
36 use_convergence_check (false) { }
37
38 bool operator() (Eigen::Matrix<default_type, Eigen::Dynamic, 1>& newx,
39 const Eigen::Matrix<default_type, Eigen::Dynamic, 1>& x,
40 const Eigen::Matrix<default_type, Eigen::Dynamic, 1>& g,
41 default_type step_size);
42
43 void set_control_points (
44 const Eigen::Matrix<default_type, Eigen::Dynamic, Eigen::Dynamic>& points,
45 const Eigen::Vector3d& coherence_dist,
46 const Eigen::Vector3d& stop_length,
47 const Eigen::Vector3d& voxel_spacing );
48
49 void set_convergence_check (const Eigen::Matrix<default_type, Eigen::Dynamic, 1>& slope_threshold,
50 default_type alpha,
51 default_type beta,
52 size_t buffer_len,
53 size_t min_iter) {
54 // convergence check using double exponential smoothing
55 convergence_check.set_parameters (slope_threshold, alpha, beta, buffer_len, min_iter);
56 use_convergence_check = true;
57 new_control_points_vec.resize(12);
58 }
59
60 private:
61 bool use_convergence_check;
62 Eigen::Matrix<default_type, Eigen::Dynamic, Eigen::Dynamic> control_points;
63 Eigen::Vector3d coherence_distance;
64 Eigen::Matrix<default_type, 4, 1> stop_len, recip_spacing;
65 DoubleExpSmoothSlopeCheck convergence_check;
66 Eigen::Matrix<default_type, Eigen::Dynamic, 1> new_control_points_vec;
67 };
68
70 public:
71 inline bool operator() (Eigen::Matrix<default_type, Eigen::Dynamic, 1>& newx,
72 const Eigen::Matrix<default_type, Eigen::Dynamic, 1>& x,
73 const Eigen::Matrix<default_type, Eigen::Dynamic, 1>& g,
74 default_type step_size);
75 };
76
77
78
85 class Rigid : public Base { MEMALIGN(Rigid)
86 public:
87
88 using ParameterType = typename Base::ParameterType;
89 using UpdateType = RigidLinearNonSymmetricUpdate;
91 using has_robust_estimator = int;
92
93 Rigid () : Base (12) {
94 default_type w1 (MR::File::Config::get_float ("RegGdWeightMatrix", 0.0003f));
95 default_type w2 (MR::File::Config::get_float ("RegGdWeightTranslation", 1.0f));
96 const Eigen::Vector4d weights (w1, w1, w1, w2);
97 this->optimiser_weights << weights, weights, weights;
98 }
99
100 Eigen::Matrix<default_type, 4, 1> get_jacobian_vector_wrt_params (const Eigen::Vector3d& p) const ;
101
102 Eigen::MatrixXd get_jacobian_wrt_params (const Eigen::Vector3d& p) const ;
103
104 void set_parameter_vector (const Eigen::Matrix<ParameterType, Eigen::Dynamic, 1>& param_vector);
105
106 void get_parameter_vector (Eigen::Matrix<ParameterType, Eigen::Dynamic, 1>& param_vector) const;
107
108 UpdateType* get_gradient_descent_updator () {
110 }
111
112 bool robust_estimate (
113 Eigen::Matrix<default_type, Eigen::Dynamic, 1>& gradient,
114 vector<Eigen::Matrix<default_type, Eigen::Dynamic, 1>>& grad_estimates,
115 const Eigen::Matrix<default_type, 4, 4>& control_points,
116 const Eigen::Matrix<default_type, Eigen::Dynamic, 1>& parameter_vector,
117 const default_type& weiszfeld_precision,
118 const size_t& weiszfeld_iterations,
119 default_type learning_rate) const;
120
121 protected:
124 };
126 }
127 }
128}
129
130#endif
static float get_float(const std::string &key, float default_value)
Eigen::VectorXd optimiser_weights
Definition: base.h:284
RobustEstimatorType robust_estimator
Definition: rigid.h:123
Definition: base.h:24
double default_type
the default type used throughout MRtrix
Definition: types.h:228
#define MEMALIGN(...)
Definition: types.h:185