8 #include "iOptimizerOneStepLate.hh" 9 #include "sOutputManager.hh" 81 Cerr(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl);
82 Cerr(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl);
83 Cerr(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl);
84 Cerr(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl);
85 Cerr(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl);
86 Cerr(
"!!!!! iOptimizerOneStepLate::Destructor() -> Several times, the update factor was not positive and was set to 1. !!!!!" << endl);
87 Cerr(
"!!!!! For convenience, it was advertised only the first time. But this may be a sign that the penalty strength !!!!!" << endl);
88 Cerr(
"!!!!! is too high for this approximative algorithm. It may also be due to voxels close to FOV extremities. Be !!!!!" << endl);
89 Cerr(
"!!!!! sure to double check your images ! !!!!!" << endl);
90 Cerr(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl);
91 Cerr(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl);
92 Cerr(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl);
93 Cerr(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl);
94 Cerr(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl);
105 cout <<
"This optimizer is the One-Step-Late algorithm from P. J. Green, IEEE TMI, Mar 1990, vol. 9, pp. 84-93." << endl;
106 cout <<
"Subsets can be used as for OSEM. It accepts penalty terms that have a derivative order of at least one." << endl;
107 cout <<
"Without penalty, it is stricly equivalent to the MLEM algorithm." << endl;
108 cout <<
"It is numerically implemented in the multiplicative form (as opposed to the gradient form)." << endl;
109 cout <<
"The following options can be used (in this particular order when provided as a list):" << endl;
110 cout <<
" initial image value: to set the uniform voxel value for the initial image" << endl;
111 cout <<
" denominator threshold: to set the threshold of the data space denominator under which the ratio is set to 1" << endl;
112 cout <<
" minimum image update: to set the minimum of the image update factor under which it stays constant (0 or a negative value" << endl;
113 cout <<
" means no minimum thus allowing a 0 update)" << endl;
114 cout <<
" maximum image update: to set the maximum of the image update factor over which it stays constant (0 or a negative value means" << endl;
115 cout <<
" no maximum)" << endl;
125 string key_word =
"";
127 key_word =
"initial image value";
130 Cerr(
"***** iOptimizerOneStepLate::ReadAndCheckConfigurationFile() -> Failed to get the '" << key_word <<
"' keyword !" << endl);
134 key_word =
"denominator threshold";
137 Cerr(
"***** iOptimizerOneStepLate::ReadAndCheckConfigurationFile() -> Failed to get the '" << key_word <<
"' keyword !" << endl);
141 key_word =
"minimum image update";
144 Cerr(
"***** iOptimizerOneStepLate::ReadAndCheckConfigurationFile() -> Failed to get the '" << key_word <<
"' keyword !" << endl);
148 key_word =
"maximum image update";
151 Cerr(
"***** iOptimizerOneStepLate::ReadAndCheckConfigurationFile() -> Failed to get the '" << key_word <<
"' keyword !" << endl);
166 const int nb_options = 4;
167 FLTNB options[nb_options];
169 if (
ReadStringOption(a_optionsList, options, nb_options,
",",
"OneStepLate configuration"))
171 Cerr(
"***** iOptimizerOneStepLate::ReadAndCheckConfigurationFile() -> Failed to correctly read the list of options !" << endl);
193 Cerr(
"***** iOptimizerOneStepLate->Initialize() -> Provided initial image value (" <<
m_initialValue <<
") must be strictly positive !" << endl);
199 Cerr(
"***** iOptimizerOneStepLate->Initialize() -> Provided data space denominator threshold (" <<
m_dataSpaceDenominatorThreshold <<
") must be strictly positive !" << endl);
211 Cerr(
"***** iOptimizerMLEM->CheckSpecificParameters() -> Cannot reconstruct list-mode transmission data !" << endl);
250 Cout(
"iOptimizerOneStepLate::Initialize() -> Use the OneStepLate optimizer" << endl);
256 else Cerr(
"!!!!! The minimum update value is not set, if using subsets, voxels could be trapped in 0 value causing some negative bias !" << endl);
279 if (
m_verbose>=1)
Cout(
"iOptimizerOneStepLate::PreImageUpdateSpecificStep() -> Compute penalty term" << endl);
284 Cerr(
"***** iOptimizerOneStepLate::PreImageUpdateSpecificStep() -> A problem occurred while computing the penalty pre-processing step !" << endl);
298 bool problem =
false;
302 #pragma omp parallel for private(v) schedule(guided) 308 th = omp_get_thread_num();
313 Cerr(
"***** iOptimizerOneStepLate::PreImageUpdateSpecificStep() -> A problem occurred while computing the penalty local pre-processing step for voxel " << v <<
" !" << endl);
322 Cerr(
"***** iOptimizerOneStepLate::PreImageUpdateSpecificStep() -> A problem occurred inside the multi-threaded loop, stop now !" << endl);
337 FLTNB a_multiplicativeCorrections,
FLTNB a_additiveCorrections,
FLTNB a_blankValue,
351 FLTNB a_multiplicativeCorrections,
FLTNB a_additiveCorrections,
FLTNB a_blankValue,
358 if (a_data<0.) a_data = 0.;
361 else *ap_backwardValues = 1.;
367 a_data -= a_additiveCorrections;
368 a_forwardModel -= a_additiveCorrections;
372 if (a_data<1. || a_forwardModel<1. || a_data>a_blankValue || a_forwardModel>a_blankValue)
374 *ap_backwardValues = 1.;
378 a_data = log(a_blankValue/a_data);
379 a_forwardModel = log(a_blankValue/a_forwardModel);
382 else *ap_backwardValues = 1.;
394 FLTNB a_sensitivity,
FLTNB* ap_correctionValues,
395 INTNB a_voxel,
int a_tbf,
int a_rbf,
int a_cbf )
398 FLTNB image_update_factor = 0.;
402 if (sensitivity_plus_penalty <= 0.)
405 image_update_factor = 1.;
408 Cerr(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl);
409 Cerr(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl);
410 Cerr(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl);
411 Cerr(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl);
412 Cerr(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl);
413 Cerr(
"!!!!! iOptimizerOneStepLate::ImageSpaceSpecificOperations() -> The update factor was not positive ! It has been set to 1. !!!!!" << endl);
414 Cerr(
"!!!!! This may be a sign that the penalty strength is too high, but it may only be due to voxels close to FOV extremities. !!!!!" << endl);
415 Cerr(
"!!!!! For convenience, this warning will appear only for this update. Be careful about your results ! !!!!!" << endl);
416 Cerr(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl);
417 Cerr(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl);
418 Cerr(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl);
419 Cerr(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl);
420 Cerr(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl);
429 image_update_factor = *ap_correctionValues / sensitivity_plus_penalty;
436 *ap_newImageValue = a_currentImageValue * image_update_factor;
FLTNB m_maximumImageUpdateFactor
int m_requiredPenaltyDerivativesOrder
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.
int GetNbCardBasisFunctions()
Get the number of cardiac basis functions.
void ShowHelpSpecific()
A function used to show help about the child optimizer.
bool m_listmodeCompatibility
oImageDimensionsAndQuantification * mp_ImageDimensionsAndQuantification
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)
virtual int LocalPreProcessingStep(int a_tbf, int a_rbf, int a_cbf, INTNB a_voxel, int a_th)
int GetNbTimeBasisFunctions()
Get the number of time basis functions.
int ImageSpaceSpecificOperations(FLTNB a_currentImageValue, FLTNB *ap_newImageValue, FLTNB a_sensitivity, FLTNB *ap_correctionValues, INTNB a_voxel, int a_tbf=-1, int a_rbf=-1, int a_cbf=-1)
int ReadOptionsList(const string &a_optionsList)
bool m_emissionCompatibility
int ReadConfigurationFile(const string &a_configurationFile)
bool m_displayWarningFlag
virtual int GlobalPreProcessingStep()
A public function computing a global pre-processing step for the penalty.
FLTNB m_minimumImageUpdateFactor
~iOptimizerOneStepLate()
The destructor of iOptimizerOneStepLate.
bool m_histogramCompatibility
FLTNB **** m4p_firstDerivativePenaltyImage
oImageSpace * mp_ImageSpace
#define KEYWORD_MANDATORY
#define SPEC_TRANSMISSION
bool m_transmissionCompatibility
This class is designed to generically described any iterative optimizer.
This class is designed to manage and store system matrix elements associated to a vEvent...
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)
int GetNbThreadsForImageComputation()
Get the number of threads used for image operations.
FLTNB m_dataSpaceDenominatorThreshold
INTNB GetNbVoxXYZ()
Get the total number of voxels.
virtual FLTNB ComputeFirstDerivative(int a_tbf, int a_rbf, int a_cbf, INTNB a_voxel, int a_th)=0
iOptimizerOneStepLate()
The constructor of iOptimizerOneStepLate.
int ReadDataASCIIFile(const string &a_file, const string &a_keyword, T *ap_return, int a_nbElts, bool a_mandatoryFlag)
Look for "a_nbElts" elts in the "a_file" file matching the "a_keyword" string passed as parameter a...
int InitializeSpecific()
This function is used to initialize specific stuff to the child optimizer.
int GetNbRespBasisFunctions()
Get the number of respiratory basis functions.
int PreImageUpdateSpecificStep()
A private function used to compute the penalty term of the OneStepLate algorithm. ...
int CheckSpecificParameters()
A private function used to check the parameters settings specific to the child optimizer.