STIR  6.2.0
ProjMatrixByBinPinholeSPECTUB.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2022, Matthew Strugari
3  Copyright (C) 2021, University College London
4  This file is part of STIR.
5 
6  SPDX-License-Identifier: Apache-2.0
7 
8  See STIR/LICENSE.txt for details
9 */
21 #ifndef __stir_recon_buildblock_ProjMatrixByBinPinholeSPECTUB__
22 #define __stir_recon_buildblock_ProjMatrixByBinPinholeSPECTUB__
23 
24 // system libraries
25 #include <iostream>
26 
27 // user defined libraries
30 #include "stir/ProjDataInfo.h"
32 #include "stir/IndexRange.h"
33 #include "stir/shared_ptr.h"
34 #include "stir/recon_buildblock/PinholeSPECTUB_Tools.h"
35 
36 START_NAMESPACE_STIR
37 
38 template <int num_dimensions, typename elemT>
39 class DiscretisedDensity;
40 class Bin;
118  : public RegisteredParsingObject<ProjMatrixByBinPinholeSPECTUB, ProjMatrixByBin, ProjMatrixByBin>
119 {
120 public:
122  static const char* const registered_name;
123 
126 
127  // disable copy-constructor as currently unsafe to copy due to bare pointers
129 
131  ~ProjMatrixByBinPinholeSPECTUB() override;
132 
134  void set_up(const shared_ptr<const ProjDataInfo>& proj_data_info_ptr,
135  const shared_ptr<const DiscretisedDensity<3, float>>& density_info_ptr // TODO should be Info only
136  ) override;
137 
138  //******************** get/set functions *************
139 
141  // no longer set minimum weight, always use 0.
142  // float get_minimum_weight() const;
143  // void set_minimum_weight( const float value );
144 
146  float get_maximum_number_of_sigmas() const;
147  void set_maximum_number_of_sigmas(const float value);
148 
150  float get_spatial_resolution_PSF() const;
151  void set_spatial_resolution_PSF(const float value);
152 
154  int get_subsampling_factor_PSF() const;
155  void set_subsampling_factor_PSF(const int value);
156 
158  // std::string get_detector_file() const;
159  void set_detector_file(const std::string& value);
160 
162  // std::string get_collimator_file() const;
163  void set_collimator_file(const std::string& value);
164 
166  std::string get_psf_correction() const;
167  void set_psf_correction(const std::string& value);
168 
170  std::string get_doi_correction() const;
171  void set_doi_correction(const std::string& value);
172 
174  float get_object_radius() const;
175  void set_object_radius(const float value);
176 
178  std::string get_attenuation_type() const;
179  void set_attenuation_type(const std::string& value);
180  shared_ptr<const DiscretisedDensity<3, float>> get_attenuation_image_sptr() const;
181 
183  void set_attenuation_image_sptr(const shared_ptr<const DiscretisedDensity<3, float>> value);
184  void set_attenuation_image_sptr(const std::string& value);
185 
187  // no longer use mask type
188  // std::string get_mask_type() const;
189  // void set_mask_type(const std::string& value);
190 
192  shared_ptr<const DiscretisedDensity<3, float>> get_mask_image_sptr() const;
193  void set_mask_image_sptr(const shared_ptr<const DiscretisedDensity<3, float>> value);
194  void set_mask_image_sptr(const std::string& value);
195 
197  bool get_mask_from_attenuation_map() const;
198  void set_mask_from_attenuation_map(bool value = false);
199 
201  bool get_keep_all_views_in_cache() const;
202  void set_keep_all_views_in_cache(bool value = false);
203 
204  ProjMatrixByBinPinholeSPECTUB* clone() const override;
205 
206 private:
207  // parameters that will be parsed
208 
209  float minimum_weight;
210  float maximum_number_of_sigmas;
211  float spatial_resolution_PSF;
212  int subsampling_factor_PSF;
213  std::string detector_file;
214  std::string collimator_file;
215  std::string psf_correction;
216  std::string doi_correction;
217  std::string attenuation_type;
218  std::string attenuation_map;
219  // std::string mask_type;
220  float object_radius;
221  std::string mask_file;
222  bool mask_from_attenuation_map;
223  bool keep_all_views_in_cache;
224 
225  // explicitly list necessary members for image details (should use an Info object instead)
226  CartesianCoordinate3D<float> voxel_size;
228  IndexRange<3> densel_range;
229 
230  shared_ptr<const ProjDataInfo> proj_data_info_ptr;
231 
232  bool already_setup;
233 
234  mutable SPECTUB_mph::wmh_mph_type wmh; // weight matrix header.
235  mutable SPECTUB_mph::wm_da_type wm; // double array weight matrix structure.
236  mutable SPECTUB_mph::pcf_type pcf; // pre-calculated functions
237 
238  void calculate_proj_matrix_elems_for_one_bin(ProjMatrixElemsForOneBin&) const override;
239 
240  void set_defaults() override;
241  void initialise_keymap() override;
242  bool post_processing() override;
243 
244  shared_ptr<const DiscretisedDensity<3, float>> attenuation_image_sptr;
245  shared_ptr<const DiscretisedDensity<3, float>> mask_image_sptr;
246 
247  // wm_SPECT starts here ---------------------------------------------------------------------------------------------
248  bool* msk_3d; // voxels to be included in matrix (no weight calculated outside the mask)
249  float* attmap; // attenuation map
250 
251  //... variables for estimated sizes of arrays to allocate ................................
252  int** Nitems;
253 
254  //... user defined structures (types defined in PinholeSPECTUB_Tools.h) .....................................
255 
256  SPECTUB_mph::volume_type vol;
257  SPECTUB_mph::prj_mph_type prj;
258  SPECTUB_mph::bin_type bin;
259 
260  // mutable to allow compute_one_subset() const function to change the fields
261  mutable SPECTUB_mph::psf2d_type psf_bin; // structure for total psf distribution in bins (bidimensional)
262  mutable SPECTUB_mph::psf2d_type psf_subs; // structure for total psf distribution: mid resolution (bidimensional)
263  mutable SPECTUB_mph::psf2d_type
264  psf_aux; // structure for total psf distribution: mid resolution auxiliar for convolution (bidimensional)
265  mutable SPECTUB_mph::psf2d_type kern; // structure for intrinsic psf distribution: mid resolution (bidimensional)
266 
267  void compute_one_subset(const int kOS) const;
268  void delete_PinholeSPECTUB_arrays();
269 };
270 
271 END_NAMESPACE_STIR
272 
273 #endif
Declaration of class stir::ProjDataInfo.
Import of std::shared_ptr, std::dynamic_pointer_cast and std::static_pointer_cast (or corresponding b...
Generates projection matrix for pinhole SPECT studies.
Definition: ProjMatrixByBinPinholeSPECTUB.h:117
declaration of stir::ProjMatrixByBin and its helpers classes
Parent class for all leaves in a RegisteredObject hierarchy that do parsing of parameter files...
Definition: RegisteredParsingObject.h:77
This file defines the stir::IndexRange class.
This stores the non-zero projection matrix elements for every &#39;densel&#39; that contributes to a given bi...
Definition: ProjMatrixElemsForOneBin.h:68
static const char *const registered_name
Name which will be used when parsing a ProjMatrixByBin object.
Definition: ProjMatrixByBinPinholeSPECTUB.h:122
defines the stir::CartesianCoordinate3D<coordT> class
Declaration of class stir::RegisteredParsingObject.