Developer documentation
Version 3.0.3-105-gd3941f44
coeff_optimiser.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 __dwi_tractography_sift2_coeff_optimiser_h__
18#define __dwi_tractography_sift2_coeff_optimiser_h__
19
20
23#include "misc/bitset.h"
24
27
29
30
31//#define SIFT2_COEFF_OPTIMISER_DEBUG
32
33
34namespace MR {
35 namespace DWI {
36 namespace Tractography {
37 namespace SIFT2 {
38
39
40
41 class TckFactor;
42
43
44
47 public:
51
52 bool operator() (const SIFT::TrackIndexRange&);
53
54
55 protected:
57 const double mu;
58
59 virtual double get_coeff_change (const SIFT::track_t) const = 0;
60
61
62#ifdef SIFT2_COEFF_OPTIMISER_DEBUG
63 size_t total, failed, wrong_dir, step_truncated, coeff_truncated;
64#endif
65
66
67 private:
68 StreamlineStats& step_stats;
69 StreamlineStats& coefficient_stats;
70 unsigned int& nonzero_streamlines;
71 BitSet& fixels_to_exclude;
72 double& sum_costs;
73
74 StreamlineStats local_stats_steps, local_stats_coefficients;
75 size_t local_nonzero_count;
76 BitSet local_to_exclude;
77
78 protected:
79 mutable double local_sum_costs;
80
81 private:
82 double do_fixel_exclusion (const SIFT::track_t);
83
84 };
85
86
87
88
89
90
91
92
93 // Golden Section Search within the permitted range
96
97 public:
101
102 private:
103 double get_coeff_change (const SIFT::track_t) const;
104
105 };
106
107
108
109
110
111 // Performs a Quadratic Line Search within the permitted domain
112 // Does not requre derivatives; only needs 3 seed points (two extremities and 0.0)
113 // Note however if that these extremities are large, the initial CF evaluation may be NAN!
116
117 public:
121
122 private:
124
125 double get_coeff_change (const SIFT::track_t) const;
126
127 };
128
129
130
131
132 // Coefficient optimiser based on iterative root-finding Newton / Halley
133 // Early exit if outside the permitted coefficient step range and moving further away
136
137 public:
141
142 private:
143 double get_coeff_change (const SIFT::track_t) const;
144
145#ifdef SIFT2_COEFF_OPTIMISER_DEBUG
146 mutable uint64_t iter_count;
147#endif
148
149 };
150
151
152
153
154
155 }
156 }
157 }
158}
159
160
161#endif
a class for storing bitwise information
Definition: bitset.h:43
virtual double get_coeff_change(const SIFT::track_t) const =0
unsigned int track_t
Definition: types.h:34
std::pair< track_t, track_t > TrackIndexRange
Definition: base.h:24
#define MEMALIGN(...)
Definition: types.h:185