CASToR  1.0
Tomographic Reconstruction (PET/SPECT)
iProjectorTemplate.cc
Go to the documentation of this file.
00001 
00002 /*
00003   Implementation of class iProjectorTemplate
00004 
00005   - separators: done
00006   - doxygen: done
00007   - default initialization: done
00008   - CASTOR_DEBUG: 
00009   - CASTOR_VERBOSE: 
00010 */
00011 
00018 #include "iProjectorTemplate.hh"
00019 #include "sOutputManager.hh"
00020 
00021 // =====================================================================
00022 // ---------------------------------------------------------------------
00023 // ---------------------------------------------------------------------
00024 // =====================================================================
00025 
00026 iProjectorTemplate::iProjectorTemplate() : vProjector()
00027 {
00028   // Set all the data members to a default value
00029 
00030   // Also tell if the projector is compatible with SPECT attenuation correction. In order
00031   // to be so, all voxels contributing to a line must be strictly sorted with respect to
00032   // their distance to point 2 (the line must also go from point 1 to point 2 and not the
00033   // inverse)
00034   m_compatibleWithSPECTAttenuationCorrection = false;
00035 }
00036 
00037 // =====================================================================
00038 // ---------------------------------------------------------------------
00039 // ---------------------------------------------------------------------
00040 // =====================================================================
00041 
00042 iProjectorTemplate::~iProjectorTemplate()
00043 {
00044   // Delete or free all structures allocated by this projector
00045 }
00046 
00047 // =====================================================================
00048 // ---------------------------------------------------------------------
00049 // ---------------------------------------------------------------------
00050 // =====================================================================
00051 
00052 int iProjectorTemplate::ReadConfigurationFile(const string& a_configurationFile)
00053 {
00054   // Implement here the reading of any options specific to this projector, through a configuration file
00055   ;
00056   // Normal end
00057   return 0;
00058 }
00059 
00060 // =====================================================================
00061 // ---------------------------------------------------------------------
00062 // ---------------------------------------------------------------------
00063 // =====================================================================
00064 
00065 int iProjectorTemplate::ReadOptionsList(const string& a_optionsList)
00066 {
00067   // Implement here the reading of any options specific to this projector, through a list of options separated by commas
00068   ;
00069   // Normal end
00070   return 0;
00071 }
00072 
00073 // =====================================================================
00074 // ---------------------------------------------------------------------
00075 // ---------------------------------------------------------------------
00076 // =====================================================================
00077 
00078 void iProjectorTemplate::ShowHelpSpecific()
00079 {
00080   // Here, display some help and guidance to how to use this projector and what it does
00081   cout << "This projector is a template class dedicated to add your own custom projector." << endl;
00082 }
00083 
00084 // =====================================================================
00085 // ---------------------------------------------------------------------
00086 // ---------------------------------------------------------------------
00087 // =====================================================================
00088 
00089 int iProjectorTemplate::CheckSpecificParameters()
00090 {
00091   // Here, check that all parameters needed by this projector are allocated and have correct values
00092   ;
00093   // Normal end
00094   return 0;
00095 }
00096 
00097 // =====================================================================
00098 // ---------------------------------------------------------------------
00099 // ---------------------------------------------------------------------
00100 // =====================================================================
00101 
00102 int iProjectorTemplate::InitializeSpecific()
00103 {
00104   // Implement here the initialization of whatever member variables specifically used by this projector
00105   ;
00106   // Normal end
00107   return 0;
00108 }
00109 
00110 // =====================================================================
00111 // ---------------------------------------------------------------------
00112 // ---------------------------------------------------------------------
00113 // =====================================================================
00114 
00115 INTNB iProjectorTemplate::EstimateMaxNumberOfVoxelsPerLine()
00116 {
00117   // Implement here a way to precompute the estimated maximum number of voxels that will contribute to a line of response.
00118   // By default, it uses a buffer size corresponding to the total number of voxels of the image.
00119   // The idea is to optimize the RAM usage by providing a better estimate that suites the need of this projector.
00120   // If you do not have a better estimation, then you can remove this function from this class because it is already
00121   // implemented as is in the mother class.
00122 
00123   // Find the maximum number of voxels along a given dimension
00124   INTNB max_nb_voxels_in_dimension = mp_ImageDimensionsAndQuantification->GetNbVoxXYZ();
00125   // Return the value
00126   return max_nb_voxels_in_dimension;
00127 }
00128 
00129 // =====================================================================
00130 // ---------------------------------------------------------------------
00131 // ---------------------------------------------------------------------
00132 // =====================================================================
00133 
00134 int iProjectorTemplate::ProjectWithoutTOF(int a_direction, oProjectionLine* ap_ProjectionLine )
00135 {
00136   #ifdef CASTOR_DEBUG
00137   if (!m_initialized)
00138   {
00139     Cerr("***** iProjectorTemplate::ProjectWithoutTOF() -> Called while not initialized !" << endl);
00140     Exit(EXIT_DEBUG);
00141   }
00142   #endif
00143 
00144   #ifdef CASTOR_VERBOSE
00145   if (m_verbose>=10)
00146   {
00147     string direction = "";
00148     if (a_direction==FORWARD) direction = "forward";
00149     else direction = "backward";
00150     Cout("iProjectorTemplate::Project without TOF -> Project line '" << ap_ProjectionLine << "' in " << direction << " direction" << endl);
00151   }
00152   #endif
00153 
00154   // --------------------------------------------------------------------------------------------------------------------------------------------
00155   // Please read the following information that will help implement your projector:
00156 
00157   // FLTNB is a macro defining the precision of the code (float, double, long double) that can be customized through some compilation options.
00158   // So please, DO NOT USE 'float' or 'double' keywords but USE INSTEAD 'FLTNB'.
00159   // Same for integers used to define image dimensions, DO NOT USE 'int' or 'long int' but USE INSTEAD 'INTNB'.
00160 
00161   // All 3D vectors of type FLTNB* or INTNB* carry the information in the following order: X then Y then Z.
00162 
00163   // The image dimensions can be accessed via some local copies of the parameters:
00164   //  - number of voxels: mp_nbVox[0] (along X), mp_nbVox[1] (along Y), mp_nbVox[2] (along Z),
00165   //  - size of voxels in mm: mp_voxSize[0] (along X), mp_voxSize[1] (along Y), mp_voxSize[2] (along Z),
00166   //  - half image dimensions in mm: mp_halfFOV[0] (along X), mp_halfFOV[1] (along Y), mp_halfFOV (along Z).
00167 
00168   // 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],
00169   // its cumulative 1D index is computed by 'index = indexZ*m_nbVoxXY + indexY*mp_nbVox[0] + indexX'.
00170 
00171   // 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
00172   // at this class to know how to get those information through some ap_ProjectionLine->GetXXX() functions.
00173 
00174   // The end points of the line are already computed by the vProjector with respect to the different options provided; e.g. mean depth of
00175   // interaction, actual position of interaction (POI), randomization of end points, etc. However, if you want to customize those end points,
00176   // 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
00177   // this function into the vScanner or children classes. The vScanner object can be accessed using the mp_Scanner member object of this class.
00178 
00179   // 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.
00180 
00181   // Finally, to add the contribution of a given voxel to this projection line, simply use this instruction:
00182   // ap_ProjectionLine->AddVoxel(a_direction, my_index, my_weight), where 'my_index' is the spatial index of the voxel and 'my_weight' is its
00183   // associated weight (i.e. its contribution to the line).
00184 
00185   // 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
00186   // piece of code can be used by anyone in any context!
00187 
00188   // --------------------------------------------------------------------------------------------------------------------------------------------
00189 
00190   Cerr("***** iProjectorTemplate::ProjectWithoutTOF() -> Not yet implemented !" << endl);
00191   return 1;
00192 
00193   // Normal end
00194   return 0;
00195 }
00196 
00197 // =====================================================================
00198 // ---------------------------------------------------------------------
00199 // ---------------------------------------------------------------------
00200 // =====================================================================
00201 
00202 int iProjectorTemplate::ProjectWithTOFPos(int a_Projector, oProjectionLine* ap_ProjectionLine)
00203 {
00204   // Read the information in the ProjectWithoutTOF function to know the general guidelines.
00205   // This function implements a projection using a continuous TOF information = when using list-mode data.
00206   // The TOF resolution and measurement associated to the running event are accessible through the ap_ProjectionLine
00207   // parameter using some GetXXX() functions.
00208 
00209   Cerr("***** iProjectorTemplate::ProjectWithTOFPos() -> Not yet implemented !" << endl);
00210   return 1;
00211 
00212   // Normal end
00213   return 0;
00214 }
00215 
00216 // =====================================================================
00217 // ---------------------------------------------------------------------
00218 // ---------------------------------------------------------------------
00219 // =====================================================================
00220 
00221 int iProjectorTemplate::ProjectWithTOFBin(int a_Projector, oProjectionLine* ap_ProjectionLine)
00222 {
00223   // Read the information in the ProjectWithoutTOF function to know the general guidelines.
00224   // This function implements a projection using a binned TOF information = when using histogram data.
00225   // The number of TOF bins, TOF resolution, etc, are accessible through the ap_ProjectionLine using
00226   // some GetXXX() functions. This function is supposed to fill all TOF bins at once. To add voxel
00227   // contributions to a specific TOF bin, use the dedicated function ap_ProjectionLine->AddVoxelInTOFBin().
00228   // All forward and backward operations will be carried out later by the vOptimizer, automatically
00229   // managing all TOF bins.
00230 
00231   Cerr("***** iProjectorTemplate::ProjectWithTOFBin() -> Not yet implemented !" << endl);
00232   return 1;
00233 
00234   // Normal end
00235   return 0;
00236 }
00237 
00238 // =====================================================================
00239 // ---------------------------------------------------------------------
00240 // ---------------------------------------------------------------------
00241 // =====================================================================
 All Classes Files Functions Variables Typedefs Defines