Developer documentation
Version 3.0.3-105-gd3941f44
jacobian.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 __image_adapter_jacobian_h__
18#define __image_adapter_jacobian_h__
19
20#include "adapter/base.h"
21#include "adapter/gradient1D.h"
22#include "transform.h"
23
24namespace MR
25{
26 namespace Adapter
27 {
28
29 template <class WarpType>
30 class Jacobian :
31 public Base<Jacobian<WarpType>,WarpType>
33 public:
34
35 using base_type = Base<Jacobian<WarpType>, WarpType>;
36 using value_type = Eigen::Matrix<typename WarpType::value_type, 3, 3>;
37
38 using base_type::name;
39 using base_type::size;
40 using base_type::spacing;
41 using base_type::index;
42
43 Jacobian (const WarpType& parent, bool wrt_scanner = true) :
44 base_type (parent),
45 gradient1D (parent, 0, wrt_scanner),
46 transform (parent),
48
49 value_type value ()
50 {
51 for (size_t dim = 0; dim < 3; ++dim)
52 gradient1D.index(dim) = index(dim);
53 for (size_t i = 0; i < 3; ++i) {
54 gradient1D.index(3) = i;
55 for (size_t j = 0; j < 3; ++j) {
56 gradient1D.set_axis(j);
57 jacobian (i, j) = gradient1D.value();
58 }
59 }
60
61 if (wrt_scanner)
62 jacobian = jacobian * transform.scanner2image.linear().template cast<typename WarpType::value_type>();
63 return jacobian;
64 }
65
66
67 protected:
68 value_type jacobian;
71 const bool wrt_scanner;
72 };
73 }
74}
75
76
77#endif
78
Transform transform
Definition: jacobian.h:70
value_type jacobian
Definition: jacobian.h:68
Gradient1D< WarpType > gradient1D
Definition: jacobian.h:69
const bool wrt_scanner
Definition: jacobian.h:71
const transform_type scanner2image
Definition: transform.h:43
Definition: base.h:24
size_t index
#define MEMALIGN(...)
Definition: types.h:185
const std::string name
Definition: thread.h:108