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

Linux Cross Reference
Tina6/tina-tools/tinatool/tlmedical/tlmedAnl_ct_tool.c

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

  1 /**********
  2  *
  3  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  4  * University of Manchester, UK.  All rights reserved.
  5  * 
  6  * Redistribution and use in source and binary forms, with or without modification, 
  7  * are permitted provided that the following conditions are met:
  8  * 
  9  *   . Redistributions of source code must retain the above copyright notice, 
 10  *     this list of conditions and the following disclaimer.
 11  *    
 12  *   . Redistributions in binary form must reproduce the above copyright notice,
 13  *     this list of conditions and the following disclaimer in the documentation 
 14  *     and/or other materials provided with the distribution.
 15  * 
 16  *   . Neither the name of the University of Manchester nor the names of its
 17  *     contributors may be used to endorse or promote products derived from this 
 18  *     software without specific prior written permission.
 19  * 
 20  * 
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  **********
 34  *
 35  * Program :    TINA
 36  * File    : 
 37  * Date    :  
 38  * Version : 
 39  * CVS Id  :  
 40  *
 41  * Notes :
 42  *
 43  *   
 44  *
 45  *********
 46 */
 47 
 48 #include "tlmedAnl_ct_tool.h"
 49 
 50 #if HAVE_CONFIG_H
 51 #   include <config.h>
 52 #endif
 53 
 54 
 55 #include <stdio.h>
 56 #include <math.h>
 57 #include <float.h>
 58 #include <tina/sys/sysDef.h>
 59 #include <tina/sys/sysPro.h>
 60 #include <tina/math/mathDef.h>
 61 #include <tina/math/mathPro.h>
 62 #include <tina/image/imgDef.h>
 63 #include <tina/image/imgPro.h>
 64 #include <tina/medical/medDef.h>
 65 #include <tina/medical/medPro.h>
 66 #include <tinatool/draw/drawDef.h>
 67 #include <tinatool/draw/drawPro.h>
 68 #include <tinatool/wdgts/wdgtsPro.h>
 69 #include <tinatool/tlbase/tlbasePro.h>
 70 #include <tinatool/tlmedical/tlmedAnl_ct_mouse.h>
 71 
 72 static int pmap, gmap;
 73 static void *pt0 = NULL;
 74 
 75 static void     imcalc_mouse_proc(Tv_mouse(*func)())
 76 {
 77   tv_set_mouse(imcalc_tv(), (*func) ());
 78   tv_set_activity(imcalc_tv(), MOUSE);
 79 }
 80 
 81 static void perm_con_proc(int val)
 82 {
 83   ct_set_perm_con(val);
 84 }
 85 
 86 static void ct_gmap_func_choice_proc(int val)
 87 {
 88    gmap = val;
 89    stack_push((void *)ct_gfit_get_image(gmap), IMRECT, im_free);
 90 
 91    if (imcalc_tv_get()!=NULL) tv_init(imcalc_tv_get());
 92    if (imcal2_tv_get()!=NULL) tv_init(imcal2_tv_get());
 93    image_choice_reset();
 94 }
 95 
 96 static void ct_pmap_func_choice_proc(int val)
 97 {
 98   pmap = val;
 99    stack_push((void *)ct_kfpfit_get_image(pmap), IMRECT, im_free);
100 
101    if (imcalc_tv_get()!=NULL) tv_init(imcalc_tv_get());
102    if (imcal2_tv_get()!=NULL) tv_init(imcal2_tv_get());
103    image_choice_reset();
104   
105 }
106 
107 static void  ct_gfit_pixels_proc()
108 {
109    Imrect *mask = NULL;
110    int     type;
111   
112 /* old call a.lacey 22.01.02
113    gfit_measure_image();
114  */
115 /*
116  *   Stack manipulation from gfit_measure_image - GAB 19 Feb 2003
117  */
118    if (stack_check_types(IMRECT, NULL) != false)
119       mask = (Imrect *) stack_pop(&type);
120 
121    ct_gfit_measure_image(0, mask);
122    stack_push((void *)ct_gfit_get_image(gmap), IMRECT, im_free);
123 
124    if (imcalc_tv_get()!=NULL) tv_init(imcalc_tv_get());
125    if (imcal2_tv_get()!=NULL) tv_init(imcal2_tv_get());
126    image_choice_reset();
127 }
128 
129 static void ct_gfit_region_proc()
130 {
131      Tv *tv = imcalc_tv_get();
132      Ipos pos;
133      *ct_min_t0_get() = ct_pixel_gfit_region(tv,pos) - 4.0;
134      tw_fglobal_reset(pt0);
135 }
136 
137 static void ct_est_plasma_conc_proc()
138 {
139   Imrect *mask, *t1im;
140   int type;
141 
142   if ((mask = (Imrect *) stack_inspect(&type)) == NULL)
143     return;
144    
145   ct_est_plasma_conc(mask); 
146 
147 }
148  
149 static void  ct_kfpfit_pixels_proc()
150 {
151    Imrect *mask;
152    int     type;
153 
154    /*if (stack_check_types(IMRECT, NULL) != false)
155      mask = (Imrect *) stack_pop(&type);*/
156 
157    if ((mask = (Imrect *) stack_inspect(&type)) == NULL)
158      return;
159                 
160    ct_kfpfit_measure_image(0, mask);
161    stack_push((void *)ct_kfpfit_get_image(pmap), IMRECT, im_free);
162 
163    if (imcalc_tv_get()!=NULL) tv_init(imcalc_tv_get());
164    if (imcal2_tv_get()!=NULL) tv_init(imcal2_tv_get());
165    image_choice_reset();
166 }
167 
168 static void     ct_gfit_param_dialog(void)
169 {
170     static void *dialog = NULL;
171 
172     if (dialog)
173     {
174         tw_show_dialog(dialog);
175         return;
176     }
177 
178     dialog = (void *)tw_dialog("CT Gamma Parameters");
179   
180     tw_fglobal(" average mtt: ", ct_ave_mtt_get(), 8);
181     tw_newrow();
182     pt0 = (void *)tw_fglobal("  minimum t0: ", ct_min_t0_get(), 8);
183     tw_button("region fit", ct_gfit_region_proc, NULL);
184     tw_newrow();
185     tw_fglobal("  recirculation cut: ", ct_recirc_cut_get(), 8);
186     tw_newrow();
187     tw_fglobal("  recirculation period: ", ct_recirc_period_get(), 8);
188     tw_newrow();
189     tw_fglobal("  rcbv scale: ", ct_scl_get(), 8);
190 
191     tw_end_dialog();
192 }
193 
194 static void     ctperm_param_dialog(void)
195 {
196     static void *dialog = NULL;
197 
198     if (dialog)
199     {
200         tw_show_dialog(dialog);
201         return;
202     }
203     dialog = (void *)tw_dialog("Permeability Parameters");
204 
205 
206     tw_choice("Constraints  ", perm_con_proc, 0, "None", "VE", "VP", NULL);
207     tw_newrow();
208     tw_fglobal("Prebolus", (double *)ct_prebolus_get(), 10);
209     
210     tw_end_dialog();
211 }
212 
213 
214 void    ctanalysis_tool(int x, int y)
215 {
216   static void *tool = NULL;
217 /*
218   void         nmr_reset_proc(void);
219 */
220 
221   if (tool)
222   {
223       tw_show_tool(tool);
224       return;
225   }
226 
227   tool = tw_tool("CT Analysis Tool", x, y);
228 
229   tw_menubar("Imcalc Mouse:  ",
230              /*"measure",
231                "null", imcalc_mouse_proc, null_mouse,
232                "line", imcalc_mouse_proc, nmr_linelen_mouse,
233                "region", imcalc_mouse_proc, nmr_regsize_mouse,
234                "mask", imcalc_mouse_proc, nmr_masksize_mouse,
235                NULL, */
236              "Plot",
237              "null", imcalc_mouse_proc, null_mouse,
238              /*"flow/T", imcalc_mouse_proc, nmr_flow_mouse,*/
239              "gamma fit", imcalc_mouse_proc, ct_gfit_mouse,
240              "perm fit", imcalc_mouse_proc, ct_permfit_mouse,
241              NULL, 
242                                                   NULL);
243   tw_help_button("ct_analysis_tool");
244   tw_newrow();
245 
246   /*tw_button("stim params", temp_param_dialog, NULL);*/
247   tw_button("gamma params", ct_gfit_param_dialog, NULL);
248   tw_button("perm params", ctperm_param_dialog, NULL);
249 
250   tw_newrow();
251    
252   /*tw_choice("Sequence  ", corr_func_choice_proc, 2,
253     "GBAM", "STIM", "FRIS", NULL);*/
254 
255   /*tw_button("compare", stim_compare_proc, NULL);
256     tw_newrow();*/
257  
258   tw_choice("Perfusion  ", ct_gmap_func_choice_proc, 0,
259             "TTM", "CBV", "MTT", "ERR", "RCC", NULL);
260   tw_button("gamma fit", ct_gfit_pixels_proc, NULL);
261   tw_newrow();
262   tw_choice("Permeability  ", ct_pmap_func_choice_proc, 0,
263             "T0", "VP", "VE", "K_trans", "ERR", NULL);
264   tw_button("perm fit", ct_kfpfit_pixels_proc, NULL);
265 
266   tw_newrow();
267   /*tw_button("Flips ", flip_proc, NULL);
268     tw_button("T1 Calib.", t1_calc_proc, NULL);*/
269   tw_button("Est. Plasma conc.", ct_est_plasma_conc_proc, NULL);
270 
271   /*tw_newrow();
272   tw_label("Test  ");
273   tw_button("flow/t",  plot_flow_proc, NULL);
274   tw_button("artificial", gen_art_proc, NULL);
275   tw_button("report", gen_report_proc, NULL);*/
276 /*
277   tw_button("nearest", nearest_proc, NULL);
278 */
279   tw_end_tool();
280 
281 }
282 

~ [ 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.