8 #include "oImageConvolverManager.hh" 9 #include "sAddonManager.hh" 61 Cerr(
"***** oImageConvolverManager::CheckParameters() -> No image dimensions provided !" << endl);
67 Cerr(
"***** oImageConvolverManager::CheckParameters() -> Wrong verbosity level provided !" << endl);
86 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
87 if (mpi_rank!=0)
return;
90 cout <<
"------------------------------------------------------------------" << endl;
91 cout <<
"----- How to use an image convolver" << endl;
92 cout <<
"------------------------------------------------------------------" << endl;
94 cout <<
"An image convolver is called through the -conv option. The provided argument describes the convolver to be used, its options," << endl;
95 cout <<
"and when to include it within the algorithm. The syntax of the argument must obey one of the three following options:" << endl;
96 cout <<
" conv::when (in this case, the default configuration file of the convolver is used to set the options values)" << endl;
97 cout <<
" conv:file.conf::when (in this case, the provided configuration is used)" << endl;
98 cout <<
" conv,param1,param2,...::when (in this case, the options values are directly provided in the argument)" << endl;
99 cout <<
"In any case, the description of the options specific to each convolver, their order in the list and their configuration" << endl;
100 cout <<
"files syntax are provided in the specific help of each convolver." << endl;
101 cout <<
"The 'when' parameter is an argument describing when to include the convolver within the algorithm. It is a list of keywords" << endl;
102 cout <<
"separating by commas. The following keywords can be used:" << endl;
103 cout <<
" forward (include convolver into forward model; a convolution of the current estimate is forward-projected)" << endl;
104 cout <<
" backward (include convolver into backward model; a convolution of the correction terms is used for the update)" << endl;
105 cout <<
" post (apply convolver before saving the image; the convolved image is not put back as the estimate for the next update)" << endl;
106 cout <<
" psf (include both 'forward' and 'backward'; the standard image-based PSF modelling)" << endl;
107 cout <<
" sieve (include both 'psf' and 'post'; the standard method of sieve)" << endl;
108 cout <<
" intra (apply convolver to the updated image and use it as the current estimate for the next update)" << endl;
122 Cerr(
"***** oImageConvolverManager::Initialize() -> Parameters have not been checked ! Please call CheckParameters() before." << endl);
132 if (
m_verbose>=1)
Cout(
"oImageConvolverManager::Initialize() -> Initialize image convolvers" << endl);
136 Cerr(
"***** oImageConvolverManager::Initialize() -> A problem occurred while parsing image convolvers options and initializing them !" << endl);
188 size_t double_colon =
m_options[c].find(
"::");
191 if (double_colon==string::npos)
193 Cerr(
"***** oImageConvolverManager::ParseOptionsAndInitializeImageConvolvers() -> Wrong syntax in the " << c+1 <<
"th image convolver !" << endl);
194 Cerr(
" No double-colon \"::\" found." << endl);
200 string conv_part_options =
m_options[c].substr(0,double_colon);
201 string when_part_options =
m_options[c].substr(double_colon+2);
207 string convolver =
"";
208 string list_options =
"";
209 string file_options =
"";
212 size_t colon = conv_part_options.find_first_of(
":");
213 size_t comma = conv_part_options.find_first_of(
",");
216 if (colon!=string::npos)
219 convolver = conv_part_options.substr(0,colon);
221 file_options = conv_part_options.substr(colon+1);
226 else if (comma!=string::npos)
229 convolver = conv_part_options.substr(0,comma);
231 list_options = conv_part_options.substr(comma+1);
239 convolver = conv_part_options;
250 while ((comma=when_part_options.find_first_of(
",")) != string::npos)
253 string option = when_part_options.substr(0,comma);
255 when_part_options = when_part_options.substr(comma+1);
265 Cerr(
"***** oImageConvolverManager::ParseOptionsAndInitializeImageConvolvers() -> Unknown keyword '" << option <<
"' provided in options list !" << endl);
273 else if (when_part_options==
"post") {
mp_applyPost[c] =
true;}
276 else if (when_part_options==
"intra") {
mp_applyIntra[c] =
true;}
279 Cerr(
"***** oImageConvolverManager::ParseOptionsAndInitializeImageConvolvers() -> Unknown keyword '" << when_part_options <<
"' provided in options list !" << endl);
291 Cerr(
"***** oImageConvolverManager::ParseOptionsAndInitializeImageConvolvers() -> Image convolver '" << convolver <<
"' does not exist !" << endl);
301 Cerr(
"***** oImageConvolverManager::ParseOptionsAndInitializeImageConvolvers() -> A problem occurred while reading and checking configuration file for image convolver '" << convolver <<
"' !" << endl);
307 Cerr(
"***** oImageConvolverManager::ParseOptionsAndInitializeImageConvolvers() -> A problem occurred while parsing and reading options list for image convolver '" << convolver <<
"' !" << endl);
313 Cerr(
"***** oImageConvolverManager::ParseOptionsAndInitializeImageConvolvers() -> A problem occurred while checking parameters for image convolver '" << convolver <<
"' !" << endl);
319 Cerr(
"***** oImageConvolverManager::ParseOptionsAndInitializeImageConvolvers() -> A problem occurred while initializing image convolver '" << convolver <<
"' !" << endl);
339 Cerr(
"***** oImageConvolverManager::ConvolveForward() -> Called while not initialized !" << endl);
352 if (m_nbImageConvolvers>1)
Cout(
"oImageConvolverManager::ConvolveForward() -> Apply convolution " << c+1 <<
" to forward image" << endl);
353 else Cout(
"oImageConvolverManager::ConvolveForward() -> Apply convolution to forward image" << endl);
386 Cerr(
"***** oImageConvolverManager::ConvolveBackward() -> Called while not initialized !" << endl);
399 if (m_nbImageConvolvers>1)
401 if (ap_ImageSpace->
IsLoadedSensitivity())
Cout(
"oImageConvolverManager::ConvolveBackward() -> Apply convolution " << c+1 <<
" to backward image" << endl);
402 else Cout(
"oImageConvolverManager::ConvolveBackward() -> Apply convolution " << c+1 <<
" to backward and sensitivity images" << endl);
406 if (ap_ImageSpace->
IsLoadedSensitivity())
Cout(
"oImageConvolverManager::ConvolveBackward() -> Apply convolution to backward image" << endl);
407 else Cout(
"oImageConvolverManager::ConvolveBackward() -> Apply convolution to backward and sensitivity images" << endl);
465 Cerr(
"***** oImageConvolverManager::ConvolveIntra() -> Called while not initialized !" << endl);
478 if (m_nbImageConvolvers>1)
Cout(
"oImageConvolverManager::ConvolveIntra() -> Apply convolution " << c+1 <<
" to current image" << endl);
479 else Cout(
"oImageConvolverManager::ConvolveIntra() -> Apply convolution to current image" << endl);
512 Cerr(
"***** oImageConvolverManager::ConvolveSensitivity() -> Called while not initialized !" << endl);
525 if (m_nbImageConvolvers>1)
Cout(
"oImageConvolverManager::ConvolveSensitivity() -> Apply convolution " << c+1 <<
" to sensitivity image" << endl);
526 else Cout(
"oImageConvolverManager::ConvolveSensitivity() -> Apply convolution to sensitivity image" << endl);
560 Cerr(
"***** oImageConvolverManager::ConvolvePost() -> Called while not initialized !" << endl);
573 if (m_nbImageConvolvers>1)
Cout(
"oImageConvolverManager::ConvolvePost() -> Apply convolution " << c+1 <<
" to output image" << endl);
574 else Cout(
"oImageConvolverManager::ConvolvePost() -> Apply convolution to output image" << endl);
int ParseOptionsAndInitializeImageConvolvers()
A function used to parse options and initialize image convolvers.
int GetNbCardBasisFunctions()
Get the number of cardiac basis functions.
vImageConvolver ** m2p_ImageConvolvers
void SetVerbose(int a_verbose)
bool IsLoadedSensitivity()
int ConvolveForward(oImageSpace *ap_ImageSpace)
int CheckParameters()
A function used to check the parameters settings.
oImageConvolverManager()
The constructor of oImageConvolverManager.
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
int GetNbTimeBasisFunctions()
Get the number of time basis functions.
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)
int ConvolveIntra(oImageSpace *ap_ImageSpace)
oImageDimensionsAndQuantification * mp_ImageDimensionsAndQuantification
FLTNB ****** m6p_backwardImage
static sAddonManager * GetInstance()
const string & GetPathToConfigDir()
Return the path to the CASTOR config directory.
std::map< string, maker_image_convolver > mp_listOfImageConvolvers
int GetNbBackwardImages()
int ConvolveBackward(oImageSpace *ap_ImageSpace)
FLTNB ***** m5p_sensitivity
int ApplyConvolutionTranspose(FLTNB *ap_image)
static void ShowCommonHelp()
This function does not take any parameter and is used to display some help about the syntax of the op...
vector< string > m_options
~oImageConvolverManager()
The destructor of oImageConvolverManager.
FLTNB **** m4p_forwardImage
int GetNb1stMotImgsForLMS(int a_fr)
int ApplyConvolution(FLTNB *ap_image)
This class holds all the matrices in the image domain that can be used in the algorithm: image...
int GetNbTimeFrames()
Get the number of time frames.
int GetNb2ndMotImgsForLMS()
call the eponym function from the oDynamicDataManager object
int ConvolveSensitivity(oImageSpace *ap_ImageSpace)
int GetNbRespBasisFunctions()
Get the number of respiratory basis functions.
This abstract class is the generic image convolver class used by the oImageConvolverManager.
int Initialize()
A function used to initialize the manager and all image convolvers it manages.
void ShowHelpImageConvolver()
Show help about all implemented image convolvers.