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
21
#include "
math/golden_section_search.h
"
22
#include "
math/quadratic_line_search.h
"
23
#include "
misc/bitset.h
"
24
25
#include "
dwi/tractography/SIFT/track_index_range.h
"
26
#include "
dwi/tractography/SIFT/types.h
"
27
28
#include "
dwi/tractography/SIFT2/streamline_stats.h
"
29
30
31
//#define SIFT2_COEFF_OPTIMISER_DEBUG
32
33
34
namespace
MR
{
35
namespace
DWI {
36
namespace
Tractography {
37
namespace
SIFT2 {
38
39
40
41
class
TckFactor
;
42
43
44
45
class
CoefficientOptimiserBase
46
{
MEMALIGN
(
CoefficientOptimiserBase
)
47
public
:
48
CoefficientOptimiserBase
(
TckFactor
&,
StreamlineStats
&,
StreamlineStats
&,
unsigned
int
&,
BitSet
&,
double
&);
49
CoefficientOptimiserBase
(
const
CoefficientOptimiserBase
&);
50
virtual
~CoefficientOptimiserBase
();
51
52
bool
operator() (
const
SIFT::TrackIndexRange
&);
53
54
55
protected
:
56
TckFactor
&
master
;
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
94
class
CoefficientOptimiserGSS
:
public
CoefficientOptimiserBase
95
{
MEMALIGN
(
CoefficientOptimiserGSS
)
96
97
public
:
98
CoefficientOptimiserGSS
(
TckFactor
&,
StreamlineStats
&,
StreamlineStats
&,
unsigned
int
&,
BitSet
&,
double
&);
99
CoefficientOptimiserGSS
(
const
CoefficientOptimiserGSS
&);
100
~CoefficientOptimiserGSS
() { }
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!
114
class
CoefficientOptimiserQLS
:
public
CoefficientOptimiserBase
115
{
MEMALIGN
(
CoefficientOptimiserQLS
)
116
117
public
:
118
CoefficientOptimiserQLS
(
TckFactor
&,
StreamlineStats
&,
StreamlineStats
&,
unsigned
int
&,
BitSet
&,
double
&);
119
CoefficientOptimiserQLS
(
const
CoefficientOptimiserQLS
&);
120
~CoefficientOptimiserQLS
() { }
121
122
private
:
123
Math::QuadraticLineSearch<double>
qls;
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
134
class
CoefficientOptimiserIterative
:
public
CoefficientOptimiserBase
135
{
MEMALIGN
(
CoefficientOptimiserIterative
)
136
137
public
:
138
CoefficientOptimiserIterative
(
TckFactor
&,
StreamlineStats
&,
StreamlineStats
&,
unsigned
int
&,
BitSet
&,
double
&);
139
CoefficientOptimiserIterative
(
const
CoefficientOptimiserIterative
&);
140
~CoefficientOptimiserIterative
();
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
bitset.h
MR::BitSet
a class for storing bitwise information
Definition:
bitset.h:43
MR::DWI::Tractography::SIFT2::CoefficientOptimiserBase
Definition:
coeff_optimiser.h:46
MR::DWI::Tractography::SIFT2::CoefficientOptimiserBase::mu
const double mu
Definition:
coeff_optimiser.h:57
MR::DWI::Tractography::SIFT2::CoefficientOptimiserBase::master
TckFactor & master
Definition:
coeff_optimiser.h:56
MR::DWI::Tractography::SIFT2::CoefficientOptimiserBase::get_coeff_change
virtual double get_coeff_change(const SIFT::track_t) const =0
MR::DWI::Tractography::SIFT2::CoefficientOptimiserBase::local_sum_costs
double local_sum_costs
Definition:
coeff_optimiser.h:79
MR::DWI::Tractography::SIFT2::CoefficientOptimiserGSS
Definition:
coeff_optimiser.h:95
MR::DWI::Tractography::SIFT2::CoefficientOptimiserIterative
Definition:
coeff_optimiser.h:135
MR::DWI::Tractography::SIFT2::CoefficientOptimiserQLS
Definition:
coeff_optimiser.h:115
MR::DWI::Tractography::SIFT2::StreamlineStats
Definition:
streamline_stats.h:35
MR::DWI::Tractography::SIFT2::TckFactor
Definition:
tckfactor.h:60
MR::Math::QuadraticLineSearch< double >
golden_section_search.h
MR::DWI::Tractography::SIFT::track_t
unsigned int track_t
Definition:
types.h:34
MR::DWI::Tractography::SIFT::TrackIndexRange
std::pair< track_t, track_t > TrackIndexRange
Definition:
track_index_range.h:38
MR
Definition:
base.h:24
quadratic_line_search.h
types.h
MEMALIGN
#define MEMALIGN(...)
Definition:
types.h:185
streamline_stats.h
track_index_range.h
src
dwi
tractography
SIFT2
coeff_optimiser.h
Generated on Mon Jul 4 2022 08:00:07 for MRtrix by
1.9.3