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.

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 476 of file tac2nii.c.

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}