highres-cortex 6.0.4
yl::PropagateAlongField Class Reference

Propagate labels along a vector field. More...

#include <highres-cortex/propagate_along_field.hh>

Classes

class  AbortedAdvection
 Exception raised by certain members if an advection cannot be completed. More...
 

Public Member Functions

 PropagateAlongField (const boost::shared_ptr< VectorField3d > &vector_field)
 
 PropagateAlongField (const carto::VolumeRef< float > &fieldx, const carto::VolumeRef< float > &fieldy, const carto::VolumeRef< float > &fieldz)
 Provide the field as separate scalar components.
 
virtual ~PropagateAlongField ()
 
void setVerbose (int verbosity=1)
 Indicate progress on stderr.
 
void setStep (float step)
 Move in steps of the specified size (millimetres).
 
void setMaxIter (unsigned int max_iter)
 Abort following the gradient after a number of iterations.
 
template<typename Tlabel>
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.
 
template<typename Tlabel>
carto::VolumeRef< Tlabel > propagate_regions (const carto::VolumeRef< Tlabel > &seeds, Tlabel target_label=0) const
 Propagate labelled regions down a vector field.
 
template<typename Tlabel>
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.
 
template<class TVisitor, typename Tlabel>
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.
 
template<typename Tlabel>
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.
 
template<typename Tlabel>
carto::VolumeRef< float > integrate_from_region (const carto::VolumeRef< Tlabel > &seeds, const boost::shared_ptr< ScalarField > &field, Tlabel target_label=0) const
 

Static Public Attributes

static const float default_step
 
static const unsigned int default_max_iter
 

Detailed Description

Propagate labels along a vector field.

From a given starting point, the field is followed in fixed-size steps until a seed is reached, or the maximum number of iterations is exceeded.

Definition at line 55 of file propagate_along_field.hh.

Constructor & Destructor Documentation

◆ PropagateAlongField() [1/2]

yl::PropagateAlongField::PropagateAlongField ( const boost::shared_ptr< VectorField3d > & vector_field)
explicit

◆ PropagateAlongField() [2/2]

yl::PropagateAlongField::PropagateAlongField ( const carto::VolumeRef< float > & fieldx,
const carto::VolumeRef< float > & fieldy,
const carto::VolumeRef< float > & fieldz )

Provide the field as separate scalar components.

The field will be linearly interpolated.

◆ ~PropagateAlongField()

virtual yl::PropagateAlongField::~PropagateAlongField ( )
virtual

Member Function Documentation

◆ ascend_until_nonzero()

template<typename Tlabel>
Tlabel yl::PropagateAlongField::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.

  • start_point is to be specified in millimetre coordinates.
  • seeds is interpreted as for propagate_regions().
  • ignore_label counts as propagation region.

Return the value of the seed encountered, or zero in the following cases:

  • the path leads outside of the image;
  • the maximum number of iterations is exceeded (e.g. the path loops);
  • a vector field value is encountered that is too close to zero, or infinite, or NaN.

◆ integrate_field_along_advection()

template<typename Tlabel>
float yl::PropagateAlongField::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.

Exceptions
AbortedAdvectionis thrown if the advection cannot be completed.

◆ integrate_from_region()

template<typename Tlabel>
carto::VolumeRef< float > yl::PropagateAlongField::integrate_from_region ( const carto::VolumeRef< Tlabel > & seeds,
const boost::shared_ptr< ScalarField > & field,
Tlabel target_label = 0 ) const

◆ propagate_regions()

template<typename Tlabel>
carto::VolumeRef< Tlabel > yl::PropagateAlongField::propagate_regions ( const carto::VolumeRef< Tlabel > & seeds,
Tlabel target_label = 0 ) const

Propagate labelled regions down a vector field.

The labels are interpreted as follows:

  • zero: propagation zone,
  • positive: seed, propagation is stopped and the target voxel is given the seed's value (except if the label is target_label),
  • negative: forbidden region, propagation is stopped and the target voxel remains unset.

    An optional target_label can be given, in which case the propagation is started only from thus labelled voxels.

◆ propagate_regions_keeping_dests()

template<typename Tlabel>
std::pair< carto::VolumeRef< Tlabel >, carto::VolumeRef< float > > yl::PropagateAlongField::propagate_regions_keeping_dests ( const carto::VolumeRef< Tlabel > & seeds,
Tlabel target_label = 0 ) const

Propagate regions, keeping track of the provenance of each voxel.

See also
propagate_regions()

The second output volume is the same size as the input seeds volume, except is has 3 time points which represent x, y, and z coordinates of the point of origin, respectively.

◆ setMaxIter()

void yl::PropagateAlongField::setMaxIter ( unsigned int max_iter)

Abort following the gradient after a number of iterations.

This is to prevent infinite looping when the propagation falls in a local minimum or loops over itself. By default this is default_max_iter.

◆ setStep()

void yl::PropagateAlongField::setStep ( float step)

Move in steps of the specified size (millimetres).

The default step size is default_step.

◆ setVerbose()

void yl::PropagateAlongField::setVerbose ( int verbosity = 1)

Indicate progress on stderr.

  • 0: be silent
  • 1: show progress and statistics
  • 2: show aborted field ascensions
  • more: for debugging, see source code and debug_output.

◆ visitor_ascension()

template<class TVisitor, typename Tlabel>
bool yl::PropagateAlongField::visitor_ascension ( const Point3df & start_point,
const carto::VolumeRef< Tlabel > & seeds,
Tlabel ignore_label,
TVisitor & visitor ) const

Visit each point along the advection path.

Return values
trueif the advection succeeds (reaches a goal region).
falseif the advection it is stopped early and fails.

Member Data Documentation

◆ default_max_iter

const unsigned int yl::PropagateAlongField::default_max_iter
static

Definition at line 140 of file propagate_along_field.hh.

◆ default_step

const float yl::PropagateAlongField::default_step
static

Definition at line 139 of file propagate_along_field.hh.


The documentation for this class was generated from the following file: