STIR  6.2.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
stir::Reconstruction< TargetT > Class Template Referenceabstract

base class for all ReconstructionsAs there is not a lot of commonality between different reconstruction algorithms, this base class is rather basic. It essentially takes care of constructing a target image, calls the virtual reconstruct() function, and writes the result to file. More...

#include "stir/recon_buildblock/Reconstruction.h"

Inheritance diagram for stir::Reconstruction< TargetT >:
Inheritance graph
[legend]

Public Member Functions

 Reconstruction ()
 default constructor (calls set_defaults())
 
 ~Reconstruction () override
 virtual destructor
 
virtual std::string method_info () const =0
 gives method information
 
virtual Succeeded reconstruct ()=0
 executes the reconstruction More...
 
virtual Succeeded reconstruct (shared_ptr< TargetT > const &target_image_sptr)=0
 executes the reconstruction storing result in target_image_sptr More...
 
virtual Succeeded set_up (shared_ptr< TargetT > const &target_data_sptr)
 operations prior to the reconstruction More...
 
void set_disable_output (bool _val)
 set_disable_output More...
 
shared_ptr< TargetT > get_target_image ()
 get_reconstructed_image More...
 
Functions to set parameters

This can be used as alternative to the parsing mechanism.

Warning
Be careful with setting shared pointers. If you modify the objects in one place, all objects that use the shared pointer will be affected.
void set_output_filename_prefix (const std::string &)
 file name for output reconstructed images
 
void set_output_file_format_ptr (const shared_ptr< OutputFileFormat< TargetT >> &)
 defines the format of the output files
 
void set_post_processor_sptr (const shared_ptr< DataProcessor< TargetT >> &)
 post-filter
 
virtual void set_input_data (const shared_ptr< ExamData > &)=0
 set input data
 
virtual const ExamDataget_input_data () const =0
 get input data More...
 
- Public Member Functions inherited from stir::RegisteredObjectBase
virtual std::string get_registered_name () const =0
 Returns the name of the type of the object. More...
 
- Public Member Functions inherited from stir::ParsingObject
 ParsingObject (const ParsingObject &)
 
ParsingObjectoperator= (const ParsingObject &)
 
void ask_parameters ()
 
virtual std::string parameter_info ()
 
bool parse (std::istream &f)
 
bool parse (const char *const filename)
 
- Public Member Functions inherited from stir::TimedObject
void reset_timers ()
 reset all timers kept by this object
 
void stop_timers () const
 stop all timers kept by this object More...
 
void start_timers (bool do_reset=false) const
 start all timers kept by this object More...
 
double get_CPU_timer_value () const
 get current value of the CPU timer (since first use or last reset)
 
double get_wall_clock_timer_value () const
 get current value of the wall-clock timer (since first use or last reset)
 

Protected Member Functions

virtual void check (TargetT const &target_data) const
 do consistency checks More...
 
void initialise (const std::string &parameter_filename)
 This function initialises all parameters, either via parsing, or by calling ask_parameters() (when parameter_filename is the empty string). More...
 
void set_defaults () override
 Set defaults before parsing.
 
void initialise_keymap () override
 Initialise all keywords.
 
bool post_processing () override
 used to check acceptable parameters after parsing More...
 
- Protected Member Functions inherited from stir::ParsingObject
virtual void set_key_values ()
 This will be called before parsing or parameter_info is called. More...
 

Protected Attributes

std::string output_filename_prefix
 file name for output reconstructed images
 
shared_ptr< OutputFileFormat< TargetT > > output_file_format_ptr
 defines the format of the output files
 
shared_ptr< DataProcessor< TargetT > > post_filter_sptr
 post-filter
 
bool _already_set_up
 
shared_ptr< TargetT > target_data_sptr
 target_data_sptr
 
bool _disable_output
 _disable_output More...
 
int _verbosity
 Verbosity level.
 
- Protected Attributes inherited from stir::ParsingObject
KeyParser parser
 

Additional Inherited Members

- Static Public Member Functions inherited from stir::RegisteredObject< Reconstruction< TargetT > >
static Reconstruction< TargetT > * read_registered_object (std::istream *in, const std::string &registered_name)
 Construct a new object (of a type derived from Root, its actual type determined by the registered_name parameter) by parsing the istream. More...
 
static Reconstruction< TargetT > * ask_type_and_parameters ()
 ask the user for the type, and then calls read_registered_object(0, type) More...
 
static void list_registered_names (std::ostream &stream)
 List all possible registered names to the stream. More...
 
- Protected Types inherited from stir::RegisteredObject< Reconstruction< TargetT > >
typedef Reconstruction< TargetT > *(* RootFactory) (std::istream *)
 The type of a root factory is a function, taking an istream* as argument, and returning a Root*.
 
typedef FactoryRegistry< std::string, RootFactory, interfile_lessRegistryType
 The type of the registry.
 
- Static Protected Member Functions inherited from stir::RegisteredObject< Reconstruction< TargetT > >
static RegistryTyperegistry ()
 Static function returning the registry. More...
 

