STIR  6.2.0
PLSPrior.h
Go to the documentation of this file.
1 //
2 //
3 /*
4  Copyright (C) 2018 University of Leeds and University College of London
5 
6  This file is part of STIR.
7 
8  SPDX-License-Identifier: Apache-2.0
9 
10  See STIR/LICENSE.txt for details.
11 */
21 #ifndef __stir_recon_buildblock_PLSPrior_H__
22 #define __stir_recon_buildblock_PLSPrior_H__
23 
26 #include "stir/Array.h"
28 #include "stir/shared_ptr.h"
29 #include <string>
30 
31 START_NAMESPACE_STIR
32 
94 template <typename elemT>
95 class PLSPrior : public RegisteredParsingObject<PLSPrior<elemT>,
96  GeneralisedPrior<DiscretisedDensity<3, elemT>>,
97  GeneralisedPrior<DiscretisedDensity<3, elemT>>>
98 {
99 private:
102  GeneralisedPrior<DiscretisedDensity<3, elemT>>>
103  base_type;
104 
105 public:
107  static const char* const registered_name;
108 
110  PLSPrior();
111 
113  PLSPrior(const bool only_2D, float penalization_factor);
114 
116 
117  Succeeded set_up(shared_ptr<const DiscretisedDensity<3, elemT>> const& target_sptr) override;
118 
119  bool is_convex() const override;
120 
122  double compute_value(const DiscretisedDensity<3, elemT>& current_image_estimate) override;
123 
125  void compute_gradient(DiscretisedDensity<3, elemT>& prior_gradient,
126  const DiscretisedDensity<3, elemT>& current_image_estimate) override;
127 
129 
133  shared_ptr<const DiscretisedDensity<3, elemT>> get_kappa_sptr() const;
134  shared_ptr<const DiscretisedDensity<3, elemT>> get_anatomical_grad_sptr(int direction) const;
135  shared_ptr<const DiscretisedDensity<3, elemT>> get_norm_sptr() const;
136 
138  double get_eta() const;
139  double get_alpha() const;
140 
142  void set_eta(const double);
144  void set_alpha(const double);
145 
147  void set_anatomical_image_sptr(const shared_ptr<const DiscretisedDensity<3, elemT>>&);
149  shared_ptr<const DiscretisedDensity<3, elemT>> get_anatomical_image_sptr() const;
151  void set_anatomical_filename(const std::string& filename);
152 
154  void set_kappa_sptr(const shared_ptr<const DiscretisedDensity<3, elemT>>&);
156  void set_kappa_filename(const std::string& filename);
157 
159  void set_only_2D(const bool arg) { only_2D = arg; }
161  bool get_only_2D() { return only_2D; }
162 
163 protected:
165  bool only_2D;
167 
172 
174  std::string kappa_filename;
175  std::string anatomical_filename;
176 
177  double eta, alpha;
178 
179  void set_defaults() override;
180  void initialise_keymap() override;
181 
183  bool post_processing() override;
184 
186  void check(DiscretisedDensity<3, elemT> const& current_image_estimate) const override;
187 
188 private:
190  static void compute_image_gradient_element(DiscretisedDensity<3, elemT>& image_gradient_elem,
191  int direction,
192  const DiscretisedDensity<3, elemT>& image);
193 
195  void compute_normalisation_anatomical_gradient(DiscretisedDensity<3, elemT>& norm_im_grad,
196  const DiscretisedDensity<3, elemT>& image_grad_z,
197  const DiscretisedDensity<3, elemT>& image_grad_y,
198  const DiscretisedDensity<3, elemT>& image_grad_x);
200  void compute_inner_product_and_penalty(DiscretisedDensity<3, elemT>& inner_product,
202  DiscretisedDensity<3, elemT>& pet_im_grad_z,
203  DiscretisedDensity<3, elemT>& pet_im_grad_y,
204  DiscretisedDensity<3, elemT>& pet_im_grad_x,
205  const DiscretisedDensity<3, elemT>& pet_image);
206 
207  shared_ptr<const DiscretisedDensity<3, elemT>> anatomical_grad_x_sptr;
208  shared_ptr<const DiscretisedDensity<3, elemT>> anatomical_grad_y_sptr;
209  shared_ptr<const DiscretisedDensity<3, elemT>> anatomical_grad_z_sptr;
210  shared_ptr<const DiscretisedDensity<3, elemT>> anatomical_sptr;
211  shared_ptr<const DiscretisedDensity<3, elemT>> norm_sptr;
212  shared_ptr<const DiscretisedDensity<3, elemT>> kappa_ptr;
213  void set_anatomical_grad_sptr(const shared_ptr<const DiscretisedDensity<3, elemT>>&, int);
214  void set_anatomical_grad_norm_sptr(const shared_ptr<const DiscretisedDensity<3, elemT>>&);
215 };
216 
217 END_NAMESPACE_STIR
218 
219 #endif
bool only_2D
can be set during parsing to restrict the gradient calculation to the 2D case
Definition: PLSPrior.h:165
std::string kappa_filename
Filename for the image that will be read by post_processing()
Definition: PLSPrior.h:174
A class in the GeneralisedPrior hierarchy. This implements the anatomical penalty function...
Definition: PLSPrior.h:95
Import of std::shared_ptr, std::dynamic_pointer_cast and std::static_pointer_cast (or corresponding b...
std::string gradient_filename_prefix
filename prefix for outputing the gradient whenever compute_gradient() is called. ...
Definition: PLSPrior.h:171
defines the stir::DiscretisedDensity class
defines the Array class for multi-dimensional (numeric) arrays
static const char *const registered_name
Name which will be used when parsing a GeneralisedPrior object.
Definition: PLSPrior.h:107
A base class for &#39;generalised&#39; priors, i.e. priors for which at least a &#39;gradient&#39; is defined...
Definition: GeneralisedPrior.h:41
bool get_only_2D()
Get only 2D.
Definition: PLSPrior.h:161
coordT inner_product(const BasicCoordinate< num_dimensions, coordT > &p1, const BasicCoordinate< num_dimensions, coordT > &p2)
compute sum_i p1[i] * p2[i]
Definition: BasicCoordinate.inl:408
void set_only_2D(const bool arg)
Set only 2D.
Definition: PLSPrior.h:159
Parent class for all leaves in a RegisteredObject hierarchy that do parsing of parameter files...
Definition: RegisteredParsingObject.h:77
Declaration of class stir::PriorWithParabolicSurrogate.
a class containing an enumeration type that can be used by functions to signal successful operation o...
Definition: Succeeded.h:43
Declaration of class stir::RegisteredParsingObject.
This abstract class is the basis for all image representations.
Definition: FBP2DReconstruction.h:35