Developer documentation
Version 3.0.3-105-gd3941f44
fixel_td_map.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_mapping_fixel_td_map_h__
18#define __dwi_tractography_mapping_fixel_td_map_h__
19
20
21#include "dwi/fixel_map.h"
22#include "dwi/directions/set.h"
24
25namespace MR
26{
27 namespace DWI
28 {
29 namespace Tractography
30 {
31 namespace Mapping
32 {
33
34
35
36 // Templated Fixel class MUST provide operator+= (const float) for adding streamline density
37
38 template <class Fixel>
39 class Fixel_TD_map : public Fixel_map<Fixel>
40 { MEMALIGN(Fixel_TD_map<Fixel>)
41
42 using MapVoxel = typename Fixel_map<Fixel>::MapVoxel;
44
45 public:
47 Fixel_map<Fixel> (H),
48 dirs (directions) { }
49 Fixel_TD_map (const Fixel_TD_map&) = delete;
50
51 virtual ~Fixel_TD_map() { }
52
53 virtual bool operator() (const SetDixel& in);
54
55 protected:
58
60
61 size_t dixel2fixel (const Dixel&) const;
62
63 };
64
65
66
67
68
69 template <class Fixel>
71 {
72 for (const auto& i : in) {
73 const size_t fixel_index = dixel2fixel (i);
74 if (fixel_index)
75 fixels[fixel_index] += i.get_length();
76 }
77 return true;
78 }
79
80
81 template <class Fixel>
82 size_t Fixel_TD_map<Fixel>::dixel2fixel (const Dixel& in) const
83 {
84 auto v = accessor();
85 assign_pos_of (in).to (v);
86 if (is_out_of_bounds (v))
87 return 0;
88 if (!v.value())
89 return 0;
90 const MapVoxel& map_voxel (*v.value());
91 if (map_voxel.empty())
92 return 0;
93 return map_voxel.dir2fixel (in.get_dir());
94 }
95
96
97
98 }
99 }
100 }
101}
102
103
104#endif
Fixel_TD_map(const Fixel_TD_map &)=delete
const DWI::Directions::FastLookupSet & dirs
Definition: fixel_td_map.h:59
size_t dixel2fixel(const Dixel &) const
Definition: fixel_td_map.h:82
virtual bool operator()(const SetDixel &in)
Definition: fixel_td_map.h:70
Fixel_TD_map(const Header &H, const DWI::Directions::FastLookupSet &directions)
Definition: fixel_td_map.h:46
Definition: base.h:24
Eigen::MatrixXd H