TPCCLIB
Loading...
Searching...
No Matches
imglhbdv.c
Go to the documentation of this file.
1
9/*****************************************************************************/
10#include "tpcclibConfig.h"
11/*****************************************************************************/
12#include <stdio.h>
13#include <stdlib.h>
14#include <unistd.h>
15#include <string.h>
16#include <math.h>
17#include <time.h>
18/*****************************************************************************/
19#include "libtpccurveio.h"
20#include "libtpcmodext.h"
21#include "libtpcmisc.h"
22#include "libtpcmodel.h"
23#include "libtpcimgio.h"
24#include "libtpcimgp.h"
25/*****************************************************************************/
26#define NNLS_N 3
27/*****************************************************************************/
28
29/*****************************************************************************/
30static char *info[] = {
31 "Computation of parametric image of blood and distribution volume (Vb and Vt)",
32 "from dynamic PET image in ECAT, NIfTI, or Analyze format applying",
33 "one-tissue compartmental model with arterial blood input.",
34 "The compartmental models are transformed to general linear least squares",
35 "functions, which are solved using Lawson-Hanson non-negative least squares",
36 "(NNLS) algorithm (1). Vt is estimated directly without division (2, 3, 4).",
37 " ",
38 "Dynamic PET image and plasma time-activity curve (PTAC) must be corrected",
39 "for decay to the tracer injection time.",
40 " ",
41 "Usage: @P [Options] btacfile imgfile vbfile vtfile",
42 " ",
43 "Options:",
44 " -thr=<threshold%>",
45 " Pixels with AUC less than (threshold/100 x BTAC AUC) are set to zero",
46 " default is 0%",
47 " -end=<Fit end time (min)>",
48 " Use data from 0 to end time; by default, model is fitted to all frames.",
49 " -max=<Max value>",
50 " Upper limit for Vt values; by default 1000.",
51 " -withVb",
52 " Vt includes Vb; by default not.",
53 " -irrz",
54 " Set Vt to zero in pixels which seem to have irreversible uptake.",
55 " -bc=<filename>",
56 " Dynamic image with Vb correction is saved.",
57 " -stdoptions", // List standard options like --help, -v, etc
58 " ",
59 "The unit of voxel values in the Vt image is (ml blood)/(ml tissue).",
60 " ",
61 "Example:",
62 " @P ua3818ab.kbq ua3818dy1.v ua3818vb.v ua3818vt.v",
63 " ",
64 "References:",
65 "1. Lawson CL & Hanson RJ. Solving least squares problems.",
66 " Prentice-Hall, 1974, ISBN 0-89871-356-0.",
67 "2. Zhou Y, Brasic J, Endres CJ, Kuwabara H, Kimes A, Contoreggi C, Maini A,",
68 " Ernst M, Wong DF. Binding potential image based statistical mapping for",
69 " detection of dopamine release by [11C]raclopride dynamic PET.",
70 " NeuroImage 2002;16(3):S91.",
71 "3. Zhou Y, Brasic JR, Ye W, Dogan AS, Hilton J, Singer HS, Wong DF.",
72 " Quantification of cerebral serotonin binding in normal controls and",
73 " subjects with Tourette's syndrome using [11C]MDL 100,907 and",
74 " (+)[11C]McN 5652 dynamic PET with parametric imaging approach.",
75 " NeuroImage 2004;22(Suppl 2):T98.",
76 "4. Hagelberg N, Aalto S, Kajander J, Oikonen V, Hinkka S, NĂ¥gren K,",
77 " Hietala J, Scheinin H. Alfentanil increases cortical dopamine D2/D3",
78 " receptor binding in healthy subjects. Pain 2004;109:86-93.",
79 " ",
80 "See also: imglhdv, imglhk3, lhsol, imgdv, imgratio, img2tif",
81 " ",
82 "Keywords: image, modelling, distribution volume, vascular fraction, NNLS",
83 0};
84/*****************************************************************************/
85
86/*****************************************************************************/
87/* Turn on the globbing of the command line, since it is disabled by default in
88 mingw-w64 (_dowildcard=0); in MinGW32 define _CRT_glob instead, if necessary;
89 In Unix&Linux wildcard command line processing is enabled by default. */
90/*
91#undef _CRT_glob
92#define _CRT_glob -1
93*/
94int _dowildcard = -1;
95/*****************************************************************************/
96
97/*****************************************************************************/
101int main(int argc, char **argv)
102{
103 int ai, help=0, version=0, verbose=1;
104 char *cptr;
105 char inpfile[FILENAME_MAX], petfile[FILENAME_MAX];
106 char vtfile[FILENAME_MAX], vbfile[FILENAME_MAX];
107 char bcfile[FILENAME_MAX];
108 float calcThreshold=0.0;
109 double upperLimit=1000.0;
110 double fittime=-1.0;
111 int weight=0;
112 int irrevZero=0;
113 int withoutVb=1; // 0= Vt includes Vb, 1= Vt does not include Vb
114 int ret;
115
116
117 /*
118 * Get arguments
119 */
120 if(argc==1) {tpcPrintUsage(argv[0], info, stderr); return(1);}
121 inpfile[0]=petfile[0]=vtfile[0]=vbfile[0]=bcfile[0]=(char)0;
122 /* Get options */
123 for(ai=1; ai<argc; ai++) if(*argv[ai]=='-') {
124 if(tpcProcessStdOptions(argv[ai], &help, &version, &verbose)==0) continue;
125 cptr=argv[ai]+1; if(*cptr=='-') cptr++; if(cptr==NULL) continue;
126 if(strncasecmp(cptr, "THR=", 4)==0) {
127 double v; ret=atof_with_check(cptr+4, &v);
128 if(!ret && v>=0.0 && v<=200.0) {calcThreshold=(float)(0.01*v); continue;}
129 } else if(strncasecmp(cptr, "END=", 4)==0) {
130 fittime=atof_dpi(cptr+4); if(fittime>0.0) continue;
131 } else if(strncasecmp(cptr, "WITHVB=", 5)==0) {
132 withoutVb=0; continue;
133 } else if(strncasecmp(cptr, "WITHOUTVB=", 5)==0) {
134 withoutVb=1; continue;
135 } else if(*cptr=='w' || *cptr=='W') {
136 weight=1; continue;
137 } else if(strncasecmp(cptr, "MAX=", 4)==0) {
138 upperLimit=atof_dpi(cptr+4); if(upperLimit>0.0) continue;
139 } else if(strcasecmp(cptr, "IRRZ")==0) {
140 irrevZero=1; continue;
141 } else if(strncasecmp(cptr, "BC=", 3)==0) {
142 strlcpy(bcfile, cptr+3, FILENAME_MAX); continue;
143 }
144 fprintf(stderr, "Error: invalid option '%s'.\n", argv[ai]);
145 return(1);
146 } else break;
147
148 /* Print help or version? */
149 if(help==2) {tpcHtmlUsage(argv[0], info, ""); return(0);}
150 if(help) {tpcPrintUsage(argv[0], info, stdout); return(0);}
151 if(version) {tpcPrintBuild(argv[0], stdout); return(0);}
152
153 /* Process other arguments, starting from the first non-option */
154 if(ai<argc) strlcpy(inpfile, argv[ai++], FILENAME_MAX);
155 if(ai<argc) strlcpy(petfile, argv[ai++], FILENAME_MAX);
156 if(ai<argc) strlcpy(vbfile, argv[ai++], FILENAME_MAX);
157 if(ai<argc) strlcpy(vtfile, argv[ai++], FILENAME_MAX);
158 if(ai<argc) {fprintf(stderr, "Error: invalid argument '%s'.\n", argv[ai]); return(1);}
159 /* Did we get all the information that we need? */
160 if(!vtfile[0]) {
161 fprintf(stderr, "Error: missing command-line argument; use option --help\n");
162 return(1);
163 }
164 if(strcasecmp(petfile, vtfile)==0 || strcasecmp(petfile, vbfile)==0 ||
165 strcasecmp(vtfile, vbfile)==0 || strcasecmp(inpfile, vbfile)==0)
166 {
167 fprintf(stderr, "Error: check the output filenames.\n");
168 return(1);
169 }
170 /* In verbose mode print arguments and options */
171 if(verbose>1) {
172 printf("inpfile := %s\n", inpfile);
173 printf("petfile := %s\n", petfile);
174 printf("vbfile := %s\n", vbfile);
175 printf("vtfile := %s\n", vtfile);
176 if(bcfile[0]) printf("bcfile := %s\n", bcfile);
177 printf("calcThreshold :=%g\n", calcThreshold);
178 if(upperLimit>0.0) printf("upperLimit := %g\n", upperLimit);
179 printf("weight := %d\n", weight);
180 printf("withoutVb := %d\n", withoutVb);
181 if(fittime>0.0) printf("required_fittime := %g min\n", fittime);
182 printf("irrevZero := %d\n", irrevZero);
183 fflush(stdout);
184 }
185 if(verbose>8) IMG_TEST=verbose-8; else IMG_TEST=0;
186
187
188 /*
189 * Read PET image and input TAC
190 */
191 if(verbose>0) printf("reading data files\n");
192 DFT tac; dftInit(&tac);
193 IMG img; imgInit(&img);
194 int dataNr;
195 {
196 char tmp[512];
197 int ret=imgReadModelingData(
198 petfile, NULL, inpfile, NULL, NULL, &fittime, &dataNr, &img,
199 NULL, &tac, 1, stdout, verbose-2, tmp);
200 if(ret!=0) {
201 fprintf(stderr, "Error: %s.\n", tmp);
202 if(verbose>1) printf(" ret := %d\n", ret);
203 return(2);
204 }
205 if(imgNaNs(&img, 1)>0)
206 if(verbose>0) fprintf(stderr, "Warning: missing pixel values.\n");
207 }
208 /* Set time unit to min, also for integrals in y2[] */
209 if(tac.timeunit==TUNIT_SEC) {
210 for(int fi=0; fi<tac.frameNr; fi++) tac.voi[0].y2[fi]/=60.0;
211 for(int fi=0; fi<tac.frameNr; fi++) tac.voi[0].y3[fi]/=3600.0;
212 }
213 ret=dftTimeunitConversion(&tac, TUNIT_MIN);
214 if(verbose>1) {
215 printf("fittimeFinal := %g min\n", fittime);
216 printf("dataNr := %d\n", dataNr);
217 }
218 /* Check that image is dynamic */
219 if(dataNr<4) {
220 fprintf(stderr, "Error: too few time frames for fitting.\n");
221 if(verbose>0) imgInfo(&img);
222 imgEmpty(&img); dftEmpty(&tac); return(2);
223 }
224
225
226 /* Add place for tissue TACs too */
227 if(verbose>1) fprintf(stdout, "allocating working memory for pixel TACs\n");
228 ret=dftAddmem(&tac, 1);
229 if(ret) {
230 fprintf(stderr, "Error: cannot allocate memory.\n");
231 if(verbose>0) printf("ret := %d\n", ret);
232 imgEmpty(&img); dftEmpty(&tac); return(3);
233 }
234 strcpy(tac.voi[0].name, "input");
235 strcpy(tac.voi[1].name, "tissue");
236
237
238 /*
239 * Allocate result images, for Vb and Vt
240 */
241 if(verbose>1) fprintf(stdout, "allocating memory for parametric image data\n");
242 IMG vbimg; imgInit(&vbimg);
243 IMG vtimg; imgInit(&vtimg);
244 ret=imgAllocateWithHeader(&vbimg, img.dimz, img.dimy, img.dimx, 1, &img);
245 if(!ret) ret=imgAllocateWithHeader(&vtimg, img.dimz, img.dimy, img.dimx, 1, &img);
246 if(ret) {
247 fprintf(stderr, "Error: cannot allocate memory for result image.\n");
248 imgEmpty(&img); dftEmpty(&tac); imgEmpty(&vbimg); imgEmpty(&vtimg); return(4);
249 }
250 /* and set the more or less necessary things */
251 vbimg.start[0]=vtimg.start[0]=0.0;
252 vbimg.end[0]=vtimg.end[0]=60.*fittime;
253 vbimg.unit=vtimg.unit=CUNIT_ML_PER_ML; /* mL/mL */
254
255
256 /*
257 * Allocate memory required by NNLS
258 */
259 if(verbose>1) fprintf(stdout, "allocating memory for NNLS\n");
260 int n, m, nnls_n, nnls_m, nnls_index[NNLS_N];
261 double *nnls_a[NNLS_N], *nnls_b, *nnls_zz, nnls_x[NNLS_N], *nnls_mat,
262 nnls_wp[NNLS_N], *dptr, nnls_rnorm;
263 nnls_n=NNLS_N; nnls_m=dataNr;
264 nnls_mat=(double*)malloc(((nnls_n+2)*nnls_m)*sizeof(double));
265 if(nnls_mat==NULL) {
266 fprintf(stderr, "Error: cannot allocate memory for NNLS.\n");
267 imgEmpty(&img); dftEmpty(&tac); imgEmpty(&vbimg); imgEmpty(&vtimg);
268 return(4);
269 }
270 for(n=0, dptr=nnls_mat; n<nnls_n; n++) {nnls_a[n]=dptr; dptr+=nnls_m;}
271 nnls_b=dptr; dptr+=nnls_m; nnls_zz=dptr;
272
273 /* Copy weights if available */
274 /* or set them to frame lengths */
275 if(weight==1 && img.isWeight==0) {
276 for(m=0; m<nnls_m; m++) img.weight[m]=img.end[m]-img.start[m];
277 img.isWeight=1;
278 }
279 /* Compute weights for NNLS */
280 if(img.isWeight) {
281 for(m=0; m<nnls_m; m++) tac.w[m]=img.weight[m];
282 for(m=0; m<nnls_m; m++) {
283 if(tac.w[m]<=1.0e-20) tac.w[m]=0.0; else tac.w[m]=sqrt(tac.w[m]);
284 }
285 }
286
287
288 /*
289 * Compute pixel-by-pixel
290 */
291 /* Determine the threshold */
292 double threshold=calcThreshold*tac.voi[0].y2[dataNr-1];
293 if(verbose>1) printf("threshold_AUC := %g\n", threshold);
294 if(verbose>0) {fprintf(stdout, "computing NNLS pixel-by-pixel\n"); fflush(stdout);}
295 nnls_n=3;
296 for(int pi=0; pi<img.dimz; pi++) {
297 if(verbose>1) printf("computing plane %d\n", img.planeNumber[pi]);
298 else if(verbose>0 && img.dimz>2) fprintf(stdout, ".");
299 if(verbose>0) fflush(stdout);
300 for(int yi=0; yi<img.dimy; yi++) {
301 for(int xi=0; xi<img.dimx; xi++) {
302 /* Set pixel results to zero */
303 vbimg.m[pi][yi][xi][0]=0.0;
304 vtimg.m[pi][yi][xi][0]=0.0;
305 /* Copy and integrate pixel curve */
306 for(int fi=0; fi<tac.frameNr; fi++)
307 tac.voi[1].y[fi]=img.m[pi][yi][xi][fi];
308 ret=petintegral(tac.x1, tac.x2, tac.voi[1].y, tac.frameNr, tac.voi[1].y2, tac.voi[1].y3);
309 if(ret) continue;
310 /* if AUC at the end is less than threshold value, then do nothing */
311 if(tac.voi[1].y2[dataNr-1]<threshold) continue;
312
313 /* Fill the NNLS data matrix for estimating Vb */
314 for(m=0; m<nnls_m; m++) {
315 nnls_a[0][m]=tac.voi[0].y[m];
316 nnls_a[1][m]=tac.voi[0].y2[m];
317 nnls_a[2][m]=-tac.voi[1].y2[m];
318 nnls_b[m]=tac.voi[1].y[m];
319 }
320 if(img.isWeight) {
321 for(m=0; m<nnls_m; m++) {
322 nnls_b[m]*=tac.w[m];
323 for(n=0; n<nnls_n; n++) nnls_a[n][m]*=tac.w[m];
324 }
325 }
326 /* NNLS */
327 ret=nnls(nnls_a, nnls_m, nnls_n, nnls_b, nnls_x, &nnls_rnorm, nnls_wp, nnls_zz, nnls_index);
328 if(ret>1) { /* no solution is possible */
329 for(n=0; n<nnls_n; n++) nnls_x[n]=0.0;
330 nnls_rnorm=0.0;
331 } else if(ret==1) { /* max iteration count exceeded */ }
332 // if(verbose>10) printf(" %g %g %g\n", nnls_x[0], nnls_x[1], nnls_x[2]);
333 /* Get Vb as the 1st linear coefficient */
334 vbimg.m[pi][yi][xi][0]=nnls_x[0];
335#if(1)
336 /* Subtract vascular contribution from tissue data */
337 for(int i=0; i<tac.frameNr; i++) tac.voi[1].y[i]-=nnls_x[0]*tac.voi[0].y[i];
338 for(int i=0; i<tac.frameNr; i++) tac.voi[1].y2[i]-=nnls_x[0]*tac.voi[0].y2[i];
339 /* Fill the NNLS data matrix for estimating Vt */
340 for(m=0; m<nnls_m; m++) {
341 nnls_a[0][m]=tac.voi[0].y2[m];
342 nnls_a[1][m]=-tac.voi[1].y[m];
343 nnls_b[m]=tac.voi[1].y2[m];
344 }
345 if(img.isWeight) {
346 for(m=0; m<nnls_m; m++) {
347 nnls_b[m]*=tac.w[m];
348 for(n=0; n<2; n++) nnls_a[n][m]*=tac.w[m];
349 }
350 }
351 /* NNLS */
352 ret=nnls(nnls_a, nnls_m, 2, nnls_b, nnls_x, &nnls_rnorm, nnls_wp, nnls_zz, nnls_index);
353 if(ret>1) { /* no solution is possible */
354 for(n=0; n<2; n++) nnls_x[n]=0.0;
355 nnls_rnorm=0.0;
356 } else if(ret==1) { /* max iteration count exceeded */ }
357 // if(verbose>10) printf(" %g %g\n", nnls_x[0], nnls_x[1]);
358 /* Get Vt as the 1st linear coefficient */
359 vtimg.m[pi][yi][xi][0]=nnls_x[0];
360 /* If the second linear component was not needed in NNLS, that means that uptake is irreversible */
361 if(nnls_x[1]<1.0E-20 && nnls_x[0]>1.0E-03) {
362 if(irrevZero) vtimg.m[pi][yi][xi][0]=0.0; else vtimg.m[pi][yi][xi][0]=upperLimit;
363 }
364 /* Add Vb if requested */
365 if(withoutVb==0) {
366 vtimg.m[pi][yi][xi][0]+=vbimg.m[pi][yi][xi][0];
367 if(vtimg.m[pi][yi][xi][0]<0.0) vtimg.m[pi][yi][xi][0]=0.0;
368 }
369
370
371#else
372 /* If K1+Vb*k2 (2nd coefficient) is not > 0, then Vt is 0 */
373 if(!(nnls_x[1]>1.0E-10)) {
374 vtimg.m[pi][yi][xi][0]=0.0;
375 continue;
376 }
377 /* If both K1+Vb*k2 and k2 (last coefficient) are small, then Vt is 0 */
378 if((!(nnls_x[1]>1.0E-04) && !(nnls_x[2]>1.0E-04)) || !((nnls_x[1]+nnls_x[2])>1.0E-03)) {
379 vtimg.m[pi][yi][xi][0]=0.0;
380 continue;
381 }
382 /* If k2 (last coefficient) is not > 0, then Vt is infinite or zero */
383 if(!(nnls_x[2]>1.0E-06)) {
384 /* if K1+Vb+k2 is small, then Vt is zero, otherwise 'infinite' */
385 if(nnls_x[1]>1.0E-03) vtimg.m[pi][yi][xi][0]=upperLimit;
386 else vtimg.m[pi][yi][xi][0]=0.0;
387 continue;
388 }
389 /* Fill the NNLS data matrix for estimating Vt */
390 for(m=0; m<nnls_m; m++) {
391 nnls_a[0][m]=tac.voi[0].y2[m];
392 nnls_a[1][m]=tac.voi[0].y[m];
393 nnls_a[2][m]=-tac.voi[1].y[m];
394 nnls_b[m]=tac.voi[1].y2[m];
395 }
396 if(img.isWeight) {
397 for(m=0; m<nnls_m; m++) {
398 nnls_b[m]*=tac.w[m];
399 for(n=0; n<nnls_n; n++) nnls_a[n][m]*=tac.w[m];
400 }
401 }
402 /* NNLS */
403 ret=nnls(nnls_a, nnls_m, nnls_n, nnls_b, nnls_x, &nnls_rnorm, nnls_wp, nnls_zz, nnls_index);
404 if(ret>1) { /* no solution is possible */
405 for(n=0; n<nnls_n; n++) nnls_x[n]=0.0;
406 nnls_rnorm=0.0;
407 } else if(ret==1) { /* max iteration count exceeded */ }
408 // if(verbose>10) printf(" %g %g %g\n", nnls_x[0], nnls_x[1], nnls_x[2]);
409 /* Get Vt+Vb as the 1st linear coefficient */
410 vtimg.m[pi][yi][xi][0]=nnls_x[0];
411 /* Subtract Vb */
412 if(withoutVb) {
413 vtimg.m[pi][yi][xi][0]-=vbimg.m[pi][yi][xi][0];
414 if(vtimg.m[pi][yi][xi][0]<0.0) vtimg.m[pi][yi][xi][0]=0.0;
415 }
416#endif
417
418 /* Remove values that are higher than the user-defined limit */
419 if(vtimg.m[pi][yi][xi][0]>upperLimit) vtimg.m[pi][yi][xi][0]=upperLimit;
420
421
422 } /* next column */
423 } /* next row */
424 } /* next plane */
425 if(verbose>0) {fprintf(stdout, " done.\n"); fflush(stdout);}
426 /* No need for NNLS data anymore */
427 free(nnls_mat);
428
429
430 /*
431 * Save Vb corrected dynamic image, if requested
432 */
433 if(bcfile[0]) {
434 IMG bcimg; imgInit(&bcimg);
435 ret=imgAllocateWithHeader(&bcimg, img.dimz, img.dimy, img.dimx, img.dimt, &img);
436 if(ret!=0) {
437 fprintf(stderr, "Error: cannot allocate memory.\n");
438 imgEmpty(&img); dftEmpty(&tac); imgEmpty(&vtimg); imgEmpty(&vbimg);
439 return(8);
440 }
441 for(int pi=0; pi<img.dimz; pi++) {
442 for(int yi=0; yi<img.dimy; yi++) {
443 for(int xi=0; xi<img.dimx; xi++) {
444 for(int ti=0; ti<img.dimt; ti++) {
445 double v=img.m[pi][yi][xi][ti]-vbimg.m[pi][yi][xi][ti]*tac.voi[0].y[ti];
446 if(v<0.0) v=0.0;
447 bcimg.m[pi][yi][xi][ti]=v;
448 }
449 }
450 }
451 }
452 if(imgWrite(bcfile, &bcimg)) {
453 fprintf(stderr, "Error: %s\n", bcimg.statmsg);
454 imgEmpty(&img); dftEmpty(&tac); imgEmpty(&vtimg); imgEmpty(&vbimg); imgEmpty(&bcimg);
455 return(13);
456 }
457 if(verbose>0) {fprintf(stdout, "Vb corrected image %s saved.\n", bcfile); fflush(stdout);}
458 imgEmpty(&bcimg);
459 }
460
461
462 /* No need for dynamic image or input data anymore */
463 imgEmpty(&img);
464 dftEmpty(&tac);
465
466
467 /*
468 * Save parametric images
469 */
470 if(imgWrite(vbfile, &vbimg)) {
471 fprintf(stderr, "Error: %s\n", vbimg.statmsg);
472 imgEmpty(&vtimg); imgEmpty(&vbimg);
473 return(11);
474 }
475 if(verbose>0) {fprintf(stdout, "Vb image %s saved.\n", vbfile); fflush(stdout);}
476
477 if(imgWrite(vtfile, &vtimg)) {
478 fprintf(stderr, "Error: %s\n", vtimg.statmsg);
479 imgEmpty(&vtimg); imgEmpty(&vbimg);
480 return(12);
481 }
482 if(verbose>0) {fprintf(stdout, "Vt image %s saved.\n", vtfile); fflush(stdout);}
483
484 imgEmpty(&vtimg); imgEmpty(&vbimg);
485
486 return(0);
487}
488/*****************************************************************************/
489
490/*****************************************************************************/
int atof_with_check(char *double_as_string, double *result_value)
Definition decpoint.c:107
double atof_dpi(char *str)
Definition decpoint.c:59
void dftInit(DFT *data)
Definition dft.c:38
int dftAddmem(DFT *dft, int voiNr)
Definition dft.c:107
void dftEmpty(DFT *data)
Definition dft.c:20
int dftTimeunitConversion(DFT *dft, int tunit)
Definition dftunit.c:119
int IMG_TEST
Definition img.c:6
void imgInfo(IMG *image)
Definition img.c:359
unsigned long long imgNaNs(IMG *img, int fix)
Definition img.c:658
int imgAllocateWithHeader(IMG *image, int planes, int rows, int columns, int frames, IMG *image_from)
Definition img.c:279
void imgEmpty(IMG *image)
Definition img.c:121
void imgInit(IMG *image)
Definition img.c:60
int imgWrite(const char *fname, IMG *img)
Definition imgfile.c:136
int imgReadModelingData(char *petfile, char *siffile, char *inputfile1, char *inputfile2, char *inputfile3, double *fitdur, int *fitframeNr, IMG *img, DFT *inp, DFT *iinp, int verifypeak, FILE *loginfo, int verbose, char *status)
Definition imginput.c:24
int petintegral(double *x1, double *x2, double *y, int nr, double *ie, double *iie)
Integrate PET TAC data to frame mid times.
Definition integr.c:771
Header file for libtpccurveio.
Header file for libtpcimgio.
Header file for libtpcimgp.
Header file for libtpcmisc.
int tpcProcessStdOptions(const char *s, int *print_usage, int *print_version, int *verbose_level)
Definition proginfo.c:40
size_t strlcpy(char *dst, const char *src, size_t dstsize)
Definition strext.c:245
int tpcHtmlUsage(const char *program, char *text[], const char *path)
Definition proginfo.c:213
void tpcPrintBuild(const char *program, FILE *fp)
Definition proginfo.c:383
void tpcPrintUsage(const char *program, char *text[], FILE *fp)
Definition proginfo.c:158
Header file for libtpcmodel.
int nnls(double **a, int m, int n, double *b, double *x, double *rnorm, double *w, double *zz, int *index)
Definition nnls.c:37
Header file for libtpcmodext.
Voi * voi
int timeunit
double * w
double * x1
double * x2
int frameNr
unsigned short int dimx
float **** m
char unit
unsigned short int dimt
int * planeNumber
float * weight
float * start
unsigned short int dimz
unsigned short int dimy
float * end
const char * statmsg
char isWeight
double * y2
double * y
char name[MAX_REGIONNAME_LEN+1]
double * y3