10#include "tpcclibConfig.h"
26static char *info[] = {
29 "Calculate the distribution volume (Vt) or distribution volume ratio (DVR)",
30 "using multiple-time graphical analysis (MTGA) for reversible PET",
31 "ligands (Logan plot) (1,2,3) from regional PET time-activity curves (TACs).",
33 "Usage: @P [options] tacfile input starttime endtime resultfile",
36 " -k2=<reference region k2>",
37 " With reference region input, the population average of reference",
38 " region k2 (or k2/(1+k5/k6) in 3-compartment model) is set.",
40 " With reference input, BPnd (=DVR-1) is reported instead of DVR",
41 " -BPnd=<reference region name>",
42 " With plasma input, BPnd can be calculated as DVroi/DVref-1",
43 " -DVR=<reference region name>",
44 " With plasma input, DVR can be calculated as DVroi/DVref",
45 " -BPp=<reference region name>",
46 " With plasma input, BPp can be calculated as DVroi-DVref",
48 " Standard deviations are saved (y, default) or not saved (n) in results.",
50 " Mid frame times are used (y) or not used (n, default) even if frame",
51 " start and end times are available.",
53 " Plots are written in specified file in Scalable Vector Graphics (SVG) 1.1",
54 " format; specification in https://www.w3.org/TR/SVG/",
55 " -plotdata=<Filename>",
56 " Data for plots is written in specified file in XHTML table format for",
57 " easy importing in Excel or OpenOffice spreadsheet, where the data can",
58 " be viewed; if filename extension is .dft, data is written in DFT format",
60 " Options for selecting the least-squares line fit method:",
61 " -C for Traditional regression model",
62 " -M for Median of two-point slopes and intercepts (Cornish-Bowden)",
63 " -P for Perpendicular regression model (4)",
64 " -R for Iterative method (York 1966, Lybanon 1984, Reed 1992); default",
65 " If tissue file contains weights, the iterative method (-R) is weighted.",
66 " With other fitting methods the weights are not used.",
67 " With options -C and -R program can automatically find the linear plot",
68 " range, if fit start time is set to zero.",
72 "Tissue curves are in ut2345.dft and plasma curve in ut2345ap.dat;",
73 "fitted data range is from 10 to 60 min; standard deviations are not needed:",
74 " @P -nosd ut2345.dft ut2345ap.dat 10 60 ut2345.res",
77 "Tissue curves in ut1234.dft, including reference region 'cer'; reference",
78 "tissue k2 is assumed to equal 0.163; plot is saved for viewing in",
80 " @P -svg=ut2345lplot.svg ut2345.dft cer -k2=0.163 20 60 ut2345.res",
83 "1. Logan J, Fowler JS, Volkow ND, Wolf AP, Dewey SL, Schlyer DJ,",
84 " MacGregor RR, Hitzemann R, Bendriem B, Gatley SJ, Christman DR.",
85 " Graphical analysis of reversible radioligand binding from time-activity",
86 " measurements applied to [N-11C-methyl]-(-)-cocaine PET studies in human",
87 " subjects. J Cereb Blood Flow Metab 1990; 10: 740-747.",
88 "2. Logan J, Fowler JS, Volkow ND, Wang GJ, Ding YS, Alexoff DL.",
89 " Distribution volume ratios without blood sampling from graphical",
90 " analysis of PET data. J Cereb Blood Flow Metab. 1996; 16: 834-840.",
91 "3. Logan J. Graphical analysis of PET data applied to reversible and",
92 " irreversible tracers. Nucl Med Biol 2000; 27:661-670.",
93 "4. Varga J & Szabo Z. Modified regression model for the Logan plot.",
94 " J Cereb Blood Flow Metab 2002; 22:240-244.",
96 "See also: imgdv, fitk4, lhsoldv, patlak, rescoll, res2html",
98 "Keywords: TAC, modelling, Vt, DVR",
117int main(
int argc,
char **argv)
119 int ai, help=0, version=0, verbose=1;
120 char tacfile[FILENAME_MAX], inpfile[FILENAME_MAX], resfile[FILENAME_MAX], svgfile[FILENAME_MAX];
123 double tstart=nan(
""), tstop=nan(
"");
128 if(argc==1) {
tpcPrintUsage(argv[0], info, stderr);
return(1);}
129 tacfile[0]=inpfile[0]=resfile[0]=svgfile[0]=(char)0;
130 k2=tstart=tstop=nan(
"");
132 for(ai=1; ai<argc; ai++)
if(*argv[ai]==
'-') {
134 char *cptr=argv[ai]+1;
if(*cptr==
'-') cptr++;
if(!*cptr)
continue;
135 if(strncasecmp(cptr,
"SVG=", 4)==0) {
136 strlcpy(svgfile, cptr+4, FILENAME_MAX);
if(strlen(svgfile)>0)
continue;
137 }
else if(strncasecmp(cptr,
"K2=", 3)==0) {
139 }
else if(strncasecmp(cptr,
"SD=", 3)==0) {
140 save_stat=
tpcYesNo(cptr+3);
if(save_stat>=0)
continue;
142 fprintf(stderr,
"Error: invalid option '%s'\n", argv[ai]);
151 if(help==2) {
tpcHtmlUsage(argv[0], info,
"");
return(0);}
156 if(ai<argc)
strlcpy(tacfile, argv[ai++], FILENAME_MAX);
157 if(ai<argc)
strlcpy(inpfile, argv[ai++], FILENAME_MAX);
160 fprintf(stderr,
"Error: invalid start time '%s'.\n", argv[ai]);
return(1);}
165 fprintf(stderr,
"Error: invalid stop time '%s'.\n", argv[ai]);
return(1);}
168 if(ai<argc)
strlcpy(resfile, argv[ai++], FILENAME_MAX);
170 fprintf(stderr,
"Error: invalid argument '%s'.\n", argv[ai]);
175 fprintf(stderr,
"Error: missing command-line argument; use option --help\n");
179 if(!isnan(tstart) && !isnan(tstop) && tstop<=tstart) {
180 fprintf(stderr,
"Error: illegal time range %g-%g\n", tstart, tstop);
187 printf(
"tacfile := %s\n", tacfile);
188 printf(
"inpfile := %s\n", inpfile);
189 printf(
"resfile := %s\n", resfile);
190 printf(
"svgfile := %s\n", svgfile);
191 if(!isnan(k2)) printf(
"k2 := %g\n", k2);
192 printf(
"tstart := %g\n", tstart);
193 printf(
"tstop := %g\n", tstop);
194 printf(
"save_stat := %d\n", save_stat);
201 if(verbose>0) printf(
"reading tissue and input data\n");
205 if(tstop>0.01) fitdur=tstop;
else fitdur=1.0E+10;
208 &fitSampleNr, &tac, &input, &status)!=
TPCERROR_OK) {
214 printf(
"tacNr := %d\n", tac.
tacNr);
215 printf(
"tac.sampleNr := %d\n", tac.
sampleNr);
216 printf(
"input.sampleNr := %d\n", input.
sampleNr);
217 printf(
"fitSampleNr := %d\n", fitSampleNr);
220 printf(
"fitdur := %g s\n", fitdur);
double atofVerified(const char *s)
int atofCheck(const char *s, double *v)
int tpcProcessStdOptions(const char *s, int *print_usage, int *print_version, int *verbose_level)
int tpcYesNo(const char *s)
int tpcHtmlUsage(const char *program, char *text[], const char *path)
void tpcPrintBuild(const char *program, FILE *fp)
void tpcPrintUsage(const char *program, char *text[], FILE *fp)
void statusInit(TPCSTATUS *s)
char * errorMsg(tpcerror e)
void statusSet(TPCSTATUS *s, const char *func, const char *srcfile, int srcline, tpcerror error)
size_t strlcpy(char *dst, const char *src, size_t dstsize)
int verbose
Verbose level, used by statusPrint() etc.
tpcerror error
Error code.
char * tacFormattxt(tacformat c)
Header file for library libtpcextensions.
char * unitName(int unit_code)
Header file for libtpcli.
Header file for libtpclinopt.
Header file for libtpcpar.
Header file for library libtpctac.
Header file for libtpctacmod.