Skip to content

Commit

Permalink
Code formatting fixes relating to mraverageheader
Browse files Browse the repository at this point in the history
  • Loading branch information
Lestropie committed Feb 28, 2024
1 parent 04a3fb2 commit 479187e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/axes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ std::array<size_t, 3> closest(const Eigen::Matrix3d &M) {
result[1] = index;
M.row(2).cwiseAbs().maxCoeff(&index);
result[2] = index;
assert(result[0]<3 && result[1]<3 && result[2]<3);
assert(result[0] < 3 && result[1] < 3 && result[2] < 3);

// Disambiguate permutations
auto not_any_of = [](size_t a, size_t b) -> size_t {
Expand Down
19 changes: 14 additions & 5 deletions core/math/average_space.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,21 @@ namespace MR {
const char *const avgspace_voxspacing_choices[]{
"min_projection", "mean_projection", "min_nearest", "mean_nearest", nullptr};

FORCE_INLINE Eigen::Matrix<default_type, 8, 4> get_cuboid_corners(const Eigen::Matrix<default_type, 4, 1> &xyz1) {
FORCE_INLINE Eigen::Matrix<default_type, 8, 4> get_cuboid_corners(const Eigen::Matrix<default_type, 4, 1> &xyz_sizes) {
Eigen::Matrix<default_type, 8, 4> corners;
// MatrixType faces = MatrixType(8,4);
// faces << 1, 2, 3, 4, 2, 6, 7, 3, 4, 3, 7, 8, 1, 5, 8, 4, 1, 2, 6, 5, 5, 6, 7, 8;
corners << 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0;
corners *= xyz1.asDiagonal();
// clang-format off
corners << 0.0, 0.0, 0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
1.0, 1.0, 0.0, 1.0,
1.0, 0.0, 0.0, 1.0,
0.0, 0.0, 1.0, 1.0,
0.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0,
1.0, 0.0, 1.0, 1.0;
// clang-format on
corners *= xyz_sizes.asDiagonal();
return corners;
}

Expand Down Expand Up @@ -207,7 +215,8 @@ void compute_average_voxel2scanner(
// internally the coefficients are stored in the following order: [x, y, z, w]
quaternions.col(itrafo) = quat.coeffs();
}
Eigen::SelfAdjointEigenSolver<Eigen::MatrixXd> es(quaternions * quaternions.transpose(), Eigen::ComputeEigenvectors);
const Eigen::SelfAdjointEigenSolver<Eigen::MatrixXd> es(quaternions * quaternions.transpose(),
Eigen::ComputeEigenvectors);
Eigen::Quaterniond average_quat;
average_quat.coeffs() = es.eigenvectors().col(3).transpose();
average_quat.normalize();
Expand Down
2 changes: 1 addition & 1 deletion core/math/average_space.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace MR {
extern const char *const avgspace_voxspacing_choices[];
enum class avgspace_voxspacing_t { MIN_PROJECTION, MEAN_PROJECTION, MIN_NEAREST, MEAN_NEAREST };

Eigen::Matrix<default_type, 8, 4> get_cuboid_corners(const Eigen::Matrix<default_type, 4, 1> &xzx1);
Eigen::Matrix<default_type, 8, 4> get_cuboid_corners(const Eigen::Matrix<default_type, 4, 1> &xyz_sizes);
Eigen::Matrix<default_type, 8, 4>
get_bounding_box(const Header &header, const Eigen::Transform<default_type, 3, Eigen::Projective> &voxel2scanner);

Expand Down

0 comments on commit 479187e

Please sign in to comment.