90 cout <<
"-- This class implements the Spectral Model : " << endl;
91 cout <<
"-- By Adnrew Reader et al. " << endl;
92 cout <<
"-- It is used to model radiotracer dynamic behaviour with a set of decaying exponential functions ( exp(-β*t) ) " << endl;
93 cout <<
"-- The decaying exponential functions are logarithmically equally spaced within the selected range of β values " << endl;
94 cout <<
" All decaying exponentials are convolved with the interpolated Arterial Input Curve, before being discretised to the duration of the reconstruction frames " << endl;
96 cout <<
" The model must be initialized using either an ASCII file with the following keywords and information :" << endl;
97 cout <<
" As this class inherits from the iLinearModel class, the following parameters must be declared inside the couple of the following specific tags: " << endl;
98 cout <<
" - DYNAMIC FRAMING/ENDDF " << endl;
99 cout <<
" - The ASCII file must contain the following keywords :" << endl;
100 cout <<
" 'AIC_input_file:' (mandatory) The file containing the sampled Arterial Input Function " << endl;
101 cout <<
" The file must contain the following information in successive lines, separated by ',' " << endl;
102 cout <<
" -> AIC_number_of_points: " << endl;
103 cout <<
" -> AIC_time_points: " << endl;
104 cout <<
" -> AIC_data_points: " << endl;
105 cout <<
" -> AIC_units: seconds " << endl;
106 cout <<
" 'Parametric_image_init: path ' (optional) path to an interfile image to be used as initialization for the parametric images." << endl;
107 cout <<
" -> Optimisation_method : x (mandatory) optimization method available options: " << endl;
108 cout <<
" x=0: Direct ( Implementation of basis functions side by system matrix in each tomographic iterative loop " << endl;
109 cout <<
" x=1: Nested EM " << endl;
110 cout <<
" x=2: Iterative non-negative Least-Square " << endl;
111 cout <<
" (C.L. Lawson and R.J. Hanson, Solving Least Squares Problems)" << endl;
113 cout <<
" Parametric images will be initialized with 0.001 and 1.0 for Patlak slope and intercept by default " << endl;
114 cout <<
" The parametric images estimations will be written on disk for each iteration" << endl;
116 cout <<
" The following keywords are common to all dynamic models :" << endl;
117 cout <<
" 'Number of iterations before image update: x' Set a number 'x' of iteration to reach before using the model to generate the images at each frames/gates" << endl;
118 cout <<
" (Default x == 0) " << endl;
119 cout <<
" 'No image update: x' If set to 1, the reconstructed images for the next iteration/subset are not reestimated using the model" << endl;
120 cout <<
" (Default x == 0) (the code just performs standard independent reconstruction of each frames/gates) " << endl;
121 cout <<
" 'No parameters update: x' If set to 1, the parameters / functions of the model are not estimated with the image" << endl;
122 cout <<
" (Default x == 0) (this could be used to test The EstimateImageWithModel() function with specific user-provided parametric images) " << endl;
123 cout <<
" 'Save parametric images : x' Enable (1)/Disable(0) saving parametric images on disk" << endl;
124 cout <<
" (Default x == 1) " << endl;
125 cout <<
" 'Save blacklisted voxels images : x' Enable (1)/Disable(0) saving blacklisted voxels images on disk" << endl;
126 cout <<
" (Default x == 0) " << endl;
143 if(
m_verbose >=3)
Cout(
"iLinearSpectralModel::ReadAndCheckConfigurationFileSpecific ..."<< endl);
155 Cerr(
"***** iLinearSpectralModel::ReadAndCheckConfigurationFileSpecific -> Error while trying to read and check generic configuration for linear models " <<
m_fileOptions << endl);
167 Cerr(
"***** iLinearModel::ReadAndCheckConfigurationFileSpecific -> Error while trying to read 'Number_spectral_functions' flag in " <<
m_fileOptions << endl);
178 Cerr(
"***** iLinearModel::ReadAndCheckConfigurationFileSpecific -> Error while trying to read 'Constant_basis_function' flag in " <<
m_fileOptions << endl);
191 Cerr(
"***** iLinearSpectralModel::ReadAndCheckConfigurationFileSpecific -> Error while trying to read 'Fastest_rate' flag in " <<
m_fileOptions << endl);
199 Cerr(
"***** iLinearSpectralModel::ReadAndCheckConfigurationFileSpecific -> Error while trying to read 'Slowest_rate' flag in " <<
m_fileOptions << endl);
208 Cerr(
"***** iLinearPatlakModel::ReadAndCheckConfigurationFileSpecific -> Error while trying to read configuration file at: " <<
m_fileOptions << endl);
228 if(
m_verbose >=3)
Cout(
"iLinearSpectralModel::ReadAndCheckConfigurationFileSpecific ..."<< endl);
231 Cerr(
"***** iLinearSpectralModel::ReadAndCheckOptionsList -> This model needs to use a file for its initialization. Use help for more info !" << endl);
268 Cerr(
"***** iLinearPatlakModel::CheckSpecificParameters -> A problem occurred while checking specific parameters ! " << endl);
290 Cerr(
"***** iLinearSpectralModel::InitializeSpecific() -> Must call CheckParameters functions before Initialize() !" << endl);
295 if(
m_verbose >=2)
Cout(
"iLinearSpectralModel::InitializeSpecific ..."<< endl);
299 Cerr(
"***** iLinearSpectralModel::InitializeSpecific() -> Error while performing generic initialisations for linear models !" << endl);
318 for (
int b = 0; b <
m_spectral_bank_size; b++) mp_spectral_bank[b] = pow(10, mp_spectral_bank[b]);
321 if(
m_verbose >=3)
Cout(
" iLinearSpectralModel::InitializeSpecific() -> Sampling exponential functions" << endl);
331 spectral_exp[ex] = (
HPFLTNB*) malloc(total_samples *
sizeof(
HPFLTNB));
337 for (
int i = 0; i < total_samples; i++)
339 spectral_exp[ex][i] = (
FLTNB) exp(-0.1 * mp_spectral_bank[ex] * i);
350 ConvSpectralFunctions[ex] = (
HPFLTNB*) malloc(total_samples *
sizeof(
HPFLTNB));
357 #pragma omp parallel for private(ex) schedule(static, 1) 361 for (
int i = 0; i <= total_samples; i++)
363 for (
int j = i; j <= total_samples; j++)
365 ConvSpectralFunctions[ex][j] += (a_AICIntrpY[i] * spectral_exp[ex][j - i]);
368 ConvSpectralFunctions[ex][i] *= 0.1;
370 if ( ConvSpectralFunctions[ex][i] <0 )
372 Cout(
" Negative spectral function value detected at " << i <<
", with value: "<< ConvSpectralFunctions[ex][i] <<
373 " -> Setting value to zero "<< endl);
374 ConvSpectralFunctions[ex][i] = 0 ;
376 if (std::isnan(ConvSpectralFunctions[ex][i]))
378 Cout(
" NaN spectral function value detected at " << i <<
"--> Setting value to zero "<< endl);
379 ConvSpectralFunctions[ex][i] = 0 ;
397 RunningSum+=ConvSpectralFunctions[ex][i];
414 RunningSum += a_AICIntrpY[i];
int ReadAndCheckOptionsList(string a_listOptions)
This function is used to read parameters from a string.
iLinearSpectralModel()
Constructor of iLinearSpectralModel. Simply set all data members to default values.
oArterialInputCurve * mp_ArterialInputCurve
int InitializeSpecific()
This function is used to initialize the model parametric images and basis functions.
uint32_t GetFrameTimeStartInMs(int a_bed, int a_frame)
Get the frame time start for the given bed, in milliseconds as a uint32_t.
oImageDimensionsAndQuantification * mp_ID
int InitializeSpecificToAllLinearModels()
This function is used to initialize the parametric images and basis functions for all Linear Models...
This class implements a general linear dynamic model applied between the images of a dynamic acquisit...
Declaration of class iLinearSpectralModel.
void ShowBasisFunctions()
This function is used to print the basis functions.
int m_constant_basis_value
int CheckSpecificParametersForAllLinearModels()
This function is used to check parameters for all Linear Models. .
int ReadDataASCIIFile(const string &a_file, const string &a_keyword, T *ap_return, int a_nbElts, bool a_mandatoryFlag)
Look for "a_nbElts" elts in the "a_file" file matching the "a_keyword" string passed as parameter a...
~iLinearSpectralModel()
Destructor of iLinearSpectralModel.
FLTNB ** m2p_nestedModelTimeBasisFunctions
#define KEYWORD_MANDATORY
void ShowHelp()
This function is used to print out specific help about the model and its options. ...
int GetNbTimeFrames()
Get the number of time frames.
HPFLTNB * mp_spectral_bank
int CheckSpecificParameters()
This function is used to check whether all member variables have been correctly initialized or not...
int ReadAndCheckConfigurationFileSpecific()
This function is used to read options from a configuration file, specific to this model...
int ReadAndCheckConfigurationFileSpecificToAllLinearModels()
This function is used to read parameters that are generic for all Linear Models. ...
uint32_t GetFrameTimeStopInMs(int a_bed, int a_frame)
Get the frame time stop for the given bed, in milliseconds as a uint32_t.