Developer documentation
Version 3.0.3-105-gd3941f44
fixel.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_fixel_h__
18#define __dwi_tractography_sift2_fixel_h__
19
20
21#include <limits>
22
25
26
27
28
29namespace MR
30{
31 namespace DWI
32 {
33 namespace Tractography
34 {
35 namespace SIFT2
36 {
37
38
39
40 class Fixel : public SIFT::FixelBase
41 { MEMALIGN(Fixel)
42
43 using track_t = SIFT::track_t;
44
45 public:
46 Fixel () :
47 SIFT::FixelBase (),
48 excluded (false),
49 count (0),
50 orig_TD (0.0),
51 mean_coeff (0.0) { }
52
53 Fixel (const FMLS::FOD_lobe& lobe) :
54 SIFT::FixelBase (lobe),
55 excluded (false),
56 count (0),
57 orig_TD (0.0),
58 mean_coeff (0.0) { }
59
60 Fixel (const Fixel& that) :
61 SIFT::FixelBase (that),
62 excluded (false),
63 count (0),
64 orig_TD (that.orig_TD),
65 mean_coeff (0.0) { }
66
67
68 // Overloaded += operator; want to track the number of streamlines as well as the sum of lengths
69 Fixel& operator+= (const double length) { TD += length; ++count; return *this; }
70
71 // This is for the multi-threaded fixel updater - only gets one update per thread
72 void add_TD (const double sum_lengths, const track_t num) { TD += sum_lengths; count += num; }
73
74 // Overloaded clear_TD(); latch the previous TD, and clear the count field also
75 void clear_TD() { TD = 0.0; count = 0; }
76
77 // Functions for altering the state of this more advanced fixel class
78 void exclude() { excluded = true; }
79 void store_orig_TD() { orig_TD = get_TD(); }
80 void clear_mean_coeff() { mean_coeff = 0.0; }
81
82 void add_to_mean_coeff (const double i) { mean_coeff += i; }
83 void normalise_mean_coeff() { if (orig_TD) mean_coeff /= orig_TD; if (count < 2) mean_coeff = 0.0; }
84
85 // get() functions
86 bool is_excluded() const { return excluded; }
87 track_t get_count() const { return count; }
88 double get_orig_TD() const { return orig_TD; }
89 double get_mean_coeff() const { return mean_coeff; }
90
91
92 private:
93 bool excluded;
94 track_t count;
95 double orig_TD, mean_coeff;
96
97 };
98
99
100
101
102 }
103 }
104 }
105}
106
107
108#endif
109
110
Fixel(const FMLS::FOD_lobe &lobe)
Definition: fixel.h:53
Fixel(const Fixel &that)
Definition: fixel.h:60
Fixel & operator+=(const double length)
Definition: fixel.h:69
void add_to_mean_coeff(const double i)
Definition: fixel.h:82
double get_mean_coeff() const
Definition: fixel.h:89
void add_TD(const double sum_lengths, const track_t num)
Definition: fixel.h:72
unsigned int track_t
Definition: types.h:34
PointType::Scalar length(const vector< PointType > &tck)
Definition: streamline.h:134
Definition: base.h:24
size_t num
Definition: thread.h:216