17#ifndef __registration_warp_utils_h__
18#define __registration_warp_utils_h__
22 namespace Registration
28 template <
class HeaderType>
31 if (warp_header.ndim() != 4)
32 throw Exception (
"input warp is not a 4D image");
33 if (warp_header.size(3) != 3)
34 throw Exception (
"input warp should have 3 volumes in the 4th dimension");
37 template <
class HeaderType>
40 if (warp_header.ndim() != 5)
41 throw Exception (
"the input warp image must be a 5D file.");
42 if (warp_header.size(3) != 3)
43 throw Exception (
"the input warp image must have 3 volumes (x,y,z) in the 4th dimension.");
44 if (warp_header.size(4) != 4)
45 throw Exception (
"the input warp image must have 4 volumes in the 5th dimension.");
48 template <
class InputWarpType>
51 const auto it = input_warps.keyval().find (
name);
52 if (it != input_warps.keyval().end()) {
54 if (lines.size() != 3)
55 throw Exception (
"linear transform in initialisation syn warps image header does not contain 3 rows");
56 for (
size_t row = 0; row < 3; ++row) {
57 const auto values =
split (lines[row],
" ",
true);
58 if (values.size() != 4)
59 throw Exception (
"linear transform in initialisation syn warps image header does not contain 4 columns");
60 for (
size_t col = 0; col < 4; ++col)
61 linear (row, col) = std::stod (values[col]);
64 throw Exception (
"no linear transform found in initialisation syn warps image header");
void check_warp(const HeaderType &warp_header)
transform_type parse_linear_transform(InputWarpType &input_warps, std::string name)
void check_warp_full(const HeaderType &warp_header)
Eigen::Transform< default_type, 3, Eigen::AffineCompact > transform_type
the type for the affine transform of an image:
vector< std::string > split_lines(const std::string &string, bool ignore_empty_fields=true, size_t num=std::numeric_limits< size_t >::max())
vector< std::string > split(const std::string &string, const char *delimiters=" \t\n", bool ignore_empty_fields=false, size_t num=std::numeric_limits< size_t >::max())