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

Linux Cross Reference
Tina6/tina-tools/tinatool/tlmedical/tlmedAnl_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    :  $Source: tlmedAnl_tool.c $
 37  * Date    :  $Date: 2012/06/20 14:20 $
 38  * Version :  $Revision: 1.12 $
 39  *
 40  * Author  : Legacy TINA modified NAT/HR
 41  *
 42  * Notes :
 43  *
 44  *   Gio Buonaccorsi altered gfit_pixels_proc to include stack manipulation from
 45  *   gfit_measure_image.
 46  *   Done to improve lib / tool separation - 19 Feb 2003.
 47  *
 48  *********
 49 */
 50 
 51 
 52 #if HAVE_CONFIG_H
 53 #   include <config.h>
 54 #endif
 55 
 56 
 57 #include <stdio.h>
 58 #include <math.h>
 59 #include <float.h>
 60 #include <stdlib.h>
 61 #include <tina/sys/sysDef.h>
 62 #include <tina/sys/sysPro.h>
 63 #include <tina/math/mathDef.h>
 64 #include <tina/math/mathPro.h>
 65 #include <tina/image/imgDef.h>
 66 #include <tina/image/imgPro.h>
 67 #include <tina/medical/medDef.h>
 68 #include <tina/medical/medPro.h>
 69 #include <tinatool/draw/drawDef.h>
 70 #include <tinatool/draw/drawPro.h>
 71 #include <tinatool/wdgts/wdgtsPro.h>
 72 #include <tinatool/tlbase/tlbasePro.h>
 73 #include <tina/medical/med_StimDef.h>            /* HR */
 74 #include <tinatool/tlmedical/tlmedAnl_mouse.h>
 75 #include <tinatool/tlmedical/tlmedAnl_tool.h>    /* HR */
 76 #include <tinatool/tlmedical/tlmedAnl_results.h>
 77 #include <tinatool/tlmedical/tlmedAnl_report.h>
 78 #include <tinatool/tlmedical/tlmedAnl_results.h>
 79 
 80 
 81 #define MAXPATHLEN 1024 /* why is this here?  this is defined by the system a.lacey 20.01.03 */
 82 #define TR_DATA   455
 83 #define FLIP_ANGLE_DATA   456
 84 
 85 
 86 static void *pt0 = NULL;
 87 static double a1=2, a2=10;
 88 static double *ptr, *pa1, *pa2, *pa3;
 89 static char filename[128]="lookup.4.199.2.10.35.asc";
 90 static char *pfn;
 91 static int lut1[1202];
 92 static float delta[1202], sig1[1202], sig2[1202], sig3[1202];
 93 static int        pmap;
 94 static int        gmap;
 95 static int        hwave = 3;
 96 static int        dtime = 0;
 97 static int        offset = 0;
 98 static int        corr_func_type = 0;
 99 static void      *pperiod = NULL;
100 static double     iphase = -1.0;
101 static void      *poffset = NULL;
102 static void      *pdtime = NULL;
103 static char       patient[256];
104 static char       notes[256];
105 static char       repname[256];
106 
107 static int        dmap=1, which_mask=0;       /* HR: new */
108 
109 /*
110 static Bool       stim_phase_on = false;
111 static void stim_phase_choice_proc(int val)
112 {
113    if (val > 0)
114       stim_phase_on = true;
115    else
116       stim_phase_on = false;   
117 }
118 */
119 
120 static void corr_func_choice_proc(int val)
121 {
122    corr_func_type = val;
123 }
124 
125 static void perm_con_proc(int val)
126 {
127    extern void perm_con();
128    set_perm_con(val);
129 }
130 
131 static void gmap_func_choice_proc(int val)
132 {
133    gmap = val;
134    stack_push((void *)gfit_get_image(gmap), IMRECT, im_free);
135 
136    if (imcalc_tv_get()!=NULL) tv_init(imcalc_tv_get());
137    if (imcal2_tv_get()!=NULL) tv_init(imcal2_tv_get());
138    image_choice_reset();
139 }
140 
141 static void dmap_func_choice_proc(int val)                      /* HR: new */
142 {
143    dmap = val;
144    stack_push((void *)dfit_get_image(dmap), IMRECT, im_free);
145 
146    if (imcalc_tv_get()!=NULL) tv_init(imcalc_tv_get());
147    if (imcal2_tv_get()!=NULL) tv_init(imcal2_tv_get());
148    image_choice_reset();
149 }
150 
151 static void pmap_func_choice_proc(int val)
152 {
153    pmap = val;
154    stack_push((void *)pfit_get_image(pmap), IMRECT, im_free);
155 
156    if (imcalc_tv_get()!=NULL) tv_init(imcalc_tv_get());
157    if (imcal2_tv_get()!=NULL) tv_init(imcal2_tv_get());
158    image_choice_reset();
159 }
160 
161 static void stim_acquire_proc(int val)
162 {
163  Imrect *tmask = NULL;
164   int     type;
165 
166   switch (val)
167     {
168     case SCORR_SQR:
169       stim_sqrwave_acqu(&hwave, offset, dtime, (float)iphase);
170       break;
171     
172     case SCORR_SIN:
173       stim_sinwave_acqu(&hwave, offset, dtime, (float)iphase);
174       break;
175 
176     case SCORR_ROI:
177       stim_roi_acqu((Imrect *)NULL, &hwave);
178       break;
179 
180     case SCORR_PREV:
181       if (stack_check_types(IMRECT, NULL) == false)
182         {
183           error("stim_acquire: wrong type on stack", warning);
184           return;
185         }
186       tmask = (Imrect *) stack_pop(&type);
187       stim_roi_acqu(tmask, &hwave);
188       stack_push((void *)tmask, IMRECT, im_free);
189       break;
190     }
191     plot_stimfunc();
192 }
193 
194 static void stim_compare_proc(void)
195 {
196    stack_push((void *)stim_corr(offset, corr_func_type ), IMRECT, im_free);
197    
198    if (imcalc_tv_get()!=NULL) tv_init(imcalc_tv_get());
199    if (imcal2_tv_get()!=NULL) tv_init(imcal2_tv_get());
200    image_choice_reset();
201 }
202 
203 /*
204 static void     nearest_proc(void)
205 {
206    Imrect  *imf_knn_density(int neighbours, Imregion *test_roi);
207    Imrect         *im;
208    Imregion *roi = tv_get_im_roi(seq_tv_get());
209    int             type;
210 
211    im = imf_knn_density(10, roi);
212    stack_push(im, IMRECT, im_free);
213    if (imcalc_tv_get()!=NULL) tv_init(imcalc_tv_get());
214    if (imcal2_tv_get()!=NULL) tv_init(imcal2_tv_get());
215    image_choice_reset();
216 }
217 */
218 
219 static void  gen_art_proc()
220 {
221   Imrect  *im;
222   int      a, i, j;
223   int      b, c;
224   float    mu, mu1, mu2;
225 
226   mu1 = 100.0;
227   mu2 = 0.0;
228   b = 1;
229 
230   for (a = 0; a < 17; a++)
231     {
232       im = im_alloc(256, 256, NULL, float_v);
233       c = 0;
234       for (i = im->region->ly; i < im->region->uy; ++i)
235         {
236           if (c == 10) 
237             { b++; c = 0; }
238           else
239             c++;
240           /*
241           for (j = im->region->lx; j < im->region->ux; ++j)
242             {
243               if (j > (im->region->ux/2))
244                 {
245                   if ((b/hwave)%2)
246                     mu = mu1;
247                   else
248                     mu = mu2;
249                   IM_SHORT(im, i, j) = mu;
250                 }
251               else
252                 IM_SHORT(im, i, j) = 2.0;
253             }
254           
255           */
256           for (j = im->region->lx; j < im->region->ux; ++j)
257             {
258               if (j > (im->region->ux/2))
259                 {
260                   if ((b/hwave)%2)
261                     mu = mu1;
262                   else
263                     mu = mu2;
264                   IM_FLOAT(im, i, j) = rand_normal((double)mu, 10.0);
265                 }
266               else
267                 IM_FLOAT(im, i, j) = rand_normal(0.0, 1.0);
268             }
269           
270         }
271 
272       stack_push((void *)im, IMRECT, im_free);
273     }
274 }
275 
276 static void  mk_report()
277 {
278   flow_report(repname, patient, notes);
279 }
280 
281 
282 static void  gen_report_proc()
283 {
284   static void *dialog = NULL;
285 
286   if (dialog)
287     {
288       tw_show_dialog(dialog);
289       return;
290     }
291 
292   dialog = (void *)tw_dialog("Flow report generator");
293   tw_sglobal("Report file:", repname, 40);
294   tw_newrow();
295   tw_sglobal("Patient :", patient, 40);
296   tw_newrow();
297   tw_sglobal("Notes:", notes, 40);
298   tw_newrow();
299   tw_button("Go", mk_report, NULL);
300   tw_end_dialog();
301 }
302 
303 
304 /*
305 static void  plot_stimfunc_proc()
306 {
307   plot_stimfunc();
308 }
309 */
310 
311 
312 static void  plot_flow_proc()
313 {
314   plot_flow();
315   pl_measures();
316 }
317 
318 /*
319  *   Altered to improve lib / tool separation - GAB 19 Feb 2003
320  *   Stack manipulation from gfit_measure_image moved here.
321  */
322 static void  gfit_pixels_proc()
323 {
324    Imrect *mask = NULL;
325    int     type;
326   
327 /* old call a.lacey 22.01.02
328    gfit_measure_image();
329  */
330 /*
331  *   Stack manipulation from gfit_measure_image - GAB 19 Feb 2003
332  */
333    if (stack_check_types(IMRECT, NULL) != false)
334       mask = (Imrect *) stack_pop(&type);
335 
336    gfit_measure_image(0, mask);
337    stack_push((void *)gfit_get_image(gmap), IMRECT, im_free);
338 
339    if (imcalc_tv_get()!=NULL) tv_init(imcalc_tv_get());
340    if (imcal2_tv_get()!=NULL) tv_init(imcal2_tv_get());
341    image_choice_reset();
342 }
343 
344 
345 void  dfit_pixels_proc()                                        /* HR: new */
346 {
347    Imrect *mask = NULL;
348    int     type;
349 
350    if (stack_check_types(IMRECT, NULL) != false)
351       mask = (Imrect *) stack_inspect(&type);
352 
353    dfit_measure_image(0, mask);
354    stack_push((void *)dfit_get_image(dmap), IMRECT, im_free);
355 
356    if (imcalc_tv_get()!=NULL) tv_init(imcalc_tv_get());
357    if (imcal2_tv_get()!=NULL) tv_init(imcal2_tv_get());
358    image_choice_reset();
359 }
360 
361 
362 static void gfit_region_proc()
363 {
364      Tv *tv = imcalc_tv_get();
365      Ipos pos;
366      *min_t0_get() = pixel_gfit_region(tv,pos) - 4.0;
367      tw_fglobal_reset(pt0);
368 }
369 
370 static void  pfit_pixels_proc()
371 {
372    Imrect *mask, *t1im;
373    int     type;
374   
375    if ((mask = (Imrect *) stack_inspect(&type)) == NULL)
376                 return;
377    if ((t1im = (Imrect *)mono_image_get()) == NULL) 
378                 return;
379                 
380    pfit_measure_image(0, mask, t1im);
381    stack_push((void *)pfit_get_image(pmap), IMRECT, im_free);
382 
383    if (imcalc_tv_get()!=NULL) tv_init(imcalc_tv_get());
384    if (imcal2_tv_get()!=NULL) tv_init(imcal2_tv_get());
385    image_choice_reset();
386 }
387 
388 
389 static void est_plasma_conc_proc()
390 {
391   Imrect *mask, *t1im;
392   int type;
393 
394   if ((mask = (Imrect *) stack_inspect(&type)) == NULL)
395     return;
396   if ((t1im = (Imrect *)mono_image_get()) == NULL) 
397     return;
398   
399   est_plasma_conc(mask, t1im); 
400 
401 }
402 
403 
404 void gen_lookup_table(void)
405 {
406   double flip_angle[3];
407   double flip_rad[3];
408   char command[100];
409   FILE *fp;
410   float step2 = 2;
411   int i,T1;
412   float delta,signal[3];
413   double Exp,Sin,Cos;
414 
415   flip_angle[0]=a1;
416   flip_angle[1]=a2;
417   flip_angle[2]=*alpha_get();
418   /* convert filp angles to radians */
419   for (i=0;i<3;i++) flip_rad[i] = flip_angle[i]*0.017453292;
420 
421   /*create output ascii file */
422   sprintf(filename ,"lookup.%5.3f.%d.%d.%d.asc",
423           *tr_get(),(int)flip_angle[0],(int)flip_angle[1],(int)flip_angle[2]);
424 
425   /* remove any previous copies */
426   sprintf(command,"rm %s\n",filename);
427   format(command);
428   system(command);
429 
430   if ((fp = fopen(filename, "w")) == NULL)
431     {
432       printf("\ncannot open output file\nExiting...\n");
433       return;
434     }
435 
436   delta = 1; /* RF offset */
437 
438   /* loop through T1 in steps of step2 */
439   for (T1=100; T1<=2500; T1+=step2)
440         {
441 
442         Exp = exp(-(double)(*tr_get())/(double)(T1));
443 
444         for (i=0;i<3;i++)
445                 {
446                 Sin = sin((double)(delta)*(double)(flip_rad[i]));
447                 Cos = cos((double)(delta)*(double)(flip_rad[i]));
448                 signal[i] = (Sin * (1-Exp)) / (1 - Cos * Exp);
449 
450                 }
451 
452         /* normalise to signal[0] */
453         for (i=2;i>=0;i--) signal[i]/=signal[0];
454         fprintf(fp, "%f %d %f %f %f\n",delta,T1,signal[0],signal[1],signal[2]);
455         }
456 
457   /* close file */
458   fclose(fp);
459 
460   return;
461 
462 }
463 
464 /*mjs 7/11/05 modified flip_proc to use sequence proplist rather than now 
465   defunct image proplists. */
466 static void flip_proc(void)
467 {
468   /*Imrect * im1,*im2,*im3;*/
469    Sequence *seq = seq_get_current();
470    float *TR_arr=NULL, *FA_arr=NULL;
471    /*List *lptr;*/
472 
473    if (seq == NULL)
474      {
475        format("Flip proc; sequence is NULL\n"); 
476        return; 
477      }
478    /*lptr = get_seq_start_el(seq);
479    im1 = (Imrect *)lptr->to;
480 
481    lptr = lptr->next;
482    im2 = (Imrect *)lptr->to;
483 
484    lptr = lptr->next;
485    im3 = (Imrect *)lptr->to;
486    */
487    /*if(prop_get(im1->props,TR_DATA) == NULL) return;
488    if(prop_get(im1->props,FLIP_ANGLE_DATA) == NULL) return;
489    if(prop_get(im2->props,FLIP_ANGLE_DATA) == NULL) return;
490    if(prop_get(im3->props,FLIP_ANGLE_DATA) == NULL) return;*/
491 
492    if(prop_get(seq->props,TR_DATA) == NULL) return;
493    if(prop_get(seq->props,FLIP_ANGLE_DATA) == NULL) return;
494 
495    /* taking the first TR in the TR data array as representative of all the TRs 
496       (ie, they should all be the same) */
497    /* also assumes that there are three elements in the FA data. faux pas.*/
498    TR_arr = (float*)prop_get(seq->props, TR_DATA);
499    FA_arr = (float*)prop_get(seq->props, FLIP_ANGLE_DATA);
500 
501    *tr_get() = TR_arr[seq->offset];
502    a1 = FA_arr[seq->offset];
503    a2 = FA_arr[seq->offset+seq->stride];
504    *alpha_get()=FA_arr[seq->offset+2*seq->stride];
505      
506    
507    /**tr_get() = *(float*)prop_get(im1->props, TR_DATA);
508    a1 = *(float*)prop_get(im1->props, FLIP_ANGLE_DATA);
509    a2 = *(float*)prop_get(im2->props, FLIP_ANGLE_DATA);
510    *alpha_get() = *(float*)prop_get(im3->props, FLIP_ANGLE_DATA);*/
511    tw_fglobal_reset(ptr);
512    tw_fglobal_reset(pa1);
513    tw_fglobal_reset(pa2);
514    tw_fglobal_reset(pa3);
515    format("flip_proc: working\n");
516 
517 }
518 
519 static void look_up_proc(void)
520 {
521 
522   FILE * fp;
523   int i;
524 
525  if ((fp = fopen(filename, "r")) == NULL)
526     {
527       printf("\ncannot open output file\nExiting...\n");
528       return;
529     }
530 
531   for(i=0; i<=1201; i++)
532     {
533       fscanf(fp, "%f %d %f %f %f", &delta[i], &lut1[i], &sig1[i], &sig2[i], &sig3[i]);
534     }
535 
536   fclose(fp);
537 
538   return;
539 }
540 
541 static void t1_calc_proc(void)
542 {
543    void ***imptrs;
544    float *signal;
545    int i,j,k,l;
546    int imptrlz, imptruz, imptrly, imptruy, imptrlx, imptrux;
547    double difference;
548    double T1_value;
549    double test;
550    Sequence *seq = seq_get_current();
551    int width, height;
552    float *row;
553    Imrect *im;
554    Imregion roi;
555    int barrier=0;
556 
557 
558    gen_lookup_table();
559    look_up_proc();
560 
561    barrier = seq_interp_choice(0);
562    seq_slice_init(seq);
563    imptrs = seq_limits(&imptrlz, &imptruz, &imptrly, &imptruy, &imptrlx,
564                          &imptrux);
565    seq_init_interp(imptrlx,imptrux,
566                imptrly,imptruy,
567                imptrlz,imptruz);
568    signal = fvector_alloc(imptrlz, imptruz);
569 
570 /*
571    roi.lx = imptrlx;
572    roi.ux = imptrux;
573    roi.ly = imptrly;
574    roi.uy = imptruy;
575 */
576    roi = *tv_get_im_roi(seq_tv_get());
577 
578    width = imptrux -imptrlx;
579    height = imptruy - imptrlx;
580 
581    im = im_alloc(height, width, &roi, float_v);
582 
583    row = fvector_alloc(roi.lx, roi.ux);
584 
585    for (i = roi.ly; i < roi.uy; i++)
586    {
587       for (j = roi.lx; j < roi.ux; j++)
588       {
589           for (k = imptrlz; k < imptruz; k++)
590           {
591             signal[k] = nearest_pixel(imptrs,
592                          vec3((double)j+0.5, (double)i+0.5,
593                          (double)k+0.5));
594             /*signal[k]=im_sub_pixf()*/
595           }
596           /*format("%f,%f,%f\n", signal[imptrlz], signal[imptrlz+1], signal[imptrlz+2]);*/
597           signal[imptrlz+1] /= signal[imptrlz];
598           signal[imptrlz+2] /= signal[imptrlz];
599 
600           difference = FLT_MAX;
601           T1_value = 0.0;
602           for (l = 0; l<=1201; l++)
603           {
604              test = fabs(sig2[l] - signal[imptrlz+1]) + fabs(sig3[l] - signal[imptrlz+2]);
605              if ( test < difference)
606              {
607                  T1_value = lut1[l];
608                  difference = test;
609              }
610            }
611 /*
612            row[j] = signal[imptrlz];
613 */
614            row[j] = (float)T1_value;
615       }
616       im_put_rowf(row, im, i, roi.lx, roi.ux);
617    }
618    stack_push((void *)im, IMRECT, im_free);
619    imcalc_draw(imcalc_tv_get());
620    fvector_free(row,roi.lx);
621    seq_interp_choice(barrier);
622 }
623 
624 
625 
626 static void     imcalc_mouse_proc(Tv_mouse(*func)())
627 {
628   tv_set_mouse(imcalc_tv(), (*func) ());
629   tv_set_activity(imcalc_tv(), MOUSE);
630 }
631 
632 /*
633 static void     seq_mouse_proc(Tv_mouse(*func)())
634 {
635   tv_set_mouse(seq_tv_get(), (*func) ());
636   tv_set_activity(seq_tv_get(), MOUSE);
637 }
638 */
639 
640 
641 
642 /*** Paramter dialog callbacks ***/
643 
644 static void     temp_param_dialog(void)
645 {
646    static void *dialog = NULL;
647 
648    if (dialog)
649    {
650       tw_show_dialog(dialog);
651       return;
652    }
653 
654    dialog = (void *)tw_dialog("Temporal Parameters");
655    tw_choice("Stimulus   ", stim_acquire_proc, 0,
656             "SQR", "SIN", "ROI", "Mask", NULL);
657 
658    tw_newrow();
659    pperiod = (void *)tw_iglobal("period/2: ", &hwave, 5);
660    poffset = (void *)tw_iglobal("  offset: ", &offset, 5);
661    tw_newrow();
662    tw_fglobal("  iphase: ", &iphase, 5);
663    pdtime = (void *)tw_iglobal(" deadtime: ", &dtime, 5);
664    tw_end_dialog();
665 }
666 
667 static void     gfit_param_dialog(void)
668 {
669     static void *dialog = NULL;
670 
671     if (dialog)
672     {
673         tw_show_dialog(dialog);
674         return;
675     }
676 
677     dialog = (void *)tw_dialog("Gamma Parameters");
678   
679     tw_fglobal(" average mtt: ", ave_mtt_get(), 8);
680     tw_newrow();
681     pt0 = (void *)tw_fglobal("  minimum t0: ", min_t0_get(), 8);
682     tw_button("region fit", gfit_region_proc, NULL);
683     tw_newrow();
684     tw_fglobal("  recirculation cut: ", recirc_cut_get(), 8);
685     tw_newrow();
686     tw_fglobal("  recirculation period: ", recirc_period_get(), 8);
687     tw_newrow();
688     tw_fglobal("  rcbv scale: ", scl_get(), 8);
689 
690     tw_end_dialog();
691 }
692 
693 static void     perm_param_dialog(void)
694 {
695     static void *dialog = NULL;
696 
697     if (dialog)
698     {
699         tw_show_dialog(dialog);
700         return;
701     }
702 
703     dialog = (void *)tw_dialog("Permeability Parameters");
704 
705     pfn = (void*) tw_sglobal("Filename: ", filename, 40);
706     tw_newrow();
707 
708     tw_choice("Constraints  ", perm_con_proc, 0,
709               "None", "VE", "VP", NULL);
710 
711     tw_newrow();
712     ptr = (void*) tw_fglobal("TR", tr_get(), 10);
713     tw_fglobal("Contrast R1", r1cont_get(), 10);
714     tw_fglobal("Prebolus", prebolus_get(), 10);
715     tw_newrow();
716     pa1 = (void*) tw_fglobal("Angle 1", &a1, 10);
717     pa2 = (void*) tw_fglobal("Angle 2", &a2, 10);
718     pa3 = (void*) tw_fglobal("Angle 3", alpha_get(), 10);
719     tw_end_dialog();
720 }
721 
722 static void which_mask_proc(int val)                            /* HR: new */
723 {
724     which_mask = val;
725 }
726 
727 static void     dfit_param_dialog(void)                         /* HR: new */
728 {
729     static void *dialog = NULL;
730 
731     if (dialog)
732     {
733         tw_show_dialog(dialog);
734         return;
735     }
736 
737     dialog = (void *)tw_dialog("Diffusion Parameters");
738   
739    tw_choice("Mask :", which_mask_proc, 0,
740             "centre", "top-left", "top-right", "bottom-right", "bottom-left", NULL);
741 
742     tw_end_dialog();
743 }
744 
745 void    nmranalysis_tool(int x, int y)                          /* HR: new */
746 {
747   static void *tool = NULL;
748 /*
749   void         nmr_reset_proc(void);
750 */
751  
752   if (tool)
753   {
754       tw_show_tool(tool);
755       return;
756   }
757 
758   tool = tw_tool("NMR Analysis Tool", x, y);
759 
760   tw_menubar("Imcalc Mouse:  ",
761              "Measure",
762              "null", imcalc_mouse_proc, null_mouse,
763              "line", imcalc_mouse_proc, nmr_linelen_mouse,
764              "region", imcalc_mouse_proc, nmr_regsize_mouse,
765              "mask", imcalc_mouse_proc, nmr_masksize_mouse,
766              NULL, 
767              "Plot",
768              "null", imcalc_mouse_proc, null_mouse,
769              "flow/T", imcalc_mouse_proc, nmr_flow_mouse,
770              "gamma fit", imcalc_mouse_proc, nmr_gfit_mouse,
771              "perm fit", imcalc_mouse_proc, nmr_permfit_mouse,
772              "diff fit", imcalc_mouse_proc, nmr_dfit_mouse,          /* HR: new */
773              NULL, 
774                                                   NULL);
775   tw_help_button("nmr_analysis_tool");
776   tw_newrow();
777 
778   tw_button("stim params", temp_param_dialog, NULL);
779   tw_button("gamma params", gfit_param_dialog, NULL);
780   tw_button("perm params", perm_param_dialog, NULL);
781   tw_button("diff params", dfit_param_dialog, NULL);                 /* HR: new */
782 
783   tw_newrow();
784    
785   tw_choice("Sequence  ", corr_func_choice_proc, 2,
786             "GBAM", "STIM", "FRIS", NULL);
787 
788   tw_button("compare", stim_compare_proc, NULL);
789   tw_newrow();
790  
791   tw_choice("Perfusion  ", gmap_func_choice_proc, 0,
792             "TTM", "CBV", "MTT", "ERR", "RCC", NULL);
793   tw_button("gamma fit", gfit_pixels_proc, NULL);
794   tw_newrow();
795   tw_choice("Permeability  ", pmap_func_choice_proc, 0,
796             "TTP", "VP", "VE", "K_trans", "ERR", NULL);
797   tw_button("perm fit", pfit_pixels_proc, NULL);
798 
799   tw_newrow();
800   tw_choice("Diffusion  ", dmap_func_choice_proc, 1,
801             "S0", "ADC", NULL);                        /* HR: the transformed mask must be on top of the stack */
802   tw_button("DW-MR fit", dfit_pixels_proc, NULL);      /* HR: new */ 
803 
804   tw_newrow();
805   tw_button("Flips ", flip_proc, NULL);
806   tw_button("T1 Calib.", t1_calc_proc, NULL);
807   tw_button("Est. Plasma conc.", est_plasma_conc_proc, NULL);
808 
809   tw_newrow();
810   tw_label("Test  ");
811   tw_button("flow/t",  plot_flow_proc, NULL);
812   tw_button("artificial", gen_art_proc, NULL);
813   tw_button("report", gen_report_proc, NULL);
814 /*
815   tw_button("nearest", nearest_proc, NULL);
816 */
817   tw_end_tool();
818 
819 }
820 
821 

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