91 cout <<
"-- This class implements the Spectral Model : " << endl;
92 cout <<
"-- first introduced by J. Cunningham et al. then used in PET reconstruction for temporal regularisation by Andrew Reader et al " << endl;
93 cout <<
"-- It is used to model radiotracer dynamic behaviour with a set of decaying exponential functions ( exp(-β*t) ) " << endl;
94 cout <<
"-- The decaying exponential coefficients β are logarithmically equally spaced within the selected range of values " << endl;
95 cout <<
" All decaying exponentials are convolved with the interpolated Arterial Input Curve, before being discretised to the duration of the reconstruction frames " << endl;
97 cout <<
" The model must be initialized using a ASCII file with the following keywords and information :" << endl;
98 cout <<
" As this class inherits from the iLinearModel class, the following parameters must be declared inside the couple of the following specific tags: " << endl;
99 cout <<
" - DYNAMIC FRAMING/ENDDF " << endl;
100 cout <<
" - The ASCII file must contain the following keywords :" << endl;
101 cout <<
" 'AIC_input_file: path/to/file' (mandatory) The file containing the sampled Arterial Input Function " << endl;
102 cout <<
" The file must contain the following information in successive lines, separated by ',' " << endl;
103 cout <<
" -> AIC_number_of_points: " << endl;
104 cout <<
" -> AIC_time_points: " << endl;
105 cout <<
" -> AIC_data_points: " << endl;
106 cout <<
" -> AIC_units: 'seconds' or 'minutes' " << endl;
107 cout <<
" The following options are required for the specification of the spectral functions. "<< endl;
108 cout <<
" As in the spectral analysis method, the spectral functions are convolved with the interpolated Input Curve. "<< endl;
109 cout <<
" By default a function which is the interpolated Input Curve is added in the dataset (equivalent to convolution of the IC with a dirac function)" << endl;
110 cout <<
" The spectral functions created will be logarithmically spaced within the selected range " << endl;
111 cout <<
" Number_spectral_functions: x (mandatory) The number of spectral functions" << endl;
112 cout <<
" Fastest_rate: x (mandatory) The rate (1/min) for the fastest decaying exponential " << endl;
113 cout <<
" Slowest_rate: x (mandatory) The rate (1/min) for the slowest decaying exponential" << endl;
114 cout <<
" Full_trapping_basis_function: 1 or 0 (optional) Option to say whether we want to include a basis function to model full trapping of tracer (1) or not (0 by default) " << endl;
115 cout <<
" Blood_fraction_basis_function: 1 or 0 (optional) Option to say whether we want to include a basis function to model the blood fraction of the tracer (1) or not (0 by default) " << endl;
116 cout <<
" In this implementation and for the blood fraction it is assumed that the whole blood input curve and plasma input curve are the same (no change due to metabolism) " << endl;
118 cout <<
" 'Parametric_image_init: path ' (optional) path to an interfile image to be used as initialization for the parametric images." << endl;
120 cout <<
" -> Optimisation_method : x (mandatory) optimization method available options: " << endl;
121 cout <<
" x=0: Direct ( Implementation of basis functions side by system matrix in each tomographic iterative loop " << endl;
122 cout <<
" x=1: Nested EM " << endl;
123 cout <<
" x=2: Iterative non-negative Least-Square " << endl;
124 cout <<
" (C.L. Lawson and R.J. Hanson, Solving Least Squares Problems)" << endl;
144 if(
m_verbose >=3)
Cout(
"iLinearSpectralModel::ReadAndCheckConfigurationFileSpecific ..."<< endl);
156 Cerr(
"***** iLinearSpectralModel::ReadAndCheckConfigurationFileSpecific -> Error while trying to read and check generic configuration for linear models " <<
m_fileOptions << endl);
168 Cerr(
"***** iLinearModel::ReadAndCheckConfigurationFileSpecific -> Error while trying to read 'Number_spectral_functions' flag in " <<
m_fileOptions << endl);
174 int full_trapping_basis_input =-1 ;
177 Cerr(
"***** iLinearModel::ReadAndCheckConfigurationFileSpecific -> Error while trying to read 'Full_trapping_basis_function' flag in " <<
m_fileOptions << endl);
183 int blood_fraction_basis_input =-1 ;
186 Cerr(
"***** iLinearModel::ReadAndCheckConfigurationFileSpecific -> Error while trying to read 'Blood_fraction_basis_function' flag in " <<
m_fileOptions << endl);
203 Cerr(
"***** iLinearSpectralModel::ReadAndCheckConfigurationFileSpecific -> Error while trying to read 'Fastest_rate' flag in " <<
m_fileOptions << endl);
211 Cerr(
"***** iLinearSpectralModel::ReadAndCheckConfigurationFileSpecific -> Error while trying to read 'Slowest_rate' flag in " <<
m_fileOptions << endl);
219 Cerr(
"***** iLinearPatlakModel::ReadAndCheckConfigurationFileSpecific -> Error while trying to read configuration file at: " <<
m_fileOptions << endl);
239 if(
m_verbose >=3)
Cout(
"iLinearSpectralModel::ReadAndCheckConfigurationFileSpecific ..."<< endl);
242 Cerr(
"***** iLinearSpectralModel::ReadAndCheckOptionsList -> This model needs to use a file for its initialization. Use help for more info !" << endl);
279 Cerr(
"***** iLinearPatlakModel::CheckSpecificParameters -> A problem occurred while checking specific parameters ! " << endl);
301 Cerr(
"***** iLinearSpectralModel::InitializeSpecific() -> Must call CheckParameters functions before Initialize() !" << endl);
306 if(
m_verbose >=2)
Cout(
"iLinearSpectralModel::InitializeSpecific ..."<< endl);
310 Cerr(
"***** iLinearSpectralModel::InitializeSpecific() -> Error while performing generic initialisations for linear models !" << endl);
328 HPFLTNB halfDeltaT = (0.001 / 2);
330 a_IntegAICY[0] = a_AICIntrpY[0] * 0.001;
334 RunningSum += a_AICIntrpY[i - 1];
335 a_IntegAICY[i] = (a_AICIntrpY[0] + 2 * RunningSum + a_AICIntrpY[i]) * halfDeltaT;
345 RunningSum += a_IntegAICY[i];
355 delete (a_IntegAICY);
370 if(
m_verbose >=3)
Cout(
" iLinearSpectralModel::InitializeSpecific() -> Sampling exponential functions" << endl);
379 spectral_exp[ex] = (
HPFLTNB*) malloc(total_samples *
sizeof(
HPFLTNB));
385 for (
int i = 0; i < total_samples; i++)
387 spectral_exp[ex][i] = (
FLTNB) exp(-0.1 * mp_spectral_bank[ex] * i);
396 ConvSpectralFunctions[ex] = (
HPFLTNB*) malloc(total_samples *
sizeof(
HPFLTNB));
403 #pragma omp parallel for private(ex) schedule(static, 1) 407 for (
int i = 0; i <= total_samples; i++)
409 for (
int j = i; j <= total_samples; j++)
411 ConvSpectralFunctions[ex][j] += (a_AICIntrpYDown[i] * spectral_exp[ex][j - i]);
414 ConvSpectralFunctions[ex][i] *= 0.1;
416 if ( ConvSpectralFunctions[ex][i] <0 )
418 Cout(
" Negative spectral function value detected at " << i <<
", with value: "<< ConvSpectralFunctions[ex][i] <<
419 " -> Setting value to zero "<< endl);
420 ConvSpectralFunctions[ex][i] = 0 ;
422 if (std::isnan(ConvSpectralFunctions[ex][i]))
424 Cout(
" NaN spectral function value detected at " << i <<
"--> Setting value to zero "<< endl);
425 ConvSpectralFunctions[ex][i] = 0 ;
445 RunningSum+=ConvSpectralFunctions[ex][i];
456 if (ConvSpectralFunctions[ex])
delete[] ConvSpectralFunctions[ex];
457 if (ConvSpectralFunctions)
delete[] ConvSpectralFunctions;
465 halfDeltaT = (0.001 / 2);
472 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
void ShowHelp()
This function is used to print out general help about dynamic models.
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...
bool m_full_trapping_basis_flag
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 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
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...
bool m_blood_fraction_fasis_flag
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. ...
void ShowHelpModelSpecific()
This function is used to print out specific help about the dynamic model and its options. It is pure virtual so must be implemented by children.
uint32_t GetFrameTimeStopInMs(int a_bed, int a_frame)
Get the frame time stop for the given bed, in milliseconds as a uint32_t.