198 else cout <<
"This optimizer is a total non-sense, not compatible with histogram nor list-mode data !!!" << endl;
211 Cerr(
"***** vOptimizer::CheckParameters() -> oImageDimensionsAndQuantification is null !" << endl);
217 Cerr(
"***** vOptimizer::CheckParameters() -> No or meaningless data mode provided !" << endl);
223 Cerr(
"***** vOptimizer::CheckParameters() -> No or meaningless data type provided !" << endl);
229 Cerr(
"***** vOptimizer::CheckParameters() -> Verbose level is negative !" << endl);
235 Cerr(
"***** vOptimizer::CheckParameters() -> The selected optimizer is not compatible with listmode data !" << endl);
241 Cerr(
"***** vOptimizer::CheckParameters() -> The selected optimizer is not compatible with histogram data !" << endl);
247 Cerr(
"***** vOptimizer::CheckParameters() -> Asked to compute FOMs in the data-space whereas the verbose is not set !" << endl);
253 Cerr(
"***** vOptimizer::CheckParameters() -> Asked to compute image update statistics whereas the verbose is not set !" << endl);
259 Cerr(
"***** vOptimizer::CheckParameters() -> Computing FOMs in the data-space with list-mode data is not possible !" << endl);
265 Cerr(
"***** vOptimizer::CheckParameters() -> A problem occured while checking parameters specific to the optimizer module !" << endl);
342 Cerr(
"***** vOptimizer::Initialize() -> A problem occured while initializing stuff specific to the optimizer module !" << endl);
374 Cerr(
"***** vOptimizer::PreDataUpdateStep() -> A problem occured while applying the specific pre-data-update step of the optimizer module !" << endl);
403 Cout(
"vOptimizer::PostDataUpdateStep() -> Data-space figures-of-merit" << endl);
438 Cout(spaces_fr << spaces_rg << spaces_cg <<
" --> Number of data channels used in optimization: " <<
m4p_FOMNbBins[fr][rg][cg][0] << endl);
439 Cout(spaces_fr << spaces_rg << spaces_cg <<
" --> Mean number of data counts per channel: " <<
m4p_FOMNbData[fr][rg][cg][0] << endl);
440 Cout(spaces_fr << spaces_rg << spaces_cg <<
" --> Log-likelihood: " <<
m4p_FOMLogLikelihood[fr][rg][cg][0] << endl);
441 Cout(spaces_fr << spaces_rg << spaces_cg <<
" --> RMSE: " <<
m4p_FOMRMSE[fr][rg][cg][0] << endl);
449 Cerr(
"***** vOptimizer::PostDataUpdateStep() -> A problem occured while applying the specific post-data-update step of the optimizer module !" << endl);
473 int a_bed,
int a_timeFrame,
int a_respGate,
int a_cardGate,
492 if (time_basis_coef==0.)
continue;
498 if (resp_basis_coef==0.)
continue;
504 if (card_basis_coef==0.)
continue;
506 FLTNB global_basis_coef = time_basis_coef * resp_basis_coef * card_basis_coef;
536 int a_bed,
int a_timeFrame,
int a_respGate,
int a_cardGate,
537 int a_iteration,
int a_th )
549 int a_bed,
int a_timeFrame,
int a_respGate,
int a_cardGate,
571 Cerr(
"***** vOptimizer::DataStep3BackwardProjectSensitivity() -> A problem occured while performing the sensitivity specific operations !" << endl);
588 int a_bed,
int a_timeFrame,
int a_respGate,
int a_cardGate,
589 int a_iteration,
int a_th )
601 int a_bed,
int a_timeFrame,
int a_respGate,
int a_cardGate,
621 Cerr(
"***** vOptimizer::DataStep5ComputeCorrections() -> A problem occured while performing specific data space operations !" << endl);
636 int a_bed,
int a_timeFrame,
int a_respGate,
int a_cardGate,
637 int a_iteration,
int a_th )
649 int a_bed,
int a_timeFrame,
int a_respGate,
int a_cardGate,
661 if (time_basis_coef==0.)
continue;
667 if (resp_basis_coef==0.)
continue;
673 if (card_basis_coef==0.)
continue;
675 FLTNB global_basis_coef = time_basis_coef * resp_basis_coef * card_basis_coef;
704 int a_timeFrame,
int a_respGate,
int a_cardGate,
714 if (model>1.e-10)
m4p_FOMLogLikelihood[a_timeFrame][a_respGate][a_cardGate][a_thread] += data*log(model)-model;
716 m4p_FOMRMSE[a_timeFrame][a_respGate][a_cardGate][a_thread] += (data-model)*(data-model);
718 m4p_FOMNbBins[a_timeFrame][a_respGate][a_cardGate][a_thread]++;
720 m4p_FOMNbData[a_timeFrame][a_respGate][a_cardGate][a_thread] += ((double)data);
734 if (
m_verbose>=3)
Cout(
"vOptimizer::UpdateVisitedVoxels() -> Tick visited voxels based on sensitivity" << endl);
737 int thread0 = 0;
int frame0 = 0;
int resp_gate0 = 0;
int card_gate0 = 0;
766 else Cout(spaces_tbf <<
"--> Time basis function: " << tbf+1 << endl);
775 else Cout(spaces_tbf << spaces_rbf <<
"--> Respiratory basis function: " << rbf+1 << endl);
784 else Cout(spaces_tbf << spaces_rbf << spaces_cbf <<
"--> Cardiac basis function: " << cbf+1 << endl);
807 #pragma omp parallel for private(v) schedule(guided)
813 th = omp_get_thread_num();
818 if (sensitivity<=0.)
continue;
838 Cerr(
"***** vOptimizer::ImageUpdateStep() -> A problem occured in while performing image space specific operations of the optimizer !" << endl);
849 double sample = ((double)(ap_Image->
m4p_image[tbf][rbf][cbf][v]));
854 sample = ((double)(ap_Image->
m4p_image[tbf][rbf][cbf][v] - old_image_value));
882 mp_imageStatMean[0] = (count1*mp_imageStatMean[0] + count2*mp_imageStatMean[th]) / count12;
886 mp_correctionStatMean[0] = (count1*mp_correctionStatMean[0] + count2*mp_correctionStatMean[th]) / count12;
892 Cout(spaces_tbf << spaces_rbf << spaces_cbf <<
" --> Image update step "
895 Cout(spaces_tbf << spaces_rbf << spaces_cbf <<
" --> New image estimate"
944 int a_timeBasisFunction,
int a_respBasisFunction,
int a_cardBasisFunction,
945 int a_voxel,
int a_nbSubsets )
948 FLTNB sensitivity = 0.;
954 if (time_basis_coef==0.)
continue;
960 if (resp_basis_coef==0.)
continue;
966 if (card_basis_coef==0.)
continue;
968 sensitivity += a4p_sensitivityMatrix[fr][rg][cg][a_voxel] *
969 time_basis_coef * resp_basis_coef * card_basis_coef;
double * mp_imageStatVariance
FLTNB **** m4p_forwardImage
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...
virtual int PostDataUpdateSpecificStep(int a_iteration, int a_nbIterations, int a_subset, int a_nbSubsets)
A private function used to perform any step required by the child optimizer, after the loop on event ...
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
FLTNB GetRespBasisCoefficient(int a_respBasisFunction, int a_respGate)
Get the respiratory basis coefficients for the provided respiratory gate and basis function...
double * mp_correctionStatMean
void SetCurrentTOFBin(int a_TOFBin)
This function is used to set the current TOF bin that is used.
oImageDimensionsAndQuantification * mp_ImageDimensionsAndQuantification
virtual int DataStep3BackwardProjectSensitivity(oProjectionLine *ap_Line, oImageSpace *ap_Image, 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.
#define TYPE_TRANSMISSION
virtual int CheckSpecificParameters()=0
A private function used to check the parameters settings specific to the child optimizer.
virtual int ImageUpdateStep(oImageSpace *ap_Image, int a_iteration, int a_nbSubsets)
A public function used to perform the image update step of the 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.
uint64_t **** m4p_FOMNbBins
double * mp_correctionStatVariance
virtual int DataStep1ForwardProjectModel(oProjectionLine *ap_Line, oImageSpace *ap_Image, 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.
bool GetRespStaticFlag()
Get the respiratory static flag that says if the reconstruction has only one respiratory gate or not...
FLTNB * mp_visitedVoxelsImage
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...
virtual int DataSpaceSpecificOperations(FLTNB a_data, FLTNB a_forwardModel, FLTNB *ap_backwardValues, FLTNB a_multiplicativeCorrections, FLTNB a_additiveCorrections, FLTNB a_quantificationFactor, oProjectionLine *ap_Line)=0
A private function used to compute the correction term in the data space from the provided data...
FLTNB ****** m6p_backwardImage
bool GetCardStaticFlag()
Get the cardiac static flag that says if the reconstruction has only one cardiac gate or not...
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 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.
int PreDataUpdateStep(int a_iteration, int a_nbIterations, int a_subset, int a_nbSubsets)
A public function used to do stuff that need to be done at the beginning of a subset (before the data...
Declaration of class vOptimizer.
FLTNB ** m2p_attenuationImage
virtual int DataStep4Optional(oProjectionLine *ap_Line, oImageSpace *ap_Image, 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.
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.
double **** m4p_FOMNbData
int UpdateVisitedVoxels(oImageSpace *ap_Image)
A public function used to update the 'visited' voxels after each subset.
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...
int PostDataUpdateStep(int a_iteration, int a_nbIterations, int a_subset, int a_nbSubsets)
A public function used to do stuff that need to be done at the beginning of a subset (before the data...
virtual int PreDataUpdateSpecificStep(int a_iteration, int a_nbIterations, int a_subset, int a_nbSubsets)
A private function used to perform any step required by the child optimizer, before the loop on event...
virtual int DataStep2Optional(oProjectionLine *ap_Line, oImageSpace *ap_Image, 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 ~vOptimizer()
The destructor of vOptimizer.
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.
This class holds all the matrices in the image domain that can be used in the algorithm: image...
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 GetNbThreadsForProjection()
Get the number of threads used for projections.
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)=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 DataStep7BackwardProjectCorrections(oProjectionLine *ap_Line, oImageSpace *ap_Image, 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.
double * mp_imageStatMean
FLTNB ** m2p_forwardValues
int GetNbRespBasisFunctions()
Get the number of respiratory basis functions.
virtual int DataStep6Optional(oProjectionLine *ap_Line, oImageSpace *ap_Image, 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.
FLTNB ***** m5p_sensitivity
FLTNB *** m3p_backwardValues
int CheckParameters()
A public function used to check the parameters settings.
virtual int SensitivitySpecificOperations(FLTNB a_data, FLTNB a_forwardModel, FLTNB *ap_weight, FLTNB a_multiplicativeCorrections, FLTNB a_additiveCorrections, FLTNB a_quantificationFactor, oProjectionLine *ap_Line)=0
A private function used to compute the sensitivity weight associated to the provided data...
FLTNB GetCardBasisCoefficient(int a_cardBasisFunction, int a_cardGate)
Get the cardiac basis coefficients for the provided cardiac gate and basis function.