Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

qplot.c File Reference

#include "mrilib.h"
#include "coxplot.h"
#include "display.h"

Go to the source code of this file.


Defines

#define DEFAULT_NCOLOVR   20

Functions

void startup_timeout_CB (XtPointer client_data, XtIntervalId *id)
void scroll_timeout_CB (XtPointer client_data, XtIntervalId *id)
int main (int argc, char *argv[])
void killfunc (void *fred)
MEM_topshell_dataplot_ts_qqq (Display *dpy, int nx, float *x, int ny, float **y, char *lab_xxx, char *lab_yyy, char *lab_top, char **nam_yyy, void_func *killfunc)

Variables

char * INIT_colovr [DEFAULT_NCOLOVR]
char * INIT_labovr [DEFAULT_NCOLOVR]
int nx
int nts
int sep = 1
float ** yar
float * xar
MCW_DCdc
char * title = NULL
char * xlabel = NULL
char * ylabel = NULL
char * dfile_nar [6]
int nyar = 0
char * ynar [128]
char ** yname = NULL
XtAppContext app
MEM_topshell_datamp = NULL

Define Documentation

#define DEFAULT_NCOLOVR   20
 

Definition at line 13 of file qplot.c.

Referenced by main().


Function Documentation

void killfunc void *    fred
 

Definition at line 321 of file qplot.c.

Referenced by plot_ts_qqq(), and startup_timeout_CB().

00321 { exit(0) ; }

int main int    argc,
char *    argv[]
 

\** File : SUMA.c

Author:
: Ziad Saad Date : Thu Dec 27 16:21:01 EST 2001
Purpose :

Input paramters :

Parameters:
param  Usage : SUMA ( )
Returns :
Returns:
Support :
See also:
OpenGL prog. Guide 3rd edition , varray.c from book's sample code
Side effects :

Definition at line 47 of file qplot.c.

References app, argc, DEFAULT_NCOLOVR, dfile_nar, far, free, INIT_colovr, INIT_labovr, MRI_IMAGE::kind, machdep(), mainENTRY, malloc, MCW_get_intlist(), MCW_new_DC(), mri_fix_data_pointer(), MRI_FLOAT_PTR, mri_free(), mri_new_vol_empty(), mri_read_ascii(), mri_to_float(), mri_transpose(), my_getenv(), nts, MRI_IMAGE::nx, nx, MRI_IMAGE::ny, nyar, realloc, sep, startup_timeout_CB(), strtod(), THD_MAX_NAME, title, xar, xlabel, yar, ylabel, yname, and ynar.

