STIR 6.5.0
vector_utils Namespace Reference

Helpers for spacing analysis and axis inference from coordinate sets. More...

Functions

bool get_spacing_uniform (std::vector< float > &spacing, const std::set< float > &unsorted_block_poss, double epsilon=1e-4)
 Compute spacings between sorted unique values and test uniformity.
const std::set< float > & get_largest_vector (const std::set< float > &x, const std::set< float > &y, const std::set< float > &z)
 Return the largest of three sets and report inferred axial direction.
void find_unique_values_1D (std::set< float > &values, const std::vector< float > &input)
 Collect unique values from a 1D vector.
void find_unique_values_2D (std::set< float > &values, const std::vector< std::vector< float > > &input)
 Collect unique values from a 2D vector (matrix).

Detailed Description

Helpers for spacing analysis and axis inference from coordinate sets.

  • vector_utils::get_spacing_uniform computes successive spacings between sorted unique values and tests if they are uniform within a tolerance.
  • vector_utils::getLargestVector returns the largest of three coordinate sets and logs which axis is inferred as “axial”.

Function Documentation

◆ get_spacing_uniform()

bool vector_utils::get_spacing_uniform ( std::vector< float > & spacing,
const std::set< float > & unsorted_block_poss,
double epsilon = 1e-4 )
inline

Compute spacings between sorted unique values and test uniformity.

Parameters
spacingOutput vector. Appends |x[i] - x[i-1]| for i=1..N-1, where x is the sorted version of unsorted_block_poss.
unsorted_block_possSet of unique positions (e.g., angles or translations).
epsilonTolerance for uniformity check (default 1e-4).
Returns
True if all spacings differ from the first spacing by <= epsilon, false otherwise.
  • If spacing ends up empty (e.g., input size < 2), returns true (trivially uniform).

References get_spacing_uniform().

Referenced by get_spacing_uniform(), and stir::PETSIRDInfo::PETSIRDInfo().

◆ get_largest_vector()

const std::set< float > & vector_utils::get_largest_vector ( const std::set< float > & x,
const std::set< float > & y,
const std::set< float > & z )

Return the largest of three sets and report inferred axial direction.

Parameters
xValues along X.
yValues along Y.
zValues along Z.
Returns
Const reference to the largest set among x, y, z.

Logs the index of the inferred axial direction: 0 (x), 1 (y), or 2 (z).

References get_largest_vector().

Referenced by get_largest_vector(), and stir::PETSIRDInfo::PETSIRDInfo().

◆ find_unique_values_1D()

void vector_utils::find_unique_values_1D ( std::set< float > & values,
const std::vector< float > & input )

Collect unique values from a 1D vector.

Parameters
valuesOutput set for unique values.
inputInput vector.

References find_unique_values_1D().

Referenced by find_unique_values_1D().

◆ find_unique_values_2D()

void vector_utils::find_unique_values_2D ( std::set< float > & values,
const std::vector< std::vector< float > > & input )

Collect unique values from a 2D vector (matrix).

Parameters
valuesOutput set for unique values.
inputInput 2D vector [rows][cols].

References find_unique_values_2D().

Referenced by find_unique_values_2D(), and stir::PETSIRDInfo::PETSIRDInfo().