~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina6/tina-libs/tina/medical/medStim_alloc.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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 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 General Public License for more details.
 14  *
 15  * You should have received a copy of the GNU 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  * ANY users of TINA who require exemption from the existing licence must
 20  * negotiate a new licence with Dr. Neil.A.Thacker, the sole agent for
 21  * the University of Manchester.
 22  *
 23  **********
 24  *
 25  * Program :    TINA
 26  * File    :  $Source: medStim_alloc.c $
 27  * Date    :  $Date: 2012/06/20 13:10 $
 28  * Version :  $Revision: 1.8 $
 29  *
 30  * Author  : Legacy TINA modified NAT/HR
 31  *
 32  * Notes:
 33  *
 34  *********
 35 */
 36 
 37 
 38 #if HAVE_CONFIG_H
 39 #   include <config.h>
 40 #endif
 41 
 42 #include <stdio.h>
 43 #include <math.h>
 44 #include <tina/sys/sysDef.h>
 45 #include <tina/sys/sysPro.h>
 46 #include <tina/math/mathDef.h>
 47 #include <tina/math/mathPro.h>
 48 #include <tina/image/imgDef.h>
 49 #include <tina/image/imgPro.h>
 50 #include <tina/medical/med_StimDef.h>
 51 #include <tina/medical/medStim_alloc.h>  /* HR */
 52 
 53 
 54 
 55 static Pl_flow   *plflow    = NULL;
 56 
 57 
 58 Diffusion  *diffusion_alloc(void)                                        /* HR: new */
 59 {
 60   Diffusion *d = NULL;
 61 
 62   if ((d = (Diffusion *)ralloc(sizeof(Diffusion))) == NULL)
 63     {
 64       error("diffusion_alloc: memory allocation error", warning);
 65       return (NULL);
 66     }
 67   
 68   d->signals = NULL;
 69   d->b_values = NULL;
 70   d->fit_params = NULL;
 71   d->no_b = 0;
 72 
 73   return (d);
 74 }
 75 
 76 
 77 void     diffusion_free(Diffusion *d)                                    /* HR: new */
 78 {
 79   if (d == NULL)
 80     return;
 81 
 82   if (d->signals)  fvector_free(d->signals,  0);
 83   if (d->b_values) fvector_free(d->b_values, 0);
 84   if (d->fit_params) dvector_free(d->fit_params, 0);
 85 
 86   rfree(d);
 87  
 88   return;
 89 }
 90 
 91 
 92 Perfusion  *perfusion_alloc(void)
 93 {
 94   Perfusion *p = NULL;
 95 
 96   if ((p = (Perfusion *)ralloc(sizeof(Perfusion))) == NULL)
 97     {
 98       error("perfusion_alloc: memory allocation error", warning);
 99       return (NULL);
100     }
101   
102   p->st_1d = NULL;
103   p->r2 = NULL;
104   p->r2_ther = NULL;
105   p->te = 0.0;
106   p->s0_av = 0.0;
107   p->qq = 0.0; 
108   p->rr = 0.0; 
109   p->bb = 0.0; 
110   p->tt = 0.0; 
111   p->refit = 0;
112 
113   return (p);
114 }
115 
116 
117 void     perfusion_free(Perfusion *p)
118 {
119   if (p == NULL)
120     return;
121 
122   if (p->st_1d) fvector_free(p->st_1d, p->n1);
123   if (p->r2) fvector_free(p->r2, p->n1);
124   if(p->r2_ther) fvector_free(p->r2_ther, p->n1);
125 
126   rfree(p);
127  
128   return;
129 }
130   
131 
132 Pl_flow  *pl_flow_alloc(void)
133 {
134   Pl_flow   *p = NULL;
135 
136   if ((p = (Pl_flow *)ralloc(sizeof(Pl_flow))) == NULL)
137     {
138       error("pl_flow_alloc: memory allocation error", warning);
139       return (NULL);
140     }
141   
142   p->mask = NULL;
143 
144   p->x = NULL;
145   p->y1 = NULL;
146   p->y1_area = 0.0;
147   p->y1_max = 0.0;
148   p->y1_min = 0.0;
149   p->y1_diff_max = 0.0;
150   p->y1_max_t = 0.0;
151   p->y1_min_t = 0.0;
152   p->y1_diff_max_t = 0.0;
153   
154   return (p);
155 }
156 
157 
158 
159 void     pl_flow_free(Pl_flow *p)
160 {
161   if (p == NULL)
162     return;
163 
164   fvector_free(p->x, p->x_n1);
165   fvector_free(p->y1, p->y1_n1);
166   im_free(p->mask);
167   
168   p->mask = NULL;
169 
170   rfree(p);
171  
172   return;
173 }
174 
175 
176 Pl_flow   *get_pl_flow(void)
177 {
178   return(plflow);
179 }
180 
181 
182 void       set_pl_flow(Pl_flow *p)
183 {
184   pl_flow_free(plflow);
185   plflow = p;
186 }
187 
188 
189 
190 Permeability  *permeability_alloc(void)
191 {
192   Permeability *p = NULL;
193 
194   if ((p = (Permeability *)ralloc(sizeof(Permeability))) == NULL)
195     {
196       error("permeability_alloc: memory allocation error", warning);
197       return (NULL);
198     }
199   
200   p->st_1d = NULL;
201   p->conc1 = NULL;
202   p->conc1_ther = NULL;
203   p->te = 0.0;
204   p->tr = 0.0;
205   p->t10 = 0.0;
206   p->NH = 0.0;
207   p->r1cont = 0.0;
208   p->s0_av = 0.0;
209   p->tt = 0.0; 
210   p->vp = 0.0;
211   p->kin = 0.0;
212   p->kout = 0.0;
213   p->ve = 0.0;
214   p->AIF = NULL;
215   p->refit = 0;
216   p->n1=0;
217   p->n2=0;
218 
219   return (p);
220 }
221 
222 
223 
224 void     permeability_free(Permeability *p)
225 {
226   if (p == NULL)
227     return;
228 
229   if (p->st_1d) fvector_free(p->st_1d, p->n1);
230   if (p->conc1) fvector_free(p->conc1, p->n1);
231   if(p->conc1_ther) fvector_free(p->conc1_ther, p->n1);
232   /*if(p->AIF) fvector_free(p->AIF, p->n1-(p->n2-p->n1));*/
233   if(p->AIF) fvector_free(p->AIF, 0);/* mjs modified to bring into line with aif_est */
234 
235   rfree(p);
236  
237   return; 
238 }
239 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.