TPCCLIB
Toggle main menu visibility
Loading...
Searching...
No Matches
libtpctacimg
misc.c
Go to the documentation of this file.
1
4
/*****************************************************************************/
5
#include "tpcclibConfig.h"
6
/*****************************************************************************/
7
#include "
tpctacimg.h
"
8
/*****************************************************************************/
9
10
/*****************************************************************************/
16
int
tacAllocateWithIMG
(
20
TAC
*tac,
22
IMG
*img,
24
int
tacNr
25
) {
26
/* Check the input */
27
if
(tac==NULL || img==NULL || tacNr<1)
return
(
TPCERROR_FAIL
);
28
if
(img->
dimt
<1)
return
(
TPCERROR_NO_DATA
);
29
30
/* Allocate TAC */
31
int
ret=
tacAllocate
(tac, img->
dimt
, tacNr);
32
if
(ret!=
TPCERROR_OK
)
return
(ret);
33
tac->
sampleNr
=img->
dimt
; tac->
tacNr
=tacNr;
34
35
/* Copy frame times */
36
tac->
isframe
=1;
37
for
(
int
i=0; i<img->
dimt
; i++) {
38
tac->
x1
[i]=img->
x1
[i];
39
tac->
x2
[i]=img->
x2
[i];
40
tac->
x
[i]=0.5*(tac->
x1
[i]+tac->
x2
[i]);
41
}
42
43
/* Copy data units */
44
tac->
cunit
=img->
cunit
;
45
tac->
tunit
=img->
tunit
;
46
47
return
(
TPCERROR_OK
);
48
}
49
/*****************************************************************************/
50
51
/*****************************************************************************/
56
int
imgVb
(
58
IMG
*img,
61
TAC
*btac,
63
double
Vb,
65
const
int
simVb,
69
const
int
petVolume
70
) {
71
if
(img==NULL || btac==NULL)
return
(
TPCERROR_FAIL
);
72
if
(img->
dimt
<1 || btac->
tacNr
<1)
return
(
TPCERROR_NO_DATA
);
73
if
(img->
dimt
>btac->
sampleNr
)
return
(
TPCERROR_INCOMPATIBLE_DATA
);
74
if
(!(Vb>=0.0) || !(Vb<=1.0))
return
TPCERROR_INVALID_VALUE
;
75
if
(Vb==1.0 && petVolume==0 && simVb==0)
// combination would lead to divide by zero
76
return
(
TPCERROR_INVALID_VALUE
);
77
78
if
(simVb==0) {
79
for
(
int
zi=0; zi<img->
dimz
; zi++)
80
for
(
int
yi=0; yi<img->
dimy
; yi++)
81
for
(
int
xi=0; xi<img->
dimx
; xi++)
82
for
(
int
ti=0; ti<img->
dimt
; ti++) {
83
img->
m
[zi][yi][xi][ti]-=Vb*btac->
c
[0].
y
[ti];
84
if
(petVolume==0) img->
m
[zi][yi][xi][ti]/=(1.0-Vb);
85
}
86
}
else
{
87
for
(
int
zi=0; zi<img->
dimz
; zi++)
88
for
(
int
yi=0; yi<img->
dimy
; yi++)
89
for
(
int
xi=0; xi<img->
dimx
; xi++)
90
for
(
int
ti=0; ti<img->
dimt
; ti++) {
91
if
(petVolume==0) img->
m
[zi][yi][xi][ti]*=(1.0-Vb);
92
img->
m
[zi][yi][xi][ti]+=Vb*btac->
c
[0].
y
[ti];
93
}
94
}
95
96
return
(
TPCERROR_OK
);
97
}
98
/*****************************************************************************/
99
100
/*****************************************************************************/
tacAllocateWithIMG
int tacAllocateWithIMG(TAC *tac, IMG *img, int tacNr)
Allocate TAC based on data in IMG.
Definition
misc.c:16
imgVb
int imgVb(IMG *img, TAC *btac, double Vb, const int simVb, const int petVolume)
Correct pixel TACs for vascular blood, or simulate its effect.
Definition
misc.c:56
IMG
Definition
tpcimage.h:82
IMG::dimx
unsigned short int dimx
Definition
tpcimage.h:112
IMG::x1
float * x1
Definition
tpcimage.h:180
IMG::cunit
unit cunit
Definition
tpcimage.h:203
IMG::m
float **** m
Definition
tpcimage.h:161
IMG::x2
float * x2
Definition
tpcimage.h:182
IMG::dimt
unsigned short int dimt
Definition
tpcimage.h:110
IMG::dimz
unsigned short int dimz
Definition
tpcimage.h:116
IMG::dimy
unsigned short int dimy
Definition
tpcimage.h:114
IMG::tunit
unit tunit
Definition
tpcimage.h:205
TACC::y
double * y
Definition
tpctac.h:75
TAC
Definition
tpctac.h:87
TAC::x
double * x
Definition
tpctac.h:97
TAC::cunit
unit cunit
Definition
tpctac.h:105
TAC::sampleNr
int sampleNr
Definition
tpctac.h:89
TAC::isframe
int isframe
Definition
tpctac.h:95
TAC::c
TACC * c
Definition
tpctac.h:117
TAC::x2
double * x2
Definition
tpctac.h:101
TAC::tunit
unit tunit
Definition
tpctac.h:109
TAC::x1
double * x1
Definition
tpctac.h:99
TAC::tacNr
int tacNr
Definition
tpctac.h:91
tacAllocate
int tacAllocate(TAC *tac, int sampleNr, int tacNr)
Definition
tac.c:130
TPCERROR_INVALID_VALUE
@ TPCERROR_INVALID_VALUE
Invalid value.
Definition
tpcextensions.h:220
TPCERROR_FAIL
@ TPCERROR_FAIL
General error.
Definition
tpcextensions.h:192
TPCERROR_OK
@ TPCERROR_OK
No error.
Definition
tpcextensions.h:191
TPCERROR_NO_DATA
@ TPCERROR_NO_DATA
File contains no data.
Definition
tpcextensions.h:203
TPCERROR_INCOMPATIBLE_DATA
@ TPCERROR_INCOMPATIBLE_DATA
Incompatible data.
Definition
tpcextensions.h:216
tpctacimg.h
Header file for libtpctacimg.
Generated on
for TPCCLIB by
1.17.0