STIR 6.4.0
stir::ReconstructionTests< TargetT > Class Template Referenceabstract

Base class for simple test on reconstruction. More...

#include "stir/recon_buildblock/test/ReconstructionTests.h"

Inheritance diagram for stir::ReconstructionTests< TargetT >:

Public Member Functions

 ReconstructionTests (const std::string &proj_data_filename="", const std::string &density_filename="")
 Constructor that can take some input data to run the test with.
 
virtual std::unique_ptr< ProjDataInfoconstruct_default_proj_data_info_uptr () const
 default proj_data_info
 
virtual void construct_input_data ()
 creates input
 
virtual void construct_reconstructor ()=0
 creates the reconstruction object
 
virtual void reconstruct (shared_ptr< TargetT > target_sptr)
 perform reconstruction
 
virtual void compare (const shared_ptr< const TargetT > output_sptr)
 compares output and input
 
- Public Member Functions inherited from stir::RunTests
 RunTests (const double tolerance=1E-4)
 Default constructor.
 
virtual ~RunTests ()
 Destructor, outputs a diagnostic message.
 
virtual void run_tests ()=0
 Function (to be overloaded) which does the actual tests.
 
bool is_everything_ok () const
 Returns if all checks were fine upto now.
 
int main_return_value () const
 Handy return value for a main() function.
 
void set_tolerance (const double tolerance)
 Set value used in floating point comparisons (see check_* functions)
 
double get_tolerance () const
 Get value used in floating point comparisons (see check_* functions)
 
bool check (const bool, const std::string &str="")
 Tests if true, str can be used to tell what you are testing.
 
bool check_if_equal (const std::string &a, const std::string &b, const std::string &str="")
 
bool check_if_equal (const double a, const double b, const std::string &str="")
 
bool check_if_equal (const short a, const short b, const std::string &str="")
 
bool check_if_equal (const unsigned short a, const unsigned short b, const std::string &str="")
 
bool check_if_equal (const int a, const int b, const std::string &str="")
 
bool check_if_equal (const unsigned int a, const unsigned int b, const std::string &str="")
 
bool check_if_equal (const long a, const long b, const std::string &str="")
 
bool check_if_equal (const unsigned long a, const unsigned long b, const std::string &str="")
 
bool check_if_equal (const Bin &a, const Bin &b, const std::string &str="")
 
template<class T>
bool check_if_equal (const DetectionPosition< T > &a, const DetectionPosition< T > &b, const std::string &str="")
 
template<class T>
bool check_if_equal (const std::complex< T > a, const std::complex< T > b, const std::string &str="")
 check equality by calling check_if_equal on real and imaginary parts
 
template<class T>
bool check_if_equal (const VectorWithOffset< T > &t1, const VectorWithOffset< T > &t2, const std::string &str="")
 check equality by comparing ranges and calling check_if_equal on all elements
 
template<class T>
bool check_if_equal (const std::vector< T > &t1, const std::vector< T > &t2, const std::string &str="")
 check equality by comparing size and calling check_if_equal on all elements
 
bool check_if_equal (const ProjDataInMemory &t1, const ProjDataInMemory &t2, const std::string &str="")
 
template<int n>
bool check_if_equal (const IndexRange< n > &t1, const IndexRange< n > &t2, const std::string &str="")
 
template<int num_dimensions, class coordT>
bool check_if_equal (const BasicCoordinate< num_dimensions, coordT > &a, const BasicCoordinate< num_dimensions, coordT > &b, const std::string &str="")
 check equality by comparing norm(a-b) with tolerance
 
bool check_if_zero (const double a, const std::string &str="")
 
bool check_if_zero (const short a, const std::string &str="")
 
bool check_if_zero (const unsigned short a, const std::string &str="")
 
bool check_if_zero (const int a, const std::string &str="")
 
bool check_if_zero (const unsigned int a, const std::string &str="")
 
bool check_if_zero (const long a, const std::string &str="")
 
bool check_if_zero (const unsigned long a, const std::string &str="")
 
template<class T>
bool check_if_zero (const VectorWithOffset< T > &t, const std::string &str="")
 use check_if_zero on all elements
 
template<int num_dimensions, class coordT>
bool check_if_zero (const BasicCoordinate< num_dimensions, coordT > &a, const std::string &str="")
 compare norm with tolerance
 
template<class T1, class T2>
bool check_if_less (T1 a, T2 b, const std::string &str="")
 check if a<b
 

Protected Attributes

std::string _proj_data_filename
 
std::string _input_density_filename
 
shared_ptr< ProjDataInMemory_proj_data_sptr
 
shared_ptr< TargetT > _input_density_sptr
 
shared_ptr< Reconstruction< TargetT > > _recon_sptr
 
double tolerance
 tolerance for comparisons with real values
 
bool everything_ok
 variable storing current status
 

Additional Inherited Members

template<class T>
bool check_if_equal_generic (const T &a, const T &b, const std::string &str)
 function that is called by some check_if_equal implementations. It just uses operator!=
 
template<class T>
bool check_if_zero_generic (T a, const std::string &str)
 function that is called by some check_if_zero implementations. It just uses operator!=
 

Detailed Description

template<class TargetT>
class stir::ReconstructionTests< TargetT >

Base class for simple test on reconstruction.

Member Function Documentation

◆ construct_default_proj_data_info_uptr()

template<class TargetT>
std::unique_ptr< ProjDataInfo > stir::ReconstructionTests< TargetT >::construct_default_proj_data_info_uptr ( ) const
inlinevirtual

default proj_data_info

Reimplemented in stir::TestFBP2D, and stir::TestFBP3DRP.

References stir::ProjDataInfo::ProjDataInfoCTI().

Referenced by construct_input_data().

◆ construct_input_data()

template<class TargetT>
void stir::ReconstructionTests< TargetT >::construct_input_data ( )
inlinevirtual

creates input

sets _proj_data_sptr and _input_density_sptr from filenames or defaults if the filename is empty.

_proj_data_sptr is constructed by forward projecting _input_density_sptr

References stir::DataProcessor< DataT >::apply(), construct_default_proj_data_info_uptr(), stir::Shape3D::construct_volume(), MAKE_SHARED, stir::ProjData::read_from_file(), stir::read_from_file(), and stir::DataProcessor< DataT >::set_up().

◆ construct_reconstructor()

template<class TargetT>
virtual void stir::ReconstructionTests< TargetT >::construct_reconstructor ( )
inlinepure virtual

creates the reconstruction object

has to set _recon_sptr

Implemented in stir::TestFBP2D, stir::TestFBP3DRP, and stir::TestOSMAPOSL.

◆ reconstruct()

template<class TargetT>
void stir::ReconstructionTests< TargetT >::reconstruct ( shared_ptr< TargetT > target_sptr)
inlinevirtual

perform reconstruction

Uses target_sptr as initialisation, and updates it

See also
Reconstruction::reconstruct(shared_ptr<TargetT>&)

References stir::error().

◆ compare()

template<class TargetT>
void stir::ReconstructionTests< TargetT >::compare ( const shared_ptr< const TargetT > output_sptr)
inlinevirtual

compares output and input

voxel-wise comparison

References stir::RunTests::check(), stir::RunTests::check_if_less(), stir::in_place_abs(), and stir::write_to_file().


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