TPCCLIB
Toggle main menu visibility
Loading...
Searching...
No Matches
libtpcidi
idimask.c
Go to the documentation of this file.
1
5
/*****************************************************************************/
6
#include "
libtpcidi.h
"
7
/*****************************************************************************/
8
9
/*****************************************************************************/
17
int
imgMaskPixelTACs
(
19
IMG
*img,
22
IMG
*mask,
24
double
thrs,
27
DFT
*dft,
29
int
verbose
30
) {
31
if
(verbose>0) printf(
"%s()\n"
, __func__);
32
33
int
xi, yi, zi, fi, ri, ret;
34
35
if
(img->
status
<
IMG_STATUS_OCCUPIED
)
return
(1);
36
if
(mask->
status
<
IMG_STATUS_OCCUPIED
)
return
(2);
37
if
(mask->
dimz
!=img->
dimz
)
return
(3);
38
if
(mask->
dimy
!=img->
dimy
)
return
(4);
39
if
(mask->
dimx
!=img->
dimx
)
return
(5);
40
if
(img->
dimt
<1 || mask->
dimt
<1)
return
(6);
41
if
(dft==NULL)
return
(7);
42
43
/* Delete any previous TAC data; do it first so that caller can check
44
the nr of extracted TACs inside DFT */
45
dftEmpty
(dft);
46
47
/* Calculate the nr of voxels to extract */
48
long
long
nr=0;
49
for
(zi=0; zi<mask->
dimz
; zi++)
50
for
(yi=0; yi<mask->
dimy
; yi++)
51
for
(xi=0; xi<mask->
dimx
; xi++)
52
if
(mask->
m
[zi][yi][xi][0]>thrs) nr++;
53
if
(verbose>1) printf(
"mask_pixel_nr := %lld\n"
, nr);
54
/* Return, if no voxels were marked in mask image */
55
if
(nr==0)
return
(0);
56
57
/* Allocate memory for pixel TACs */
58
ret=
dftAllocateWithIMG
(dft, nr, img);
59
if
(ret!=0) {
60
if
(verbose>0) fprintf(stderr,
"Error: cannot allocate memory for %lld pixel TACs.\n"
, nr);
61
return
(10);
62
}
63
strcpy(dft->
studynr
, img->
studyNr
);
64
65
/* Save the pixel TACs in DFT */
66
ri=0;
67
for
(zi=0; zi<mask->
dimz
; zi++)
68
for
(yi=0; yi<mask->
dimy
; yi++)
69
for
(xi=0; xi<mask->
dimx
; xi++)
if
(mask->
m
[zi][yi][xi][0]>thrs)
70
{
71
sprintf(dft->
voi
[ri].
voiname
,
"%d"
, 1+xi);
72
sprintf(dft->
voi
[ri].
hemisphere
,
"%d"
, 1+yi);
73
sprintf(dft->
voi
[ri].
place
,
"%d"
, 1+zi);
74
sprintf(dft->
voi
[ri].
name
,
"%d %d %d"
, 1+xi, 1+yi, 1+zi);
75
for
(fi=0; fi<img->
dimt
; fi++) dft->
voi
[ri].
y
[fi]=img->
m
[zi][yi][xi][fi];
76
dft->
voi
[ri].
size
=mask->
m
[zi][yi][xi][0];
77
ri++;
78
}
79
dft->
voiNr
=ri;
80
81
return
(0);
82
}
83
/*****************************************************************************/
84
85
/*****************************************************************************/
dftEmpty
void dftEmpty(DFT *data)
Definition
dft.c:20
imgMaskPixelTACs
int imgMaskPixelTACs(IMG *img, IMG *mask, double thrs, DFT *dft, int verbose)
Definition
idimask.c:17
libtpcidi.h
Header file for libtpcidi.
IMG_STATUS_OCCUPIED
#define IMG_STATUS_OCCUPIED
Definition
libtpcimgio.h:1479
dftAllocateWithIMG
int dftAllocateWithIMG(DFT *dft, int tacNr, IMG *img)
Definition
misc_model.c:296
DFT
Definition
libtpccurveio.h:73
DFT::voi
Voi * voi
Definition
libtpccurveio.h:108
DFT::studynr
char studynr[MAX_STUDYNR_LEN+1]
Definition
libtpccurveio.h:80
DFT::voiNr
int voiNr
Definition
libtpccurveio.h:78
IMG
Definition
libtpcimgio.h:1657
IMG::dimx
unsigned short int dimx
Definition
libtpcimgio.h:1780
IMG::m
float **** m
Definition
libtpcimgio.h:1799
IMG::status
char status
Definition
libtpcimgio.h:1665
IMG::dimt
unsigned short int dimt
Definition
libtpcimgio.h:1778
IMG::dimz
unsigned short int dimz
Definition
libtpcimgio.h:1784
IMG::dimy
unsigned short int dimy
Definition
libtpcimgio.h:1782
IMG::studyNr
char studyNr[MAX_STUDYNR_LEN+1]
Definition
libtpcimgio.h:1677
Voi::size
double size
Definition
libtpccurveio.h:56
Voi::voiname
char voiname[MAX_REGIONSUBNAME_LEN+1]
Definition
libtpccurveio.h:50
Voi::y
double * y
Definition
libtpccurveio.h:59
Voi::name
char name[MAX_REGIONNAME_LEN+1]
Definition
libtpccurveio.h:48
Voi::hemisphere
char hemisphere[MAX_REGIONSUBNAME_LEN+1]
Definition
libtpccurveio.h:52
Voi::place
char place[MAX_REGIONSUBNAME_LEN+1]
Definition
libtpccurveio.h:54
Generated on
for TPCCLIB by
1.17.0