STIR  6.2.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 */
18 #include "stir/KeyParser.h"
19 #include "stir/error.h"
20 
21 START_NAMESPACE_STIR
22 
28 template <class TargetT>
30 {
31 private:
33 
34 public:
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 
53 protected:
54  shared_ptr<PoissonLogLikelihoodWithLinearModelForMeanAndProjData<TargetT>> _objective_function_sptr;
55  shared_ptr<ProjectorByBinPair> _projector_pair_sptr;
56 };
57 
58 template <class TargetT>
59 void
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 }
77 template <class TargetT>
78 void
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 
93 END_NAMESPACE_STIR
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
A class to parse Interfile headers.
Definition: KeyParser.h:161
Declaration of class stir::PoissonLogLikelihoodWithLinearModelForMeanAndProjData. ...
Declaration of class stir::KeyParser.
void add_stop_key(const std::string &keyword)
add a keyword that when encountered, will stop the parsing
Definition: KeyParser.cxx:501
A projector pair based on a single matrix.
Definition: ProjectorByBinPairUsingProjMatrixByBin.h:34
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
Declaration of stir::error()
Base class for simple test on reconstruction.
Definition: ReconstructionTests.h:34
Computes projection matrix elements for VoxelsOnCartesianGrid images by using a Length of Intersectio...
Definition: ProjMatrixByBinUsingRayTracing.h:112
Test class for reconstructions.
bool parse(std::istream &f, const bool write_warnings=true)
parse() returns false if there is some error, true otherwise
Definition: KeyParser.cxx:263
void add_start_key(const std::string &keyword)
add keyword that has to occur before all others
Definition: KeyParser.cxx:496
stir::ProjMatrixByBinUsingRayTracing&#39;s definition
Declares class stir::ProjectorByBinPairUsingProjMatrixByBin.
void error(const char *const s,...)
Print error with format string a la printf and throw exception.
Definition: error.cxx:42
Base class for tests for iterative reconstruction that use PoissonLogLikelihoodWithLinearModelForMean...
Definition: PoissonLLReconstructionTests.h:29
An objective function class appropriate for PET emission data.
Definition: PoissonLogLikelihoodWithLinearModelForMeanAndProjData.h:121