Detailed Description

template<typename TargetT>
class stir::Reconstruction< TargetT >

base class for all Reconstructions

As there is not a lot of commonality between different reconstruction algorithms, this base class is rather basic. It essentially takes care of constructing a target image, calls the virtual reconstruct() function, and writes the result to file.

For convenience, the class is derived from TimedObject. It is the responsibility of the derived class to run these timers though.

Parsing parameters
; post-processing after image reconstruction,see DataProcessor<TargetT>
; defaults to no processing ("None")
post-filter type :=

; output file(s) will be written with the following file name
output filename prefix :=
; output file(s) will use the following file format
; see OutputFileFormat<TargetT>
output file format :=

Member Function Documentation

◆ reconstruct() [1/2]

template<typename TargetT>
virtual Succeeded stir::Reconstruction< TargetT >::reconstruct ( )
pure virtual

executes the reconstruction

Returns
Succeeded::yes if everything was alright.

Implemented in stir::IterativeReconstruction< TargetT >, and stir::AnalyticReconstruction.

◆ reconstruct() [2/2]

template<typename TargetT>
virtual Succeeded stir::Reconstruction< TargetT >::reconstruct ( shared_ptr< TargetT > const &  target_image_sptr)
pure virtual

executes the reconstruction storing result in target_image_sptr

Parameters
target_image_sptrThe result of the reconstruction is stored in *target_image_sptr.
Returns
Succeeded::yes if everything was alright.
Developer\'s note

Because of C++ rules, overloading one of the reconstruct() functions in a derived class, will hide the other. So you have to overload both.

Warning
you need to call set_up() first.

Implemented in stir::IterativeReconstruction< TargetT >, and stir::AnalyticReconstruction.

◆ set_up()

template<typename TargetT>
Succeeded stir::Reconstruction< TargetT >::set_up ( shared_ptr< TargetT > const &  target_data_sptr)
virtual

operations prior to the reconstruction

Will do various consistency checks and return Succeeded::no if something is wrong.

Todo:
Currently, set_up() is called by reconstruct(). This is in contrast with some other class hierarchies in STIR where set_up() has to be called before any actual processing. Maybe this should be made consistent.

Reimplemented in stir::IterativeReconstruction< TargetT >, stir::OSMAPOSLReconstruction< TargetT >, stir::OSSPSReconstruction< TargetT >, and stir::FBP2DReconstruction.

◆ get_input_data()

template<typename TargetT>
virtual const ExamData& stir::Reconstruction< TargetT >::get_input_data ( ) const
pure virtual

get input data

Will throw an exception if it wasn't set first

Implemented in stir::IterativeReconstruction< TargetT >, and stir::AnalyticReconstruction.

◆ set_disable_output()

template<typename TargetT >
void stir::Reconstruction< TargetT >::set_disable_output ( bool  _val)

set_disable_output

Parameters
_val
Author
Nikos Efthimiou

This function is called if the user deside to mute any output images. The best way to do this is to use the "disable output" key in the par file.

Warning
The "output filename prefix" has to be set.

◆ get_target_image()

template<typename TargetT >
shared_ptr< TargetT > stir::Reconstruction< TargetT >::get_target_image ( )

get_reconstructed_image

Author
Nikos Efthimiou
Returns

◆ check()

template<typename TargetT>
void stir::Reconstruction< TargetT >::check ( TargetT const &  target_data) const
protectedvirtual

do consistency checks

calls error() if anything is wrong, in particular when set_up() hasn't been called yet.

If overriding this function in a derived class, you need to call this one.

◆ initialise()

template<typename TargetT >
void stir::Reconstruction< TargetT >::initialise ( const std::string &  parameter_filename)
protected

This function initialises all parameters, either via parsing, or by calling ask_parameters() (when parameter_filename is the empty string).

It should be called in the constructor of the last class in the hierarchy. At that time, all Interfile keys will have been initialised, and ask_parameters() will be the appropriate virtual function, such that questions are asked for all parameters.

Todo:
It currently calls error() when something goes wrong. It should return Succeeded (or throw an exception).

◆ post_processing()

template<typename TargetT >
bool stir::Reconstruction< TargetT >::post_processing ( )
overrideprotectedvirtual

used to check acceptable parameters after parsing

The function should be used to set members that have are not set directly by the parsing. For example, parsing might set input_filename, and post_processing() might then read in the data and set the corresponding Reconstruction parameter.

Consistency checks mostly belong in set_up(). The reason for this is that for instance a GUI might not use the parsing mechanism and set parameters by calling various set_ functions (such as set_post_processor_sptr() ).

Reimplemented from stir::ParsingObject.

Member Data Documentation

◆ _disable_output

template<typename TargetT>
bool stir::Reconstruction< TargetT >::_disable_output
protected

_disable_output

Author
Nikos Efthimiou

This member mutes the creatation and write into an output image. You want to use it if you call for reconstruction from within some other code and want to use directly the output image.


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