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