Developer documentation
Version 3.0.3-105-gd3941f44
externalenergy.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 __gt_externalenergy_h__
18#define __gt_externalenergy_h__
19
20#include "image.h"
21#include "transform.h"
23
27
28
29namespace MR {
30 namespace DWI {
31 namespace Tractography {
32 namespace GT {
33
36 public:
37
38 ExternalEnergyComputer(Stats& stat, const Image<float>& dwimage, const Properties& props);
39
40
41 Image<float>& getTOD() { return tod; }
42 Image<float>& getFiso() { return fiso; }
43 Image<float>& getEext() { return eext; }
44
45 void resetEnergy();
46
47 double stageAdd(const Point_t& pos, const Point_t& dir)
48 {
49 add(pos, dir, 1.0);
50 return eval();
51 }
52
53 double stageShift(const Particle* par, const Point_t& pos, const Point_t& dir)
54 {
55 add(par->getPosition(), par->getDirection(), -1.0);
56 add(pos, dir, 1.0);
57 return eval();
58 }
59
60 double stageRemove(const Particle* par)
61 {
62 add(par->getPosition(), par->getDirection(), -1.0);
63 return eval();
64 }
65
66 void acceptChanges();
67
68 void clearChanges();
69
70 EnergyComputer* clone() const { return new ExternalEnergyComputer(*this); }
71
72
73
74 protected:
75
80
82
83 int lmax;
84 size_t nrows, ncols, nf;
85 double beta, mu, dE;
86 Eigen::MatrixXd K, Ak;
87 Eigen::VectorXd y, t, d, fk;
88
90
95
96
97 void add(const Point_t& pos, const Point_t& dir, const double factor = 1.);
98
99 void add2vox(const Eigen::Vector3i& vox, const double w);
100
101 double eval();
102
103 double calcEnergy();
104
105 inline double hanning(const double w) const
106 {
107 return (w <= (1.0-beta)/2) ? 0.0 : (w >= (1.0+beta)/2) ? 1.0 : (1 - std::cos(Math::pi * (w-(1.0-beta)/2)/beta )) / 2;
108 }
109
110 };
111
112
113 }
114 }
115 }
116}
117
118#endif // __gt_externalenergy_h__
void add2vox(const Eigen::Vector3i &vox, const double w)
void add(const Point_t &pos, const Point_t &dir, const double factor=1.)
constexpr double pi
Definition: math.h:40
Eigen::Vector3f Point_t
Definition: particle.h:29
Definition: base.h:24
Eigen::Transform< default_type, 3, Eigen::AffineCompact > transform_type
the type for the affine transform of an image:
Definition: types.h:234
#define MEMALIGN(...)
Definition: types.h:185