STIR 6.4.0
ProjMatrixByBin.h
Go to the documentation of this file.
1#ifndef __stir_recon_buildblock_ProjMatrixByBin_H__
2#define __stir_recon_buildblock_ProjMatrixByBin_H__
3
16/*
17 Copyright (C) 2000 PARAPET partners
18 Copyright (C) 2000-2009, Hammersmith Imanet Ltd
19 Copyright (C) 2013, 2015, 2022 University College London
20 Copyright (C) 2016, University of Hull
21
22 This file is part of STIR.
23
24 SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license
25
26 See STIR/LICENSE.txt for details
27*/
28
30#include "stir/ParsingObject.h"
33#include "stir/shared_ptr.h"
35#include "stir/TimedObject.h"
38#include <cstdint>
39//#include <map>
40#include <unordered_map>
41#ifdef STIR_OPENMP
42# include <omp.h>
43#endif
44
45START_NAMESPACE_STIR
46
47/* TODO
48class ProjMatrixElemsForOneViewgram;
49class SubsetInfo;
50*/
51
52class Bin;
53
78class ProjMatrixByBin : public RegisteredObject<ProjMatrixByBin>, public TimedObject
79{
80public:
81 ~ProjMatrixByBin() override {}
82
84
90 virtual void set_up(const shared_ptr<const ProjDataInfo>& proj_data_info_ptr,
91 const shared_ptr<const DiscretisedDensity<3, float>>& density_info_ptr // TODO should be Info only
92 )
93 = 0;
94
95 virtual ProjMatrixByBin* clone() const = 0;
96
98 inline const DataSymmetriesForBins* get_symmetries_ptr() const;
100 inline const shared_ptr<DataSymmetriesForBins> get_symmetries_sptr() const;
101
103
111
112#if 0
113 // TODO
119 virtual void write_to_file_by_bin(
120 const char * const file_name_without_extension) const;
121#endif
122 // TODO implement this one at some point ?
123 /*
124 virtual void write_to_file_by_voxel(
125 const char * const file_name_without_extension);
126 */
127
128 // void set_maximum_cache_size(const unsigned long size){;}
129 /* TODO
130 void set_subset_usage(const SubsetInfo&, const int num_access_times);
131 */
132 void enable_cache(const bool v = true);
133 void store_only_basic_bins_in_cache(const bool v = true);
134
135 bool is_cache_enabled() const;
136 bool does_cache_store_only_basic_bins() const;
137
138 // void reserve_num_elements_in_cache(const std::size_t);
140 void clear_cache() const;
141
142protected:
143 shared_ptr<DataSymmetriesForBins> symmetries_sptr;
144
146
151
159
161
163
164 void set_defaults() override;
166
167 void initialise_keymap() override;
169
170 bool post_processing() override;
171
173
174 bool cache_disabled;
175 bool cache_stores_only_basic_bins;
178
186
189 shared_ptr<const VoxelsOnCartesianGrid<float>> image_info_sptr;
190
192 shared_ptr<const ProjDataInfo> proj_data_info_sptr;
193
196
197private:
198 typedef std::uint64_t CacheKey;
200 // note: sum needs to be less than 64 - 3 (for the 3 sign bits)
202 const CacheKey tang_pos_bits = 12;
203 const CacheKey axial_pos_bits = 28;
204 const CacheKey timing_pos_bits = 20;
206 // typedef std::map<CacheKey, ProjMatrixElemsForOneBin> MapProjMatrixElemsForOneBin;
207 typedef std::unordered_map<CacheKey, ProjMatrixElemsForOneBin> MapProjMatrixElemsForOneBin;
208 typedef MapProjMatrixElemsForOneBin::iterator MapProjMatrixElemsForOneBinIterator;
209 typedef MapProjMatrixElemsForOneBin::const_iterator const_MapProjMatrixElemsForOneBinIterator;
210
213#ifdef STIR_OPENMP
215#endif
216
218 // KT 15/05/2002 not static anymore as it uses cache_stores_only_basic_bins
219 CacheKey cache_key(const Bin& bin) const;
220
224 void enable_tof(const shared_ptr<const ProjDataInfo>& proj_data_info_sptr, const bool v = true);
225
227 float gauss_sigma_in_mm;
229 float r_sqrt2_gauss_sigma;
230
232 inline void apply_tof_kernel(ProjMatrixElemsForOneBin& probabilities) const;
233
235 inline float get_tof_value(const float d1, const float d2) const;
236
238 FastErf erf_interpolation;
239};
240
241END_NAMESPACE_STIR
242
244
245#endif // __ProjMatrixByBin_H__
Declaration of class stir::DataSymmetriesForBins.
Implementation of an erf interpolation.
Declaration of class stir::ParsingObject.
Implementations of inline functions for class stir::ProjMatrixByBin.
Declaration of class stir::ProjMatrixElemsForOneBin.
Declaration of class stiir::RegisteredObject.
declares the stir::TimedObject class
defines the stir::VectorWithOffset class
defines the stir::VoxelsOnCartesianGrid class
A class for storing coordinates and value of a single projection bin.
Definition Bin.h:49
A class for encoding/finding symmetries common to the geometry of the projection data and the discret...
Definition DataSymmetriesForBins.h:68
This abstract class is the basis for all image representations.
Definition DiscretisedDensity.h:99
const DataSymmetriesForBins * get_symmetries_ptr() const
get a pointer to an object encoding all symmetries that are used by this ProjMatrixByBin
Definition ProjMatrixByBin.inl:37
const shared_ptr< DataSymmetriesForBins > get_symmetries_sptr() const
get a shared_ptr to an object encoding all symmetries that are used by this ProjMatrixByBin
Definition ProjMatrixByBin.inl:43
bool post_processing() override
Checks if parameters have sensible values.
Definition ProjMatrixByBin.cxx:50
void set_defaults() override
sets value for caching configuration (enables caching, but for 'basic' bins only)
Definition ProjMatrixByBin.cxx:34
void cache_proj_matrix_elems_for_one_bin(const ProjMatrixElemsForOneBin &) const
The method to store data in the cache.
Definition ProjMatrixByBin.cxx:202
shared_ptr< const VoxelsOnCartesianGrid< float > > image_info_sptr
We need a local copy of the discretised density in order to find the cartesian coordinates of each vo...
Definition ProjMatrixByBin.h:189
ProjMatrixByBin()
default ctor (calls set_defaults())
Definition ProjMatrixByBin.cxx:55
virtual void set_up(const shared_ptr< const ProjDataInfo > &proj_data_info_ptr, const shared_ptr< const DiscretisedDensity< 3, float > > &density_info_ptr)=0
To be called before any calculation is performed.
Definition ProjMatrixByBin.cxx:122
virtual void calculate_proj_matrix_elems_for_one_bin(ProjMatrixElemsForOneBin &) const =0
This method needs to be implemented in the derived class.
void initialise_keymap() override
sets keys for caching configuration
Definition ProjMatrixByBin.cxx:43
bool tof_enabled
If activated TOF reconstruction will be performed.
Definition ProjMatrixByBin.h:177
void get_proj_matrix_elems_for_one_bin(ProjMatrixElemsForOneBin &, const Bin &) const
The main method for getting a row of the matrix.
Definition ProjMatrixByBin.inl:49
void clear_cache() const
Remove all elements from the cache.
Definition ProjMatrixByBin.cxx:96
Succeeded get_cached_proj_matrix_elems_for_one_bin(ProjMatrixElemsForOneBin &) const
The method that tries to get data from the cache.
Definition ProjMatrixByBin.cxx:221
shared_ptr< const ProjDataInfo > proj_data_info_sptr
We need a local copy of the proj_data_info to get the integration boundaries and RayTracing.
Definition ProjMatrixByBin.h:192
This stores the non-zero projection matrix elements for every 'densel' that contributes to a given bi...
Definition ProjMatrixElemsForOneBin.h:69
a class containing an enumeration type that can be used by functions to signal successful operation o...
Definition Succeeded.h:44
base class for all objects which need timers. At the moment, there's only a CPU timer.
Definition TimedObject.h:36
A templated class for vectors, but with indices starting not from 0.
Definition VectorWithOffset.h:65
Import of std::shared_ptr, std::dynamic_pointer_cast and std::static_pointer_cast into the stir names...