TPCCLIB
Loading...
Searching...
No Matches
tac2nii.c
Go to the documentation of this file.
1
7/*****************************************************************************/
8#include "tpcclibConfig.h"
9/*****************************************************************************/
10#include <stdio.h>
11#include <stdlib.h>
12#include <unistd.h>
13#include <math.h>
14#include <string.h>
15#include <time.h>
16/*****************************************************************************/
17#include "tpcextensions.h"
18#include "tpcift.h"
19#include "tpccsv.h"
20#include "tpctac.h"
21#include "tpcdcm.h"
22#include "tpcecat.h"
23#include "tpcnifti.h"
24#include "tpcimage.h"
25/*****************************************************************************/
26
27/*****************************************************************************/
28int simRCDims(
30 const long long N,
32 const int mxdim,
34 const int mydim,
36 const int mzdim,
38 int *rnx,
40 int *rny,
42 int *rnz,
44 int *rcxdim,
46 int *rcydim,
48 int *rczdim
49);
50/*****************************************************************************/
51
52/*****************************************************************************/
53static char *info[] = {
54 "Create a 4D PET image file in NIfTI 1S format, with contents from",
55 "the user-specified TAC file, for software testing.",
56 "Image volume is divided into rectangular cuboids, containing as pixel",
57 "values the regional TAC values.",
58 "Frame times are written in SIF as specified in the TAC file.",
59 " ",
60 "Usage: @P [Options] tacfile xdim ydim zdim imagefile [template]",
61 " ",
62 "If file name for template NIfTI is given, the rectangular cuboids are",
63 "are saved in it, with integer pixel values starting from 1.",
64 " ",
65 "Options:",
66 " -stdoptions", // List standard options like --help, -v, etc
67 " ",
68 "See also: dft2img, flat2img, img2tif, img2dft, simboxes, pxl2mask",
69 " ",
70 "Keywords: image, NIfTI, simulation, software testing",
71 0};
72/*****************************************************************************/
73
74/*****************************************************************************/
75/* Turn on the globbing of the command line, since it is disabled by default in
76 mingw-w64 (_dowildcard=0); in MinGW32 define _CRT_glob instead, if necessary;
77 In Unix&Linux wildcard command line processing is enabled by default. */
78/*
79#undef _CRT_glob
80#define _CRT_glob -1
81*/
82int _dowildcard = -1;
83/*****************************************************************************/
84
85/*****************************************************************************/
89/*****************************************************************************/
90int main(int argc, char **argv)
91{
92 int ai, help=0, version=0, verbose=1;
93 char tacfile[FILENAME_MAX], dbname[FILENAME_MAX], tname[FILENAME_MAX];
94 int dimx=0, dimy=0, dimz=0;
95 int ret=0;
96
97 /*
98 * Get arguments
99 */
100 if(argc==1) {tpcPrintUsage(argv[0], info, stderr); return(1);}
101 tacfile[0]=dbname[0]=tname[0]=(char)0;
102 /* Options */
103 for(ai=1; ai<argc; ai++) if(*argv[ai]=='-') { /* options */
104 char *cptr=argv[ai]+1; if(*cptr=='-') cptr++; if(cptr==NULL) continue;
105 if(tpcProcessStdOptions(argv[ai], &help, &version, &verbose)==0) continue;
106 fprintf(stderr, "Error: invalid option '%s'.\n", argv[ai]);
107 return(1);
108 } else break; // tac name argument may start with '-'
109
110 TPCSTATUS status; statusInit(&status);
111 statusSet(&status, __func__, __FILE__, __LINE__, TPCERROR_OK);
112 status.verbose=verbose-1;
113
114 /* Print help or version? */
115 if(help==2) {tpcHtmlUsage(argv[0], info, ""); return(0);}
116 if(help) {tpcPrintUsage(argv[0], info, stdout); return(0);}
117 if(version) {tpcPrintBuild(argv[0], stdout); return(0);}
118
119 /* Process other arguments, starting from the first non-option */
120 ret=0;
121 if(ai<argc) {strlcpy(tacfile, argv[ai], FILENAME_MAX); ai++;}
122 if(ai<argc) {if(atoiCheck(argv[ai++], &dimx)) ret++;}
123 if(ai<argc) {if(atoiCheck(argv[ai++], &dimy)) ret++;}
124 if(ai<argc) {if(atoiCheck(argv[ai++], &dimz)) ret++;}
125 if(ret || dimx<1 || dimy<1 || dimz<1) {
126 fprintf(stderr, "Error: invalid dimension.\n");
127 return(1);
128 }
129 if(ai<argc) {strlcpy(dbname, argv[ai], FILENAME_MAX); ai++;}
130 if(ai<argc) {strlcpy(tname, argv[ai], FILENAME_MAX); ai++;}
131 if(ai<argc) {fprintf(stderr, "Error: too many arguments.\n"); return(1);}
132
133 /* Is something missing or wrong? */
134 if(!dbname[0]) {
135 fprintf(stderr, "Error: missing command-line argument; use option --help\n");
136 return(1);
137 }
138
139 /* In verbose mode print arguments and options */
140 if(verbose>1) {
141 printf("tacfile := %s\n", tacfile);
142 printf("dbname := %s\n", dbname);
143 if(tname[0]) printf("tname := %s\n", tname);
144 printf("dimx := %d\n", dimx);
145 printf("dimy := %d\n", dimy);
146 printf("dimz := %d\n", dimz);
147 fflush(stdout);
148 }
149
150 /*
151 * Read regional data
152 */
153 if(verbose>1) printf("reading %s\n", tacfile);
154 TAC tac;
155 tacInit(&tac);
156 ret=tacRead(&tac, tacfile, &status);
157 if(ret!=TPCERROR_OK) {
158 fprintf(stderr, "Error (%d): %s\n", ret, errorMsg(status.error));
159 tacFree(&tac); return(2);
160 }
161 if(verbose>2) {
162 printf("fileformat := %s\n", tacFormattxt(tac.format));
163 printf("tacNr := %d\n", tac.tacNr);
164 printf("sampleNr := %d\n", tac.sampleNr);
165 printf("xunit := %s\n", unitName(tac.tunit));
166 printf("yunit := %s\n", unitName(tac.cunit));
167 printf("isframe := %d\n", tac.isframe);
168 fflush(stdout);
169 }
170 /* Get the min and max pixel values for the header and scaling */
171 double min, max;
172 if(tacYRange(&tac, -1, &min, &max, NULL, NULL, NULL, NULL)) {
173 fprintf(stderr, "Error: invalid TAC contents.\n");
174 tacFree(&tac);
175 return(2);
176 }
177 if(verbose>2) printf("min := %g\nmax := %g\n", min, max);
178
179
180 /*
181 * Determine dimensions of rectangular cuboids
182 */
183 if(verbose>1) printf("Determine dimensions of rectangular cuboids\n");
184 int rdimx=0, rdimy=0, rdimz=0;
185 int rnx=0, rny=0, rnz=0;
186 if(simRCDims(tac.tacNr, dimx, dimy, dimz, &rnx, &rny, &rnz, &rdimx, &rdimy, &rdimz)) {
187 fprintf(stderr, "Error: incompatible input data.\n");
188 tacFree(&tac);
189 return(3);
190 }
191 if(verbose>3)
192 printf("%d into %d x %d x %d -> %d x %d x %d (%d x %d x %d)\n",
193 tac.tacNr, dimx, dimy, dimz, rdimx, rdimy, rdimz, rnx, rny, rnz);
194
195
196 /*
197 * Make template data
198 */
199 if(verbose>1) printf("Allocate memory for template xyz matrix\n");
200 size_t pxlNr=(size_t)dimz*dimy*dimx;
201 int *idata;
202 idata=(int*)calloc(pxlNr, sizeof(int));
203 if(idata==NULL) {
204 fprintf(stderr, "Error: out of memory.\n");
205 tacFree(&tac);
206 return(4);
207 }
208 /* Fill the template with TAC numbers */
209 if(verbose>1) printf("Fill the template\n");
210 {
211 int xi, yi, zi;
212 int x[2], y[2], z[2];
213 xi=yi=zi=0;
214 for(int ri=0; ri<tac.tacNr; ri++) {
215 x[0]=xi*rdimx; x[1]=x[0]+rdimx-1;
216 y[0]=yi*rdimy; y[1]=y[0]+rdimy-1;
217 z[0]=zi*rdimz; z[1]=z[0]+rdimz-1;
218 if(verbose>4)
219 printf(" %s : %d,%d,%d - %d,%d,%d\n", tac.c[ri].name, x[0],y[0],z[0], x[1],y[1],z[1]);
220 for(int cz=z[0]; cz<=z[1]; cz++)
221 for(int cy=y[0]; cy<=y[1]; cy++)
222 for(int cx=x[0]; cx<=x[1]; cx++) {
223 size_t pos=((size_t)dimy*dimx)*cz + dimx*cy + cx;
224 idata[pos]=1+ri;
225 }
226 xi++; if(xi==rnx) {xi=0; yi++; if(yi==rny) {yi=0; zi++; if(zi==rnz) break;}}
227 }
228 }
229
230
231 /*
232 * Set NIfTI header contents, first for the template
233 */
234 if(verbose>1) printf("Fill NIfTI header\n");
235 NIFTI_DSR dsr;
236 dsr.n=1;
237 /* Set NIfTI byte order to current machines byte order */
239 /* Initiate header structures with zeroes */
240 memset(&dsr.h1, 0, sizeof(NIFTI_1_HEADER));
241 memset(&dsr.e, 0, sizeof(NIFTI_EXTENDER));
242 /* Set header */
244 strcpy(dsr.h1.data_type, "");
245 strlcpy(dsr.h1.db_name, dbname, 17);
246 dsr.h1.extents=16384; // not used in NIfTI, but required for Analyze compatibility
247 dsr.h1.regular='r'; // not used in NIfTI, but required for Analyze compatibility
248 dsr.h1.dim_info='\0'; // MRI slice ordering
249 /* Image dimension */
250 for(int i=0; i<8; i++) dsr.h1.dim[i]=1;
251 dsr.h1.dim[0]=3;
252 dsr.h1.dim[1]=dimx;
253 dsr.h1.dim[2]=dimy;
254 dsr.h1.dim[3]=dimz;
255 dsr.h1.dim[4]=1;
256 dsr.h1.intent_p1=0.0;
257 dsr.h1.intent_p2=0.0;
258 dsr.h1.intent_p3=0.0;
260 dsr.h1.datatype=NIFTI_DT_SIGNED_INT; // For the template
261 dsr.h1.bitpix=32;
262 dsr.h1.slice_start=0;
263 for(int i=0; i<8; i++) dsr.h1.pixdim[i]=0.0;
264 // https://nifti.nimh.nih.gov/nifti-1/documentation/nifti1fields/nifti1fields_pages/qsform.html
265 dsr.h1.pixdim[0]=1.0; // Set to either 1.0 or -1.0
266 dsr.h1.pixdim[1]=1.0; // pixel size in x dimension
267 dsr.h1.pixdim[2]=1.0; // pixel size in y dimension
268 dsr.h1.pixdim[3]=1.0; // pixel size in z dimension
269 dsr.h1.vox_offset=352; // Would be 0 for 1D format
270 dsr.h1.scl_slope=1.0; // no need to scale pixel values
271 dsr.h1.scl_inter=0.0; // no need to scale pixel values
272 dsr.h1.slice_end=0;
273 dsr.h1.slice_code=0;
275 dsr.h1.cal_max=tac.tacNr; // For the template
276 dsr.h1.cal_min=0.0; // there may be voxels that have no TAC defined
277 dsr.h1.slice_duration=0.0;
278 dsr.h1.toffset=0.0;
279 dsr.h1.glmax=dsr.h1.cal_max; // unused in NIfTI
280 dsr.h1.glmin=0; // unused in NIfTI
281 strlcpy(dsr.h1.descrip, "tac2nii", 80);
282 strcpy(dsr.h1.aux_file, "");
283 dsr.h1.qform_code=0;
284 dsr.h1.sform_code=0;
285 dsr.h1.quatern_b=0;
286 dsr.h1.quatern_c=0;
287 dsr.h1.quatern_d=0;
288 dsr.h1.qoffset_x=0;
289 dsr.h1.qoffset_y=0;
290 dsr.h1.qoffset_z=0;
291 for(int i=0; i<4; i++) dsr.h1.srow_x[i]=0;
292 for(int i=0; i<4; i++) dsr.h1.srow_y[i]=0;
293 for(int i=0; i<4; i++) dsr.h1.srow_z[i]=0;
294 strcpy(dsr.h1.intent_name, "");
295 strcpy(dsr.h1.magic, "n+1"); // Would be "ni1" for 1D format
296 /* Extension is left as 0 0 0 0 */
297
298
299 /*
300 * Write template, if required.
301 */
302 if(tname[0]) {
303
304 if(verbose>1) printf("Make NIfTI file names for the template\n");
305 char hdrfile[FILENAME_MAX], imgfile[FILENAME_MAX];
306 if(niftiCreateFNames(tname, hdrfile, imgfile, NULL, IMG_FORMAT_NIFTI_1S)) {
307 fprintf(stderr, " Error: invalid NIfTI name %s\n", tname);
308 tacFree(&tac); free(idata);
309 return(11);
310 }
311
312 if(verbose>1) printf("Writing template NIfTI header\n");
313 /* Delete previous NIfTI */
314 if(fileExist(hdrfile)) remove(hdrfile);
315 if(fileExist(imgfile)) remove(imgfile);
316 /* Write NIfTI header */
317 if(niftiWriteHeader(hdrfile, &dsr, verbose-1)) {
318 fprintf(stderr, "Error: cannot write template header.\n");
319 tacFree(&tac); free(idata);
320 return(12);
321 }
322
323 if(verbose>1) printf("Writing NIfTI image data\n");
324 FILE *fp=fopen(imgfile, "r+b");
325 if(fp==NULL) {
326 fprintf(stderr, "Error: cannot open %s for write.\n", imgfile);
327 tacFree(&tac); free(idata);
328 if(fileExist(hdrfile)) remove(hdrfile);
329 if(fileExist(imgfile)) remove(imgfile);
330 return(13);
331 }
332 /* Move file pointer to the place of matrix data start */
333 if(fseeko(fp, (size_t)dsr.h1.vox_offset, SEEK_SET)!=0) {
334 fprintf(stderr, "Error: invalid file write position.\n");
335 fclose(fp); tacFree(&tac); free(idata);
336 if(fileExist(hdrfile)) remove(hdrfile);
337 if(fileExist(imgfile)) remove(imgfile);
338 return(14);
339 }
340 /* Write template data */
341 if(fwrite(idata, sizeof(int), pxlNr, fp) != pxlNr) {
342 fprintf(stderr, "Error: cannot write template matrix.\n");
343 fclose(fp); tacFree(&tac); free(idata);
344 if(fileExist(hdrfile)) remove(hdrfile);
345 if(fileExist(imgfile)) remove(imgfile);
346 return(15);
347 }
348 fclose(fp);
349 if(verbose>0) printf("written %s\n", imgfile);
350 }
351
352 /*
353 * Edit NIfTI header for the 4D image
354 */
355 if(verbose>1) printf("Set NIfTI header\n");
356 dsr.h1.dim[0]=4;
357 dsr.h1.dim[4]=tac.sampleNr;
358 dsr.h1.datatype=NIFTI_DT_FLOAT; // data as floats, so no need to scale
359 dsr.h1.bitpix=32;
360 dsr.h1.cal_max=max;
361 if(min>0.0) dsr.h1.cal_min=0.0; // For voxels that do not represent any TAC
362 else dsr.h1.cal_min=min;
363 dsr.h1.glmax=max; // unused in NIfTI
364 dsr.h1.glmin=dsr.h1.cal_min; // unused in NIfTI
365 strlcpy(dsr.h1.descrip, "tac2nii", 80);
366
367 /* Make NIfTI filenames */
368 if(verbose>1) printf("Make NIfTI file names\n");
369 char hdrfile[FILENAME_MAX], imgfile[FILENAME_MAX], siffile[FILENAME_MAX];
370 if(niftiCreateFNames(dbname, hdrfile, imgfile, siffile, IMG_FORMAT_NIFTI_1S)) {
371 fprintf(stderr, " Error: invalid NIfTI name %s\n", dbname);
372 tacFree(&tac); free(idata);
373 return(21);
374 }
375
376 /* Allocate memory for float data for one frame */
377 if(verbose>1) printf("Allocate memory for one xyz matrix\n");
378 float *fdata;
379 fdata=(float*)calloc(pxlNr, sizeof(float));
380 if(fdata==NULL) {
381 fprintf(stderr, "Error: out of memory.\n");
382 tacFree(&tac); free(idata);
383 return(6);
384 }
385
386 /*
387 * Write NIfTI header
388 */
389 if(verbose>1) printf("Writing NIfTI header\n");
390 /* Delete previous NIfTI */
391 /* It does not need to be valid NIfTI format, just that the filenames match */
392 if(fileExist(hdrfile)) remove(hdrfile);
393 if(fileExist(imgfile)) remove(imgfile);
394 if(fileExist(siffile)) remove(siffile);
395 /* Write NIfTI header */
396 {
397 if(niftiWriteHeader(hdrfile, &dsr, verbose-1)) {
398 fprintf(stderr, "Error: cannot write header.\n");
399 tacFree(&tac); free(fdata); free(idata);
400 return(22);
401 }
402 }
403
404 /*
405 * Write matrix data
406 */
407 if(verbose>1) printf("Writing NIfTI image data\n");
408 FILE *fp=fopen(imgfile, "r+b");
409 if(fp==NULL) {
410 fprintf(stderr, "Error: cannot open %s for write.\n", imgfile);
411 tacFree(&tac); free(fdata); free(idata);
412 if(fileExist(hdrfile)) remove(hdrfile);
413 if(fileExist(imgfile)) remove(imgfile);
414 return(23);
415 }
416 /* Move file pointer to the place of matrix data start */
417 if(fseeko(fp, (size_t)dsr.h1.vox_offset, SEEK_SET)!=0) {
418 fprintf(stderr, "Error: invalid file write position.\n");
419 fclose(fp); tacFree(&tac); free(fdata); free(idata);
420 if(fileExist(hdrfile)) remove(hdrfile);
421 if(fileExist(imgfile)) remove(imgfile);
422 return(24);
423 }
424 /* Write frame data */
425 for(int fi=0; fi<tac.sampleNr; fi++) {
426 if(verbose>8) printf("Writing frame %d\n", 1+fi);
427 /* Fill matrix data */
428 memset(fdata, 0, pxlNr*sizeof(float));
429 for(size_t i=0; i<pxlNr; i++) {
430 if(idata[i]==0) fdata[i]=0.0;
431 else fdata[i]=tac.c[idata[i]-1].y[fi];
432 }
433 if(fwrite(fdata, sizeof(float), pxlNr, fp) != pxlNr) {
434 fprintf(stderr, "Error: cannot write image matrix.\n");
435 fclose(fp); tacFree(&tac); free(fdata); free(idata);
436 if(fileExist(hdrfile)) remove(hdrfile);
437 if(fileExist(imgfile)) remove(imgfile);
438 return(25);
439 }
440 }
441 fclose(fp); free(fdata); free(idata);
442 if(verbose>0) printf("written %s\n", imgfile);
443
444 /*
445 * Write SIF
446 */
447 if(verbose>1) printf("Making SIF\n");
448 fp=fopen(siffile, "w");
449 if(fp==NULL) {
450 fprintf(stderr, "Error: cannot write %s\n", siffile);
451 tacFree(&tac);
452 return(31);
453 }
454 tac.tacNr=0;
455 if(tacWriteSIF(&tac, fp, 0, NULL)) {
456 fprintf(stderr, "Error: cannot write %s\n", siffile);
457 tacFree(&tac); fclose(fp);
458 return(31);
459 }
460 fclose(fp);
461 if(verbose>0) printf("written %s\n", siffile);
462
463 tacFree(&tac);
464 return(0);
465}
466/*****************************************************************************/
467
468/*****************************************************************************/
470/*****************************************************************************/
471
472/*****************************************************************************/
478 const long long N,
480 const int mxdim,
482 const int mydim,
484 const int mzdim,
486 int *rnx,
488 int *rny,
490 int *rnz,
492 int *rcxdim,
494 int *rcydim,
496 int *rczdim
497) {
498 if(rnx!=NULL) *rnx=0;
499 if(rny!=NULL) *rny=0;
500 if(rnz!=NULL) *rnz=0;
501 if(rcxdim!=NULL) *rcxdim=0;
502 if(rcydim!=NULL) *rcydim=0;
503 if(rczdim!=NULL) *rczdim=0;
504 if(N<1 || mxdim<1 || mydim<1 || mzdim<1) return(1);
505
506 int xd, yd, zd;
507 xd=mxdim; yd=mydim; zd=mzdim;
508
509 long long nx=1, ny=1, nz=1;
510 long long maxn=nx*ny*nz;
511 long long n=N-maxn;
512 while(n>0 && (nz<mzdim || ny<mydim || nx<mxdim)) {
513//printf(" n=%lld nx=%lld ny=%lld nz=%lld\n", n, nx, ny, nz);
514 if(n>0 && nx<mxdim) {
515 nx++; maxn=nx*ny*nz; n=N-maxn;
516 }
517 if(n>0 && ny<mydim) {
518 ny++; maxn=nx*ny*nz; n=N-maxn;
519 }
520 if(n>0 && nz<mzdim) {
521 nz++; maxn=nx*ny*nz; n=N-maxn;
522 }
523 }
524 if(n>0) return(2);
525
526 xd/=nx; yd/=ny; zd/=nz;
527
528 if(rnx!=NULL) *rnx=nx;
529 if(rny!=NULL) *rny=ny;
530 if(rnz!=NULL) *rnz=nz;
531 if(rcxdim!=NULL) *rcxdim=xd;
532 if(rcydim!=NULL) *rcydim=yd;
533 if(rczdim!=NULL) *rczdim=zd;
534 return(0);
535}
536/*****************************************************************************/
537
538/*****************************************************************************/
int endianLittle()
Definition endian.c:53
int fileExist(const char *filename)
Definition filexist.c:17
int niftiCreateFNames(const char *filename, char *hdrfile, char *imgfile, char *siffile, int fileformat)
Definition imagenii.c:17
int atoiCheck(const char *s, int *v)
Definition intutil.c:25
int niftiWriteHeader(const char *filename, NIFTI_DSR *dsr, int verbose)
Definition niftiio.c:445
int tpcProcessStdOptions(const char *s, int *print_usage, int *print_version, int *verbose_level)
Definition proginfo.c:47
int tpcHtmlUsage(const char *program, char *text[], const char *path)
Definition proginfo.c:169
void tpcPrintBuild(const char *program, FILE *fp)
Definition proginfo.c:339
void tpcPrintUsage(const char *program, char *text[], FILE *fp)
Definition proginfo.c:114
int tacWriteSIF(TAC *tac, FILE *fp, int extra, TPCSTATUS *status)
Definition sifio.c:26
void statusInit(TPCSTATUS *s)
Definition statusmsg.c:104
char * errorMsg(tpcerror e)
Definition statusmsg.c:68
void statusSet(TPCSTATUS *s, const char *func, const char *srcfile, int srcline, tpcerror error)
Definition statusmsg.c:142
size_t strlcpy(char *dst, const char *src, size_t dstsize)
Definition stringext.c:632
float quatern_d
Definition tpcnifti.h:289
float quatern_c
Definition tpcnifti.h:287
short int qform_code
Definition tpcnifti.h:281
char db_name[18]
Definition tpcnifti.h:220
float qoffset_x
Definition tpcnifti.h:291
short int slice_start
Definition tpcnifti.h:247
short int slice_end
Definition tpcnifti.h:257
float slice_duration
Definition tpcnifti.h:267
short int datatype
Definition tpcnifti.h:243
float intent_p2
Definition tpcnifti.h:237
char aux_file[24]
Definition tpcnifti.h:278
float intent_p1
Definition tpcnifti.h:235
float srow_z[4]
Definition tpcnifti.h:301
float srow_x[4]
Definition tpcnifti.h:297
char intent_name[16]
Definition tpcnifti.h:303
float intent_p3
Definition tpcnifti.h:239
short int bitpix
Definition tpcnifti.h:245
float pixdim[8]
Definition tpcnifti.h:249
char data_type[10]
Definition tpcnifti.h:218
short int sform_code
Definition tpcnifti.h:283
float vox_offset
Definition tpcnifti.h:251
float srow_y[4]
Definition tpcnifti.h:299
float qoffset_y
Definition tpcnifti.h:293
char descrip[80]
Definition tpcnifti.h:276
char magic[4]
Definition tpcnifti.h:306
float scl_inter
Definition tpcnifti.h:255
float qoffset_z
Definition tpcnifti.h:295
short int dim[8]
Definition tpcnifti.h:233
short int intent_code
Definition tpcnifti.h:241
float quatern_b
Definition tpcnifti.h:285
float scl_slope
Definition tpcnifti.h:253
NIFTI_EXTENDER e
Definition tpcnifti.h:408
NIFTI_1_HEADER h1
Definition tpcnifti.h:404
int byte_order
Definition tpcnifti.h:412
char name[MAX_TACNAME_LEN+1]
Definition tpctac.h:81
double * y
Definition tpctac.h:75
Definition tpctac.h:87
unit cunit
Definition tpctac.h:105
tacformat format
Definition tpctac.h:93
int sampleNr
Definition tpctac.h:89
int isframe
Definition tpctac.h:95
TACC * c
Definition tpctac.h:117
unit tunit
Definition tpctac.h:109
int tacNr
Definition tpctac.h:91
int verbose
Verbose level, used by statusPrint() etc.
tpcerror error
Error code.
int simRCDims(const long long N, const int mxdim, const int mydim, const int mzdim, int *rnx, int *rny, int *rnz, int *rcxdim, int *rcydim, int *rczdim)
Definition tac2nii.c:476
void tacFree(TAC *tac)
Definition tac.c:106
void tacInit(TAC *tac)
Definition tac.c:24
int tacRead(TAC *d, const char *fname, TPCSTATUS *status)
Definition tacio.c:413
char * tacFormattxt(tacformat c)
Definition tacio.c:98
int tacYRange(TAC *d, int i, double *ymin, double *ymax, int *smin, int *smax, int *imin, int *imax)
Get the range of y values (concentrations) in TAC struct.
Definition tacy.c:26
Header file for library libtpccsv.
Header file for libtpcdcm.
Header file for libtpcecat.
Header file for library libtpcextensions.
@ TPCERROR_OK
No error.
char * unitName(int unit_code)
Definition units.c:143
Header file for library libtpcift.
Header file for libtpcimage.
@ IMG_FORMAT_NIFTI_1S
NIfTI-1 single-file format.
Definition tpcimage.h:43
Header file for libtpcnifti.
#define NIFTI_DT_FLOAT
Definition tpcnifti.h:100
#define NIFTI_DT_SIGNED_INT
Definition tpcnifti.h:98
#define NIFTI1_HEADER_SIZE
Definition tpcnifti.h:33
#define NIFTI_INTENT_NONE
Definition tpcnifti.h:129
#define NIFTI_UNITS_SEC
Definition tpcnifti.h:52
#define NIFTI_UNITS_MM
Definition tpcnifti.h:48
Header file for library libtpctac.