8 #include "vProjector.hh" 10 #include "vDataFile.hh" 71 if (ap_ImageDimensionsAndQuantification==NULL)
73 Cerr(
"***** vProjector::SetImageDimensionsAndQuantification() -> Input image dimensions object is null !" << endl);
102 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
103 if (mpi_rank!=0)
return;
106 cout <<
"------------------------------------------------------------------" << endl;
107 cout <<
"----- Common options for all projectors" << endl;
108 cout <<
"------------------------------------------------------------------" << endl;
109 cout <<
"Only options related to TOF implementation are available." << endl;
110 cout <<
"If used, values for all of the following options must be provided as a list of numbers separated by commas." << endl;
112 cout <<
" the number of standard deviations for truncating the nominal TOF Gaussian distribution (-1 for no truncation)." << endl;
113 cout <<
" whether the TOF weighting function is precomputed (1 for yes, 0 for no)" << endl;
114 cout <<
" whether the TOF weighting function takes properly into account the TOF bin using convolution or integration (1 for yes, 0 for no)." << endl;
116 cout <<
"The default values are -1,1,1" << endl;
131 else cout <<
"This projector is NOT compatible with SPECT attenuation correction." << endl;
142 if (a_optionsList!=
"")
148 Cerr(
"***** vProjector::ReadCommonOptionsList() -> Failed to correctly read the list of options !" << endl);
168 Cerr(
"***** vProjector::CheckParameters() -> Please provide a valid scanner object !" << endl);
174 Cerr(
"***** vProjector::CheckParameters() -> Please provide a valid image dimensions and quantification object !" << endl);
179 Cerr(
"***** vProjector::CheckParameters() -> One or more voxel sizes is negative or null !" << endl);
184 Cerr(
"***** vProjector::CheckParameters() -> One or more number of voxels is negative or null !" << endl);
190 Cerr(
"***** vProjector::CheckParameters() -> TOF flag is incorrect or not set !" << endl);
198 Cerr(
"***** vProjector::CheckParameters() -> Inconsistent TOF related parameters !" << endl);
203 Cout(
"***** vProjector::CheckParameters() -> Warning: quantization TOF bin size wrong or not provided, so switching to TOF list-mode reconstruction which neglects the quantization TOF bin size!" << endl);
208 Cout(
"***** vProjector::CheckParameters() -> Warning: ToF weighting function cannot be precomputed when using per event ToF resolution. Disabling precomputation.");
216 Cerr(
"***** vProjector::CheckParameters() -> Verbose level is negative !" << endl);
222 Cerr(
"***** vProjector::CheckParameters() -> An error occurred while checking parameters of the child projector class !" << endl);
241 Cerr(
"***** vProjector::Initialize() -> Must call the CheckParameters() function before initialization !" << endl);
271 if (nb_samples_tof_gauss % 2 == 0) nb_samples_tof_gauss += 1;
279 INTNB mu = nb_samples_tof_gauss/2;
280 for (
INTNB g=0;g<nb_samples_tof_gauss;g++)
282 HPFLTNB temp = ((
HPFLTNB)(g-mu))/(tof_resolution_sigma*m_TOFPrecomputedSamplingFactor);
294 if (nb_samples_tof_bin % 2 == 0) nb_samples_tof_bin += 1;
297 INTNB nb_samples_conv = nb_samples_tof_gauss+nb_samples_tof_bin-1;
302 INTNB mu = nb_samples_conv/2;
303 for (
INTNB sgauss=0;sgauss<nb_samples_conv;sgauss++)
305 if (sgauss<mu-nb_samples_tof_gauss/2 || sgauss>mu+nb_samples_tof_gauss/2) tof_gauss[sgauss]=0.;
308 HPFLTNB temp = (
HPFLTNB)((sgauss-mu))/(tof_resolution_sigma*m_TOFPrecomputedSamplingFactor);
317 for (
INTNB sbin=0;sbin<nb_samples_tof_bin;sbin++) tof_bin[sbin] = tof_bin_value;
325 #pragma omp parallel for private(c) schedule(static, 1) 326 for (c=0;c<nb_samples_conv;c++)
328 for (
INTNB ib=0;ib<nb_samples_tof_bin;ib++)
330 INTNB temp = c-nb_samples_tof_bin/2+ib;
331 if (temp>=0 && temp<nb_samples_conv)
mp_TOFWeightingFcn[c] += tof_gauss[temp]*tof_bin[ib];
348 Cout(
" --> TOF weighting function implementation: " << endl);
349 Cout(
" --> Gaussian truncation (number of standard deviations) " << m_TOFNbSigmas << endl);
352 Cout(
" --> Precomputed " << endl);
365 Cout(
" --> Computation on the fly " << endl);
382 Cerr(
"***** vProjector::Initialize() -> A problem occurred while calling the specific initialization of the child projector !" << endl);
388 Cout(
"vProjector::Initialize() -> Exit function" << endl);
416 Cerr(
"***** vProjector::Project() -> Called while not initialized !" << endl);
435 ap_ProjectionLine->
SetIndex1(((
int)(ap_index1[0])));
436 ap_ProjectionLine->
SetIndex2(((
int)(ap_index2[0])));
443 Cerr(
"***** vProjector::Project() -> A problem occurred while getting positions and orientations from scanner !" << endl);
464 for (
int i=0; i<3; i++)
468 orientation1[i] = 0.;
469 orientation2[i] = 0.;
472 for (
int l=0; l<a_nbIndices; l++)
476 buffer_position1, buffer_position2,
477 buffer_orientation1, buffer_orientation2,
480 Cerr(
"***** vProjector::Project() -> A problem occurred while getting positions and orientations from scanner !" << endl);
484 for (
int i=0; i<3; i++)
486 position1[i] += buffer_position1[i];
487 position2[i] += buffer_position2[i];
488 orientation1[i] += buffer_orientation1[i];
489 orientation2[i] += buffer_orientation2[i];
493 for (
int i=0; i<3; i++)
495 position1[i] /= ((
FLTNB)a_nbIndices);
496 position2[i] /= ((
FLTNB)a_nbIndices);
497 orientation1[i] /= ((
FLTNB)a_nbIndices);
498 orientation2[i] /= ((
FLTNB)a_nbIndices);
530 Cerr(
"***** vProjector::Project() -> A problem occurred while projecting a line without time-of-flight !" << endl);
542 Cerr(
"***** oProjectorManager::ComputeProjectionLine() -> TOF per-event resolution has not been initialized!" << endl);
553 Cerr(
"***** vProjector::Project() -> A problem occurred while projecting a line with time-of-flight position !" << endl);
560 Cerr(
"***** vProjector::Project() -> A problem occurred while projecting a line with binned time-of-flight !" << endl);
567 #ifdef CASTOR_VERBOSE 570 Cout(
"vProjector::Project() -> Exit function" << endl);
bool m_compatibleWithSPECTAttenuationCorrection
FLTNB * GetOrientation1()
This function is used to get the pointer to the mp_orientation1 (3-values tab).
FLTNB * GetPOI1()
This function is used to get the pointer to POI of point 1 (3-values tab).
static void ShowCommonHelp()
This function is used to print out some help about the use of options common to all projectors...
int ReadStringOption(const string &a_input, T *ap_return, int a_nbElts, const string &sep, const string &a_option)
Parse the 'a_input' string corresponding to the 'a_option' into 'a_nbElts' elements, using the 'sep' separator. The results are returned in the templated 'ap_return' dynamic templated array. Call "ConvertFromString()" to perform the correct conversion depending on the type of the data to convert.
FLTNB GetVoxSizeX()
Get the voxel's size along the X axis, in mm.
FLTNB m_TOFGaussianNormCoef
FLTNB GetVoxSizeZ()
Get the voxel's size along the Z axis, in mm.
FLTNB * GetBufferPosition2()
This function is used to get the pointer to the mp_bufferPosition2 (3-values tab).
FLTNB GetTOFResolutionInPs() const
This function is used to get the TOF standard deviation in ps.
#define SPEED_OF_LIGHT_IN_MM_PER_PS
vProjector()
The constructor of vProjector.
int Initialize()
A public function used to initialize the projector.
bool m_TOFWeightingFcnPrecomputedFlag
virtual int ProjectTOFHistogram(int a_direction, oProjectionLine *ap_ProjectionLine)=0
bool m_TOFBinProperProcessingFlag
HPFLTNB * mp_TOFWeightingFcn
int Project(int a_direction, oProjectionLine *ap_ProjectionLine, uint32_t *ap_index1, uint32_t *ap_index2, int a_nbIndices)
bool m_readPerEventTOFResolution
oImageDimensionsAndQuantification * mp_ImageDimensionsAndQuantification
FLTNB * GetBufferPosition1()
This function is used to get the pointer to the mp_bufferPosition1 (3-values tab).
virtual int ProjectWithoutTOF(int a_direction, oProjectionLine *ap_ProjectionLine)=0
FLTNB * GetOrientation2()
This function is used to get the pointer to the mp_orientation2 (3-values tab).
virtual int CheckSpecificParameters()=0
A private function used to check the parameters settings specific to the child projector.
void ComputeLineLength()
Simply compute and update the m_length using the associated mp_position1 and mp_position2.
int ReadCommonOptionsList(const string &a_optionsList)
FLTNB GetVoxSizeY()
Get the voxel's size along the Y axis, in mm.
void ApplyOffset()
Apply the offset of oImageDimensionsAndQuantification to the mp_position1 and mp_position2.
FLTNB * GetPosition1()
This function is used to get the pointer to the mp_position1 (3-values tab).
virtual void ShowHelpSpecific()=0
A function used to show help about the child module.
#define DEBUG_VERBOSE(IGNORED1, IGNORED2)
FLTNB * GetBufferOrientation1()
This function is used to get the pointer to the mp_bufferOrientation1 (3-values tab).
virtual ~vProjector()
The destructor of vProjector.
int CheckParameters()
A public function used to check the parameters settings.
FLTNB m_TOFResolutionInMm
void SetIndex2(int a_index2)
FLTNB * GetBufferOrientation2()
This function is used to get the pointer to the mp_bufferOrientation2 (3-values tab).
This class is designed to manage and store system matrix elements associated to a vEvent...
FLTNB m_TOFPrecomputedSamplingFactor
virtual int ProjectTOFListmode(int a_direction, oProjectionLine *ap_ProjectionLine)=0
void SetIndex1(int a_index1)
virtual int InitializeSpecific()=0
A private function used to initialize everything specific to the child projector. ...
INTNB GetNbVoxXYZ()
Get the total number of voxels.
FLTNB m_TOFMeasurementRangeInMm
This class is designed to manage all dimensions and quantification related stuff. ...
FLTNB * GetPosition2()
This function is used to get the pointer to the mp_position2 (3-values tab).
INTNB GetNbVoxX()
Get the number of voxels along the X axis.
INTNB GetNbVoxZ()
Get the number of voxels along the Z axis.
virtual INTNB EstimateMaxNumberOfVoxelsPerLine()
This function is used to compute and provide an estimate of the maximum number of voxels that could c...
bool m_compatibleWithCompression
void ShowHelp()
A function used to show help about the projector.
FLTNB * GetPOI2()
This function is used to get the pointer to POI of point 2 (3-values tab).
int SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
#define TWO_SQRT_TWO_LN_2
void ApplyBedOffset()
Apply the bed offset of m_bedOffset to the mp_position1 and mp_position2.
virtual int GetPositionsAndOrientations(int a_index1, int a_index2, FLTNB ap_Position1[3], FLTNB ap_Position2[3], FLTNB ap_Orientation1[3], FLTNB ap_Orientation2[3], FLTNB *ap_POI1=NULL, FLTNB *ap_POI2=NULL)=0
INTNB GetNbVoxY()
Get the number of voxels along the Y axis.
#define VERBOSE_DEBUG_EVENT
INTNB m_TOFWeightingFcnNbSamples