STIR  6.2.0
BackProjectorByBinUsingInterpolation.h
Go to the documentation of this file.
1 //
2 //
14 /*
15  Copyright (C) 2000 PARAPET partners
16  Copyright (C) 2000- 2008, Hammersmith Imanet Ltd
17  This file is part of STIR.
18 
19  SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license
20 
21  See STIR/LICENSE.txt for details
22 */
23 #ifndef __BackProjectorByBinUsingInterpolation_h_
24 #define __BackProjectorByBinUsingInterpolation_h_
25 
28 #include "stir/shared_ptr.h"
29 
30 START_NAMESPACE_STIR
31 
32 template <typename elemT>
33 class Viewgram;
34 template <typename elemT>
35 class RelatedViewgrams;
36 template <typename elemT>
37 class VoxelsOnCartesianGrid;
38 template <int num_dimensions, typename elemT>
39 class Array;
40 class ProjDataInfo;
41 class ProjDataInfoCylindricalArcCorr;
42 class DataSymmetriesForBins_PET_CartesianGrid;
59 {
60 private:
61  // store some scanner related data to avoid recomputation
62  const float R2;
63  const float dxy2;
64  const float ring_spacing2;
65  // total normalisation of backprojection, 3 factors:
66  // (_Pi/scanner.num_views) for discretisation of integral over phi
67  // scanner.ring_spacing for discretisation of integral over delta
68  // normalisation of projection space integral: 1/(2 Pi)
69 
70  const float backprojection_normalisation;
71 
72  const bool use_exact_Jacobian_now;
73 
74 public:
75  explicit JacobianForIntBP(const shared_ptr<const ProjDataInfoCylindricalArcCorr> proj_data_info_sptr, bool exact);
76 
77  float operator()(const float delta, const float s) const
78  {
79  float tmp;
80  if (use_exact_Jacobian_now)
81  tmp = 4 * (R2 - dxy2 * s * s);
82  else
83  tmp = 4 * R2;
84  return tmp / pow(tmp + ring_spacing2 * delta * delta, 1.5F) * backprojection_normalisation;
85  }
86 };
87 
127  : public RegisteredParsingObject<BackProjectorByBinUsingInterpolation, BackProjectorByBin>
128 
129 {
130 public:
132  static const char* const registered_name;
133 
135  explicit BackProjectorByBinUsingInterpolation(const bool use_piecewise_linear_interpolation = true,
136  const bool use_exact_Jacobian = true);
137 
139 
140  BackProjectorByBinUsingInterpolation(shared_ptr<const ProjDataInfo> const&,
141  shared_ptr<const DiscretisedDensity<3, float>> const& image_info_ptr,
142  const bool use_piecewise_linear_interpolation = true,
143  const bool use_exact_Jacobian = true);
144 
146 
148  void set_up(const shared_ptr<const ProjDataInfo>& proj_data_info_ptr,
149  const shared_ptr<const DiscretisedDensity<3, float>>& density_info_ptr // TODO should be Info only
150  ) override;
151 
159  const DataSymmetriesForViewSegmentNumbers* get_symmetries_used() const override;
164  void use_exact_Jacobian(const bool use_exact_Jacobian);
165 
170  void use_piecewise_linear_interpolation(const bool use_piecewise_linear_interpolation);
171 
172  BackProjectorByBinUsingInterpolation* clone() const override;
173 
174 private:
175  // KT 20/06/2001 changed type to enable use of more methods
176  shared_ptr<DataSymmetriesForBins_PET_CartesianGrid> symmetries_ptr;
177  // const DataSymmetriesForViewSegmentNumbers * symmetries_ptr;
178 
179  bool use_piecewise_linear_interpolation_now;
180 
181  bool use_exact_Jacobian_now;
182 
184 
186  bool do_symmetry_90degrees_min_phi;
187  bool do_symmetry_180degrees_min_phi;
188  bool do_symmetry_swap_segment;
189  bool do_symmetry_swap_s;
190  bool do_symmetry_shift_z;
192 
193 #if 0
194  // not used yet
195 struct ProjDataForIntBP
196 {
197  float view__pos_s;
198  float view__pos_sp1;
199  float view__neg_s;
200  float view__neg_sp1;
201  float min90__pos_s;
202  float min90__pos_sp1;
203  float min90__neg_s;
204  float min90__neg_sp1;
205  float plus90__pos_s;
206  float plus90__pos_sp1;
207  float plus90__neg_s;
208  float plus90__neg_sp1;
209  float min180__pos_s;
210  float min180__pos_sp1;
211  float min180__neg_s;
212  float min180__neg_sp1;
213 };
214 #endif
215 
216  void actual_back_project(DiscretisedDensity<3, float>&,
218  const int min_axial_pos_num,
219  const int max_axial_pos_num,
220  const int min_tangential_pos_num,
221  const int max_tangential_pos_num) override;
222 
223  void actual_back_project(DiscretisedDensity<3, float>&, const Bin&);
224 
225  virtual void back_project_all_symmetries(VoxelsOnCartesianGrid<float>& image,
226  const Viewgram<float>& pos_view,
227  const Viewgram<float>& neg_view,
228  const Viewgram<float>& pos_plus90,
229  const Viewgram<float>& neg_plus90,
230  const Viewgram<float>& pos_min180,
231  const Viewgram<float>& neg_min180,
232  const Viewgram<float>& pos_min90,
233  const Viewgram<float>& neg_min90,
234  const int min_axial_pos_num,
235  const int max_axial_pos_num,
236  const int min_tangential_pos_num,
237  const int max_tangential_pos_num);
238 
239  /*
240  This function projects 4 viewgrams related by symmetry.
241  It will be used for view=0 or 45 degrees
242  (or all others if the above version is not implemented in
243  the derived class)
244  Here 0<=view < num_views/2 (= 90 degrees)
245  */
246 
247  virtual void back_project_view_plus_90_and_delta(VoxelsOnCartesianGrid<float>& image,
248  const Viewgram<float>& pos_view,
249  const Viewgram<float>& neg_view,
250  const Viewgram<float>& pos_plus90,
251  const Viewgram<float>& neg_plus90,
252  const int min_axial_pos_num,
253  const int max_axial_pos_num,
254  const int min_tangential_pos_num,
255  const int max_tangential_pos_num);
256  /*
257  void back_project_2D_view_plus_90(const PETSinogram<float> &sino, PETPlane &image, int view,
258  const int min_bin_num, const intmax_tangential_pos_num);
259  void back_project_2D_all_symmetries(const PETSinogram<float> &sino, PETPlane &image, int view,
260  const int min_bin_num, const intmax_tangential_pos_num);
261 */
262 
263  /*
264 
265  These functions use a 3D version of Cho's algorithm for backprojecting incrementally.
266  See M. Egger's thesis for details.
267  In addition to the symmetries mentioned above, they also use s,-s symmetry
268  (while being careful when s=0 to avoid self-symmetric cases)
269  */
270 
271  static void piecewise_linear_interpolation_backproj3D_Cho_view_viewplus90(
272  Array<4, float> const& Projptr,
274  const shared_ptr<const ProjDataInfoCylindricalArcCorr> proj_data_info_sptr,
275  float delta,
276  const double cphi,
277  const double sphi,
278  int s,
279  int ax_pos0,
280  const int num_planes_per_axial_pos,
281  const float axial_pos_to_z_offset);
282 
283  static void piecewise_linear_interpolation_backproj3D_Cho_view_viewplus90_180minview_90minview(
284  Array<4, float> const& Projptr,
286  const shared_ptr<const ProjDataInfoCylindricalArcCorr> proj_data_info_sptr,
287  float delta,
288  const double cphi,
289  const double sphi,
290  int s,
291  int ax_pos0,
292  const int num_planes_per_axial_pos,
293  const float axial_pos_to_z_offset);
294 
295  static void
296  linear_interpolation_backproj3D_Cho_view_viewplus90(Array<4, float> const& Projptr,
298  const shared_ptr<const ProjDataInfoCylindricalArcCorr> proj_data_info_sptr,
299  float delta,
300  const double cphi,
301  const double sphi,
302  int s,
303  int ax_pos0,
304  const int num_planes_per_axial_pos,
305  const float axial_pos_to_z_offset);
306 
307  static void linear_interpolation_backproj3D_Cho_view_viewplus90_180minview_90minview(
308  Array<4, float> const& Projptr,
310  const shared_ptr<const ProjDataInfoCylindricalArcCorr> proj_data_info_sptr,
311  float delta,
312  const double cphi,
313  const double sphi,
314  int s,
315  int ax_pos0,
316  const int num_planes_per_axial_pos,
317  const float axial_pos_to_z_offset);
318 
319  /*
320 static void backproj2D_Cho_view_viewplus90( PETPlane & image,
321  const ProjDataForIntBP &projs,
322  const double cphi, const double sphi, int s);
323 
324  static void backproj2D_Cho_view_viewplus90_180minview_90minview( PETPlane & image,
325  const ProjDataForIntBP &projs,
326  const double cphi, const double sphi, int s);
327 
328 */
329  void set_defaults() override;
330  void initialise_keymap() override;
331 };
332 
333 END_NAMESPACE_STIR
334 
335 #endif // __BackProjectorByBinUsingInterpolation_h_
This class is used to represent voxelised densities on a cuboid grid (3D).
Definition: FBP3DRPReconstruction.h:43
Import of std::shared_ptr, std::dynamic_pointer_cast and std::static_pointer_cast (or corresponding b...
does backprojection by interpolating between the bins.
Definition: BackProjectorByBinUsingInterpolation.h:126
A class for encoding/finding symmetries. Works only on ViewSegmentNumbers (instead of Bin)...
Definition: DataSymmetriesForViewSegmentNumbers.h:49
The next class is used in BackProjectorByBinUsingInterpolation to take geometric things into account...
Definition: BackProjectorByBinUsingInterpolation.h:58
A class for storing coordinates and value of a single projection bin.
Definition: Bin.h:48
Parent class for all leaves in a RegisteredObject hierarchy that do parsing of parameter files...
Definition: RegisteredParsingObject.h:77
static const char *const registered_name
Name which will be used when parsing a BackProjectorByBin object.
Definition: BackProjectorByBinUsingInterpolation.h:132
Declares class stir::BackProjectorByBin.
Declaration of class stir::RegisteredParsingObject.