highres-cortex 6.0.4
cortex_column_region_quality.hh
Go to the documentation of this file.
1/*
2Copyright CEA (2014).
3Copyright Université Paris XI (2014).
4
5Contributor: Yann Leprince <yann.leprince@ylep.fr>.
6
7This file is part of highres-cortex, a collection of software designed
8to process high-resolution magnetic resonance images of the cerebral
9cortex.
10
11This software is governed by the CeCILL licence under French law and
12abiding by the rules of distribution of free software. You can use,
13modify and/or redistribute the software under the terms of the CeCILL
14licence as circulated by CEA, CNRS and INRIA at the following URL:
15<http://www.cecill.info/>.
16
17As a counterpart to the access to the source code and rights to copy,
18modify and redistribute granted by the licence, users are provided only
19with a limited warranty and the software's author, the holder of the
20economic rights, and the successive licensors have only limited
21liability.
22
23In this respect, the user's attention is drawn to the risks associated
24with loading, using, modifying and/or developing or reproducing the
25software by the user in light of its specific status of scientific
26software, that may mean that it is complicated to manipulate, and that
27also therefore means that it is reserved for developers and experienced
28professionals having in-depth computer knowledge. Users are therefore
29encouraged to load and test the software's suitability as regards their
30requirements in conditions enabling the security of their systems and/or
31data to be ensured and, more generally, to use and operate it in the
32same conditions as regards security.
33
34The fact that you are presently reading this means that you have had
35knowledge of the CeCILL licence and that you accept its terms.
36*/
37
38// TODO rename this to cortical_traverse_quality
39
40#ifndef CORTEX_COLUMN_REGION_QUALITY_HH_INCLUDED
41#define CORTEX_COLUMN_REGION_QUALITY_HH_INCLUDED
42
43#include <cartodata/volume/volume.h>
44#include "label_volume.hh"
45
46namespace yl
47{
48
50{
51public:
53 : m_000(0.f),
54 m_100(0.f), m_010(0.f), m_001(0.f),
55 m_200(0.f),
56 m_110(0.f), m_020(0.f),
57 m_101(0.f), m_011(0.f), m_002(0.f) {}
58
60 float m100, float m010, float m001,
61 float m200,
62 float m110, float m020,
63 float m101, float m011, float m002)
64 : m_000(m000),
65 m_100(m100), m_010(m010), m_001(m001),
66 m_200(m200),
67 m_110(m110), m_020(m020),
68 m_101(m101), m_011(m011), m_002(m002) {}
69
70 void update(float x, float y, float z)
71 {
72 m_000 += 1;
73 m_100 += x; m_010 += y; m_001 += z;
74 m_200 += x * x;
75 m_110 += y * x; m_020 += y * y;
76 m_101 += z * x; m_011 += z * y; m_002 += z * z;
77 };
78
80 {
81 return MomentAccumulator(m_000 + other.m_000,
82 m_100 + other.m_100,
83 m_010 + other.m_010,
84 m_001 + other.m_001,
85 m_200 + other.m_200,
86 m_110 + other.m_110,
87 m_020 + other.m_020,
88 m_101 + other.m_101,
89 m_011 + other.m_011,
90 m_002 + other.m_002);
91 };
92
93 std::size_t m_000;
94 float m_100, m_010, m_001;
95 float m_200;
96 float m_110, m_020;
97 float m_101, m_011, m_002;
98};
99
100
102{
103public:
105 const carto::VolumeRef<float>& white_projections,
106 const carto::VolumeRef<int16_t>& classif);
107
108 void setShapeParametres(float goal_diameter);
109
110 template <typename Tlabel>
111 float fusion_ordering(const LabelVolume<Tlabel>& /*label_vol*/, Tlabel /*label*/) const;
112
113 template <typename Tlabel>
114 float fusion_ordering(const LabelVolume<Tlabel>& /*label_vol*/, Tlabel /*label1*/, Tlabel /*label2*/) const;
115
116 template <class PointIterator>
117 inline float fusion_ordering(const PointIterator& point_it_begin,
118 const PointIterator& point_it_end) const;
119
120 class Cache
121 {
122 public:
124 : m_CSF_moments(),
125 m_white_moments(),
126 m_region_size(0),
127 m_touches_CSF(false),
128 m_touches_white(false)
129 {};
132 std::size_t region_size,
133 bool touches_CSF,
134 bool touches_white)
135 : m_CSF_moments(CSF_moments),
136 m_white_moments(white_moments),
137 m_region_size(region_size),
138 m_touches_CSF(touches_CSF),
139 m_touches_white(touches_white)
140 {};
141
142 Cache operator + (const Cache& other) const
143 {
144 return Cache(CSF_moments() + other.CSF_moments(),
145 white_moments() + other.white_moments(),
146 region_size() + other.region_size(),
147 touches_CSF() || other.touches_CSF(),
148 touches_white() || other.touches_white());
149 };
150
151 const MomentAccumulator& CSF_moments() const {return m_CSF_moments;};
152 MomentAccumulator& CSF_moments() {return m_CSF_moments;};
153 const MomentAccumulator& white_moments() const {return m_white_moments;};
154 MomentAccumulator& white_moments() {return m_white_moments;};
155 std::size_t region_size() const {return m_region_size;};
156 std::size_t& region_size() {return m_region_size;};
157 bool touches_CSF() const {return m_touches_CSF;};
158 bool& touches_CSF() {return m_touches_CSF;};
159 bool touches_white() const {return m_touches_white;};
160 bool& touches_white() {return m_touches_white;};
161 private:
162 MomentAccumulator m_CSF_moments;
163 MomentAccumulator m_white_moments;
164 std::size_t m_region_size;
165 bool m_touches_CSF;
166 bool m_touches_white;
167 };
168 float fusion_ordering(const Cache& /*cache*/) const;
169 bool want_fusion (const Cache& /*cache*/) const;
170 float pseudo_area(const Cache& /*cache*/) const;
171 template <class PointIterator>
172 Cache cache(const PointIterator& point_it_begin,
173 const PointIterator& point_it_end) const;
174 template <typename Tlabel>
175 Cache cache(const LabelVolume<Tlabel>& /*label_vol*/, Tlabel /*label*/) const;
176
177 static float default_goal_diameter();
178
179private:
180 carto::VolumeRef<float> m_CSF_projections;
181 carto::VolumeRef<float> m_white_projections;
183 float m_pseudo_area_cutoff;
184}; // class CortexColumnRegionQuality
185
186}; // namespace yl
187
188#endif // !defined(CORTEX_COLUMN_REGION_QUALITY_HH_INCLUDED)
const MomentAccumulator & white_moments() const
Cache(const MomentAccumulator &CSF_moments, const MomentAccumulator &white_moments, std::size_t region_size, bool touches_CSF, bool touches_white)
const MomentAccumulator & CSF_moments() const
Cache cache(const PointIterator &point_it_begin, const PointIterator &point_it_end) const
void setShapeParametres(float goal_diameter)
float pseudo_area(const Cache &) const
CortexColumnRegionQuality(const carto::VolumeRef< float > &CSF_projections, const carto::VolumeRef< float > &white_projections, const carto::VolumeRef< int16_t > &classif)
static float default_goal_diameter()
float fusion_ordering(const LabelVolume< Tlabel > &, Tlabel, Tlabel) const
bool want_fusion(const Cache &) const
float fusion_ordering(const Cache &) const
Cache cache(const LabelVolume< Tlabel > &, Tlabel) const
float fusion_ordering(const PointIterator &point_it_begin, const PointIterator &point_it_end) const
float fusion_ordering(const LabelVolume< Tlabel > &, Tlabel) const
Definition cortex.hh:41
MomentAccumulator(float m000, float m100, float m010, float m001, float m200, float m110, float m020, float m101, float m011, float m002)
void update(float x, float y, float z)
MomentAccumulator operator+(const MomentAccumulator &other) const