61 Cerr(
"***** iIterativeAlgorithm::StepBeforeIterationLoop() -> A problem occurred while calling StepBeforeIterationLoop() function !" << endl);
64 if (
m_verbose>=2)
Cout(
"iIterativeAlgorithm::StepBeforeIterationLoop ... " << endl);
72 Cerr(
"***** iIterativeAlgorithm::StepBeforeIterationLoop() -> An error occurred while reading the initialization image !" << endl);
90 if (
m_verbose>=3)
Cout(
"iIterativeAlgorithm::StepBeforeSubsetLoop ... " << endl);
106 if (
m_verbose>=3)
Cout(
"iIterativeAlgorithm::StepPreProcessInsideSubsetLoop ... " << endl);
123 Cerr(
"***** iIterativeAlgorithm::StepPreProcessInsideSubsetLoop() -> A problem occurred while applyin image processing to forward image !" << endl);
131 Cerr(
"***** iIterativeAlgorithm::StepPreProcessInsideSubsetLoop() -> A problem occurred while applying image convolver to forward image !" << endl);
159 if (
m_nbBeds>1)
Cout(
"iIterativeAlgorithm::StepInnerLoopInsideSubsetLoop() -> Start loop over events for bed " << a_bed+1 << endl << flush);
160 else Cout(
"iIterativeAlgorithm::StepInnerLoopInsideSubsetLoop() -> Start loop over events" << endl << flush);
172 cout <<
"0 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%" << endl;
173 cout <<
"|----|----|----|----|----|----|----|----|----|----|" << endl;
174 cout <<
"|" << flush;
176 int progression_percentage_old = 0;
177 int progression_nb_bars = 0;
178 uint64_t progression_printing_index = 0;
181 int64_t index_start = 0;
182 int64_t index_stop = 0;
187 MPI_Barrier(MPI_COMM_WORLD);
196 bool problem =
false;
208 #pragma omp parallel for private(index) schedule(static, 1) 209 for ( index = index_start ; index < index_stop ; index +=
mp_nbSubsets[a_iteration] )
214 th = omp_get_thread_num();
219 if (progression_printing_index%1000==0)
221 int progression_percentage_new = ((int)( (((
float)(index-index_start+1))/((float)(index_stop-index_start)) ) * 100.));
222 if (progression_percentage_new>=progression_percentage_old+2)
224 int nb_steps = (progression_percentage_new-progression_percentage_old)/2;
225 for (
int i=0; i<nb_steps; i++)
227 cout <<
"-" << flush;
228 progression_nb_bars++;
230 progression_percentage_old += nb_steps*2;
233 progression_printing_index++;
236 if (p_end_loop_flags[th])
continue;
241 if (
m_verbose>=4)
Cout(
"iIterativeAlgorithm::StepInnerLoopInsideSubsetLoop() -> Step1: Get current event for that thread index " << endl);
246 Cerr(
"***** iIterativeAlgorithm::StepInnerLoopInsideSubsetLoop() -> An error occurred while getting the event from index " 247 << index <<
" (thread " << th <<
") !" << endl);
260 Cout(
"iIterativeAlgorithm::StepInnerLoopInsideSubsetLoop() -> Step2: Check for Dynamic event (frame/gate switch, image-based deformation " << endl);
263 int dynamic_switch_value =
mp_ID->
DynamicSwitch(index, event->GetTimeInMs(), a_bed, th);
276 #pragma omp critical (deformation_requirements_first) 281 bool wait_for_deformation =
true;
282 while (wait_for_deformation)
288 bool all_threads_ready =
false;
290 #pragma omp critical (deformation_requirements_first) 294 if (all_threads_ready)
299 #pragma omp critical (deformation_requirements_second) 306 #pragma omp critical (deformation_requirements_second) 319 cout <<
"0 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%" << endl;
320 cout <<
"|----|----|----|----|----|----|----|----|----|----|" << endl;
321 int progression_percentage_new = ((int)( (((
float)(index-index_start+1))/((float)(index_stop-index_start)) ) * 100.));
324 for (
int i=0; i< progression_percentage_new / 2 ; i++) cout <<
"-";
331 p_end_loop_flags[th] =
true;
339 if (
m_verbose>=4)
Cout(
"iIterativeAlgorithm::StepInnerLoopInsideSubsetLoop() -> Step3: Compute the projection line " << endl);
344 Cerr(
"***** iIterativeAlgorithm::StepInnerLoopInsideSubsetLoop() -> A problem occurred while computing the projection line !" << endl);
355 if (
m_verbose>=4)
Cout(
"iIterativeAlgorithm::StepInnerLoopInsideSubsetLoop() -> Step4: Optimize in the data space " << endl);
369 MPI_Barrier(MPI_COMM_WORLD);
380 int progression_total_bars = 49;
381 for (
int i=0; i<progression_total_bars-progression_nb_bars; i++) cout <<
"-";
388 Cerr(
"***** iIterativeAlgorithm::StepInnerLoopInsideSubsetLoop() -> A problem occurred inside the parallel loop over events !" << endl);
403 if (
m_verbose>=3)
Cout(
"iIterativeAlgorithm::StepPostProcessInsideSubsetLoop ... " << endl);
421 Cerr(
"***** iIterativeAlgorithm::StepPostProcessInsideSubsetLoop() -> A problem occurred while applying convolver to backward images !" << endl);
429 Cerr(
"***** iIterativeAlgorithm::StepPostProcessInsideSubsetLoop() -> A problem occurred while performing the pre-image-update step !" << endl);
436 Cerr(
"***** iIterativeAlgorithm::StepPostProcessInsideSubsetLoop() -> A problem occurred while performing the image update step !" << endl);
444 Cerr(
"***** iIterativeAlgorithm::StepPostProcessInsideSubsetLoop() -> A problem occurred while applying convolver to current estimate images !" << endl);
452 Cerr(
"***** iIterativeAlgorithm::StepPostProcessInsideSubsetLoop() -> A problem occurred while applying dynamic model to current estimate images !" << endl);
459 Cerr(
"***** iIterativeAlgorithm::StepPostProcessInsideSubsetLoop() -> A problem occurred while applying image processing to current estimate images !" << endl);
470 stringstream temp_it; temp_it << a_iteration + 1;
471 stringstream temp_ss; temp_ss << a_subset + 1;
472 temp_sens.append(
"_it").append(temp_it.str()).append(
"_ss").append(temp_ss.str()).append(
"_sensitivity");
481 if (
m_verbose>=1)
Cout(
"iIterativeAlgorithm::StepPostProcessInsideSubsetLoop() -> Save image at iteration " << a_iteration+1 <<
" for subset " << a_subset+1 << endl);
485 Cerr(
"***** iIterativeAlgorithm::StepPostProcessInsideSubsetLoop() -> A problem occurred while saving images at iteration " << a_iteration+1 <<
" !" << endl);
501 if (
m_verbose>=3)
Cout(
"iIterativeAlgorithm::StepAfterSubsetLoop() -> Clean never visited voxels and save images if needed" << endl);
508 if (
m_verbose>=1)
Cout(
"iIterativeAlgorithm::StepAfterSubsetLoop() -> Save image at iteration " << a_iteration+1 << endl);
512 Cerr(
"***** iIterativeAlgorithm::StepAfterSubsetLoop() -> A problem occurred while saving images at iteration " << a_iteration+1 <<
" !" << endl);
529 Cerr(
"***** iIterativeAlgorithm::StepAfterIterationLoop() -> A problem occurred while calling StepAfterIterationLoop() function !" << endl);
532 if (
m_verbose>=2)
Cout(
"iIterativeAlgorithm::StepAfterIterationLoop ... " << endl);
556 Cerr(
"***** iIterativeAlgorithm::StepImageOutput() -> A problem occurred while saving parametric images related to the dynamic model !" << endl);
568 Cerr(
"***** iIterativeAlgorithm::StepImageOutput() -> A problem occurred while convolving the output image !" << endl);
575 Cerr(
"***** iIterativeAlgorithm::StepImageOutput() -> A problem occurred while applying image processing the output image !" << endl);
581 Cerr(
"***** iIterativeAlgorithm::StepImageOutput() -> A problem occurred while applying output FOV masking !" << endl);
587 Cerr(
"***** iIterativeAlgorithm::StepImageOutput() -> A problem occurred while applying output flip !" << endl);
600 Cerr(
"***** iIterativeAlgorithm::StepImageOutput() -> A problem occurred while saving output image !" << endl);
614 Cerr(
"***** iIterativeAlgorithm::StepImageOutput() -> A problem occurred while saving output image !" << endl);
628 (void)a_specificOptions;
629 if (
m_verbose>=2)
Cout(
"iIterativeAlgorithm::InitSpecificOptions ... " << endl);
oImageConvolverManager * mp_ImageConvolverManager
void StopIterativeDataUpdateStep1(int a_thread)
Stop the timer for duration of iterative data update step 1.
int ApplyProcessingForward(oImageSpace *ap_ImageSpace)
A function used to apply image processing modules onto the forward image of the oImageSpace.
This header file is mainly used to declare some macro definitions and all includes needed from the st...
int GetCurrentCardImage(int a_th)
call the eponym function from the oDynamicDataManager object
oOptimizerManager * mp_OptimizerManager
void GetEventIndexStartAndStop(int64_t *ap_indexStart, int64_t *ap_indexStop, int a_subsetNum=0, int a_NbSubsets=1)
Compute the index start and stop of the events loop with respect to the current subset and MPI size a...
oImageProcessingManager * mp_ImageProcessingManager
void DeallocateBackwardImageFromDynamicBasis()
Free memory for the backward image matrices.
FLTNB GetInitialValue()
Return the initial image value used by the optimizer, explaining why the eponym function of vOptimize...
#define DYNAMIC_SWITCH_CONTINUE
int PreImageUpdateStep()
A function that simply calls the eponym function from the vOptimizer.
void Reduce()
Merge parallel results into the matrix of the backward image matrix of the first thread. Also for MPI.
Declaration of class oIterativeAlgorithm.
int ConvolveForward(oImageSpace *ap_ImageSpace)
A function used to apply convolvers onto the forward image of the oImageSpace.
int InitSpecificOptions(string a_specificOptions)
int DynamicSwitch(int64_t a_currentEventIndex, uint32_t a_currentTime, int a_bed, int a_th)
Call the eponym function from the oDynamicDataManager class using the member object.
int ApplyOutputFOVMasking()
Mask the outside of the transaxial FOV based on the m_fovOutPercent.
oProjectorManager * mp_ProjectorManager
int StepInnerLoopInsideSubsetLoop(int a_iteration, int a_subset, int a_bed)
This function is called inside the subset loop and manages the main loop over the events The loop o...
bool m_saveSensitivityHistoFlag
void SetCurrentSubset(int a_currentSubset)
Set the current subset to the vOptimizer.
void StopIterativeDataUpdateStep3(int a_thread)
Stop the timer for duration of iterative data update step 3.
#define DYNAMIC_SWITCH_END_LOOP
void InstantiateBackwardImageFromDynamicBasis(int a_nbBackwardImages)
Allocate memory for the backward image matrices and set the number of backward images for the whole c...
void SetNumbersOfIterationsAndSubsets(int a_nbIterations, int *ap_nbSubsets)
Set these numbers of iterations and subsets to the vOptimizer.
int ApplyMaskToSensitivity()
Apply the mask to the sensitivity image (only for the first thread, the image must be reduced beforeh...
static sOutputManager * GetInstance()
Instanciate the singleton object and Initialize member variables if not already done, return a pointer to this object otherwise.
int ConvolvePost(oImageSpace *ap_ImageSpace)
A function used to apply convolvers onto the output image of the oImageSpace.
int ConvolveIntra(oImageSpace *ap_ImageSpace)
A function used to apply convolvers onto the current image of the oImageSpace.
int ApplyProcessingPost(oImageSpace *ap_ImageSpace)
A function used to apply convolvers onto the output image of the oImageSpace.
int InitImage(const string &a_pathToInitialImage, FLTNB a_value)
Initialize the main image, either using:
int StepAfterIterationLoop()
This function is called at the end of the RunCPU function.
int DataUpdateStep(oProjectionLine *ap_Line, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_thread)
A function dedicated to the update step in the data space (for each event inside the loop) ...
void StartIterativeDataUpdateStep1(int a_thread)
Start the timer for duration of iterative data update step 1.
void StopIterativeDataUpdateStep4(int a_thread)
Stop the timer for duration of iterative data update step 4.
bool GetRespStaticFlag()
Get the respiratory static flag that says if the reconstruction has only one respiratory gate or not...
oImageSpace * mp_ImageSpace
void StartIterativeDataUpdateStep2(int a_thread)
Start the timer for duration of iterative data update step 2.
int StepPostProcessInsideSubsetLoop(int a_iteration, int a_subset)
vEvent * GetEvent(int64_t a_eventIndex, int a_th=0)
vDataFile ** m2p_DataFile
void PrepareForwardImage()
Copy current image matrix in the forward-image buffer matrix.
int SaveOutputBasisCoefficientImage(int a_iteration, int a_subset=-1)
Call the interfile function to write output basis function coefficient image on disk.
bool m_saveDynamicBasisCoefficients
const string & GetPathName()
bool GetCardStaticFlag()
Get the cardiac static flag that says if the reconstruction has only one cardiac gate or not...
int StepBeforeSubsetLoop(int a_iteration)
This function is called before starting the subset loop.
void CleanNeverVisitedVoxels()
Based on the visitedVoxelsImage, clean the never visited voxels in the image. This function must be c...
Singleton class that manages output writing on disk (images, sinograms, etc). It also manages loggi...
int StepPreProcessInsideSubsetLoop(int a_iteration, int a_subset)
This function is called right after starting the subset loop. Apply any kind of processing on the for...
string m_pathToInitialImg
int GetNbBackwardImages()
Return the number of backward images used by the optimizer, explaining why the eponym function of vOp...
oDynamicModelManager * mp_DynamicModelManager
int SaveOutputImage(int a_iteration, int a_subset=-1)
Call the interfile function to write output image on disk.
Declaration of class iEventHistoCT.
int PreDataUpdateStep()
A function that simply calls the eponym function from the vOptimizer.
void ResetCurrentDynamicIndices()
Call the eponym function from the oDynamicDataManager class using the member object.
virtual int StepBeforeIterationLoop()
This function is called at the beginning of the RunCPU function.
bool m_saveImageAfterSubsets
void ComputeOutputImage()
void StartIterativeDataUpdateStep3(int a_thread)
Start the timer for duration of iterative data update step 3.
oProjectionLine * ComputeProjectionLine(vEvent *ap_Event, int a_th)
This function is used to compute system matrix elements from the associated projector or pre-computed...
int ConvolveBackward(oImageSpace *ap_ImageSpace)
A function used to apply convolvers onto the backward images of the oImageSpace.
void StopIterativeDataUpdateStep2(int a_thread)
Stop the timer for duration of iterative data update step 2.
int SaveParametricImages(int a_iteration, int a_subset=-1)
Call SaveParametricImages() function of the dynamic model object is 'm_UseModel' is on...
void ApplyBedOffset(int a_bed)
Compute the bed offset from the provided bed index and apply it to all projection lines...
void StartConvolution()
Start the timer for duration of convolution.
bool GetTimeStaticFlag()
Get the time static flag that says if the reconstruction has only one frame or not.
bool NotEmptyLine()
This function is used to know if the line contains any voxel contribution.
int ApplyProcessingIntra(oImageSpace *ap_ImageSpace)
A function used to apply image processing modules onto the current image of the oImageSpace.
oDeformationManager * mp_DeformationManager
int StepBeforeIterationLoop()
This function is called at the beginning of the RunCPU function.
void StartIterativeDataUpdateStep4(int a_thread)
Start the timer for duration of iterative data update step 4.
This class is designed to manage and store system matrix elements associated to a vEvent...
const string & GetBaseName()
int ApplyOutputFlip()
Just flip the output image.
oImageDimensionsAndQuantification * mp_ID
virtual int StepAfterIterationLoop()
This function is called at the end of the RunCPU function.
int StepImageOutput(int a_iteration, int a_subset=-1)
This function deals with everything about saving output images from the reconstruction.
This is the base class for reconstructions, containing a framework with iteration and data subset loo...
void StopConvolution()
Stop the timer for duration of convolution.
Mother class for the Event objects.
int GetNbThreadsForImageComputation()
Get the number of threads used for image operations.
int ImageUpdateStep()
A function dedicated to the update step in the image space (performed after the loop on events) ...
int GetNbThreadsForProjection()
Get the number of threads used for projections.
int StepAfterSubsetLoop(int a_iteration)
This function is called after finishing the subset loop.
bool * mp_outputIterations
void SetCurrentIteration(int a_currentIteration)
Set the current iteration to the vOptimizer.
This class is designed to manage some profiling of the code.
int SaveSensitivityImage(const string &a_pathToSensitivityImage)
Call the interfile function to write the sensitivity image on disk.
void InitBackwardImage()
Initialize each voxel of the backward images to 0, also for sensitivity if not loaded (estimated on t...
int GetCurrentRespImage(int a_th)
call the eponym function from the oDynamicDataManager object
static sChronoManager * GetInstance()
Instantiate the singleton if not already done, then return the pointer to its instance.
int GetMPIRank()
Get the MPI instance number (the rank)
int ApplyDynamicModel(oImageSpace *ap_ImageS, int a_iteration, int a_subset)
int GetCurrentTimeFrame(int a_th)
call the eponym function from the oDynamicDataManager object
#define DYNAMIC_SWITCH_DEFORMATION