highres-cortex 6.0.4
propagate_along_field.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#ifndef YL_PROPAGATE_ALONG_FIELD_HH
39#define YL_PROPAGATE_ALONG_FIELD_HH
40
41#include <boost/shared_ptr.hpp>
42
43#include <cartodata/volume/volume.h>
44#include <aims/vector/vector.h>
45#include "field.hh"
46
47namespace yl
48{
49
56{
57public:
58 explicit PropagateAlongField(const boost::shared_ptr<VectorField3d>& vector_field);
64 const carto::VolumeRef<float>& fieldy,
65 const carto::VolumeRef<float>& fieldz);
67
75 void setVerbose(int verbosity=1);
76
81 void setStep(float step);
82
88 void setMaxIter(unsigned int max_iter);
89
102 template<typename Tlabel>
103 Tlabel
104 ascend_until_nonzero(const Point3df &start_point,
105 const carto::VolumeRef<Tlabel> &seeds,
106 Tlabel ignore_label) const;
107
120 template<typename Tlabel>
123 Tlabel target_label=0) const;
124
133 template<typename Tlabel>
134 std::pair<carto::VolumeRef<Tlabel>, carto::VolumeRef<float> >
136 Tlabel target_label=0) const;
137
138
139 static const float default_step;
140 static const unsigned int default_max_iter;
141
147 template <class TVisitor, typename Tlabel>
148 bool
149 visitor_ascension(const Point3df &start_point,
150 const carto::VolumeRef<Tlabel> &seeds,
151 Tlabel ignore_label,
152 TVisitor& visitor) const;
153
159 template <typename Tlabel>
160 float
161 integrate_field_along_advection(const Point3df &start_point,
162 const carto::VolumeRef<Tlabel> &seeds,
163 const boost::shared_ptr<ScalarField>& field,
164 Tlabel ignore_label) const;
165
166
169 {
170 };
171
172 template<typename Tlabel>
175 const boost::shared_ptr<ScalarField>& field,
176 Tlabel target_label=0) const;
177
178private:
179 boost::shared_ptr<VectorField3d> m_vector_field;
180 unsigned int m_max_iter;
181 float m_step;
182 int m_verbose;
183
184 static const int debug_output = 0;
185
186 template <template <typename> class ResultChooserTemplate, typename Tlabel>
187 typename ResultChooserTemplate<Tlabel>::result_type
188 internal_ascension(const Point3df &start_point,
189 const carto::VolumeRef<Tlabel> &seeds,
190 Tlabel ignore_label,
191 const ResultChooserTemplate<Tlabel>& result_chooser) const;
192
193 template <class ResultChooser, typename Tlabel>
194 typename ResultChooser::result_type
195 internal_ascension(const Point3df &start_point,
196 const carto::VolumeRef<Tlabel> &seeds,
197 Tlabel ignore_label,
198 const ResultChooser& result_chooser) const;
199
200 template<class ResultRecorder, typename Tlabel>
201 void
202 internal_propagation(const carto::VolumeRef<Tlabel> &seeds,
203 Tlabel target_label,
204 ResultRecorder& result_recorder) const;
205};
206
207} // namespace yl
208
209#endif // !defined(YL_PROPAGATE_ALONG_FIELD_HH)
Exception raised by certain members if an advection cannot be completed.
bool visitor_ascension(const Point3df &start_point, const carto::VolumeRef< Tlabel > &seeds, Tlabel ignore_label, TVisitor &visitor) const
Visit each point along the advection path.
void setMaxIter(unsigned int max_iter)
Abort following the gradient after a number of iterations.
float integrate_field_along_advection(const Point3df &start_point, const carto::VolumeRef< Tlabel > &seeds, const boost::shared_ptr< ScalarField > &field, Tlabel ignore_label) const
Return the integral of a scalar field along an advection path.
carto::VolumeRef< float > integrate_from_region(const carto::VolumeRef< Tlabel > &seeds, const boost::shared_ptr< ScalarField > &field, Tlabel target_label=0) const
PropagateAlongField(const carto::VolumeRef< float > &fieldx, const carto::VolumeRef< float > &fieldy, const carto::VolumeRef< float > &fieldz)
Provide the field as separate scalar components.
static const unsigned int default_max_iter
void setStep(float step)
Move in steps of the specified size (millimetres).
PropagateAlongField(const boost::shared_ptr< VectorField3d > &vector_field)
void setVerbose(int verbosity=1)
Indicate progress on stderr.
std::pair< carto::VolumeRef< Tlabel >, carto::VolumeRef< float > > propagate_regions_keeping_dests(const carto::VolumeRef< Tlabel > &seeds, Tlabel target_label=0) const
Propagate regions, keeping track of the provenance of each voxel.
carto::VolumeRef< Tlabel > propagate_regions(const carto::VolumeRef< Tlabel > &seeds, Tlabel target_label=0) const
Propagate labelled regions down a vector field.
Tlabel ascend_until_nonzero(const Point3df &start_point, const carto::VolumeRef< Tlabel > &seeds, Tlabel ignore_label) const
Move along the field until a nonzero label is found.
virtual ~PropagateAlongField()
Definition cortex.hh:41