CASToR  2.0
Tomographic Reconstruction (PET/SPECT/CT)
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
iProjectorTemplate.cc
Go to the documentation of this file.
1 /*
2 This file is part of CASToR.
3 
4  CASToR is free software: you can redistribute it and/or modify it under the
5  terms of the GNU General Public License as published by the Free Software
6  Foundation, either version 3 of the License, or (at your option) any later
7  version.
8 
9  CASToR is distributed in the hope that it will be useful, but WITHOUT ANY
10  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12  details.
13 
14  You should have received a copy of the GNU General Public License along with
15  CASToR (in file GNU_GPL.TXT). If not, see <http://www.gnu.org/licenses/>.
16 
17 Copyright 2017-2018 all CASToR contributors listed below:
18 
19  --> current contributors: Thibaut MERLIN, Simon STUTE, Didier BENOIT, Claude COMTAT, Marina FILIPOVIC, Mael MILLARDET
20  --> past contributors: Valentin VIELZEUF
21 
22 This is CASToR version 2.0.
23 */
24 
31 #include "iProjectorTemplate.hh"
32 #include "sOutputManager.hh"
33 
34 // =====================================================================
35 // ---------------------------------------------------------------------
36 // ---------------------------------------------------------------------
37 // =====================================================================
38 
40 {
41  // Set all the data members to a default value
42 
43  // Also tell if the projector is compatible with SPECT attenuation correction. In order
44  // to be so, all voxels contributing to a line must be strictly sorted with respect to
45  // their distance to point 2 (the line must also go from point 1 to point 2 and not the
46  // inverse)
48 
49  // Tell if the projector is compatible with compression. This means that for a given event,
50  // multiple couples of indices are used to compute a centroid position for each line's end
51  // point. Then the detection element indices in the projection line are set to -1 because
52  // it is undefined. So inside the projection algorithm, if such indices must be used, then
53  // the projector will not be compatible with compression.
55 }
56 
57 // =====================================================================
58 // ---------------------------------------------------------------------
59 // ---------------------------------------------------------------------
60 // =====================================================================
61 
63 {
64  // Delete or free all structures allocated by this projector
65 }
66 
67 // =====================================================================
68 // ---------------------------------------------------------------------
69 // ---------------------------------------------------------------------
70 // =====================================================================
71 
72 int iProjectorTemplate::ReadConfigurationFile(const string& a_configurationFile)
73 {
74  // Implement here the reading of any options specific to this projector, through a configuration file
75  ;
76  // Normal end
77  return 0;
78 }
79 
80 // =====================================================================
81 // ---------------------------------------------------------------------
82 // ---------------------------------------------------------------------
83 // =====================================================================
84 
85 int iProjectorTemplate::ReadOptionsList(const string& a_optionsList)
86 {
87  // Implement here the reading of any options specific to this projector, through a list of options separated by commas
88  ;
89  // Normal end
90  return 0;
91 }
92 
93 // =====================================================================
94 // ---------------------------------------------------------------------
95 // ---------------------------------------------------------------------
96 // =====================================================================
97 
99 {
100  // Here, display some help and guidance to how to use this projector and what it does
101  cout << "This projector is a template class dedicated to add your own custom projector." << endl;
102 }
103 
104 // =====================================================================
105 // ---------------------------------------------------------------------
106 // ---------------------------------------------------------------------
107 // =====================================================================
108 
110 {
111  // Here, check that all parameters needed by this projector are allocated and have correct values
112  ;
113  // Normal end
114  return 0;
115 }
116 
117 // =====================================================================
118 // ---------------------------------------------------------------------
119 // ---------------------------------------------------------------------
120 // =====================================================================
121 
123 {
124  // Implement here the initialization of whatever member variables specifically used by this projector
125  ;
126  // Normal end
127  return 0;
128 }
129 
130 // =====================================================================
131 // ---------------------------------------------------------------------
132 // ---------------------------------------------------------------------
133 // =====================================================================
134 
136 {
137  // Implement here a way to precompute the estimated maximum number of voxels that will contribute to a line of response.
138  // By default, it uses a buffer size corresponding to the total number of voxels of the image.
139  // The idea is to optimize the RAM usage by providing a better estimate that suites the need of this projector.
140  // If you do not have a better estimation, then you can remove this function from this class because it is already
141  // implemented as is in the mother class.
142 
143  // Find the maximum number of voxels along a given dimension
144  INTNB max_nb_voxels_in_dimension = mp_ImageDimensionsAndQuantification->GetNbVoxXYZ();
145  // Return the value
146  return max_nb_voxels_in_dimension;
147 }
148 
149 // =====================================================================
150 // ---------------------------------------------------------------------
151 // ---------------------------------------------------------------------
152 // =====================================================================
153 
154 int iProjectorTemplate::ProjectWithoutTOF(int a_direction, oProjectionLine* ap_ProjectionLine )
155 {
156  #ifdef CASTOR_DEBUG
157  if (!m_initialized)
158  {
159  Cerr("***** iProjectorTemplate::ProjectWithoutTOF() -> Called while not initialized !" << endl);
160  Exit(EXIT_DEBUG);
161  }
162  #endif
163 
164  #ifdef CASTOR_VERBOSE
165  if (m_verbose>=10)
166  {
167  string direction = "";
168  if (a_direction==FORWARD) direction = "forward";
169  else direction = "backward";
170  Cout("iProjectorTemplate::Project without TOF -> Project line '" << ap_ProjectionLine << "' in " << direction << " direction" << endl);
171  }
172  #endif
173 
174  // --------------------------------------------------------------------------------------------------------------------------------------------
175  // Please read the following information that will help implement your projector:
176 
177  // FLTNB is a macro defining the precision of the code (float, double, long double) that can be customized through some compilation options.
178  // So please, DO NOT USE 'float' or 'double' keywords but USE INSTEAD 'FLTNB'.
179  // Same for integers used to define image dimensions, DO NOT USE 'int' or 'long int' but USE INSTEAD 'INTNB'.
180 
181  // All 3D vectors of type FLTNB* or INTNB* carry the information in the following order: X then Y then Z.
182 
183  // The image dimensions can be accessed via some local copies of the parameters:
184  // - number of voxels: mp_nbVox[0] (along X), mp_nbVox[1] (along Y), mp_nbVox[2] (along Z),
185  // - size of voxels in mm: mp_voxSize[0] (along X), mp_voxSize[1] (along Y), mp_voxSize[2] (along Z),
186  // - half image dimensions in mm: mp_halfFOV[0] (along X), mp_halfFOV[1] (along Y), mp_halfFOV (along Z).
187 
188  // 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],
189  // its cumulative 1D index is computed by 'index = indexZ*m_nbVoxXY + indexY*mp_nbVox[0] + indexX'.
190 
191  // 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
192  // at this class to know how to get those information through some ap_ProjectionLine->GetXXX() functions.
193 
194  // The end points of the line are already computed by the vProjector with respect to the different options provided; e.g. mean depth of
195  // interaction, actual position of interaction (POI), randomization of end points, etc. However, if you want to customize those end points,
196  // 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
197  // this function into the vScanner or children classes. The vScanner object can be accessed using the mp_Scanner member object of this class.
198 
199  // 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.
200 
201  // Finally, to add the contribution of a given voxel to this projection line, simply use this instruction:
202  // ap_ProjectionLine->AddVoxel(a_direction, my_index, my_weight), where 'my_index' is the spatial index of the voxel and 'my_weight' is its
203  // associated weight (i.e. its contribution to the line).
204 
205  // 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
206  // piece of code can be used by anyone in any context!
207 
208  // --------------------------------------------------------------------------------------------------------------------------------------------
209 
210  Cerr("***** iProjectorTemplate::ProjectWithoutTOF() -> Not yet implemented !" << endl);
211  return 1;
212 
213  // Normal end
214  return 0;
215 }
216 
217 // =====================================================================
218 // ---------------------------------------------------------------------
219 // ---------------------------------------------------------------------
220 // =====================================================================
221 
222 int iProjectorTemplate::ProjectWithTOFPos(int a_Projector, oProjectionLine* ap_ProjectionLine)
223 {
224  // Read the information in the ProjectWithoutTOF function to know the general guidelines.
225  // This function implements a projection using a continuous TOF information = when using list-mode data.
226  // The TOF resolution and measurement associated to the running event are accessible through the ap_ProjectionLine
227  // parameter using some GetXXX() functions.
228 
229  Cerr("***** iProjectorTemplate::ProjectWithTOFPos() -> Not yet implemented !" << endl);
230  return 1;
231 
232  // Normal end
233  return 0;
234 }
235 
236 // =====================================================================
237 // ---------------------------------------------------------------------
238 // ---------------------------------------------------------------------
239 // =====================================================================
240 
241 int iProjectorTemplate::ProjectWithTOFBin(int a_Projector, oProjectionLine* ap_ProjectionLine)
242 {
243  // Read the information in the ProjectWithoutTOF function to know the general guidelines.
244  // This function implements a projection using a binned TOF information = when using histogram data.
245  // The number of TOF bins, TOF resolution, etc, are accessible through the ap_ProjectionLine using
246  // some GetXXX() functions. This function is supposed to fill all TOF bins at once. To add voxel
247  // contributions to a specific TOF bin, use the dedicated function ap_ProjectionLine->AddVoxelInTOFBin().
248  // All forward and backward operations will be carried out later by the vOptimizer, automatically
249  // managing all TOF bins.
250 
251  Cerr("***** iProjectorTemplate::ProjectWithTOFBin() -> Not yet implemented !" << endl);
252  return 1;
253 
254  // Normal end
255  return 0;
256 }
257 
258 // =====================================================================
259 // ---------------------------------------------------------------------
260 // ---------------------------------------------------------------------
261 // =====================================================================
bool m_compatibleWithSPECTAttenuationCorrection
Definition: vProjector.hh:355
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:344
This class is designed to generically described any on-the-fly projector.
Definition: vProjector.hh:76
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:364
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:92
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:97
int ProjectWithTOFPos(int a_direction, oProjectionLine *ap_ProjectionLine)
A function to project with TOF continuous information.
#define FORWARD
#define Cout(MESSAGE)
bool m_compatibleWithCompression
Definition: vProjector.hh:358
Declaration of class iProjectorTemplate.