CASToR  1.1
Tomographic Reconstruction (PET/SPECT)
 All Classes Files Functions Variables Typedefs Macros Groups Pages
iProjectorTemplate.cc
Go to the documentation of this file.
1 
2 /*
3  Implementation of class iProjectorTemplate
4 
5  - separators: done
6  - doxygen: done
7  - default initialization: done
8  - CASTOR_DEBUG:
9  - CASTOR_VERBOSE:
10 */
11 
18 #include "iProjectorTemplate.hh"
19 #include "sOutputManager.hh"
20 
21 // =====================================================================
22 // ---------------------------------------------------------------------
23 // ---------------------------------------------------------------------
24 // =====================================================================
25 
27 {
28  // Set all the data members to a default value
29 
30  // Also tell if the projector is compatible with SPECT attenuation correction. In order
31  // to be so, all voxels contributing to a line must be strictly sorted with respect to
32  // their distance to point 2 (the line must also go from point 1 to point 2 and not the
33  // inverse)
35 }
36 
37 // =====================================================================
38 // ---------------------------------------------------------------------
39 // ---------------------------------------------------------------------
40 // =====================================================================
41 
43 {
44  // Delete or free all structures allocated by this projector
45 }
46 
47 // =====================================================================
48 // ---------------------------------------------------------------------
49 // ---------------------------------------------------------------------
50 // =====================================================================
51 
52 int iProjectorTemplate::ReadConfigurationFile(const string& a_configurationFile)
53 {
54  // Implement here the reading of any options specific to this projector, through a configuration file
55  ;
56  // Normal end
57  return 0;
58 }
59 
60 // =====================================================================
61 // ---------------------------------------------------------------------
62 // ---------------------------------------------------------------------
63 // =====================================================================
64 
65 int iProjectorTemplate::ReadOptionsList(const string& a_optionsList)
66 {
67  // Implement here the reading of any options specific to this projector, through a list of options separated by commas
68  ;
69  // Normal end
70  return 0;
71 }
72 
73 // =====================================================================
74 // ---------------------------------------------------------------------
75 // ---------------------------------------------------------------------
76 // =====================================================================
77 
79 {
80  // Here, display some help and guidance to how to use this projector and what it does
81  cout << "This projector is a template class dedicated to add your own custom projector." << endl;
82 }
83 
84 // =====================================================================
85 // ---------------------------------------------------------------------
86 // ---------------------------------------------------------------------
87 // =====================================================================
88 
90 {
91  // Here, check that all parameters needed by this projector are allocated and have correct values
92  ;
93  // Normal end
94  return 0;
95 }
96 
97 // =====================================================================
98 // ---------------------------------------------------------------------
99 // ---------------------------------------------------------------------
100 // =====================================================================
101 
103 {
104  // Implement here the initialization of whatever member variables specifically used by this projector
105  ;
106  // Normal end
107  return 0;
108 }
109 
110 // =====================================================================
111 // ---------------------------------------------------------------------
112 // ---------------------------------------------------------------------
113 // =====================================================================
114 
116 {
117  // Implement here a way to precompute the estimated maximum number of voxels that will contribute to a line of response.
118  // By default, it uses a buffer size corresponding to the total number of voxels of the image.
119  // The idea is to optimize the RAM usage by providing a better estimate that suites the need of this projector.
120  // If you do not have a better estimation, then you can remove this function from this class because it is already
121  // implemented as is in the mother class.
122 
123  // Find the maximum number of voxels along a given dimension
124  INTNB max_nb_voxels_in_dimension = mp_ImageDimensionsAndQuantification->GetNbVoxXYZ();
125  // Return the value
126  return max_nb_voxels_in_dimension;
127 }
128 
129 // =====================================================================
130 // ---------------------------------------------------------------------
131 // ---------------------------------------------------------------------
132 // =====================================================================
133 
134 int iProjectorTemplate::ProjectWithoutTOF(int a_direction, oProjectionLine* ap_ProjectionLine )
135 {
136  #ifdef CASTOR_DEBUG
137  if (!m_initialized)
138  {
139  Cerr("***** iProjectorTemplate::ProjectWithoutTOF() -> Called while not initialized !" << endl);
140  Exit(EXIT_DEBUG);
141  }
142  #endif
143 
144  #ifdef CASTOR_VERBOSE
145  if (m_verbose>=10)
146  {
147  string direction = "";
148  if (a_direction==FORWARD) direction = "forward";
149  else direction = "backward";
150  Cout("iProjectorTemplate::Project without TOF -> Project line '" << ap_ProjectionLine << "' in " << direction << " direction" << endl);
151  }
152  #endif
153 
154  // --------------------------------------------------------------------------------------------------------------------------------------------
155  // Please read the following information that will help implement your projector:
156 
157  // FLTNB is a macro defining the precision of the code (float, double, long double) that can be customized through some compilation options.
158  // So please, DO NOT USE 'float' or 'double' keywords but USE INSTEAD 'FLTNB'.
159  // Same for integers used to define image dimensions, DO NOT USE 'int' or 'long int' but USE INSTEAD 'INTNB'.
160 
161  // All 3D vectors of type FLTNB* or INTNB* carry the information in the following order: X then Y then Z.
162 
163  // The image dimensions can be accessed via some local copies of the parameters:
164  // - number of voxels: mp_nbVox[0] (along X), mp_nbVox[1] (along Y), mp_nbVox[2] (along Z),
165  // - size of voxels in mm: mp_voxSize[0] (along X), mp_voxSize[1] (along Y), mp_voxSize[2] (along Z),
166  // - half image dimensions in mm: mp_halfFOV[0] (along X), mp_halfFOV[1] (along Y), mp_halfFOV (along Z).
167 
168  // For code efficiency and readability, the spatial index of a voxel is a cumulative 1D index. That is to say, given a voxel [indexX,indexY,indexZ],
169  // its cumulative 1D index is computed by 'index = indexZ*m_nbVoxXY + indexY*mp_nbVox[0] + indexX'.
170 
171  // All information that you may need about the line of response are embedded into the oProjectionLine object given as a parameter. So take a look
172  // at this class to know how to get those information through some ap_ProjectionLine->GetXXX() functions.
173 
174  // The end points of the line are already computed by the vProjector with respect to the different options provided; e.g. mean depth of
175  // interaction, actual position of interaction (POI), randomization of end points, etc. However, if you want to customize those end points,
176  // take a look at what the vScanner and children can do through the use of some dedicated functions. If it cannot do what you want, consider adding
177  // this function into the vScanner or children classes. The vScanner object can be accessed using the mp_Scanner member object of this class.
178 
179  // The projected line must go from point 1 to point 2 and voxel contributions by sorted in order to be compatible with SPECT attenuation correction.
180 
181  // Finally, to add the contribution of a given voxel to this projection line, simply use this instruction:
182  // ap_ProjectionLine->AddVoxel(a_direction, my_index, my_weight), where 'my_index' is the spatial index of the voxel and 'my_weight' is its
183  // associated weight (i.e. its contribution to the line).
184 
185  // Finally, remember that the mantra of CASToR is the genericity, so when you add some code, think about it twice in order to ensure that this
186  // piece of code can be used by anyone in any context!
187 
188  // --------------------------------------------------------------------------------------------------------------------------------------------
189 
190  Cerr("***** iProjectorTemplate::ProjectWithoutTOF() -> Not yet implemented !" << endl);
191  return 1;
192 
193  // Normal end
194  return 0;
195 }
196 
197 // =====================================================================
198 // ---------------------------------------------------------------------
199 // ---------------------------------------------------------------------
200 // =====================================================================
201 
202 int iProjectorTemplate::ProjectWithTOFPos(int a_Projector, oProjectionLine* ap_ProjectionLine)
203 {
204  // Read the information in the ProjectWithoutTOF function to know the general guidelines.
205  // This function implements a projection using a continuous TOF information = when using list-mode data.
206  // The TOF resolution and measurement associated to the running event are accessible through the ap_ProjectionLine
207  // parameter using some GetXXX() functions.
208 
209  Cerr("***** iProjectorTemplate::ProjectWithTOFPos() -> Not yet implemented !" << endl);
210  return 1;
211 
212  // Normal end
213  return 0;
214 }
215 
216 // =====================================================================
217 // ---------------------------------------------------------------------
218 // ---------------------------------------------------------------------
219 // =====================================================================
220 
221 int iProjectorTemplate::ProjectWithTOFBin(int a_Projector, oProjectionLine* ap_ProjectionLine)
222 {
223  // Read the information in the ProjectWithoutTOF function to know the general guidelines.
224  // This function implements a projection using a binned TOF information = when using histogram data.
225  // The number of TOF bins, TOF resolution, etc, are accessible through the ap_ProjectionLine using
226  // some GetXXX() functions. This function is supposed to fill all TOF bins at once. To add voxel
227  // contributions to a specific TOF bin, use the dedicated function ap_ProjectionLine->AddVoxelInTOFBin().
228  // All forward and backward operations will be carried out later by the vOptimizer, automatically
229  // managing all TOF bins.
230 
231  Cerr("***** iProjectorTemplate::ProjectWithTOFBin() -> Not yet implemented !" << endl);
232  return 1;
233 
234  // Normal end
235  return 0;
236 }
237 
238 // =====================================================================
239 // ---------------------------------------------------------------------
240 // ---------------------------------------------------------------------
241 // =====================================================================
bool m_compatibleWithSPECTAttenuationCorrection
Definition: vProjector.hh:317
int ProjectWithTOFBin(int a_direction, oProjectionLine *ap_ProjectionLine)
A function to project with TOF binned information.
iProjectorTemplate()
The constructor of iProjectorTemplate.
int ProjectWithoutTOF(int a_direction, oProjectionLine *ap_ProjectionLine)
A function to project without TOF.
int ReadOptionsList(const string &a_optionsList)
A function used to read options from a list of options.
INTNB EstimateMaxNumberOfVoxelsPerLine()
This function is used to compute and provide an estimate of the maximum number of voxels that could c...
oImageDimensionsAndQuantification * mp_ImageDimensionsAndQuantification
Definition: vProjector.hh:307
This class is designed to generically described any on-the-fly projector.
Definition: vProjector.hh:54
void ShowHelpSpecific()
A function used to show help about the child module.
~iProjectorTemplate()
The destructor of iProjectorTemplate.
int CheckSpecificParameters()
A private function used to check the parameters settings specific to the child projector.
void Exit(int code)
#define Cerr(MESSAGE)
bool m_initialized
Definition: vProjector.hh:323
int InitializeSpecific()
This function is used to initialize specific stuff to the child projector.
int ReadConfigurationFile(const string &a_configurationFile)
A function used to read options from a configuration file.
#define INTNB
Definition: gVariables.hh:64
This class is designed to manage and store system matrix elements associated to a vEvent...
Declaration of class sOutputManager.
INTNB GetNbVoxXYZ()
Get the total number of voxels.
#define EXIT_DEBUG
Definition: gVariables.hh:69
int ProjectWithTOFPos(int a_direction, oProjectionLine *ap_ProjectionLine)
A function to project with TOF continuous information.
#define FORWARD
#define Cout(MESSAGE)
Declaration of class iProjectorTemplate.