8 #include "oOptimizerManager.hh" 9 #include "sOutputManager.hh" 10 #include "sAddonManager.hh" 66 Cerr(
"***** oOptimizerManager::CheckParameters() -> No image dimensions provided !" << endl);
72 Cerr(
"***** oOptimizerManager::CheckParameters() -> No image space provided !" << endl);
78 Cerr(
"***** oOptimizerManager::CheckParameters() -> No or meaningless data mode provided !" << endl);
84 Cerr(
"***** oOptimizerManager::CheckParameters() -> No or meaningless data type provided !" << endl);
90 Cerr(
"***** oOptimizerManager::CheckParameters() -> No or meaningless data specificity provided (emission or transmission) !" << endl);
96 Cerr(
"***** oOptimizerManager::CheckParameters() -> No optimizer options provided !" << endl);
102 Cerr(
"***** oOptimizerManager::CheckParameters() -> Wrong verbosity level provided !" << endl);
117 if (
m_verbose>=1)
Cout(
"oOptimizerManager::Initialize() -> Initialize optimizer and penalty" << endl);
122 Cerr(
"***** oOptimizerManager::Initialize() -> A problem occurred while parsing optimizer options and initializing it !" << endl);
141 string name_optimizer =
"";
142 string list_options_optimizer =
"";
143 string file_options_optimizer =
"";
154 Cerr(
"***** oOptimizerManager::ParseOptionsAndInitializeOptimizerAndPenalty() -> No optimizer provided !" << endl);
163 if (colon!=string::npos)
170 list_options_optimizer =
"";
173 else if (comma!=string::npos)
180 file_options_optimizer =
"";
188 list_options_optimizer =
"";
191 file_options_optimizer = p_output_manager->
GetPathToConfigDir() +
"/optimizer/" + name_optimizer +
".conf";
200 if (list_optimizer[name_optimizer])
mp_Optimizer = list_optimizer[name_optimizer]();
203 Cerr(
"***** oOptimizerManager::ParseOptionsAndInitializeOptimizerAndPenalty() -> Optimizer '" << name_optimizer <<
"' does not exist !" << endl);
221 Cerr(
"***** oOptimizerManager::ParseOptionsAndInitializeOptimizerAndPenalty() -> A problem occurred while reading and checking optimizer's configuration file !" << endl);
227 Cerr(
"***** oOptimizerManager::ParseOptionsAndInitializeOptimizerAndPenalty() -> A problem occurred while parsing and reading optimizer's options !" << endl);
233 Cerr(
"***** oOptimizerManager::ParseOptionsAndInitializeOptimizerAndPenalty() -> A problem occurred while checking optimizer parameters !" << endl);
241 string name_penalty =
"";
242 string list_options_penalty =
"";
243 string file_options_penalty =
"";
246 typedef vPenalty *(*maker_penalty) ();
258 Cerr(
"***** oOptimizerManager::ParseOptionsAndInitializeOptimizerAndPenalty() -> Penalty provided while the selected optimizer does not accept penalties !" << endl);
259 Cerr(
" Remove penalty or change for another optimizer that accepts penalties." << endl);
266 if (colon!=string::npos)
273 list_options_penalty =
"";
276 else if (comma!=string::npos)
283 file_options_penalty =
"";
291 list_options_penalty =
"";
294 file_options_penalty = p_output_manager->
GetPathToConfigDir() +
"/optimizer/" + name_penalty +
".conf";
301 if (list_penalty[name_penalty])
mp_Penalty = list_penalty[name_penalty]();
304 Cerr(
"***** oOptimizerManager::ParseOptionsAndInitializeOptimizerAndPenalty() -> Penalty '" << name_penalty <<
"' does not exist !" << endl);
318 Cerr(
"***** oOptimizerManager::ParseOptionsAndInitializeOptimizerAndPenalty() -> A problem occurred while reading and checking penalty's configuration file !" << endl);
324 Cerr(
"***** oOptimizerManager::ParseOptionsAndInitializeOptimizerAndPenalty() -> A problem occurred while parsing and reading penalty's options !" << endl);
330 Cerr(
"***** oOptimizerManager::ParseOptionsAndInitializeOptimizerAndPenalty() -> A problem occurred while checking penalty parameters !" << endl);
336 Cerr(
"***** oOptimizerManager::ParseOptionsAndInitializeOptimizerAndPenalty() -> A problem occurred while initializing the penalty !" << endl);
342 Cerr(
"***** oOptimizerManager::ParseOptionsAndInitializeOptimizerAndPenalty() -> Derivatives order allowed by chosen penalty is not compatible with the order required by the optimizer !" << endl);
352 Cerr(
"***** oOptimizerManager::ParseOptionsAndInitializeOptimizerAndPenalty() -> A problem occurred while initializing the optimizer !" << endl);
370 Cerr(
"***** oOptimizerManager::PreDataUpdateStep() -> A problem occurred while applying the pre-data-update step to the optimizer !" << endl);
387 Cerr(
"***** oOptimizerManager::PreImageUpdateStep() -> A problem occurred while applying the pre-image-update step to the optimizer !" << endl);
400 int a_bed,
int a_timeFrame,
int a_respGate,
int a_cardGate,
411 if (multiplicative_correction<=0.)
return 0;
431 Cerr(
"***** oOptimizerManager::DataUpdateStep() -> An error occurred while forward projecting !" << endl);
438 Cerr(
"***** oOptimizerManager::DataUpdateStep() -> An error occurred while performing optional step 1 !" << endl);
446 Cerr(
"***** oOptimizerManager::DataUpdateStep() -> An error occurred while backward projecting the sensitivity !" << endl);
453 Cerr(
"***** oOptimizerManager::DataUpdateStep() -> An error occurred while performing optional step 2 !" << endl);
460 Cerr(
"***** oOptimizerManager::DataUpdateStep() -> An error occurred while computing correction terms !" << endl);
467 Cerr(
"***** oOptimizerManager::DataUpdateStep() -> An error occurred while performing optional step 3 !" << endl);
474 Cerr(
"***** oOptimizerManager::DataUpdateStep() -> An error occurred while backward projecting the correction !" << endl);
481 Cerr(
"***** oOptimizerManager::DataUpdateStep() -> An error occurred while computing FOMs !" << endl);
497 if (
m_verbose>=2)
Cout(
"oOptimizerManager::ImageUpdateStep() -> Proceed to image update" << endl);
501 Cerr(
"***** oOptimizerManager::ImageUpdateStep() -> Problem while updating visited voxels !" << endl);
507 Cerr(
"***** oOptimizerManager::ImageUpdateStep() -> Problem while updating image space !" << endl);
virtual int ReadConfigurationFile(const string &a_configurationFile)=0
void SetPenaltyID(const string &a_penaltyID)
virtual int ReadOptionsList(const string &a_optionsList)=0
bool GetNeedGlobalSensitivity()
Get the boolean saying if the sensitivity has to be computed globally for all data channels and not p...
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
virtual int DataStep2Optional(oProjectionLine *ap_Line, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_thread)
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
int PreImageUpdateStep()
A function that simply calls the eponym function from the vOptimizer.
void SetVerbose(int a_verbose)
void SetMultiplicativeCorrection(FLTNB a_multiplicativeCorrection)
virtual int ImageUpdateStep()
A public function used to perform the image update step of the optimizer.
void SetDataType(int a_dataType)
virtual FLTNB GetMultiplicativeCorrections()=0
This is a pure virtual function implemented in the child classes.
static sOutputManager * GetInstance()
Instanciate the singleton object and Initialize member variables if not already done, return a pointer to this object otherwise.
int PreDataUpdateStep()
A public function used to do stuff that need to be done at the beginning of a subset (before the data...
int Initialize()
A function used to initialize the manager and the optimizer it manages.
int DataUpdateStep(oProjectionLine *ap_Line, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_thread)
int Initialize()
A public function used to initialize the penalty.
static sAddonManager * GetInstance()
void SetFOMFlag(bool a_optimizerFOMFlag)
void SetImageSpace(oImageSpace *ap_ImageSpace)
virtual int DataStep6Optional(oProjectionLine *ap_Line, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_thread)
bool m_optimizerImageStatFlag
int ParseOptionsAndInitializeOptimizerAndPenalty()
int GetRequiredPenaltyDerivativesOrder()
Get the penalty derivative order needed for this algorithm.
std::map< string, maker_optimizer > mp_listOfOptimizers
bool GetAcceptPenalty()
Get the boolean saying if the optimizer accepts penalties.
void SetAttenuationImage(FLTNB *ap_attenuationImage, int a_thread)
Singleton class that manages output writing on disk (images, sinograms, etc). It also manages loggi...
const string & GetPathToConfigDir()
Return the path to the CASTOR config directory.
virtual int DataStep3BackwardProjectSensitivity(oProjectionLine *ap_Line, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_thread)
std::map< string, maker_penalty > mp_listOfPenalties
int PreDataUpdateStep()
A function that simply calls the eponym function from the vOptimizer.
void SetOptimizerID(const string &a_optimizerID)
virtual int DataStep1ForwardProjectModel(oProjectionLine *ap_Line, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_thread)
void SetDataMode(int a_dataMode)
void SetDataFile(vDataFile *ap_DataFile)
Set the image space in use.
FLTNB GetQuantificationFactor(int a_bed, int a_frame, int a_respGate, int a_cardGate)
This class is designed to generically described any penalty applied to MAP algorithms.
virtual int DataStep8ComputeFOM(oProjectionLine *ap_Line, vEvent *ap_Event, int a_timeFrame, int a_respGate, int a_cardGate, int a_thread)
void SetNbTOFBins(int a_nbTOFBins)
FLTNB **** m4p_attenuation
int CheckParameters()
A function used to check the parameters settings.
void SetDataFile(vDataFile *ap_DataFile)
Set the data file in use.
void SetVerbose(int a_verbose)
int GetPenaltyDerivativesOrder()
Get the penalty deratives order.
#define SPEC_TRANSMISSION
void SetPenaltyStrength(FLTNB a_penaltyStrength)
int CheckParameters()
A public function used to check the parameters settings.
oImageSpace * mp_ImageSpace
int PreImageUpdateStep()
A public function used to do stuff that need to be done between the loop over events and the image up...
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...
~oOptimizerManager()
The destructor of oOptimizerManager.
void SetImageStatFlag(bool a_optimizerImageStatFlag)
int Initialize()
A public function used to initialize the optimizer.
virtual int DataStep4Optional(oProjectionLine *ap_Line, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_thread)
Mother class for the Event objects.
virtual int DataStep5ComputeCorrections(oProjectionLine *ap_Line, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_thread)
int ImageUpdateStep()
A function dedicated to the update step in the image space (performed after the loop on events) ...
oOptimizerManager()
The constructor of oOptimizerManager.
int UpdateVisitedVoxels()
A public function used to update the 'visited' voxels after each subset.
void SetImageSpace(oImageSpace *ap_ImageSpace)
virtual int ReadConfigurationFile(const string &a_configurationFile)=0
void SetDataSpec(int a_dataSpec)
virtual int DataStep7BackwardProjectCorrections(oProjectionLine *ap_Line, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_thread)
string m_optionsOptimizer
void SetPenalty(vPenalty *ap_penalty)
int CheckParameters()
A public function used to check the parameters settings.
oImageDimensionsAndQuantification * mp_ImageDimensionsAndQuantification
vOptimizer * mp_Optimizer
virtual int ReadOptionsList(const string &a_optionsList)=0