00048 {
00049    int iarg , ii , ny , ignore=0 , use=0 , install=0 ;
00050    float dx=1.0 ;
00051    char * tsfile , * cpt ;
00052    char dname[THD_MAX_NAME] , subv[THD_MAX_NAME] ;
00053    MRI_IMAGE * inim , * flim ;
00054    float * far ;
00055    Widget shell ;
00056    int use_stdin=0 ; /* 01 Aug 2001 */
00057 
00058    /*-- help? --*/
00059 
00060    if( argc < 2 || strcmp(argv[1],"-help") == 0 ){
00061      printf("Usage: 1dplot [options] tsfile\n"
00062             "Graphs the columns of a *.1D type time series file to the screen.\n"
00063             "\n"
00064             "Options:\n"
00065             " -install   = Install a new X11 colormap.\n"
00066             " -sep       = Plot each column in a separate sub-graph.\n"
00067             " -one       = Plot all columns together in one big graph.\n"
00068             "                [default = -sep]\n"
00069             " -dx xx     = Spacing between points on the x-axis is 'xx'\n"
00070             "                [default = 1]\n"
00071             " -ignore nn = Skip first 'nn' rows in the input file\n"
00072             "                [default = 0]\n"
00073             " -use mm    = Plot 'mm' points [default = all of them]\n"
00074             " -xlabel aa = Put string 'aa' below the x-axis\n"
00075             "                [default = no axis label]\n"
00076             " -ylabel aa = Put string 'aa' to the left of the y-axis\n"
00077             "                [default = no axis label]\n"
00078             "\n"
00079             " -stdin     = Don't read from tsfile; instead, read from\n"
00080             "              stdin and plot it.\n"
00081             "\n"
00082             " -ynames aa bb ... = Use the strings 'aa', 'bb', etc., as\n"
00083             "                     labels to the right of the graphs,\n"
00084             "                     corresponding to each input column.\n"
00085             "                     These strings CANNOT start with the\n"
00086             "                     '-' character.\n"
00087             "\n"
00088             " -volreg           = Makes the 'ynames' be the same as the\n"
00089             "                     6 labels used in plug_volreg for\n"
00090             "                     Roll, Pitch, Yaw, I-S, R-L, and A-P\n"
00091             "                     movements, in that order.\n"
00092             "\n"
00093             "You may also select a subset of columns to display using\n"
00094             "a tsfile specification like 'fred.1D[0,3,5]', indicating\n"
00095             "that columns #0, #3, and #5 will be the only ones plotted.\n"
00096             "For more details on this selection scheme, see the output\n"
00097             "of '3dcalc -help'.\n"
00098             "\n"
00099             "Example: graphing a 'dfile' output by 3dvolreg, when TR=5:\n"
00100             "   1dplot -volreg -dx 5 -xlabel Time 'dfile[1..6]'\n"
00101             "\n"
00102            ) ;
00103       exit(0) ;
00104    }
00105 
00106    mainENTRY("1dplot main"); machdep();
00107 
00108    /* open X11 */
00109 
00110    shell = XtVaAppInitialize(
00111               &app , "AFNI" , NULL , 0 , &argc , argv , NULL , NULL ) ;
00112    if( shell == NULL ){
00113       fprintf(stderr,"** Cannot initialize X11!\n") ; exit(1) ;
00114    }
00115 
00116    cpt = my_getenv("TMPDIR") ;  /* just for fun */
00117 
00118    /*-- scan arguments that X11 didn't eat --*/
00119 
00120    iarg = 1 ;
00121    while( iarg < argc && argv[iarg][0] == '-' ){
00122 
00123      if( strcmp(argv[iarg],"-install") == 0 ){
00124         install++ ; iarg++ ; continue ;
00125      }
00126 
00127      if( strcmp(argv[iarg],"-stdin") == 0 ){  /* 01 Aug 2001 */
00128         use_stdin++ ; iarg++ ; continue ;
00129      }
00130 
00131      if( strcmp(argv[iarg],"-") == 0 ){  /* skip */
00132         iarg++ ; continue ;
00133      }
00134 
00135      if( strcmp(argv[iarg],"-ynames") == 0 ){
00136         iarg++ ;
00137         while( iarg < argc && argv[iarg][0] != '-' ){
00138            ynar[nyar++] = argv[iarg++] ;
00139         }
00140         continue ;
00141      }
00142 
00143      if( strcmp(argv[iarg],"-volreg") == 0 ){
00144         int ii ;
00145         for( ii=0 ; ii < 6 ; ii++ ) ynar[nyar++] = dfile_nar[ii] ;
00146         iarg++ ; continue ;
00147      }
00148 
00149      if( strcmp(argv[iarg],"-title") == 0 ){
00150         title = argv[++iarg] ;
00151         iarg++ ; continue ;
00152      }
00153 
00154      if( strcmp(argv[iarg],"-xlabel") == 0 ){
00155         xlabel = argv[++iarg] ;
00156         iarg++ ; continue ;
00157      }
00158 
00159      if( strcmp(argv[iarg],"-ylabel") == 0 ){
00160         ylabel = argv[++iarg] ;
00161         iarg++ ; continue ;
00162      }
00163 
00164      if( strcmp(argv[iarg],"-ignore") == 0 ){
00165         ignore = strtod( argv[++iarg] , NULL ) ;
00166         if( ignore < 0 ){fprintf(stderr,"** Illegal -ignore value!\n");exit(1);}
00167         iarg++ ; continue ;
00168      }
00169 
00170      if( strcmp(argv[iarg],"-use") == 0 ){
00171         use = strtod( argv[++iarg] , NULL ) ;
00172         if( use < 2 ){fprintf(stderr,"** Illegal -use value!\n");exit(1);}
00173         iarg++ ; continue ;
00174      }
00175 
00176      if( strcmp(argv[iarg],"-dx") == 0 ){
00177         dx = strtod( argv[++iarg] , NULL ) ;
00178         if( dx <= 0.0 ){fprintf(stderr,"** Illegal -dx value!\n");exit(1);}
00179         iarg++ ; continue ;
00180      }
00181 
00182      if( strcmp(argv[iarg],"-sep") == 0 ){
00183         sep = 1 ; iarg++ ; continue ;
00184      }
00185 
00186      if( strcmp(argv[iarg],"-one") == 0 ){
00187         sep = 0 ; iarg++ ; continue ;
00188      }
00189 
00190      fprintf(stderr,"** Unknown option: %s\n",argv[iarg]) ; exit(1) ;
00191    }
00192 
00193    if( iarg >= argc && !use_stdin ){
00194       fprintf(stderr,"** No tsfile on command line!\n") ; exit(1) ;
00195    }
00196 
00197    dc = MCW_new_DC( shell , 16 ,
00198                     DEFAULT_NCOLOVR , INIT_colovr , INIT_labovr ,
00199                     1.0 , install ) ;
00200 
00201    if( nyar > 0 ) yname = ynar ;
00202 
00203    /*-- 01 Aug 2001: read from stdin instead of a file --*/
00204 
00205    if( use_stdin ){
00206      char lbuf[2560] , *cpt ;
00207      int nval ;
00208      float val[9] ;
00209 
00210      cpt = fgets(lbuf,2560,stdin) ;
00211      if( cpt == NULL ){
00212         fprintf(stderr,"*** Can't read from stdin!\n"); exit(1);
00213      }
00214      nval = sscanf(lbuf,"%f%f%f%f%f%f%f%f%f",
00215                    val+0,val+1,val+2,val+3,val+4,val+5,val+6,val+7,val+8) ;
00216      if( nval < 1 ){
00217         fprintf(stderr,"*** Can't read numbers from stdin!\n"); exit(1);
00218      }
00219 
00220      subv[0] = '\0' ; nx = nval ; ny = 1 ;
00221      far = (float *) malloc(sizeof(float)*nval) ;
00222      memcpy(far,val,sizeof(float)*nx) ;
00223      while(1){  /* read from stdin */
00224         cpt = fgets(lbuf,2560,stdin) ;
00225         if( cpt == NULL ) break ;
00226         nval = sscanf(lbuf,"%f%f%f%f%f%f%f%f%f",
00227                       val+0,val+1,val+2,val+3,val+4,val+5,val+6,val+7,val+8) ;
00228         if( nval < 1 ) break ;
00229         far = (float *) realloc( far , sizeof(float)*(ny+1)*nx ) ;
00230         memcpy(far+ny*nx,val,sizeof(float)*nx) ;
00231         ny++ ;
00232      }
00233      if( ny < 2 ){
00234         fprintf(stderr,"** Can't read enough data from stdin\n"); exit(1);
00235      }
00236      inim = mri_new_vol_empty( nx,ny,1 , MRI_float ) ;
00237      mri_fix_data_pointer( far , inim ) ;
00238 
00239    } else {  /*-- old code: read from a file --*/
00240 
00241      /* check input filename for index strings */
00242 
00243      tsfile = argv[iarg] ;
00244      cpt    = strstr(tsfile,"[") ;
00245 
00246      if( cpt == NULL ){
00247         strcpy( dname , tsfile ) ;
00248         subv[0] = '\0' ;
00249      } else if( cpt == tsfile ){
00250         fprintf(stderr,"** Illegal filename on command line!\n");exit(1);
00251      } else {
00252         ii = cpt - tsfile ;
00253         memcpy(dname,tsfile,ii) ; dname[ii] = '\0' ;
00254         strcpy(subv,cpt) ;
00255      }
00256 
00257      /* read input file */
00258 
00259      inim = mri_read_ascii( dname ) ;
00260      if( inim == NULL ){
00261         fprintf(stderr,"** Can't read input file %s\n",dname) ;
00262         exit(1);
00263      }
00264    } /* end of file input */
00265 
00266    if( inim->kind != MRI_float ){  /* should not happen */
00267       flim = mri_to_float(inim) ; mri_free(inim) ; inim = flim ;
00268    }
00269    flim = mri_transpose(inim) ; mri_free(inim) ;
00270    far  = MRI_FLOAT_PTR(flim) ;
00271    nx   = flim->nx ;
00272    ny   = flim->ny ;
00273 
00274    /* make x axis */
00275 
00276    xar = (float *) malloc( sizeof(float) * nx ) ;
00277    for( ii=0 ; ii < nx ; ii++ ) xar[ii] = dx * ii ;
00278 
00279    /* select data to plot */
00280 
00281    if( subv[0] == '\0' ){  /* no sub-list */
00282 
00283       nts = ny ;
00284       yar = (float **) malloc(sizeof(float *)*nts) ;
00285       for( ii=0 ; ii < ny ; ii++ ) yar[ii] = far + (ii*nx+ignore) ;
00286 
00287    } else {                /* process sub-list */
00288       int  * ivlist , * ivl ;
00289 
00290       ivlist = MCW_get_intlist( ny , subv ) ;
00291       if( ivlist == NULL || ivlist[0] < 1 ){
00292          fprintf(stderr,"** Illegal column selectors on command line!\n");
00293          exit(1);
00294       }
00295       nts = ivlist[0] ;
00296       ivl = ivlist + 1 ;
00297       for( ii=0 ; ii < nts ; ii++ ){
00298          if( ivl[ii] < 0 || ivl[ii] >= ny ){
00299             fprintf(stderr,"** Illegal selector on command line!\n");
00300             exit(1) ;
00301          }
00302       }
00303       yar = (float **) malloc(sizeof(float *)*nts) ;
00304       for( ii=0 ; ii < nts ; ii++ ) yar[ii] = far + (ivl[ii]*nx+ignore) ;
00305       free(ivlist) ;
00306    }
00307 
00308    nx = nx - ignore ;  /* cut off the ignored points */
00309 
00310    if( use > 1 && nx > use ) nx = use ;  /* 29 Nov 1999 */
00311 
00312    /* start X11 */
00313 
00314    (void) XtAppAddTimeOut( app , 123 , startup_timeout_CB , NULL ) ;
00315 
00316    XtAppMainLoop(app) ;
00317    exit(0) ;
00318 }

MEM_topshell_data* plot_ts_qqq Display *    dpy,
int    nx,
float *    x,
int    ny,
float **    y,
char *    lab_xxx,
char *    lab_yyy,
char *    lab_top,
char **    nam_yyy,
void_func   killfunc
 

Definition at line 324 of file qplot.c.

References dpy, killfunc(), memplot_to_topshell(), mp, nx, and plot_ts_mem().

Referenced by startup_timeout_CB().

00328 {
00329    MEM_plotdata * mp ;
00330    MEM_topshell_data * mpmp=NULL ;
00331    int ymask = 0 ;
00332 
00333    if( dpy == NULL ) return ;
00334 
00335    if( ny < 0 ){ ymask = TSP_SEPARATE_YBOX ; ny = -ny ; }
00336 
00337    mp = plot_ts_mem( nx,x , ny,ymask,y , lab_xxx , lab_yyy , lab_top , nam_yyy ) ;
00338    if( mp != NULL )
00339     mpmp = memplot_to_topshell( dpy , mp , killfunc ) ;
00340 
00341    return mpmp ;
00342 }

void scroll_timeout_CB XtPointer    client_data,
XtIntervalId *    id
 

Definition at line 361 of file qplot.c.

References app, client_data, MEM_topshell_data::drawing, and scroll_timeout_CB().

Referenced by scroll_timeout_CB(), and startup_timeout_CB().

00362 {
00363    XWindowAttributes xwat ;
00364 
00365    XGetWindowAttributes( XtDisplay(mp->drawing),
00366                          XtWindow(mp->drawing) , &xwat ) ;
00367 
00368    XCopyArea( XtDisplay(mp->drawing) ,
00369               XtWindow(mp->drawing) , XtWindow(mp->drawing) ,
00370               DefaultGC(XtDisplay(mp->drawing),0) ,
00371               1 , 0 , xwat.width-1 , xwat.height , 0 , 0 ) ;
00372 
00373    XClearArea( XtDisplay(mp->drawing) ,
00374                XtWindow(mp->drawing) ,
00375                xwat.width-1 , 0 , 1 , xwat.height , FALSE ) ;
00376 
00377    (void) XtAppAddTimeOut( app , 16 , scroll_timeout_CB , NULL ) ;
00378    return ;
00379 }

void startup_timeout_CB XtPointer    client_data,
XtIntervalId *    id
 

Definition at line 346 of file qplot.c.

References app, client_data, MCW_DC::display, killfunc(), nts, nx, plot_ts_qqq(), scroll_timeout_CB(), title, xar, xlabel, yar, ylabel, and yname.

Referenced by main().

00347 {
00348    int ng ;
00349 
00350    /* make graph */
00351 
00352    ng = (sep) ? (-nts) : (nts) ;
00353    
00354    mp = plot_ts_qqq( dc->display , nx , xar , ng , yar ,
00355                      xlabel , ylabel , title , yname , killfunc ) ;
00356 
00357    (void) XtAppAddTimeOut( app , 16 , scroll_timeout_CB , NULL ) ;
00358    return ;
00359 }

Variable Documentation

XtAppContext app
 

Definition at line 45 of file qplot.c.

Referenced by main(), scroll_timeout_CB(), and startup_timeout_CB().

MCW_DC* dc [static]
 

Definition at line 31 of file qplot.c.

char* dfile_nar[6] [static]
 

Initial value:

 {
         "Roll [\\degree]" , "Pitch [\\degree]" , "Yaw [\\degree]"    ,
         "\\Delta I-S [mm]" , "\\Delta R-L [mm]" , "\\Delta A-P [mm]"  }

Definition at line 34 of file qplot.c.

Referenced by main().

