Developer documentation
Version 3.0.3-105-gd3941f44
shared.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_tracking_shared_h__
18#define __dwi_tractography_tracking_shared_h__
19
20#include <atomic>
21
22#include "header.h"
23#include "image.h"
24#include "memory.h"
25#include "transform.h"
32
33
34// If this is enabled, images will be output in the current directory showing the density of streamline terminations due to different termination mechanisms throughout the brain
35//#define DEBUG_TERMINATIONS
36
37
38
39namespace MR
40{
41 namespace DWI
42 {
43 namespace Tractography
44 {
45 namespace Tracking
46 {
47
48
49
51
52 public:
53
54 SharedBase (const std::string& diff_path, Properties& property_set);
55
56 virtual ~SharedBase();
57
58
59 Image<float> source;
60 Properties& properties;
61 Eigen::Vector3f init_dir;
62 size_t max_num_tracks, max_num_seeds;
63 size_t min_num_points_preds, max_num_points_preds;
64 size_t min_num_points_postds, max_num_points_postds;
65 float min_dist, max_dist;
66 // Different variables for 1st-order integration vs. higher-order integration
67 float max_angle_1o, max_angle_ho, cos_max_angle_1o, cos_max_angle_ho;
68 float step_size, min_radius, threshold, init_threshold;
69 size_t max_seed_attempts;
70 bool unidirectional, rk4, stop_on_all_include, implicit_max_num_seeds;
72
73 // Additional members for ACT
74 bool is_act() const { return bool (act_shared_additions); }
75 const ACT::ACT_Shared_additions& act() const { return *act_shared_additions; }
76
77 float vox () const
78 {
79 return std::pow (source.spacing(0)*source.spacing(1)*source.spacing(2), float (1.0/3.0));
80 }
81
82 void set_step_and_angle (const float stepsize, const float angle, bool is_higher_order);
83 void set_num_points();
84 void set_num_points (const float angle_minradius_preds, const float max_step_postds);
85 void set_cutoff (float cutoff);
86
87 // This gets overloaded for iFOD2, as each sample is output rather than just each step, and there are
88 // multiple samples per step
89 // (Only utilised for Exec::satisfy_wm_requirement())
90 virtual float internal_step_size() const { return step_size; }
91
92
93 void add_termination (const term_t i) const { terminations[i].fetch_add (1, std::memory_order_relaxed); }
94 void add_rejection (const reject_t i) const { rejections[i] .fetch_add (1, std::memory_order_relaxed); }
95
96
97#ifdef DEBUG_TERMINATIONS
98 void add_termination (const term_t i, const Eigen::Vector3f& p) const;
99#endif
100
101
102 private:
103 mutable std::atomic<size_t> terminations[TERMINATION_REASON_COUNT];
104 mutable std::atomic<size_t> rejections [REJECTION_REASON_COUNT];
105
106 std::unique_ptr<ACT::ACT_Shared_additions> act_shared_additions;
107
108#ifdef DEBUG_TERMINATIONS
109 Header debug_header;
111 const Transform transform;
112#endif
113
114 };
115
116
117
118 }
119 }
120 }
121}
122
123#endif
124
default_type spacing(size_t axis) const
Definition: image.h:67
Definition: base.h:24
#define TERMINATION_REASON_COUNT
Definition: types.h:39
#define REJECTION_REASON_COUNT
Definition: types.h:46
#define MEMALIGN(...)
Definition: types.h:185