Developer documentation
Version 3.0.3-105-gd3941f44
sifter.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_sift_sifter_h__
18#define __dwi_tractography_sift_sifter_h__
19
20
21
22#include "image.h"
23#include "types.h"
24
25#include "math/rng.h"
26
27#include "dwi/fixel_map.h"
28#include "dwi/directions/set.h"
35
36
37
38namespace MR
39{
40 namespace DWI
41 {
42 namespace Tractography
43 {
44 namespace SIFT
45 {
46
47
48 class SIFTer : public Model<Fixel>
50
51 protected:
52 using MapType = Model<Fixel>;
53 using MapVoxel = Fixel_map<Fixel>::MapVoxel;
55
56
57 public:
59 MapType (i, d),
60 output_debug (false),
61 term_number (0),
62 term_ratio (0.0),
63 term_mu (0.0),
64 enforce_quantisation (true) { }
65
66 SIFTer (const SIFTer& that) = delete;
67
68 ~SIFTer() { }
69
70
71 // CORE OPERATIONS
73 void output_filtered_tracks (const std::string&, const std::string&) const;
74 void output_selection (const std::string&) const;
75
76 // CONFIGURATION OPTIONS
77 void set_term_number (const track_t i) { term_number = i; }
78 void set_term_ratio (const float i) { term_ratio = i; }
79 void set_term_mu (const float i) { term_mu = i; }
80 void set_csv_path (const std::string& i) { csv_path = i; }
81
82 void set_regular_outputs (const vector<uint32_t>&, const bool);
83
84
85 // DEBUGGING
86 void test_sorting_block_size (const size_t) const;
87
88
89 protected:
92
93 using MapType::FOD_sum;
94 using MapType::TD_sum;
95 using MapType::proc_mask;
96 using MapType::num_tracks;
97
98
99 // User-controllable settings
104 double term_mu;
106 std::string csv_path;
107
108
109 // Convenience functions
111 double calc_gradient (const track_t, const double, const double) const;
112
113
114
115 // For calculating the streamline removal gradients in a multi-threaded fashion
117 { MEMALIGN(TrackGradientCalculator)
118 public:
119 TrackGradientCalculator (const SIFTer& sifter, vector<Cost_fn_gradient_sort>& v, const double mu, const double r) :
120 master (sifter), gradient_vector (v), current_mu (mu), current_roc_cost (r) { }
121 bool operator() (const TrackIndexRange&) const;
122 private:
123 const SIFTer& master;
124 vector<Cost_fn_gradient_sort>& gradient_vector;
125 const double current_mu, current_roc_cost;
126 };
127
128
129 };
130
131
132
133
134 }
135 }
136 }
137}
138
139
140#endif
141
142
void set_term_ratio(const float i)
Definition: sifter.h:78
void set_regular_outputs(const vector< uint32_t > &, const bool)
void output_selection(const std::string &) const
SIFTer(Image< float > &i, const DWI::Directions::FastLookupSet &d)
Definition: sifter.h:58
void output_filtered_tracks(const std::string &, const std::string &) const
SIFTer(const SIFTer &that)=delete
vector< track_t > output_at_counts
Definition: sifter.h:100
void set_term_number(const track_t i)
Definition: sifter.h:77
void test_sorting_block_size(const size_t) const
void set_term_mu(const float i)
Definition: sifter.h:79
void set_csv_path(const std::string &i)
Definition: sifter.h:80
double calc_gradient(const track_t, const double, const double) const
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