19 #include "i1TCModel.hh" 129 if(
mp_Y[ th ] )
delete mp_Y[ th ] ;
130 if(
mp_X[ th ] )
delete mp_X[ th ] ;
181 cout <<
"-- This class implements a 2 compartments kinetic model " << endl;
182 cout <<
"-- or 1 Tissue Compartment Model (1TCM) for perfusion quantitation " << endl;
183 cout <<
"-- for radiotracers such as [15-O]H2O. " << endl;
185 cout <<
"-- *--------* K1 *--------* " << endl;
186 cout <<
"-- | | -----> | | " << endl;
187 cout <<
"-- | Cp | | Ct | " << endl;
188 cout <<
"-- | | <----- | | " << endl;
189 cout <<
"-- *--------* k2 *--------* " << endl;
191 cout <<
"-- This model contains 3 parameters, including 2 rate constants, " << endl;
192 cout <<
"-- K1 (v/s/v, where v is a volume unit), k2 (s-1) and the arterial volume fraction in tissue (Va), " << endl;
193 cout <<
"-- as described by the following equations : " << endl;
194 cout <<
"-- (1) Cpet ( t ) = Ct( t ) + Va*Cp( t ) " << endl;
195 cout <<
"-- (2) dCt( t ) / dt = K1*Cp( t ) - k2*Ct( t ) " << endl;
196 cout <<
"-- where Cpet( t ) is the image value in voxel for frame t, and" << endl;
197 cout <<
"-- Ct and Cp are activity concentration in tissue and plasma," << endl;
198 cout <<
"-- The model estimates K1, k2 and Va parametric images." << endl;
199 cout <<
"-- The input function (Cp) must be provided by the user." << endl;
201 cout <<
"--------------------------------------" << endl;
202 cout <<
" The model can be initialized using either a configuration text file, or a list of options :" << endl;
204 cout <<
" - CONFIGURATION FILE : (command-line options : _1TCM:path/to/conf/file.txt:)" << endl;
206 cout <<
" 'Input_function:' (mandatory) " << endl;
207 cout <<
" Enter the activity concentration values (kBq/v/s) of the plasma function (cp) for each time frame (tf)," << endl;
208 cout <<
" separated by ','. Time unit is seconds : " << endl;
209 cout <<
" -> Input functions: " << endl;
210 cout <<
" -> val_cp_tf1 , val_cp_tf2 , ..., val_cp_tfn" << endl;
212 cout <<
" 'Integral_input_function:' (optional) " << endl;
213 cout <<
" Enter the activity concentration values of the integral of the plasma function (Icp) for each time frame (tf)," << endl;
214 cout <<
" separated by ','. Time unit is seconds :" << endl;
215 cout <<
" -> Integral_input_function: " << endl;
216 cout <<
" -> val_Icp_tf1, val_Icp_tf2, ..., val_Icp_tfn" << endl;
217 cout <<
" NOTE: If not provided, the integral will be estimated from the input function" << endl;
218 cout <<
" Set the 'Integral method' flag below to select the method for TAC integration (default: WPO))" << endl;
220 cout <<
" 'Optimisation_method:' (optional) Define the method to use for parameters estimation. Only least-squares methods " << endl;
221 cout <<
" (default: NNLS) are currently available to estimate O = (K1, k2, Va)" << endl;
222 cout <<
" Ô = [ X'WX ]-1 X'Wy, with " << endl;
223 cout <<
" with y = data vector " << endl;
224 cout <<
" X = model matrix (Cp, Icp, Cpet) " << endl;
225 cout <<
" W = weights vector (frame duration) " << endl;
226 cout <<
" If the estimated parameter values are negative, the activity value for the related voxels will be kept to their original number" << endl;
227 cout <<
" 0 (default) = Non-negative least-square (NNLS)" << endl;
228 cout <<
" Derived from Turku PET center libraries, authors: Vesa Oikonen and Kaisa Sederholm" << endl;
229 cout <<
" (http://www.turkupetcentre.net/petanalysis/index.html)" << endl;
230 cout <<
" Routine based on the text and fortran code in C.L. Lawson and R.J. Hanson," << endl;
231 cout <<
" Solving Least Squares Problems, Prentice-Hall, Englewood Cliffs, New Jersey, 1974." << endl;
232 cout <<
" Note: K1 estimated values could still be negative as they are computed from a substraction of the estimated NNLS parameters." << endl;
233 cout <<
" Activity values will be kept to their original values for the voxels involved" << endl;
234 cout <<
" 1 = Standard Least Square (LS) optimization " << endl;
236 cout <<
" 'Integration_method:' (optional) Define the method to use for TAC integration over the time samples" << endl;
237 cout <<
" 0 (default) = Weighed parabola overlapping (WPO) (Z.Wang, D.Feng, Int. Sys. Sci 23 (1992), pp.1361-69)" << endl;
238 cout <<
" 1 = Trapezoidal " << endl;
239 cout <<
" 'Ridge_parameter:' (optional) Constant for Ridge Regression during Least-Square optimization (only available with Least-Square algorithm and not NNLS ) " << endl;
240 cout <<
" (default: 0) Bounds must be provided with the eponym options below in order to compute ridge weights and means for the new cost function: " << endl;
241 cout <<
" Ô = [ X'*W*X + t.Rw ]-1 [ X'*W*y ] " << endl;
242 cout <<
" + [ X'*W*X + t.Rw ]-1 [ t.Rw*Rm ] " << endl;
243 cout <<
" with y = data vector " << endl;
244 cout <<
" X = model matrix (Cp, Icp, Cpet) " << endl;
245 cout <<
" W = weights vector (frame duration) " << endl;
246 cout <<
" t = Ridge constant " << endl;
247 cout <<
" Rw= Ridge weights " << endl;
248 cout <<
" Rm= Ridge means " << endl;
249 cout <<
" 'Bounds:' (optional) Upper / Lower Bounds for each 3 parameters, to define ridge means mr0, and weights wr0," << endl;
250 cout <<
" such as mr0 = (Max+Min)/2 and wr0 = 1 / (Max-Min)^2 " << endl;
251 cout <<
" They must be provided as in the following syntax: " << endl;
252 cout <<
" Bounds: K1Max, K1Min, k2Max, k2Min, VaMax, VaMin" << endl;
253 cout <<
" Default: K1(Max,Min) = 0.1, 0. " << endl;
254 cout <<
" K2(Max,Min) = 0.1, 0. " << endl;
255 cout <<
" Va(Max,Min) = 1. , 0. " << endl;
256 cout <<
" 'VA_image:' (optional) Path to an interfile image containing the arterial volume fraction value in tissue for each voxel," << endl;
257 cout <<
" only K1 and k2 rate constants will be estimated (Default: All parameters are estimated) " << endl;
259 cout <<
" - LINE OPTIONS : (command-line options : _1TCM,options:)" << endl;
261 cout <<
" Command-line options just require the samples of the plasma input curve, separated by commas. " << endl;
262 cout <<
" All other options will be set to default. The optimization algorithm will be NNLS, the integration method for TAC will be WPO " << endl;
263 cout <<
" -> 1cptModel,val_cp_tf1 , val_cp_tf2 , ..., val_cp_tfn" << endl;
284 if(
m_verbose >=3)
Cout(
"i1TCModel::ReadAndCheckConfigurationFileSpecific ..."<< endl);
297 string dtag =
"Integration_method";
304 Cerr(
"***** i1TCModel::ReadAndCheckConfigurationFileSpecific() -> Error while trying to read '"<< dtag <<
"' flag in "<<
m_fileOptions << endl);
309 dtag =
"Optimisation_method";
316 Cerr(
"***** i1TCModel::ReadAndCheckConfigurationFileSpecific() -> Error while trying to read '"<< dtag <<
"' flag in "<<
m_fileOptions << endl);
321 dtag =
"Save_blacklisted_voxels_images";
328 Cerr(
"***** vDynamicModel::ReadAndCheckConfigurationFile() -> Error while trying to read '"<< dtag <<
"' flag in " <<
m_fileOptions << endl);
333 const int nb_params = 3;
335 HPFLTNB p_bounds_params[ 6 ] = {0.1, 0., 0.1, 0., 1., 0.};
338 dtag =
"Ridge_Parameter";
345 Cerr(
"***** i1TCModel::ReadAndCheckConfigurationFileSpecific() -> Error while trying to read '"<< dtag <<
"' flag in "<<
m_fileOptions << endl);
360 Cerr(
"***** i1TCModel::ReadAndCheckConfigurationFileSpecific() -> Error while trying to read '"<< dtag <<
"' flag (upper/lower bounds) in "<<
m_fileOptions << endl);
368 for (
int p=0 ; p<nb_params ; p++ )
376 Cerr(
"***** i1TCModel::ReadAndCheckConfigurationFileSpecific() -> Error while trying to read configuration file at: " <<
m_fileOptions << endl);
398 if(
m_verbose >=2)
Cout(
"i1TCModel::ReadAndCheckOptionsList ..."<< endl);
423 if(
m_verbose >=2)
Cout(
"i1TCModel::CheckSpecificParameters ..."<< endl);
428 Cerr(
"***** i1TCModel::CheckSpecificParameters() -> ImageDimensions object has not been provided !" << endl);
435 Cerr(
"***** i1TCModel::CheckSpecificParameters() -> Wrong number of time frame basis functions !" << endl);
442 Cerr(
"***** i1TCModel::CheckSpecificParameters() -> Either a file or a list of options have to be selected to initialize the model, but not both ! " << endl);
449 Cerr(
"***** i1TCModel::CheckSpecificParameters -> Either a file or a list of options should have been provided at this point ! " << endl);
456 Cerr(
"***** i1TCModel::CheckSpecificParameters -> The implemented model is not compatible yet with gated reconstruction (parametric images will be the same for each gate)! " << endl);
464 Cerr(
"***** i1TCModel::CheckSpecificParameters() -> Error, ridge regression is not compatible with NNLS algorithm. Switch 'Optimisation method' flag to LS in order to use ridge-regression !" << endl);
486 if(
m_verbose >=2)
Cout(
"i1TCModel::InitializeSpecific() ..."<< endl);
491 Cerr(
"***** oDynamicModelManager::InitializeSpecific() -> Must call CheckParameters functions before Initialize() !" << endl);
532 string dtag =
"Input_function";
539 Cerr(
"***** i1TCModel::InitializeSpecific() -> Error while trying to read 1TCPM input functions !" << endl);
545 dtag =
"Integral_input_function";
552 Cerr(
"***** i1TCModel::InitializeSpecific() -> Error while trying to read 1TCPM input functions !" << endl);
559 string input_image =
"";
560 int return_value = 0;
562 dtag =
"Parametric_images_init";
569 if( return_value == 0)
579 Cerr(
"***** i1TCModel::InitializeSpecific() -> Error while trying to read the provided initialization parametric images : " << input_image << endl);
583 else if( return_value == 1)
585 Cerr(
"***** i1TCModel::InitializeSpecific() -> Error while trying to read input functions coefficients !" << endl);
598 string path_to_VAimage;
606 Cerr(
"***** i1TCModel::InitializeSpecific() -> Error while trying to read '"<< dtag <<
"' keyword in " <<
m_fileOptions << endl);
610 if(!path_to_VAimage.empty())
616 Cerr(
"***** i1TCModel::InitializeSpecific()-> Error reading Interfile : " << path_to_VAimage <<
" !" << endl);
626 Cerr(
"***** i1TCModel::InitializeSpecific() -> Voxels values in provided Va image ;"<< path_to_VAimage <<
" must be between [0,1]. One voxel value is "<<
m_fileOptions << endl);
639 Cerr(
"***** i1TCModel::InitializeSpecific() -> Error while trying to read configuration file at: " <<
m_fileOptions << endl);
653 "1cpt model configuration"))
655 Cerr(
"***** i1TCModel::InitializeSpecific() -> Failed to correctly read the list of options !" << endl);
730 Cerr(
"***** i1TCModel::InitializeSpecific() -> Error, plasma input curve has not been initialized !" << endl);
806 for (
int pl=0 ; pl<
m_nnlsN ; pl++)
807 for (
int pc=0 ; pc<
m_nnlsN ; pc++)
815 mp_RRnum[ th ]->SetMatriceElt( pl , 0 , 0. ) ;
830 Cout(
"i1TCModel::InitializeSpecific() -> Input Plasma TAC coefficients :" << endl);
835 Cout(
"i1TCModel::InitializeSpecific() -> Plasma TAC coefficients :" << endl);
842 Cout(
"i1TCModel::InitializeSpecific() -> Image update from estimated parametric images is disabled" << endl);
866 if(
m_verbose >=2)
Cout(
"i1TCModel::EstimateModelParameters ..." <<endl);
871 Cerr(
"***** i1TCModel::EstimateModelParameters() -> Called while not initialized !" << endl);
881 Cerr(
"***** i1TCModel::EstimateModelParameters() -> A problem occured when estimating 1cpt model parameters with LS method !" << endl);
889 Cerr(
"***** i1TCModel::EstimateModelParameters() -> A problem occured when estimating 1cpt model parameters with Basis functions method !" << endl);
897 Cerr(
"***** i1TCModel::EstimateModelParameters() -> A problem occured when estimating 1cpt model parameters with NNLS method !" << endl);
908 #pragma omp parallel for private(v) schedule(guided) 970 if(
m_verbose >=2)
Cout(
"i1TCModel::EstimateModelParametersWithNNLS ..." <<endl);
975 Cerr(
"***** i1TCModel::EstimateModelParametersWithNNLS() -> Called while not initialized !" << endl);
985 #pragma omp parallel for private(v) schedule(guided) 994 th = omp_get_thread_num();
1013 int *nnls_index =
new int[
m_nnlsN ];
1018 FLTNB *dptr=_p_nnlsMat;
1043 for(
size_t t=0; t<nb_tf; t++)
1044 ct[t] = ap_ImageS->
m4p_image[t][rg][cg][v];
1049 for(
size_t t=0; t<nb_tf; t++)
1052 if (ct[t]<0) ct[t]=0.;
1063 for(
size_t t=0; t<nb_tf; t++)
1065 if(cti[t]<0) cti[t] = 0.;
1068 _2p_nnlsA[0][t]=-cti[t]*
mp_w[t];
1070 _2p_nnlsA[1][t]=cpi[t]*mp_w[t];
1072 _2p_nnlsA[2][t]=cp[t]*mp_w[t];
1075 _p_nnlsB[t]=ct[t]*mp_w[t];
1078 if(
NNLS(_2p_nnlsA, nb_tf, m_nnlsN, _p_nnlsB, nnls_x, &nnls_rnorm,
1079 nnls_wp, nnls_zz, nnls_index) )
1101 for(
size_t t=0; t<nb_tf; t++)
1105 _2p_nnlsA[0][t] = -cti[t]*
mp_w[t];
1107 _2p_nnlsA[1][t] = cpi[t]*mp_w[t];
1110 _p_nnlsB[t] = ct[t]*mp_w[t];
1114 if(
NNLS(_2p_nnlsA, nb_tf, m_nnlsN, _p_nnlsB, nnls_x, &nnls_rnorm,
1115 nnls_wp, nnls_zz, nnls_index) )
1125 if(nnls_x)
delete[]nnls_x;
1126 if(nnls_wp)
delete[]nnls_wp;
1127 if(nnls_index)
delete[]nnls_index;
1149 if(
m_verbose >=2)
Cout(
"i1TCModel::EstimateModelParametersWithBF ..." <<endl);
1154 Cerr(
"***** i1TCModel::EstimateModelParametersWithBF() -> Called while not initialized !" << endl);
1159 Cerr(
"i1TCModel::EstimateModelParametersWithBF -> Not yet implemented !!!" <<endl);
1184 if(
m_verbose >=2)
Cout(
"i1TCModel::EstimateModelParametersWithLS ..." <<endl);
1189 Cerr(
"***** i1TCModel::EstimateModelParametersWithLS() -> Called while not initialized !" << endl);
1198 bool error_in_th_loop =
false;
1199 string error_msg =
"";
1204 #pragma omp parallel for private(v) schedule(guided) 1213 th = omp_get_thread_num();
1226 for(
size_t t=0; t<nb_tf; t++)
1227 ct[t] = ap_ImageS->
m4p_image[t][rg][cg][v];
1233 for(
size_t t=0; t<nb_tf; t++)
1236 if (ct[t]<0) ct[t]=0.;
1252 LS_Mod[0][t] = -cti[t];
1254 LS_Mod[1][t] = cpi[t];
1257 LS_Mod[2][t] = cp[t];
1271 error_in_th_loop =
true;
1272 error_msg =
"***** i1TCModel::EstimateModelParametersWithLS() -> An error occurred when minimizing WRSS function with ridge-regression!";
1285 error_in_th_loop =
true;
1286 error_msg =
"***** i1TCModel::EstimateModelParametersWithLS() -> An error occurred when minimizing WRSS function with standard LS!";
1301 if( LS_res )
delete[] LS_res;
1304 if ( error_in_th_loop ==
true )
1306 Cerr(error_msg << endl);
1355 Cerr(
"***** i1TCModel::RRLS() -> Called while not initialized !" << endl);
1364 Cerr(
"***** i1TCModel::RRLS() -> Function is called while the optimization method is not Least-square !" << endl);
1370 th = omp_get_thread_num();
1387 for( uint16_t t=0 ; t<a_nT ; t++ )
1391 for( uint16_t p=0 ; p<a_nP ; p++ )
1392 for( uint16_t t=0 ; t<a_nT ; t++ )
1399 cout <<
" ----------------------------------------------- " << endl;
1400 cout <<
" X->Describe() " << endl;
1401 cout <<
" ----------------------------------------------- " << endl;
1409 for( uint16_t p=0 ; p<a_nP ; p++ )
1410 for( uint16_t t=0 ; t<a_nT ; t++ )
1411 X->
SetMatriceElt( t , p , a2p_model[ p ][ t ] * ap_w[ t ] );
1417 cout <<
" ----------------------------------------------- " << endl;
1418 cout <<
" Xt->Describe() " << endl;
1420 cout <<
" ----------------------------------------------- " << endl;
1428 for (
int pl=0 ; pl<a_nP ; pl++)
1429 for (
int pc=0 ; pc<a_nP ; pc++)
1438 cout <<
" ----------------------------------------------- " << endl;
1439 cout <<
" X'WX->Describe() " << endl;
1441 cout <<
" ----------------------------------------------- " << endl;
1447 if ( XtX->
Inverse( LSden ) == 1 )
1449 for( uint16_t p=0 ; p<a_nP ; p++ )
1450 ap_result[ p ] = 0.;
1458 cout <<
" ----------------------------------------------- " << endl;
1459 cout <<
" RRLS denominator ->Describe() " << endl;
1461 cout <<
" ----------------------------------------------- " << endl;
1471 cout <<
" ----------------------------------------------- " << endl;
1472 cout <<
" LS numerator ->Describe() " << endl;
1474 cout <<
" ----------------------------------------------- " << endl;
1482 for (
int p=0 ; p<a_nP ; p++)
1489 cout <<
" ----------------------------------------------- " << endl;
1490 cout <<
" RRLS numerator ->Describe() " << endl;
1492 cout <<
" ----------------------------------------------- " << endl;
1505 cout <<
" ----------------------------------------------- " << endl;
1506 cout <<
" Theta->Describe() " << endl;
1512 for( uint16_t p=0 ; p<a_nP ; p++ )
1557 Cerr(
"***** i1TCModel::LS() -> Called while not initialized !" << endl);
1566 Cerr(
"***** i1TCModel::LS() -> Function is called while the optimization method is not Least-square !" << endl);
1572 th = omp_get_thread_num();
1585 for( uint16_t t=0 ; t<a_nT ; t++ )
1589 for( uint16_t p=0 ; p<a_nP ; p++ )
1590 for( uint16_t t=0 ; t<a_nT ; t++ )
1597 cout <<
" ----------------------------------------------- " << endl;
1598 cout <<
" X->Describe() " << endl;
1599 cout <<
" ----------------------------------------------- " << endl;
1607 for( uint16_t p=0 ; p<a_nP ; p++ )
1608 for( uint16_t t=0 ; t<a_nT ; t++ )
1609 X->
SetMatriceElt( t , p , a2p_model[ p ][ t ] * ap_w[ t ] );
1615 cout <<
" ----------------------------------------------- " << endl;
1616 cout <<
" Xt->Describe() " << endl;
1618 cout <<
" ----------------------------------------------- " << endl;
1628 cout <<
" ----------------------------------------------- " << endl;
1629 cout <<
" X'WX->Describe() " << endl;
1631 cout <<
" ----------------------------------------------- " << endl;
1641 cout <<
" ----------------------------------------------- " << endl;
1642 cout <<
" LS numerator ->Describe() " << endl;
1644 cout <<
" ----------------------------------------------- " << endl;
1650 if ( XtX->
Inverse( LSden ) == 1 )
1652 for( uint16_t p=0 ; p<a_nP ; p++ )
1653 ap_result[ p ] = 0.;
1661 cout <<
" ----------------------------------------------- " << endl;
1662 cout <<
" LS denominator ->Describe() " << endl;
1664 cout <<
" ----------------------------------------------- " << endl;
1674 cout <<
" ----------------------------------------------- " << endl;
1675 cout <<
" Theta->Describe() " << endl;
1681 for( uint16_t p=0 ; p<a_nP ; p++ )
1705 if(
m_verbose >= 2)
Cout(
"i1TCModel::EstimateImageWithModel ... " <<endl);
1710 Cerr(
"***** i1TCModel::EstimateImageWithModel() -> Called while not initialized !" << endl);
1721 DTavg[ 0 ] =
mp_DT2[ 0 ];
1729 #pragma omp parallel for private(v) schedule(guided) 1738 if( ( K1>0. || k2>0. || Va>0.)
1739 && ( K1>=0. && k2>=0. && Va>=0. ) )
1752 b = cti + DTavg[t]*b_ct ;
1755 / ( 1 + k2*DTavg[ t ] );
1767 / (1 + k2*DTavg[t]);
1770 cti +=
WPOinc( t, ct, b_ct, bb_ct, n_ct);
1773 cti +=
mp_DT2[t]*(ct + b_ct);
1777 ap_ImageS->
m4p_image[t][rg][cg][v] = (new_value > 0) ?
1815 FLTNB wpo_p=0., wpo_p_n=0, wpo_fd_n=0., wpo_bd=0.;
1816 uint32_t t = a_time;
1819 Itac =
mp_DT2[t]*tac*0.5;
1823 wpo_fd_n = 2*
mp_DT2[1] * ( 0.5*( tac + b_tac ) + wpo_p_n *
mp_wpoQ[t+1] );
1824 wpo_bd =
mp_DT2[t-1] * ( b_tac + tac );
1833 wpo_fd_n = 2*
mp_DT2[t] * ( 0.5*( tac + b_tac ) + wpo_p_n *
mp_wpoQ[t+1] );
1834 wpo_bd = 2*
mp_DT2[t-1] * ( 0.5*( b_tac + tac ) + wpo_p /
mp_wpoQ[t] );
1841 wpo_bd = 2*
mp_DT2[t-1] * ( 0.5*( b_tac + tac ) + wpo_p /
mp_wpoQ[t] );
1867 return WPO(ap_tac, ap_citac, a_th);
1869 return Trapz(ap_tac, ap_citac);
1899 for(uint32_t t=0 ; t<nb_tf ; t++)
1904 WPO_BD[t] = ap_tac[0] ;
1905 WPO_FD[t] = ap_tac[0] ;
1910 WPO_FD[t] = DT2[t-1] *( ( ap_tac[ t-1 ] ) );
1911 WPO_BD[t] = DT2[t-1] *( ( ap_tac[ t-1 ] + ap_tac[ t ] ));
1915 WPO_P[t] = ( ap_tac[ t-1 ] - ( DT2[t]*ap_tac[ t-2 ] + DT2[t-1]*ap_tac[ t ] ) / ( DT2[t] + DT2[t-1] ) ) / 6;
1916 WPO_FD[t] = 2*DT2[t-1] * ( 0.5 *( ap_tac[ t-1 ] + ap_tac[ t-2 ] ) + WPO_P[t] *
mp_wpoQ[t] );
1917 WPO_BD[t] = 2*DT2[t-1] * ( 0.5 *( ap_tac[ t-1 ] + ap_tac[ t ] ) + WPO_P[t] /
mp_wpoQ[t] );
1922 for(uint32_t t=0 ; t<nb_tf ; t++)
1926 itac = ap_tac[ t ] * DT2[ t ] ;
1927 else if( t == (nb_tf-1) )
1930 itac = (1-
mp_wpoA[ t ]) * WPO_BD[ t ] +
mp_wpoA[ t ]*WPO_FD[ t+1 ];
1934 ap_citac[ t ] = itac ;
1936 ap_citac[ t ] = ap_citac[ t-1] + itac;
1963 for(uint32_t t=0 ; t<nb_tf ; t++)
1970 itac = ap_tac[0] * DT2[0] *0.5;
1975 itac = ( ap_tac[t]+ap_tac[t-1] ) * DT2[t];
1976 ap_citac[t] += ap_citac[t-1] + itac;
#define INTF_LERP_DISABLED
int NNLS(FLTNB **A, int m, int n, FLTNB *B, FLTNB *X, FLTNB *rnorm, FLTNB *wp, FLTNB *zzp, int *indexp)
int Inverse(oMatrix *ap_MtxResult)
int CheckSpecificParameters()
This function is used to check whether all member variables have been correctly initialized or not...
int ReadStringOption(const string &a_input, T *ap_return, int a_nbElts, const string &sep, const string &a_option)
Parse the 'a_input' string corresponding to the 'a_option' into 'a_nbElts' elements, using the 'sep' separator. The results are returned in the templated 'ap_return' dynamic templated array. Call "ConvertFromString()" to perform the correct conversion depending on the type of the data to convert.
FLTNB GetFrameDurationInSec(int a_bed, int a_frame)
i1TCModel()
Constructor of i1TCModel. Simply set all data members to default values.
int InitializeSpecific()
This function is used to initialize parametric images and basis functions.
FLTNB * mp_parLowerBounds
bool m_ridgeRegressionFlag
oImageDimensionsAndQuantification * mp_ID
void ShowHelp()
This function is used to print out general help about dynamic models.
FLTNB ** m2p_parametricImages
This is the mother class of dynamic model classes.
~i1TCModel()
Destructor of i1TCModel.
bool m_saveBlacklistedImageMaskFlag
int Trapz(FLTNB *ap_tac, FLTNB *ap_citac)
FLTNB * mp_blackListedvoxelsImage
int EstimateModelParametersWithBF(oImageSpace *ap_ImageS)
int RRLS(uint16_t a_nP, uint16_t a_nT, FLTNB **a2p_model, FLTNB *ap_data, FLTNB *ap_w, FLTNB *ap_result)
int IntfReadImage(const string &a_pathToHeaderFile, FLTNB *ap_ImgMatrix, oImageDimensionsAndQuantification *ap_ID, int vb, bool a_lerpFlag)
Main function dedicated to Interfile 3D image loading.
int WPO(FLTNB *ap_tac, FLTNB *ap_citac, int a_th)
FLTNB ** m2p_nestedModelTimeBasisFunctions
int ReadAndCheckOptionsList(string a_listOptions)
int EstimateModelParameters(oImageSpace *ap_Image, int a_ite, int a_sset)
int ReadAndCheckConfigurationFileSpecific()
This function is used to read options from a configuration file.
int EstimateImageWithModel(oImageSpace *ap_Image, int a_ite, int a_sset)
HPFLTNB GetMatriceElt(uint16_t l, uint16_t c)
void Describe()
Display the element of the matrix.
#define KEYWORD_MANDATORY
int IntfReadImgDynCoeffFile(const string &a_pathToHeaderFile, FLTNB **a2p_ImgMatrix, oImageDimensionsAndQuantification *ap_ID, int a_nbFbases, int vb, bool a_lerpFlag)
Function dedicated to Interfile image reading for dynamic coefficients images.
int EstimateModelParametersWithLS(oImageSpace *ap_ImageS)
int GetNbCardGates()
Get the number of cardiac gates.
This class holds all the matrices in the image domain that can be used in the algorithm: image...
int m_OptimisationMethodFlag
int GetNbThreadsForImageComputation()
Get the number of threads used for image operations.
int GetNbTimeFrames()
Get the number of time frames.
INTNB GetNbVoxXYZ()
Get the total number of voxels.
Structure designed for basic matrices operations.
int EstimateModelParametersWithNNLS(oImageSpace *ap_ImageS)
int GetNbRespGates()
Get the number of respiratory gates.
int LS(uint16_t a_nP, uint16_t a_nT, FLTNB **a2p_model, FLTNB *ap_data, FLTNB *ap_w, FLTNB *ap_result)
int Multiplication(oMatrix *ap_Mtx, oMatrix *ap_MtxResult)
FLTNB WPOinc(uint32_t a_time, FLTNB tac, FLTNB b_tac, FLTNB bb_tac, FLTNB n_tac)
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...
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.
int SetMatriceElt(uint16_t l, uint16_t c, HPFLTNB a_val)
int IntegrateTAC(FLTNB *ap_tac, FLTNB *ap_citac, int a_th)
int Transpose(oMatrix *a_MtxResult)
FLTNB * mp_parUpperBounds