88 if (a_nbIterationsSubsets==
"")
return 0;
93 string buf = a_nbIterationsSubsets;
97 while ((pos_comma=buf.find_first_of(
","))!=string::npos)
100 string sub_buf = buf.substr(0,pos_comma);
102 size_t pos_column = sub_buf.find_first_of(
":");
103 if (pos_column==string::npos || pos_column==0)
105 Cerr(
"***** vAlgorithm::SetNbIterationsAndSubsets() -> Syntax problem in number of iterations and subsets !" << endl);
108 int iter = atoi( sub_buf.substr(0,pos_column).c_str() );
109 int subs = atoi( sub_buf.substr(pos_column+1).c_str() );
111 for (
int it=0; it<iter; it++) mp_nbSubsets[
m_nbIterations+it] = subs;
113 buf = buf.substr(pos_comma+1);
117 size_t pos_column = buf.find_first_of(
":");
118 if (pos_column==string::npos || pos_column==0)
120 Cerr(
"***** vAlgorithm::SetNbIterationsAndSubsets() -> Syntax problem in number of iterations and subsets !" << endl);
123 int iter = atoi( buf.substr(0,pos_column).c_str() );
124 int subs = atoi( buf.substr(pos_column+1).c_str() );
126 for (
int it=0; it<iter; it++) mp_nbSubsets[
m_nbIterations+it] = subs;
131 Cout(
"vAlgorithm::SetNbIterationsAndSubsets() -> Selected numbers of subsets for each iteration:" << endl);
132 Cout(
" Iteration / number of subsets "<< endl);
133 for (
int it=0 ; it<
m_nbIterations ; it++)
Cout(
" " << it+1 <<
" / " << mp_nbSubsets[it] << endl);
146 if (
m_verbose>=2)
Cout(
"vAlgorithm::SetOutputIterations ..." << endl);
153 if (a_outputIterations==
"")
160 string buf = a_outputIterations;
164 int current_iteration = -1;
165 while ((pos_comma=buf.find_first_of(
","))!=string::npos)
168 string sub_buf = buf.substr(0,pos_comma);
170 size_t pos_column = sub_buf.find_first_of(
":");
171 if (pos_column==string::npos || pos_column==0)
173 Cerr(
"***** vAlgorithm::SetOutputIterations() -> Syntax problem in output iteration numbers !" << endl);
176 int step_iteration = atoi( sub_buf.substr(0,pos_column).c_str() );
177 if (step_iteration<=0)
179 Cerr(
"***** vAlgorithm::SetOutputIterations() -> Iteration step must be strictly positive (here it is " << step_iteration <<
") !" << endl);
182 int stop_iteration = atoi( sub_buf.substr(pos_column+1).c_str() );
183 if (stop_iteration<=current_iteration)
185 Cerr(
"***** oIterationAlgorithm::SetOutputIterations() -> Output iteration number must be increasing through provided couples !" << endl);
188 for (
int it=current_iteration+step_iteration; it<stop_iteration; it+=step_iteration)
if (it<m_nbIterations)
mp_outputIterations[it] =
true;
189 current_iteration = stop_iteration-1;
190 buf = buf.substr(pos_comma+1);
194 size_t pos_column = buf.find_first_of(
":");
195 if (pos_column==string::npos || pos_column==0)
206 Cerr(
"***** vAlgorithm::SetOutputIterations() -> Syntax problem in output iteration numbers !" << endl);
210 int step_iteration = atoi( buf.substr(0,pos_column).c_str() );
211 if (step_iteration<=0)
213 Cerr(
"***** vAlgorithm::SetOutputIterations() -> Iteration step must be strictly positive (here it is " << step_iteration <<
") !" << endl);
216 int stop_iteration = atoi( buf.substr(pos_column+1).c_str() );
217 if (stop_iteration<=current_iteration)
219 Cerr(
"***** oIterationAlgorithm::SetOutputIterations() -> Output iteration number must be increasing through provided couples !" << endl);
222 for (
int it=current_iteration+step_iteration; it<stop_iteration; it+=step_iteration)
if (it<m_nbIterations)
mp_outputIterations[it] =
true;
268 MPI_Barrier(MPI_COMM_WORLD);
275 clock_t clock_start_whole = clock();
276 time_t time_start_whole = time(NULL);
282 Cerr(
"***** vAlgorithm::IterateCPU() -> A problem occurred while calling StepBeforeIterationLoop() function !" << endl);
293 Cerr(
"***** vAlgorithm::IterateCPU() -> A problem occurred while calling StepBeforeSubsetLoop() function !" << endl);
298 for (
int subset=0 ; subset<
mp_nbSubsets[iteration] ; subset++)
303 Cout(
"vAlgorithm::IterateCPU() -> Start iteration " << iteration+1 <<
"/" << m_nbIterations
304 <<
" subset " << subset+1 <<
"/" << mp_nbSubsets[iteration] << endl);
308 clock_t clock_start_subset = clock();
309 time_t time_start_subset = time(NULL);
314 Cerr(
"***** vAlgorithm::IterateCPU() -> A problem occurred while calling StepPreProcessInsideSubsetLoop() function !" << endl);
320 MPI_Barrier(MPI_COMM_WORLD);
324 for (
int bed=0 ; bed<
m_nbBeds ; bed++)
329 Cerr(
"***** vAlgorithm::IterateCPU() -> A problem occurred while calling StepInnerLoopInsideSubsetLoop() function !" << endl);
336 MPI_Barrier(MPI_COMM_WORLD);
342 Cerr(
"***** vAlgorithm::IterateCPU() -> A problem occurred while calling StepPostProcessInsideSubsetLoop() function !" << endl);
347 clock_t clock_stop_subset = clock();
348 time_t time_stop_subset = time(NULL);
349 if (
m_verbose>=2)
Cout (
"vAlgorithm::IterateCPU() -> Time spent for subset " << subset+1 <<
" | User: " << time_stop_subset-time_start_subset
350 <<
" sec | CPU: " << (clock_stop_subset-clock_start_subset)/((
FLTNB)CLOCKS_PER_SEC) <<
" sec" << endl);
359 Cerr(
"***** vAlgorithm::IterateCPU() -> A problem occurred while calling StepAfterSubsetLoop() function !" << endl);
369 Cerr(
"***** vAlgorithm::IterateCPU() -> A problem occurred while calling StepAfterIterationLoop() function !" << endl);
374 clock_t clock_stop_whole = clock();
375 time_t time_stop_whole = time(NULL);
376 if (
m_verbose>=1)
Cout(
"vAlgorithm::IterateCPU() -> Total time spent | User: " << time_stop_whole-time_start_whole
377 <<
" sec | CPU: " << (clock_stop_whole-clock_start_whole)/((
FLTNB)CLOCKS_PER_SEC) <<
" sec" << endl);
390 if (
m_verbose>=2)
Cout(
"vAlgorithm::StepBeforeIterationLoop ... " << endl);
395 Cerr(
"***** vAlgorithm::StepBeforeIterationLoop() -> Image space has not been created or was not checked !" << endl);
408 Cerr(
"***** vAlgorithm::StepBeforeIterationLoop()-> Error during attenuation image initialization !" << endl);
414 Cerr(
"***** vAlgorithm::StepBeforeIterationLoop() -> An error occurred while initializing the sensitivity image !" << endl);
420 Cerr(
"***** vAlgorithm::StepBeforeIterationLoop()-> Error during multimodal image initialization !" << endl);
426 Cerr(
"***** vAlgorithm::StepBeforeIterationLoop()-> Error during mask image initialization !" << endl);
485 if (
m_verbose>=2)
Cout(
"vAlgorithm::StepAfterIterationLoop ... " << endl);
518 (void)a_specificOptions;
oImageConvolverManager * mp_ImageConvolverManager
This header file is mainly used to declare some macro definitions and all includes needed from the st...
oOptimizerManager * mp_OptimizerManager
Declaration of class vAlgorithm.
virtual int InitSpecificOptions(string a_specificOptions)
oImageProcessingManager * mp_ImageProcessingManager
int SetNbIterationsAndSubsets(const string &a_nbIterationsSubsets)
Set the number of iterations and subsets.
int InitMaskImage(const string &a_pathToImage)
Memory allocation and initialization for the mask image.
void DeallocateImage()
Free memory for the main image matrices.
int InitMultiModalImage(const vector< string > &a_pathToMultiModalImage)
Memory allocation and initialization for the multimodal image matrices.
int RunCPU()
Perform the iterative loop of the algorithm. Function designed to be executed on the CPU only...
void DeallocateMultiModalImage()
Free memory for the multimodal image.
oProjectorManager * mp_ProjectorManager
virtual int StepBeforeSubsetLoop(int a_iteration)
This function is called before starting the data subset loop.
int Run()
Just call either the RunCPU or the RunGPU function as asked for.
bool m_saveSensitivityHistoFlag
void DeallocateSensitivityImage()
Free memory for the sensitivity image matrices.
void InstantiateImage()
Allocate memory for the main image matrices.
virtual int StepInnerLoopInsideSubsetLoop(int a_iteration, int a_subset, int a_bed)=0
This function is called inside the subset loop. It contains the core operations of the algorithm an...
void InstantiateSensitivityImage(const string &a_pathToSensitivityImage)
Allocate the sensitivity image matrices.
int InitAttenuationImage(const string &a_pathToAtnImage)
Memory allocation and initialisation for the attenuation image using either :
virtual int StepImageOutput(int a_iteration, int a_subset=-1)=0
This function deals with everything about saving output images from the reconstruction.
void DeallocateVisitedVoxelsImage()
Free memory for the image matrix containing binary information regarding which 3D voxels have been vi...
void DeallocateMaskImage()
Free memory for the mask image.
oImageSpace * mp_ImageSpace
virtual int StepPostProcessInsideSubsetLoop(int a_iteration, int a_subset)
vAlgorithm()
vAlgorithm constructor. Initialize the member variables to their default values.
vDataFile ** m2p_DataFile
bool m_saveDynamicBasisCoefficients
string m_pathToSensitivityImg
void InstantiateVisitedVoxelsImage()
Memory allocation and initialization for the image matrix containing binary information regarding whi...
string m_pathToInitialImg
oDynamicModelManager * mp_DynamicModelManager
Declaration of class iEventHistoCT.
virtual int StepPreProcessInsideSubsetLoop(int a_iteration, int a_subset)
This function is called right after starting the data subset loop.
virtual int StepBeforeIterationLoop()
This function is called at the beginning of the RunCPU function.
bool m_saveImageAfterSubsets
virtual ~vAlgorithm()
vAlgorithm destructor.
void InstantiateForwardImage()
Allocate memory for the forward image matrices.
oDeformationManager * mp_DeformationManager
virtual int StepAfterSubsetLoop(int a_iteration)
This function is called after finishing the data subset loop.
oImageDimensionsAndQuantification * mp_ID
vector< string > m_pathToMultiModalImg
virtual int StepAfterIterationLoop()
This function is called at the end of the RunCPU function.
void DeallocateOutputImage()
Free memory for the Image matrices dedicated to output writing on disk.
int SetOutputIterations(const string &a_outputIterations)
Set the selected output iterations.
bool * mp_outputIterations
bool Checked()
Simply check that the image dimensions and verbosity has been set.
int InitSensitivityImage(const string &a_pathToSensitivityImage)
Initialization for the sensitivity image matrices.
void DeallocateForwardImage()
Free memory for the forward image matrices.
void InstantiateOutputImage()
Instanciate Image matrices dedicated to output writing on disk.