1 /**********
2 *
3 * This file is part of the TINA Open Source Image Analysis Environment
4 * henceforth known as TINA
5 *
6 * TINA is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation.
9 *
10 * TINA is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with TINA; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 **********
20 *
21 * Program : TINA
22 * File : $Source: /home/tina/cvs/tina-libs/tina/medical/medStim_alloc.c,v $
23 * Date : $Date: 2005/12/20 16:28:02 $
24 * Version : $Revision: 1.7 $
25 * CVS Id : $Id: medStim_alloc.c,v 1.7 2005/12/20 16:28:02 matts Exp $
26 *
27 * Notes:
28 *
29 *********
30 */
31
32 #if HAVE_CONFIG_H
33 # include <config.h>
34 #endif
35
36 #include "medStim_alloc.h"
37
38
39 #include <stdio.h>
40 #include <math.h>
41 #include <tina/sys/sysDef.h>
42 #include <tina/sys/sysPro.h>
43 #include <tina/math/mathDef.h>
44 #include <tina/math/mathPro.h>
45 #include <tina/image/imgDef.h>
46 #include <tina/image/imgPro.h>
47 #include <tina/medical/med_StimDef.h>
48
49 static Pl_flow *plflow = NULL;
50
51 Perfusion *perfusion_alloc(void)
52 {
53 Perfusion *p = NULL;
54
55 if ((p = (Perfusion *)ralloc(sizeof(Perfusion))) == NULL)
56 {
57 error("perfusion_alloc: memory allocation error", warning);
58 return (NULL);
59 }
60
61 p->st_1d = NULL;
62 p->r2 = NULL;
63 p->r2_ther = NULL;
64 p->te = 0.0;
65 p->s0_av = 0.0;
66 p->qq = 0.0;
67 p->rr = 0.0;
68 p->bb = 0.0;
69 p->tt = 0.0;
70 p->refit = 0;
71
72 return (p);
73 }
74
75
76
77 void perfusion_free(Perfusion *p)
78 {
79 if (p == NULL)
80 return;
81
82 if (p->st_1d) fvector_free(p->st_1d, p->n1);
83 if (p->r2) fvector_free(p->r2, p->n1);
84 if(p->r2_ther) fvector_free(p->r2_ther, p->n1);
85
86 rfree(p);
87
88 return;
89 }
90
91
92 Pl_flow *pl_flow_alloc(void)
93 {
94 Pl_flow *p = NULL;
95
96 if ((p = (Pl_flow *)ralloc(sizeof(Pl_flow))) == NULL)
97 {
98 error("pl_flow_alloc: memory allocation error", warning);
99 return (NULL);
100 }
101
102 p->mask = NULL;
103
104 p->x = NULL;
105 p->y1 = NULL;
106 p->y1_area = 0.0;
107 p->y1_max = 0.0;
108 p->y1_min = 0.0;
109 p->y1_diff_max = 0.0;
110 p->y1_max_t = 0.0;
111 p->y1_min_t = 0.0;
112 p->y1_diff_max_t = 0.0;
113
114 return (p);
115 }
116
117
118
119 void pl_flow_free(Pl_flow *p)
120 {
121 if (p == NULL)
122 return;
123
124 fvector_free(p->x, p->x_n1);
125 fvector_free(p->y1, p->y1_n1);
126 im_free(p->mask);
127
128 p->mask = NULL;
129
130 rfree(p);
131
132 return;
133 }
134
135
136 Pl_flow *get_pl_flow(void)
137 {
138 return(plflow);
139 }
140
141
142 void set_pl_flow(Pl_flow *p)
143 {
144 pl_flow_free(plflow);
145 plflow = p;
146 }
147
148
149
150 Permeability *permeability_alloc(void)
151 {
152 Permeability *p = NULL;
153
154 if ((p = (Permeability *)ralloc(sizeof(Permeability))) == NULL)
155 {
156 error("permeability_alloc: memory allocation error", warning);
157 return (NULL);
158 }
159
160 p->st_1d = NULL;
161 p->conc1 = NULL;
162 p->conc1_ther = NULL;
163 p->te = 0.0;
164 p->tr = 0.0;
165 p->t10 = 0.0;
166 p->NH = 0.0;
167 p->r1cont = 0.0;
168 p->s0_av = 0.0;
169 p->tt = 0.0;
170 p->vp = 0.0;
171 p->kin = 0.0;
172 p->kout = 0.0;
173 p->ve = 0.0;
174 p->AIF = NULL;
175 p->refit = 0;
176 p->n1=0;
177 p->n2=0;
178
179 return (p);
180 }
181
182
183
184 void permeability_free(Permeability *p)
185 {
186 if (p == NULL)
187 return;
188
189 if (p->st_1d) fvector_free(p->st_1d, p->n1);
190 if (p->conc1) fvector_free(p->conc1, p->n1);
191 if(p->conc1_ther) fvector_free(p->conc1_ther, p->n1);
192 /*if(p->AIF) fvector_free(p->AIF, p->n1-(p->n2-p->n1));*/
193 if(p->AIF) fvector_free(p->AIF, 0);/* mjs modified to bring into line with aif_est */
194
195 rfree(p);
196
197 return;
198 }
199
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.