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

Linux Cross Reference
Tina6/tina-tools/tinatool/tlmedical/tlmedAnl_results.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    :  $Source: /home/tina/cvs/tina-tools/tinatool/tlmedical/tlmedAnl_results.c,v $
 37  * Date    :  $Date: 2007/02/15 01:55:50 $
 38  * Version :  $Revision: 1.6 $
 39  * CVS Id  :  $Id: tlmedAnl_results.c,v 1.6 2007/02/15 01:55:50 paul Exp $
 40  *
 41  * Notes:
 42  *
 43  *********
 44 */
 45 
 46 #include "tlmedAnl_results.h"
 47 
 48 #if HAVE_CONFIG_H
 49 #   include <config.h>
 50 #endif
 51 
 52 #include <stdio.h>
 53 #include <math.h>
 54 #include <tina/sys/sysDef.h>
 55 #include <tina/sys/sysPro.h>
 56 #include <tina/math/mathDef.h>
 57 #include <tina/math/mathPro.h>
 58 #include <tina/image/imgDef.h>
 59 #include <tina/image/imgPro.h>
 60 #include <tina/medical/medDef.h>
 61 #include <tina/medical/medPro.h>
 62 #include <tinatool/draw/drawPro.h>
 63 #include <tinatool/draw/drawDef.h>
 64 #include <tinatool/tlbase/tlbaseDef.h>
 65 #include <tinatool/tlbase/tlbasePro.h>
 66 #include <tinatool/tlmedical/tlmedCoreg_view.h>
 67 
 68 static void ***imptrs = NULL;
 69 
 70 void  plot_stimfunc(void)
 71 {
 72   Sequence *seq = seq_get_current();
 73   Pl_flow  *plot_data = pl_flow_alloc();
 74   Tv       *tv = (Tv *)imcalc_graph_tv_get();
 75 /*
 76   Imrect   *im;
 77 */
 78   float    *time, *flow;
 79   int       imptrlx, imptrux, imptrly, imptruy, imptrlz, imptruz;
 80   int       length,  k;
 81   float    *stim;
 82 
 83   if (tv == NULL || tv->tv_screen == NULL)
 84     return;
 85   if ((stim=get_stimulus()) == NULL)
 86     return;
 87 
 88 /*
 89   im = (Imrect *)(get_seq_current_el(seq)->to);
 90 */
 91 
 92   seq_slice_init(seq);
 93   imptrs = seq_limits(&imptrlz, &imptruz, &imptrly, &imptruy, &imptrlx, 
 94                         &imptrux);
 95   
 96   length = imptruz-imptrlz;    
 97   flow = (float *)fvector_alloc(0, length);
 98   time = (float *)fvector_alloc(0, length); 
 99 
100   for (k = 0; k < length; k++)
101     {
102       if (!isnan((double)stim[k]))
103         flow[k] = stim[k];
104       else
105         flow[k] = 0.0;
106       time[k] = (float)k;
107     }
108 
109   tv_erase(tv);
110   plot(PL_INIT, PL_TV, tv,
111        PL_AXIS_COLOR, black,
112        PL_X_TEXT, true, 
113        PL_Y_TEXT, true,
114        PL_TITLE, "Stim Signal v Frame",
115        PL_STYLE, PL_CROSS,
116        PL_COLOR, red,
117        PL_GRAPH_DATA, length, time, flow,
118        PL_PLOT,
119        NULL);
120 
121   plot_data->mask = NULL;
122   plot_data->y1 = flow;
123   plot_data->x = time;
124   plot_data->y1_n2 = plot_data->x_n2 = length;
125   plot_data->y1_n1 = plot_data->x_n1 = 0;
126   set_pl_flow(plot_data);
127   
128   return;
129 }
130 
131 
132 void  plot_flow(void)
133 {
134   Sequence *seq = seq_get_current();
135   Pl_flow  *plot_data = pl_flow_alloc();
136   Vec3     *scale = NULL;
137   Imrect   *mask = NULL, *fmask = NULL, *im;
138   Tv       *tv = (Tv *)imcalc_graph_tv_get();
139   float    *time, *flow, single_time;
140   int       imptrlx, imptrux, imptrly, imptruy, imptrlz, imptruz;
141   int       length,  i, j, k;
142   int       type;
143   int old_val; /* mjs 10.10.03 introduced to store previous value of barrier (see imgSeq_slice.c) */
144 
145   if (tv == NULL || tv->tv_screen == NULL)
146     return;
147 
148   if ((single_time = seq->dim[3]) == 1.0)
149     {
150       error("plot_flow: timing info may be missing", warning);
151       return;
152     }
153     
154   scale = seq_dim_to_vec3();
155   if ((scale->el[0] == 1.0) || (scale->el[1] == 1.0) || (scale->el[2] == 1.0))
156     {
157       error("plot_flow: scale info may be missing", warning);
158       return;
159     }
160                  
161   if (stack_check_types(IMRECT, NULL) == false)
162     {
163       error("plot_flow: wrong type on stack", warning);
164       return;
165     }
166   mask = (Imrect *) stack_pop(&type);
167   fmask = im_copy(mask);
168 
169   old_val = seq_interp_choice(0);
170   coreg_slice_init(seq, (Vec3 *)NULL);
171   imptrs = seq_limits(&imptrlz, &imptruz, &imptrly, &imptruy, &imptrlx, 
172                         &imptrux);
173   seq_init_interp(imptrlx, imptrux, imptrly, imptruy, imptrlz, imptruz);
174   
175   length = imptruz-imptrlz;    
176   format("length; %d imptruz: %d imptrlz %d\n", length, imptruz, imptrlz);
177   flow = (float *)fvector_alloc(0, length);
178   time = (float *)fvector_alloc(0, length);
179   for (k = 0; k < length; k++)
180     {
181       flow[k] = 0.0;
182 
183       for (i = fmask->region->ly; i < fmask->region->uy; i++)
184         {
185           for (j = fmask->region->lx; j < fmask->region->ux; j++)
186             {
187               if (IM_CHAR(fmask, i, j) > 0)
188                  flow[k] += nearest_pixel(imptrs, vec3((double)j, (double)i, (double)k+imptrlz));
189             }
190         }
191       flow[k] *= ((scale->el[0])*(scale->el[1])/100);
192       time[k] = k * single_time; 
193     }
194 
195 
196   tv_erase(tv);
197   plot(PL_INIT, PL_TV, tv,
198        PL_AXIS_COLOR, black,
199        PL_X_TEXT, true,
200        PL_Y_TEXT, true,
201        PL_TITLE, "Signal v Time",
202        PL_STYLE, PL_CROSS,
203        PL_COLOR, red,
204        PL_GRAPH_DATA, length, time, flow,
205        PL_PLOT,
206        NULL);
207 
208   stack_push((void *)mask, IMRECT, im_free);
209 
210   plot_data->mask = fmask;
211   plot_data->y1 = flow;
212   plot_data->x = fvector_copy((void *)time, 0, length);
213   plot_data->y1_n2 = plot_data->x_n2 = length;
214   plot_data->y1_n1 = plot_data->x_n1 = 0;
215   set_pl_flow(plot_data);
216   
217   seq_interp_choice(old_val);
218 
219   return;
220 }
221 

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