CASToR  2.0
Tomographic Reconstruction (PET/SPECT/CT)
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
oIterativeAlgorithm Class Reference

This is the main class for iterative reconstructions, that manages the iteration loops.
This class manages an iterative reconstruction of any kind, using a vDataFile, and through the use of an oProjector, an oOptimizer, a oConvolver, a oImageSpace. More...

#include <oIterativeAlgorithm.hh>

Collaboration diagram for oIterativeAlgorithm:
Collaboration graph

Public Member Functions

 oIterativeAlgorithm ()
 oIterativeAlgorithm constructor. Initialize the member variables to their default values. More...
 
virtual ~oIterativeAlgorithm ()
 oIterativeAlgorithm destructor. More...
 
int Iterate ()
 Just call either the IterateCPU or the IterateGPU function as asked for. More...
 
int IterateCPU ()
 Perform the iterative loop of the algorithm, call the different object for optimization, projection, update, etc. Function designed to be executed on the CPU only. More...
 
void SetSaveSensitivityHistoFlag (bool a_saveSensitivityHistoFlag)
 Set the flag that specifies if the sensitivity image in histogram mode has to be saved for each subset/iteration. More...
 
void SetSaveSubsetImageFlag (bool a_saveImageAfterSubsets)
 Set the flag that specifies if the image has to be saved for each subset. More...
 
void SetOptimizerManager (oOptimizerManager *ap_OptimizerManager)
 Set the Optimizer Manager Object. More...
 
