17#ifndef __registration_metric_demons4D_h__
18#define __registration_metric_demons4D_h__
28 namespace Registration
33 template <
class Im1ImageType,
class Im2ImageType,
class Im1MaskType,
class Im2MaskType>
37 const Im1ImageType& im1_image,
const Im2ImageType& im2_image,
const Im1MaskType
im1_mask,
const Im2MaskType
im2_mask,
43 mutex (
new std::mutex),
51 nvols (im1_image.size(3))
53 for (
size_t d = 0; d < 3; ++d)
54 normaliser += im1_image.spacing(d) * im2_image.spacing(d);
63 weight.segment(mc.start,mc.nvols).fill(mc.weight);
70 std::lock_guard<std::mutex> lock (*
mutex);
84 void operator() (Im1ImageType& im1_image,
85 Im2ImageType& im2_image,
88 assert (im1_image.size(3) ==
nvols);
89 assert (im2_image.size(3) ==
nvols);
91 if (im1_image.index(0) == 0 || im1_image.index(0) == im1_image.size(0) - 1 ||
92 im1_image.index(1) == 0 || im1_image.index(1) == im1_image.size(1) - 1 ||
93 im1_image.index(2) == 0 || im1_image.index(2) == im1_image.size(2) - 1) {
94 im1_update.row(3) = 0.0;
95 im2_update.row(3) = 0.0;
102 assign_pos_of (im1_image, 0, 3).to (
im1_mask);
104 if (im1_mask_value < 0.1) {
105 im1_update.row(3) = 0.0;
106 im2_update.row(3) = 0.0;
113 assign_pos_of (im2_image, 0, 3).to (
im2_mask);
115 if (im2_mask_value < 0.1) {
116 im1_update.row(3) = 0.0;
117 im2_update.row(3) = 0.0;
124 speed = im2_image.row(3);
125 speed -= im1_image.row(3);
134 for (ssize_t vol = 0; vol <
nvols; ++vol) {
175 Eigen::Matrix<default_type, 3, 1>
grad;
const vector< MultiContrastSetting > * contrast_settings
Eigen::Matrix< default_type, Eigen::Dynamic, 1 > speed
Eigen::Vector3d total_update
default_type & global_cost
size_t thread_voxel_count
const default_type intensity_difference_threshold
const default_type robustness_parameter
Eigen::Matrix< default_type, Eigen::Dynamic, 1 > speed_squared
size_t & global_voxel_count
Adapter::Gradient3D< Im2ImageType > im2_gradient
Eigen::Matrix< default_type, 3, 1 > grad
Adapter::Gradient3D< Im1ImageType > im1_gradient
const default_type denominator_threshold
std::shared_ptr< std::mutex > mutex
MR::default_type value_type
double default_type
the default type used throughout MRtrix
constexpr std::enable_if< std::is_arithmetic< X >::value &&std::is_unsigned< X >::value, X >::type abs(X x)
std::string str(const T &value, int precision=0)