214 else cout <<
"This optimizer is a total non-sense, not compatible with histogram nor list-mode data !!!" << endl;
219 else cout <<
"This optimizer is a total non-sense, not compatible with emission nor transmission data !!!" << endl;
232 Cerr(
"***** vOptimizer::CheckParameters() -> oImageDimensionsAndQuantification is null !" << endl);
238 Cerr(
"***** vOptimizer::CheckParameters() -> oImageSpace is null !" << endl);
244 Cerr(
"***** vOptimizer::CheckParameters() -> No or meaningless data mode provided !" << endl);
250 Cerr(
"***** vOptimizer::CheckParameters() -> No or meaningless data type provided !" << endl);
256 Cerr(
"***** vOptimizer::CheckParameters() -> No or meaningless data specificity provided (emission or transmission) !" << endl);
262 Cerr(
"***** vOptimizer::CheckParameters() -> Verbose level is negative !" << endl);
268 Cerr(
"***** vOptimizer::CheckParameters() -> The selected optimizer is not compatible with listmode data !" << endl);
274 Cerr(
"***** vOptimizer::CheckParameters() -> The selected optimizer is not compatible with histogram data !" << endl);
280 Cerr(
"***** vOptimizer::CheckParameters() -> The selected optimizer is not compatible with emission data !" << endl);
286 Cerr(
"***** vOptimizer::CheckParameters() -> The selected optimizer is not compatible with transmission data !" << endl);
292 Cerr(
"***** vOptimizer::CheckParameters() -> Asked to compute FOMs in the data-space whereas the verbose is not set !" << endl);
298 Cerr(
"***** vOptimizer::CheckParameters() -> Asked to compute image update statistics whereas the verbose is not set !" << endl);
304 Cerr(
"***** vOptimizer::CheckParameters() -> Computing FOMs in the data-space with list-mode data is not possible !" << endl);
310 Cerr(
"***** vOptimizer::CheckParameters() -> A problem occured while checking parameters specific to the optimizer module !" << endl);
387 Cerr(
"***** vOptimizer::Initialize() -> A problem occured while initializing stuff specific to the optimizer module !" << endl);
419 Cerr(
"***** vOptimizer::PreDataUpdateStep() -> A problem occured while applying the specific pre-data-update step of the optimizer module !" << endl);
448 Cout(
"vOptimizer::PostDataUpdateStep() -> Data-space figures-of-merit" << endl);
483 Cout(spaces_fr << spaces_rg << spaces_cg <<
" --> Number of data channels used in optimization: " <<
m4p_FOMNbBins[fr][rg][cg][0] << endl);
484 Cout(spaces_fr << spaces_rg << spaces_cg <<
" --> Mean number of data counts per channel: " <<
m4p_FOMNbData[fr][rg][cg][0] << endl);
485 Cout(spaces_fr << spaces_rg << spaces_cg <<
" --> Log-likelihood: " <<
m4p_FOMLogLikelihood[fr][rg][cg][0] << endl);
486 Cout(spaces_fr << spaces_rg << spaces_cg <<
" --> RMSE: " <<
m4p_FOMRMSE[fr][rg][cg][0] << endl);
494 Cerr(
"***** vOptimizer::PostDataUpdateStep() -> A problem occured while applying the specific post-data-update step of the optimizer module !" << endl);
520 int a_bed,
int a_timeFrame,
int a_respGate,
int a_cardGate,
539 if (time_basis_coef==0.)
continue;
545 if (resp_basis_coef==0.)
continue;
551 if (card_basis_coef==0.)
continue;
553 FLTNB global_basis_coef = time_basis_coef * resp_basis_coef * card_basis_coef;
600 int a_bed,
int a_timeFrame,
int a_respGate,
int a_cardGate,
601 int a_iteration,
int a_th )
613 int a_bed,
int a_timeFrame,
int a_respGate,
int a_cardGate,
636 Cerr(
"***** vOptimizer::DataStep3BackwardProjectSensitivity() -> A problem occured while performing the sensitivity specific operations !" << endl);
653 int a_bed,
int a_timeFrame,
int a_respGate,
int a_cardGate,
654 int a_iteration,
int a_th )
666 int a_bed,
int a_timeFrame,
int a_respGate,
int a_cardGate,
687 Cerr(
"***** vOptimizer::DataStep5ComputeCorrections() -> A problem occured while performing specific data space operations !" << endl);
702 int a_bed,
int a_timeFrame,
int a_respGate,
int a_cardGate,
703 int a_iteration,
int a_th )
715 int a_bed,
int a_timeFrame,
int a_respGate,
int a_cardGate,
727 if (time_basis_coef==0.)
continue;
733 if (resp_basis_coef==0.)
continue;
739 if (card_basis_coef==0.)
continue;
741 FLTNB global_basis_coef = time_basis_coef * resp_basis_coef * card_basis_coef;
770 int a_timeFrame,
int a_respGate,
int a_cardGate,
780 if (model>1.e-10)
m4p_FOMLogLikelihood[a_timeFrame][a_respGate][a_cardGate][a_thread] += data*log(model)-model;
782 m4p_FOMRMSE[a_timeFrame][a_respGate][a_cardGate][a_thread] += (data-model)*(data-model);
784 m4p_FOMNbBins[a_timeFrame][a_respGate][a_cardGate][a_thread]++;
800 if (
m_verbose>=3)
Cout(
"vOptimizer::UpdateVisitedVoxels() -> Tick visited voxels based on sensitivity" << endl);
840 else Cout(spaces_tbf <<
"--> Time basis function: " << tbf+1 << endl);
849 else Cout(spaces_tbf << spaces_rbf <<
"--> Respiratory basis function: " << rbf+1 << endl);
858 else Cout(spaces_tbf << spaces_rbf << spaces_cbf <<
"--> Cardiac basis function: " << cbf+1 << endl);
881 #pragma omp parallel for private(v) schedule(guided)
887 th = omp_get_thread_num();
892 if (sensitivity<=0.)
continue;
913 Cerr(
"***** vOptimizer::ImageUpdateStep() -> A problem occured in while performing image space specific operations of the optimizer !" << endl);
957 mp_imageStatMean[0] = (count1*mp_imageStatMean[0] + count2*mp_imageStatMean[th]) / count12;
961 mp_correctionStatMean[0] = (count1*mp_correctionStatMean[0] + count2*mp_correctionStatMean[th]) / count12;
967 Cout(spaces_tbf << spaces_rbf << spaces_cbf <<
" --> Image update step "
970 Cout(spaces_tbf << spaces_rbf << spaces_cbf <<
" --> New image estimate"
1019 int a_timeBasisFunction,
int a_respBasisFunction,
int a_cardBasisFunction,
1020 int a_voxel,
int a_nbSubsets )
1023 FLTNB sensitivity = 0.;
1029 if (time_basis_coef==0.)
continue;
1035 if (resp_basis_coef==0.)
continue;
1041 if (card_basis_coef==0.)
continue;
1043 sensitivity += a4p_sensitivityMatrix[fr][rg][cg][a_voxel] *
1044 time_basis_coef * resp_basis_coef * card_basis_coef;
FLTNB **** m4p_forwardImage
virtual int ImageUpdateStep(int a_iteration, int a_nbSubsets)
A public function used to perform the image update step of the optimizer.
virtual FLTNB GetBlankValue()
This is a pure virtual function implemented in the child classes.
FLTNB ForwardProjectWithSPECTAttenuation(FLTNB *ap_attenuation, FLTNB *ap_image=NULL)
Forward projects the provided image for the current TOF bin with an inner loop on the attenuation (fo...
int GetNbCardBasisFunctions()
Get the number of cardiac basis functions.
virtual FLTNB GetAdditiveCorrections(int a_bin)=0
Pure virtual function implemented in the child classes.
bool m_listmodeCompatibility
virtual int DataStep6Optional(oProjectionLine *ap_Line, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_iteration, int a_thread)
A public function which does nothing but being virtual.
virtual int PreDataUpdateSpecificStep(int a_iteration, int a_nbIterations, int a_subset, int *ap_nbSubsets)
A private function used to perform any step required by the child optimizer, before the loop on event...
HPFLTNB **** m4p_FOMNbData
FLTNB GetRespBasisCoefficient(int a_respBasisFunction, int a_respGate)
Get the respiratory basis coefficients for the provided respiratory gate and basis function...
void SetCurrentTOFBin(int a_TOFBin)
This function is used to set the current TOF bin that is used.
oImageDimensionsAndQuantification * mp_ImageDimensionsAndQuantification
virtual int CheckSpecificParameters()=0
A private function used to check the parameters settings specific to the child optimizer.
int GetNbTimeBasisFunctions()
Get the number of time basis functions.
vOptimizer()
The constructor of vOptimizer.
FLTNB ForwardProject(oProjectionLine *ap_Line, FLTNB *ap_image=NULL)
A function used to forward project the provided image (or 1 if NULL), based on the provided oProjecti...
virtual FLTNB GetMultiplicativeCorrections()=0
This is a pure virtual function implemented in the child classes.
int GetThreadNumber()
This function is used to get the thread number associated to this line.
virtual int DataStep4Optional(oProjectionLine *ap_Line, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_iteration, int a_thread)
A public function which does nothing but being virtual.
uint64_t **** m4p_FOMNbBins
int PostDataUpdateStep(int a_iteration, int a_nbIterations, int a_subset, int *ap_nbSubsets)
A public function used to do stuff that need to be done at the beginning of a subset (before the data...
HPFLTNB * mp_correctionStatMean
virtual int DataSpaceSpecificOperations(FLTNB a_data, FLTNB a_forwardModel, FLTNB *ap_backwardValues, FLTNB a_multiplicativeCorrections, FLTNB a_additiveCorrections, FLTNB a_blankValue, FLTNB a_quantificationFactor, oProjectionLine *ap_Line)=0
A private function used to compute the correction term in the data space from the provided data...
bool GetRespStaticFlag()
Get the respiratory static flag that says if the reconstruction has only one respiratory gate or not...
INTNB * mp_imageStatNbVox
void BackwardProject(FLTNB *ap_image, FLTNB a_value)
Simply backward projects the provided value inside the provided image, for the current TOF bin...
FLTNB ****** m6p_backwardImage
bool GetCardStaticFlag()
Get the cardiac static flag that says if the reconstruction has only one cardiac gate or not...
bool m_emissionCompatibility
void BackwardProjectWithSPECTAttenuation(FLTNB *ap_attenuation, FLTNB *ap_image, FLTNB a_value)
Backward project the provided value inside the provided image with an inner loop on the attenuation (...
virtual int DataStep3BackwardProjectSensitivity(oProjectionLine *ap_Line, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_thread)
A public function used to back-project the sensitivity terms for the provided event.
virtual int InitializeSpecific()=0
A private function used to initialize everything specific to the child optimizer. ...
int GetNbThreadsMax()
Get the maximum between the number of threads used for projections and image operations.
void BackwardProject(oProjectionLine *ap_Line, FLTNB *ap_image, FLTNB a_value)
A function used to backward project the provided value into the provided image, based on the provided...
virtual FLTNB GetEventValue(int a_bin)=0
Pure virtual function implemented in the child classes.
virtual int DataStep1ForwardProjectModel(oProjectionLine *ap_Line, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_thread)
A public function used to compute the model: forward projection of the provided event.
Declaration of class vOptimizer.
FLTNB ** m2p_attenuationImage
bool m_histogramCompatibility
bool m_optimizerImageStatFlag
FLTNB GetQuantificationFactor(int a_bed, int a_frame, int a_respGate, int a_cardGate)
Get the quantification factor corresponding to the provided bed, frame, respiratory and cardiac gates...
virtual int DataStep8ComputeFOM(oProjectionLine *ap_Line, vEvent *ap_Event, int a_timeFrame, int a_respGate, int a_cardGate, int a_thread)
A public function used to update the computation of figures-of-merit in the data space.
FLTNB GetTimeBasisCoefficient(int a_timeBasisFunction, int a_timeFrame)
Get the time basis coefficients for the provided frame and basis function.
bool GetTimeStaticFlag()
Get the time static flag that says if the reconstruction has only one frame or not.
FLTNB ComputeSensitivity(FLTNB ****a4p_sensitivityImage, int a_timeBasisFunction, int a_respBasisFunction, int a_cardBasisFunction, int a_voxel, int a_nbSubsets)
A function used to compute the sensitivity of a given voxel and a given set of dynamic basis function...
HPFLTNB * mp_imageStatVariance
#define SPEC_TRANSMISSION
virtual ~vOptimizer()
The destructor of vOptimizer.
bool m_transmissionCompatibility
This class is designed to manage and store system matrix elements associated to a vEvent...
int GetNbCardGates()
Get the number of cardiac gates.
FLTNB **** m4p_FOMLogLikelihood
int Initialize()
A public function used to initialize the optimizer.
oImageSpace * mp_ImageSpace
Mother class for the Event objects.
int GetNbThreadsForImageComputation()
Get the number of threads used for image operations.
int GetNbTimeFrames()
Get the number of time frames.
FLTNB ForwardProject(FLTNB *ap_image=NULL)
Simply forward projects the provided image if not null, or else 1, for the current TOF bin...
INTNB GetNbVoxXYZ()
Get the total number of voxels.
virtual int DataStep5ComputeCorrections(oProjectionLine *ap_Line, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_thread)
A public function used to compute the correction terms in the data space, for the provided event...
int GetNbTOFBins()
This function is used to get the number of TOF bins in use.
int PreDataUpdateStep(int a_iteration, int a_nbIterations, int a_subset, int *ap_nbSubsets)
A public function used to do stuff that need to be done at the beginning of a subset (before the data...
HPFLTNB * mp_imageStatMean
int GetNbThreadsForProjection()
Get the number of threads used for projections.
virtual int DataStep2Optional(oProjectionLine *ap_Line, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_iteration, int a_thread)
A public function which does nothing but being virtual.
int UpdateVisitedVoxels()
A public function used to update the 'visited' voxels after each subset.
virtual int PostDataUpdateSpecificStep(int a_iteration, int a_nbIterations, int a_subset, int *ap_nbSubsets)
A private function used to perform any step required by the child optimizer, after the loop on event ...
int GetNbRespGates()
Get the number of respiratory gates.
virtual void ShowHelpSpecific()=0
A function used to show help about the child module.
virtual int ImageSpaceSpecificOperations(FLTNB a_currentImageValue, FLTNB *ap_newImageValue, FLTNB a_sensitivity, FLTNB *ap_correctionValues, INTNB a_voxel)=0
A private function used to update the image value from the provided data.
FLTNB GetFrameDurationInSec(int a_bed, int a_frame)
Get the frame duration for the given bed, in seconds as a FLTNB.
virtual int SensitivitySpecificOperations(FLTNB a_data, FLTNB a_forwardModel, FLTNB *ap_weight, FLTNB a_multiplicativeCorrections, FLTNB a_additiveCorrections, FLTNB a_blankValue, FLTNB a_quantificationFactor, oProjectionLine *ap_Line)=0
A private function used to compute the sensitivity weight associated to the provided data...
virtual int DataStep7BackwardProjectCorrections(oProjectionLine *ap_Line, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_thread)
A public function used to back-project the correction terms into the backward correction image...
void ShowHelp()
A function used to show help about the optimizer.
HPFLTNB * mp_correctionStatVariance
FLTNB ** m2p_forwardValues
int GetNbRespBasisFunctions()
Get the number of respiratory basis functions.
FLTNB ***** m5p_sensitivity
FLTNB *** m3p_backwardValues
int CheckParameters()
A public function used to check the parameters settings.
FLTNB **** m4p_visitedVoxelsImage
FLTNB GetCardBasisCoefficient(int a_cardBasisFunction, int a_cardGate)
Get the cardiac basis coefficients for the provided cardiac gate and basis function.