void SetImageDimensionsAndQuantification (oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
 Set the Image Dimensions and Quantification Object. More...
 
void SetImageSpace (oImageSpace *ap_ImageSpace)
 Set the Image Space Object. More...
 
void SetProjectorManager (oProjectorManager *ap_ProjectorManager)
 Set the Projector Manager Object. More...
 
void SetImageConvolverManager (oImageConvolverManager *ap_ImageConvolverManager)
 Set the Image Convolver Manager Object. More...
 
void SetImageProcessingManager (oImageProcessingManager *ap_ImageProcessingManager)
 Set the Image Processing Manager Object. More...
 
void SetDynamicModelManager (oDynamicModelManager *ap_DynamicModelManager)
 Set the Dynamic Model Manager Object. More...
 
void SetDeformationManager (oDeformationManager *ap_DeformationManager)
 Set the Deformation Manager Object. More...
 
void SetDataFile (vDataFile **a2p_DataFile)
 Set the list of DataFile. More...
 
void SetGPUflag (bool a_flagGPU)
 Set the GPU flag. More...
 
void SetVerbose (int a_verboseLevel)
 Set Verbosity. More...
 
void SetNbBeds (int a_nbBeds)
 Set number of beds (bed positions) More...
 
void SetPathInitImage (string a_pathToInitialImage)
 Set path to an initial image. More...
 
void SetPathToAttenuationImage (string a_pathToAttenuationImage)
 This function is used to set the path to the attenuation image. More...
 
void SetPathToSensitivityImage (string a_pathToSensitivityImage)
 Set path to the sensitivity image. More...
 
void SetPathToMultiModalImage (vector< string > a_pathToMultiModalImage)
 Set path to multimodal images. More...
 
void SetPathToMaskImage (string a_pathToMaskImage)
 Set path to a mask image. More...
 
int SetNbIterationsAndSubsets (const string &a_nbIterationsSubsets)
 Set the number of iterations and subsets. More...
 
int SetOutputIterations (const string &a_outputIterations)
 Set the selected output iterations. More...
 
virtual int InitSpecificOptions (string a_specificOptions)
 Set the selected output iterations. More...
 

Protected Member Functions

virtual int StepBeforeIterationLoop ()
 This function is called at the beginning of the IterateCPU function. More...
 
virtual int StepAfterIterationLoop ()
 This function is called at the end of the IterateCPU function. More...
 
virtual int StepBeforeSubsetLoop (int a_iteration)
 This function is called before starting the subset loop. More...
 
virtual int StepAfterSubsetLoop (int a_iteration)
 This function is called after finishing the subset loop. More...
 
virtual 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 forward image before projections. More...
 
virtual int StepPostProcessInsideSubsetLoop (int a_iteration, int a_subset)
 
virtual 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 over the events is multithreaded, and involves a thread lock in the case of image-based deformation. More...
 
void ThreadBarrierIncrement ()
 Increment (thread safe) the m_nbThreadsWaiting variable. More...
 
bool ThreadBarrierFlag ()
 Check if the m_releaseThreads boolean is enabled or not. More...
 
bool ThreadBarrierCheck ()
 Check if all the threads are currently in waiting condition. More...
 
void ThreadBarrierSetOff ()
 Disable the thread locking variable (thread safe), and reset the number of waiting threads to 0. More...
 
void ThreadBarrierSetOn ()
 Enable the thread locking variable (thread safe), and reset the number of waiting threads to 0. More...
 

Protected Attributes

int m_nbIterations
 
int * mp_nbSubsets
 
bool * mp_outputIterations
 
int m_verbose
 
bool m_flagGPU
 
oImageDimensionsAndQuantificationmp_ID
 
vDataFile ** m2p_DataFile
 
oProjectorManagermp_ProjectorManager
 
oOptimizerManagermp_OptimizerManager
 
oDeformationManagermp_DeformationManager
 
oDynamicModelManagermp_DynamicModelManager
 
oImageSpacemp_ImageSpace
 
oImageConvolverManagermp_ImageConvolverManager
 
oImageProcessingManagermp_ImageProcessingManager
 
int m_nbBeds
 
string m_pathToInitialImg
 
string m_pathToAtnImg
 
string m_pathToSensitivityImg
 
vector< string > m_pathToMultiModalImg
 
string m_pathToMaskImg
 
bool m_saveSensitivityHistoFlag
 
bool m_saveImageAfterSubsets
 
bool m_generalizedImplementation
 

Detailed Description

This is the main class for iterative reconstructions, that manages the iteration loops.
This class manages an iterative reconstruction of any kind, using a vDataFile, and through the use of an oProjector, an oOptimizer, a oConvolver, a oImageSpace.

Definition at line 53 of file oIterativeAlgorithm.hh.

Constructor & Destructor Documentation

oIterativeAlgorithm::oIterativeAlgorithm ( )

oIterativeAlgorithm constructor. Initialize the member variables to their default values.

Definition at line 46 of file oIterativeAlgorithm.cc.

oIterativeAlgorithm::~oIterativeAlgorithm ( )
virtual

oIterativeAlgorithm destructor.

Definition at line 81 of file oIterativeAlgorithm.cc.

Member Function Documentation

int oIterativeAlgorithm::InitSpecificOptions ( string  a_specificOptions)
virtual

Set the selected output iterations.

Parameters
a_specificOptions

Not Implemented yet

Returns
0

Definition at line 1036 of file oIterativeAlgorithm.cc.

int oIterativeAlgorithm::Iterate ( )

Just call either the IterateCPU or the IterateGPU function as asked for.

Returns
0 if success, positive value otherwise

Definition at line 262 of file oIterativeAlgorithm.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int oIterativeAlgorithm::IterateCPU ( )

Perform the iterative loop of the algorithm, call the different object for optimization, projection, update, etc. Function designed to be executed on the CPU only.

Loops over the iterations, subsets, bed position
Call functions related to each steps of iterative reconstruction:

StepBeforeIterationLoop()
/ Loop on iterations
| StepBeforeSubsetLoop(iteration)
| / Loop on subsets
| | StepPreProcessInsideSubsetLoop(iteration,subset)
| | / Loop on bed positions
| | | StepInnerLoopInsideSubsetLoop(iteration,subset,bed)
| | StepPostProcessInsideSubsetLoop(iteration,subset)
| StepAfterSubsetLoop(iteration)
StepAfterIterationLoop()

Returns
0 if success, positive value otherwise

Definition at line 301 of file oIterativeAlgorithm.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

public oIterativeAlgorithm::SetDataFile ( vDataFile **  a2p_DataFile)
inline

Set the list of DataFile.

Parameters
a2p_DataFile

Definition at line 178 of file oIterativeAlgorithm.hh.

Here is the caller graph for this function:

public oIterativeAlgorithm::SetDeformationManager ( oDeformationManager ap_DeformationManager)
inline

Set the Deformation Manager Object.

Parameters
ap_DeformationManager

Definition at line 172 of file oIterativeAlgorithm.hh.

Here is the caller graph for this function:

public oIterativeAlgorithm::SetDynamicModelManager ( oDynamicModelManager ap_DynamicModelManager)
inline

Set the Dynamic Model Manager Object.

Parameters
ap_DynamicModelManager

Definition at line 166 of file oIterativeAlgorithm.hh.

Here is the caller graph for this function:

public oIterativeAlgorithm::SetGPUflag ( bool  a_flagGPU)
inline

Set the GPU flag.

Parameters
a_flagGPU

Definition at line 184 of file oIterativeAlgorithm.hh.

Here is the caller graph for this function:

public oIterativeAlgorithm::SetImageConvolverManager ( oImageConvolverManager ap_ImageConvolverManager)
inline

Set the Image Convolver Manager Object.

Parameters
ap_ImageConvolverManager

Definition at line 154 of file oIterativeAlgorithm.hh.

Here is the caller graph for this function:

public oIterativeAlgorithm::SetImageDimensionsAndQuantification ( oImageDimensionsAndQuantification ap_ImageDimensionsAndQuantification)
inline

Set the Image Dimensions and Quantification Object.

Parameters
ap_ImageDimensionsAndQuantification

Definition at line 136 of file oIterativeAlgorithm.hh.

Here is the caller graph for this function:

public oIterativeAlgorithm::SetImageProcessingManager ( oImageProcessingManager ap_ImageProcessingManager)
inline

Set the Image Processing Manager Object.

Parameters
ap_ImageProcessingManager

Definition at line 160 of file oIterativeAlgorithm.hh.

Here is the caller graph for this function:

public oIterativeAlgorithm::SetImageSpace ( oImageSpace ap_ImageSpace)
inline

Set the Image Space Object.

Parameters
ap_ImageSpace

Definition at line 142 of file oIterativeAlgorithm.hh.

Here is the caller graph for this function:

public oIterativeAlgorithm::SetNbBeds ( int  a_nbBeds)
inline

Set number of beds (bed positions)

Parameters
a_nbBeds

Definition at line 196 of file oIterativeAlgorithm.hh.

Here is the caller graph for this function:

int oIterativeAlgorithm::SetNbIterationsAndSubsets ( const string &  a_nbIterationsSubsets)

Set the number of iterations and subsets.

Parameters
a_nbIterationsSubsets

The provided string is a list of iteration:subset pairs separated by commas.

Returns
0 if success, positive value otherwise

Definition at line 226 of file oIterativeAlgorithm.hh.

Here is the caller graph for this function:

public oIterativeAlgorithm::SetOptimizerManager ( oOptimizerManager ap_OptimizerManager)
inline

Set the Optimizer Manager Object.

Parameters
ap_OptimizerManager

Definition at line 130 of file oIterativeAlgorithm.hh.

Here is the caller graph for this function:

int oIterativeAlgorithm::SetOutputIterations ( const string &  a_outputIterations)

Set the selected output iterations.

Parameters
a_outputIterations

The provided string is a list of couple a:b separated by commas.
It means that we save one iteration over a until b is reached.
"b" must be incrementing for each successive couples. If the list is empty, we save all iterations by default.
If the list is equal to "-1", then we save only the last iteration.

Returns
0 if success, positive value otherwise

Definition at line 169 of file oIterativeAlgorithm.cc.

Here is the caller graph for this function:

public oIterativeAlgorithm::SetPathInitImage ( string  a_pathToInitialImage)
inline

Set path to an initial image.

Parameters
a_pathToInitialImage

Definition at line 202 of file oIterativeAlgorithm.hh.

Here is the caller graph for this function:

public oIterativeAlgorithm::SetPathToAttenuationImage ( string  a_pathToAttenuationImage)
inline

This function is used to set the path to the attenuation image.

Parameters
stringa_pathToAttenuationImage

Definition at line 208 of file oIterativeAlgorithm.hh.

Here is the caller graph for this function:

public oIterativeAlgorithm::SetPathToMaskImage ( string  a_pathToMaskImage)
inline

Set path to a mask image.

Parameters
a_pathToMaskImage

Definition at line 226 of file oIterativeAlgorithm.hh.

Here is the caller graph for this function:

public oIterativeAlgorithm::SetPathToMultiModalImage ( vector< string >  a_pathToMultiModalImage)
inline

Set path to multimodal images.

Parameters
a_pathToMultiModalImage

Definition at line 220 of file oIterativeAlgorithm.hh.

Here is the caller graph for this function:

public oIterativeAlgorithm::SetPathToSensitivityImage ( string  a_pathToSensitivityImage)
inline

Set path to the sensitivity image.

Parameters
a_pathToSensitivityImage

Definition at line 214 of file oIterativeAlgorithm.hh.

Here is the caller graph for this function:

public oIterativeAlgorithm::SetProjectorManager ( oProjectorManager ap_ProjectorManager)
inline

Set the Projector Manager Object.

Parameters
ap_ProjectorManager

Definition at line 148 of file oIterativeAlgorithm.hh.

Here is the caller graph for this function:

public void oIterativeAlgorithm::SetSaveSensitivityHistoFlag ( bool  a_saveSensitivityHistoFlag)
inline

Set the flag that specifies if the sensitivity image in histogram mode has to be saved for each subset/iteration.

Parameters
boola_saveSensitivityHistoFlag

Definition at line 118 of file oIterativeAlgorithm.hh.

Here is the caller graph for this function:

public void oIterativeAlgorithm::SetSaveSubsetImageFlag ( bool  a_saveImageAfterSubsets)
inline

Set the flag that specifies if the image has to be saved for each subset.

Parameters
boola_saveImageAfterSubsets

Definition at line 124 of file oIterativeAlgorithm.hh.

Here is the caller graph for this function:

public oIterativeAlgorithm::SetVerbose ( int  a_verboseLevel)
inline

Set Verbosity.

Parameters
a_verboseLevel

Definition at line 190 of file oIterativeAlgorithm.hh.

Here is the caller graph for this function:

int oIterativeAlgorithm::StepAfterIterationLoop ( )
protectedvirtual

This function is called at the end of the IterateCPU function.

Free Memory for the imageSpace and some managers

Returns
0 if success, positive value otherwise.

Definition at line 1006 of file oIterativeAlgorithm.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int oIterativeAlgorithm::StepAfterSubsetLoop ( int  a_iteration)
protectedvirtual

This function is called after finishing the subset loop.

Parameters
a_iteration: iteration index

Clean the main images from never visited voxels
Apply post-convolution/post-processing if needed
Write output images on disk as requested by the user

Definition at line 935 of file oIterativeAlgorithm.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int oIterativeAlgorithm::StepBeforeIterationLoop ( )
protectedvirtual

This function is called at the beginning of the IterateCPU function.

Initialization and memory allocation for the imageSpace and some managers

Returns
0 if success, positive value otherwise.

Definition at line 430 of file oIterativeAlgorithm.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int oIterativeAlgorithm::StepBeforeSubsetLoop ( int  a_iteration)
protectedvirtual

This function is called before starting the subset loop.

Parameters
a_iteration: iteration index
Returns
0 if success, positive value otherwise.

Definition at line 495 of file oIterativeAlgorithm.cc.

Here is the caller graph for this function:

int oIterativeAlgorithm::StepInnerLoopInsideSubsetLoop ( int  a_iteration,
int  a_subset,
int  a_bed 
)
protectedvirtual

This function is called inside the subset loop and manages the main loop over the events
The loop over the events is multithreaded, and involves a thread lock in the case of image-based deformation.

Parameters
a_iteration: iteration index
a_subset: subset index
a_bed: bed position

Step 1: Get the current event for that thread index
Step 2: Call the dynamic switch function that updates the current frame and gate numbers, and also detects involuntary patient motion
Perform image-based deformation if needed (thread lock is required)
Step 3: Compute the projection line
Step 4: Optimize in the data space (forward-proj, update, backward-proj)

Definition at line 579 of file oIterativeAlgorithm.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int oIterativeAlgorithm::StepPostProcessInsideSubsetLoop ( int  a_iteration,
int  a_subset 
)
protectedvirtual

Definition at line 802 of file oIterativeAlgorithm.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int oIterativeAlgorithm::StepPreProcessInsideSubsetLoop ( int  a_iteration,
int  a_subset 
)
protectedvirtual

This function is called right after starting the subset loop. Apply any kind of processing on the forward image before projections.

This function is called right after starting the subset loop.
Apply any kind of image processing on the backward image and main image after backprojections.

Parameters
a_iteration: iteration index
a_subset: subset index

Copy current main image into forward image matrix
Reinitialize backward image and 4D gating indices
Apply image processing/convolution on the forward image matrix (image to be projeted)

Parameters
a_iteration: iteration index
a_subset: subset index

Synchronize parallel results
Apply image deformation/processing/convolution on the backward image
Update the image using the optimizer functions
Apply dynamic model/image processing/convolution on the main image

Returns
0 if success, positive value otherwise.

Definition at line 519 of file oIterativeAlgorithm.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

bool oIterativeAlgorithm::ThreadBarrierCheck ( )
protected

Check if all the threads are currently in waiting condition.

Returns
true if all the threads are waiting, false otherwise

Definition at line 1099 of file oIterativeAlgorithm.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

bool oIterativeAlgorithm::ThreadBarrierFlag ( )
protected

Check if the m_releaseThreads boolean is enabled or not.

Returns
true if the threads can be released, false otherwise

Definition at line 1079 of file oIterativeAlgorithm.cc.

Here is the caller graph for this function:

void oIterativeAlgorithm::ThreadBarrierIncrement ( )
protected

Increment (thread safe) the m_nbThreadsWaiting variable.

Definition at line 1058 of file oIterativeAlgorithm.cc.

Here is the caller graph for this function:

void oIterativeAlgorithm::ThreadBarrierSetOff ( )
protected

Disable the thread locking variable (thread safe), and reset the number of waiting threads to 0.

Definition at line 1117 of file oIterativeAlgorithm.cc.

Here is the caller graph for this function:

void oIterativeAlgorithm::ThreadBarrierSetOn ( )
protected

Enable the thread locking variable (thread safe), and reset the number of waiting threads to 0.

Definition at line 1137 of file oIterativeAlgorithm.cc.

Here is the caller graph for this function:

Member Data Documentation

vDataFile** oIterativeAlgorithm::m2p_DataFile
protected

Pointer to the array of vDataFile object

Definition at line 386 of file oIterativeAlgorithm.hh.

bool oIterativeAlgorithm::m_flagGPU
protected

Do we use GPU or not (default=false)

Definition at line 384 of file oIterativeAlgorithm.hh.

bool oIterativeAlgorithm::m_generalizedImplementation
protected

No purpose yet. For upcoming features

Definition at line 402 of file oIterativeAlgorithm.hh.

int oIterativeAlgorithm::m_nbBeds
protected

number of bed FOVs (1 datafile by bed) (default=-1)

Definition at line 394 of file oIterativeAlgorithm.hh.

int oIterativeAlgorithm::m_nbIterations
protected

Number of iterations (default=1)

Definition at line 380 of file oIterativeAlgorithm.hh.

string oIterativeAlgorithm::m_pathToAtnImg
protected

String of the path to the attenuation images

Definition at line 396 of file oIterativeAlgorithm.hh.

string oIterativeAlgorithm::m_pathToInitialImg
protected

String containing the path to an initialization image

Definition at line 395 of file oIterativeAlgorithm.hh.

string oIterativeAlgorithm::m_pathToMaskImg
protected

String containing the path to a mask image

Definition at line 399 of file oIterativeAlgorithm.hh.

vector<string> oIterativeAlgorithm::m_pathToMultiModalImg
protected

String vector containing paths to multimodal images

Definition at line 398 of file oIterativeAlgorithm.hh.

string oIterativeAlgorithm::m_pathToSensitivityImg
protected

String containing the path to a sensitivity image

Definition at line 397 of file oIterativeAlgorithm.hh.

bool oIterativeAlgorithm::m_saveImageAfterSubsets
protected

Flag specifying that the image has to be saved after each subset

Definition at line 401 of file oIterativeAlgorithm.hh.

bool oIterativeAlgorithm::m_saveSensitivityHistoFlag
protected

Flag specifying that the sensitivity image has to be saved for each subset/iteration in histogram mode

Definition at line 400 of file oIterativeAlgorithm.hh.

int oIterativeAlgorithm::m_verbose
protected

Verbosity (default=-1)

Definition at line 383 of file oIterativeAlgorithm.hh.

oDeformationManager* oIterativeAlgorithm::mp_DeformationManager
protected

Pointer to the Deformation Manager object

Definition at line 389 of file oIterativeAlgorithm.hh.

oDynamicModelManager* oIterativeAlgorithm::mp_DynamicModelManager
protected

Pointer to the Dynamic Model Manager object

Definition at line 390 of file oIterativeAlgorithm.hh.

oImageDimensionsAndQuantification* oIterativeAlgorithm::mp_ID
protected

Pointer to the oImageDimensionsAndQuantification object

Definition at line 385 of file oIterativeAlgorithm.hh.

oImageConvolverManager* oIterativeAlgorithm::mp_ImageConvolverManager
protected

Pointer to the Image Convolver Manager object

Definition at line 392 of file oIterativeAlgorithm.hh.

oImageProcessingManager* oIterativeAlgorithm::mp_ImageProcessingManager
protected

Pointer to the Image Processing Manager object

Definition at line 393 of file oIterativeAlgorithm.hh.

oImageSpace* oIterativeAlgorithm::mp_ImageSpace
protected

Pointer to the Image Space object

Definition at line 391 of file oIterativeAlgorithm.hh.

int* oIterativeAlgorithm::mp_nbSubsets
protected

Number of subsets (default=1)

Definition at line 381 of file oIterativeAlgorithm.hh.

oOptimizerManager* oIterativeAlgorithm::mp_OptimizerManager
protected

Pointer to the Optimizer Manager object

Definition at line 388 of file oIterativeAlgorithm.hh.

bool* oIterativeAlgorithm::mp_outputIterations
protected

A boolean for each iteration saying if we save it or not

Definition at line 382 of file oIterativeAlgorithm.hh.

oProjectorManager* oIterativeAlgorithm::mp_ProjectorManager
protected

Pointer to the Projector Manager object

Definition at line 387 of file oIterativeAlgorithm.hh.


The documentation for this class was generated from the following files: