STIR 6.4.0
PoissonLLReconstructionTests.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2020-2021, University College London
3 This file is part of STIR.
4 SPDX-License-Identifier: Apache-2.0
5 See STIR/LICENSE.txt for details
6*/
13
18#include "stir/KeyParser.h"
19#include "stir/error.h"
20
21START_NAMESPACE_STIR
22
28template <class TargetT>
30{
31private:
32 typedef ReconstructionTests<TargetT> base_type;
33
34public:
36 explicit inline PoissonLLReconstructionTests(const std::string& projector_pair_filename = "",
37 const std::string& proj_data_filename = "",
38 const std::string& density_filename = "")
39 : base_type(proj_data_filename, density_filename)
40 {
41 this->construct_projector_pair(projector_pair_filename);
42 }
43
45
46 void construct_projector_pair(const std::string& filename = "");
47
49
51 virtual inline void construct_log_likelihood();
52
53protected:
54 shared_ptr<PoissonLogLikelihoodWithLinearModelForMeanAndProjData<TargetT>> _objective_function_sptr;
55 shared_ptr<ProjectorByBinPair> _projector_pair_sptr;
56};
57
58template <class TargetT>
59void
61{
62 if (filename.empty())
63 {
64 shared_ptr<ProjMatrixByBin> proj_matrix_sptr(new ProjMatrixByBinUsingRayTracing());
65 this->_projector_pair_sptr.reset(new ProjectorByBinPairUsingProjMatrixByBin(proj_matrix_sptr));
66 return;
67 }
68
69 KeyParser parser;
70 parser.add_start_key("projector pair parameters");
71 parser.add_parsing_key("projector pair type", &this->_projector_pair_sptr);
72 parser.add_stop_key("end projector pair parameters");
73 parser.parse(filename.c_str());
74 if (!this->_projector_pair_sptr)
75 error("Error parsing projector pair file");
76}
77template <class TargetT>
78void
80{
81 this->_objective_function_sptr.reset(new PoissonLogLikelihoodWithLinearModelForMeanAndProjData<TargetT>);
83 = reinterpret_cast<PoissonLogLikelihoodWithLinearModelForMeanAndProjData<TargetT>&>(*this->_objective_function_sptr);
84 objective_function.set_proj_data_sptr(this->_proj_data_sptr);
85 if (!this->_projector_pair_sptr)
86 error("Internal error: need to set the projector pair first");
87 objective_function.set_projector_pair_sptr(this->_projector_pair_sptr);
88 /*objective_function.set_normalisation_sptr(bin_norm_sptr);
89 objective_function.set_additive_proj_data_sptr(add_proj_data_sptr);
90 */
91}
92
93END_NAMESPACE_STIR
Declaration of class stir::KeyParser.
Declaration of class stir::PoissonLogLikelihoodWithLinearModelForMeanAndProjData.
stir::ProjMatrixByBinUsingRayTracing's definition
Declares class stir::ProjectorByBinPairUsingProjMatrixByBin.
Test class for reconstructions.
A class to parse Interfile headers.
Definition KeyParser.h:162
bool parse(std::istream &f, const bool write_warnings=true)
parse() returns false if there is some error, true otherwise
Definition KeyParser.cxx:260
void add_start_key(const std::string &keyword)
add keyword that has to occur before all others
Definition KeyParser.cxx:493
void add_parsing_key(const std::string &keyword, ParsingClass **parsed_object_ptr_ptr)
add keyword corresponding to an object that will parse the next keys itself
Definition KeyParser.h:303
void add_stop_key(const std::string &keyword)
add a keyword that when encountered, will stop the parsing
Definition KeyParser.cxx:498
PoissonLLReconstructionTests(const std::string &projector_pair_filename="", const std::string &proj_data_filename="", const std::string &density_filename="")
Constructor that can take some input data to run the test with.
Definition PoissonLLReconstructionTests.h:36
virtual void construct_log_likelihood()
creates Poisson log likelihood
Definition PoissonLLReconstructionTests.h:79
void construct_projector_pair(const std::string &filename="")
An objective function class appropriate for PET emission data.
Definition PoissonLogLikelihoodWithLinearModelForMeanAndProjData.h:125
Computes projection matrix elements for VoxelsOnCartesianGrid images by using a Length of Intersectio...
Definition ProjMatrixByBinUsingRayTracing.h:114
A projector pair based on a single matrix.
Definition ProjectorByBinPairUsingProjMatrixByBin.h:36
ReconstructionTests(const std::string &proj_data_filename="", const std::string &density_filename="")
Constructor that can take some input data to run the test with.
Definition ReconstructionTests.h:73
Declaration of stir::error()
void error(const char *const s,...)
Print error with format string a la printf and throw exception.
Definition error.cxx:42