TPCCLIB
Loading...
Searching...
No Matches
tac2nii.c File Reference

Create NIfTI format PET image with contents from specified TAC file. More...

Go to the source code of this file.

Functions

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)

Detailed Description

Create NIfTI format PET image with contents from specified TAC file.

Note
Moved into v2.
Author
Vesa Oikonen

Definition in file tac2nii.c.

Function Documentation

◆ simRCDims()

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 )

Determine dimensions of N rectangular cuboids fitting specified 3D matrix.

Returns
Returns 0 when successful.
Parameters
NNr of rectangular cuboids.
mxdim3D matrix xdim.
mydim3D matrix ydim.
mzdim3D matrix zdim.
rnxNr of cuboids in x dim.
rnyNr of cuboids in y dim.
rnzNr of cuboids in z dim.
rcxdimRectangular cuboid xdim.
rcydimRectangular cuboid ydim.
rczdimRectangular cuboid zdim.

Definition at line 469 of file tac2nii.c.

490 {
491 if(rnx!=NULL) *rnx=0;
492 if(rny!=NULL) *rny=0;
493 if(rnz!=NULL) *rnz=0;
494 if(rcxdim!=NULL) *rcxdim=0;
495 if(rcydim!=NULL) *rcydim=0;
496 if(rczdim!=NULL) *rczdim=0;
497 if(N<1 || mxdim<1 || mydim<1 || mzdim<1) return(1);
498
499 int xd, yd, zd;
500 xd=mxdim; yd=mydim; zd=mzdim;
501
502 long long nx=1, ny=1, nz=1;
503 long long maxn=nx*ny*nz;
504 long long n=N-maxn;
505 while(n>0 && (nz<mzdim || ny<mydim || nx<mxdim)) {
506//printf(" n=%lld nx=%lld ny=%lld nz=%lld\n", n, nx, ny, nz);
507 if(n>0 && nx<mxdim) {
508 nx++; maxn=nx*ny*nz; n=N-maxn;
509 }
510 if(n>0 && ny<mydim) {
511 ny++; maxn=nx*ny*nz; n=N-maxn;
512 }
513 if(n>0 && nz<mzdim) {
514 nz++; maxn=nx*ny*nz; n=N-maxn;
515 }
516 }
517 if(n>0) return(2);
518
519 xd/=nx; yd/=ny; zd/=nz;
520
521 if(rnx!=NULL) *rnx=nx;
522 if(rny!=NULL) *rny=ny;
523 if(rnz!=NULL) *rnz=nz;
524 if(rcxdim!=NULL) *rcxdim=xd;
525 if(rcydim!=NULL) *rcydim=yd;
526 if(rczdim!=NULL) *rczdim=zd;
527 return(0);
528}