char* INIT_colovr[DEFAULT_NCOLOVR] [static]
 

Initial value:

 {
   "#ffff00" , "#ffcc00"   , "#ff9900"  , "#ff6900" , "#ff4400" , "#ff0000" ,
   "#0000ff" , "#0044ff"   , "#0069ff"  , "#0099ff" , "#00ccff" , "#00ffff" ,
   "green"   , "limegreen" , "violet"   , "hotpink" ,
   "white"   , "#dddddd"   , "#bbbbbb"  , "black"
}

Definition at line 15 of file qplot.c.

Referenced by main().

char* INIT_labovr[DEFAULT_NCOLOVR] [static]
 

Initial value:

 {
   "yellow" , "yell-oran" , "oran-yell" , "orange"   , "oran-red" , "red"   ,
   "dk-blue", "blue"      , "lt-blue1"  , "lt-blue2" , "blue-cyan", "cyan"  ,
   "green"  , "limegreen" , "violet"    , "hotpink"  ,
   "white"  , "gry-dd"    , "gry-bb"    , "black"
}

Definition at line 22 of file qplot.c.

Referenced by main().

MEM_topshell_data* mp = NULL
 

Definition at line 344 of file qplot.c.

Referenced by AFNI_brick_to_mri(), AFNI_drive_clear_graph_1D(), AFNI_drive_clear_graph_xy(), AFNI_drive_close_graph_xy(), AFNI_drive_open_window(), AFNI_startup_layout_CB(), append_to_memplot(), calculate_t_from_sums(), cinvit_(), clip_memplot(), combak_(), copy_memplot(), cortb_(), corth_(), cutlines_memplot(), delete_memplot(), elmbak_(), eltran_(), expose_CB(), flip_memplot(), get_options(), init_structs(), insert_at_memplot(), invit_(), ISQ_getmemplot(), ISQ_graymap_draw(), ISQ_graymap_mtdkill(), ISQ_make_image(), ISQ_make_montage(), ISQ_plot_label(), ISQ_record_getim(), ISQ_rowgraph_draw(), ISQ_rowgraph_mtdkill(), ISQ_saver_CB(), ISQ_surfgraph_draw(), ISQ_surfgraph_mtdkill(), kill_graph_xy(), main(), memplot_to_postscript(), memplot_to_RGB_sef(), memplot_to_topshell(), memplot_to_X11_sef(), MTD_killfunc(), nline_active_memplot(), ortbak_(), orthes_(), ortran_(), plot_image_surface(), PLOT_matrix_gray(), PLOT_scatterellipse(), plot_strip_addto(), plot_strip_clear(), plot_strip_init(), plot_ts_addto(), plot_ts_init(), plot_ts_lab(), plot_ts_mem(), plot_ts_qqq(), PLOT_tsgray(), plotcirc_memplot(), plotline_memplot(), plotrect_memplot(), PLUTO_scatterplot(), psprint_CB(), read_socket(), RIC_CalcCoeffAB(), RIC_CorrectDataset(), ROIPLOT_main(), RT_mp_comm_send_data(), scale_memplot(), set_opacity_memplot(), sort_clusters(), sort_extrema(), SPLASH_imseq_getim(), startup_timeout_CB(), and SUMA_isDsetRelated().

int nts [static]
 

Definition at line 29 of file qplot.c.

Referenced by main(), and startup_timeout_CB().

int nx [static]
 

Definition at line 29 of file qplot.c.

Referenced by main(), plot_ts_qqq(), and startup_timeout_CB().

int nyar = 0 [static]
 

Definition at line 38 of file qplot.c.

Referenced by main().

int sep = 1 [static]
 

Definition at line 29 of file qplot.c.

Referenced by main().

char* title = NULL [static]
 

Definition at line 32 of file qplot.c.

Referenced by main(), and startup_timeout_CB().

float * xar [static]
 

Definition at line 30 of file qplot.c.

Referenced by main(), and startup_timeout_CB().

char * xlabel = NULL [static]
 

Definition at line 32 of file qplot.c.

Referenced by main(), and startup_timeout_CB().

float** yar [static]
 

Definition at line 30 of file qplot.c.

Referenced by main(), and startup_timeout_CB().

char * ylabel = NULL [static]
 

Definition at line 32 of file qplot.c.

Referenced by main(), and startup_timeout_CB().

char** yname = NULL [static]
 

Definition at line 40 of file qplot.c.

Referenced by main(), and startup_timeout_CB().

char* ynar[128] [static]
 

Definition at line 39 of file qplot.c.

Referenced by main().

 

Powered by Plone

This site conforms to the following standards: