Doxygen Source Code Documentation
afni_plugin.h File Reference
#include <sys/types.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#include <sys/time.h>#include <sys/errno.h>#include <sys/times.h>#include <limits.h>#include "afni.h"#include <Xm/XmAll.h>#include <dlfcn.h>Go to the source code of this file.
Defines | |
| #define | PLUTO_X11_display (GLOBAL_library.dc->display) |
| #define | PLUTO_Xt_appcontext (GLOBAL_library.dc->appcontext) |
| #define | PLUTO_extract_series(ijk, ds) THD_extract_series((ijk),(ds),0) |
| #define | PLUTO_extract_series_raw(ijk, ds) THD_extract_series((ijk),(ds),1) |
| #define | PLUTO_register_0D_function AFNI_register_0D_function |
| #define | PLUTO_register_1D_function AFNI_register_1D_function |
| #define | PLUTO_register_2D_function AFNI_register_2D_function |
| #define | PLUTO_register_1D_funcstr AFNI_register_1D_funcstr |
| #define | PLUTO_cursorize(w) NORMAL_cursorize(w) |
Functions | |
| void | PLUTO_register_timeseries (char *, MRI_IMAGE *) |
| THD_3dim_dataset * | PLUTO_find_dset (MCW_idcode *) |
| THD_3dim_dataset * | PLUTO_find_dset_idc (char *) |
| THD_slist_find | PLUTO_dset_finder (char *) |
| void | PLUTO_histoplot (int, float, float, int *, char *, char *, char *, int, int **) |
| void | PLUTO_scatterplot (int, float *, float *, char *, char *, char *, float, float) |
| void | PLUTO_force_redisplay (void) |
| void | PLUTO_force_rebar (void) |
| void | PLUTO_register_workproc (XtWorkProc, XtPointer) |
| void | PLUTO_remove_workproc (XtWorkProc) |
| Boolean | PLUG_workprocess (XtPointer) |
| void | PLUTO_register_timeout (int, generic_func *, XtPointer) |
| double | PLUTO_cpu_time (void) |
| double | PLUTO_elapsed_time (void) |
Define Documentation
|
|
Definition at line 680 of file afni_plugin.h. Referenced by AFNI_misc_CB(), DRAW_main(), NOTES_main(), NUD_main(), PLUG_startup_plugin_CB(), RCREND_main(), REND_main(), TAG_main(), and TTRR_setup_widgets(). |
|
|
Definition at line 671 of file afni_plugin.h. |
|
|
Definition at line 672 of file afni_plugin.h. |
|
|
Definition at line 674 of file afni_plugin.h. Referenced by EXP0D_init(). |
|
|
Definition at line 678 of file afni_plugin.h. Referenced by PLUGIN_init(). |
|
|
Definition at line 675 of file afni_plugin.h. Referenced by PLUGIN_init(). |
|
|
Definition at line 676 of file afni_plugin.h. |
|
|
Definition at line 15 of file afni_plugin.h. |
|
|
Definition at line 16 of file afni_plugin.h. Referenced by PLUTO_register_timeout(), and PLUTO_register_workproc(). |
Function Documentation
|
|
Definition at line 5178 of file afni_plugin.c. References datap, free, num_workp, and workp. Referenced by PLUTO_register_workproc().
05179 {
05180 int ii , ngood ;
05181 Boolean done ;
05182
05183 #ifdef WPDEBUG
05184 { static int ncall=0 ;
05185 if( (ncall++) % 1000 == 0 )
05186 fprintf(stderr,"PLUG_workprocess: entry %d\n",ncall) ; }
05187 #endif
05188
05189 if( num_workp == 0 ) return True ;
05190
05191 for( ii=0,ngood=0 ; ii < num_workp ; ii++ ){
05192 if( workp[ii] != NULL ){
05193 done = workp[ii]( datap[ii] ) ;
05194 if( done == True ) workp[ii] = NULL ;
05195 else ngood++ ;
05196 }
05197 }
05198
05199 if( ngood == 0 ){
05200 #ifdef WPDEBUG
05201 fprintf(stderr,"Found no workprocs left\n") ;
05202 #endif
05203 free(workp) ; workp = NULL ; free(datap) ; datap = NULL ;
05204 num_workp = 0 ;
05205 return True ;
05206 }
05207 return False ;
05208 }
|
|
|
Definition at line 5285 of file afni_plugin.c. Referenced by new_RT_input().
05286 {
05287 #ifdef CLK_TCK
05288 struct tms ttt ;
05289
05290 (void) times( &ttt ) ;
05291 return ( (double) (ttt.tms_utime
05292 /* + ttt.tms_stime */
05293 )
05294 / (double) CLK_TCK ) ;
05295 #else
05296 return 0.0l ;
05297 #endif
05298 }
|
|
|
Definition at line 4807 of file afni_plugin.c. References BADFIND, FIND_IDCODE, GLOBAL_library, MCW_IDSIZE, MCW_strncpy, AFNI_library_type::sslist, MCW_idcode::str, and THD_dset_in_sessionlist(). Referenced by process_NIML_AFNI_dataset(), process_NIML_AFNI_volumedata(), process_NIML_Node_ROI(), process_NIML_SUMA_ijk(), process_NIML_SUMA_ixyz(), and process_NIML_SUMA_node_normals().
04808 {
04809 MCW_idcode idcode ;
04810 THD_slist_find find ;
04811
04812 BADFIND(find) ;
04813 if( idc == NULL ) return find ;
04814 MCW_strncpy( idcode.str , idc , MCW_IDSIZE ) ;
04815 find = THD_dset_in_sessionlist( FIND_IDCODE , &idcode ,
04816 GLOBAL_library.sslist , -1 ) ;
04817 return find ;
04818 }
|
|
|
Definition at line 5261 of file afni_plugin.c. Referenced by new_RT_input(), RT_start_child(), and RT_worker().
05262 {
05263 struct timeval new_tval ;
05264 struct timezone tzone ;
05265 static struct timeval old_tval ;
05266 static int first = 1 ;
05267
05268 gettimeofday( &new_tval , &tzone ) ;
05269
05270 if( first ){
05271 old_tval = new_tval ;
05272 first = 0 ;
05273 return 0.0 ;
05274 }
05275
05276 if( old_tval.tv_usec > new_tval.tv_usec ){
05277 new_tval.tv_usec += 1000000 ;
05278 new_tval.tv_sec -- ;
05279 }
05280
05281 return (double)( (new_tval.tv_sec - old_tval.tv_sec )
05282 +(new_tval.tv_usec - old_tval.tv_usec)*1.0e-6 ) ;
05283 }
|
|
|
|
Definition at line 4778 of file afni_plugin.c. References MCW_IDSIZE, MCW_strncpy, PLUTO_find_dset(), and MCW_idcode::str.
04779 {
04780 MCW_idcode idcode ;
04781 if( idc == NULL ) return NULL ;
04782 MCW_strncpy( idcode.str , idc , MCW_IDSIZE ) ;
04783 return PLUTO_find_dset( &idcode ) ;
04784 }
|
|
|
Definition at line 5086 of file afni_plugin.c. References AFNI_library_type::controllers, drive_MCW_imseq(), ENTRY, GLOBAL_library, IM3D_OPEN, isqDR_rebar, MAX_CONTROLLERS, Three_D_View::s123, Three_D_View::s231, and Three_D_View::s312. Referenced by AFNI_seq_send_CB().
05087 {
05088 Three_D_View * im3d ;
05089 int ii ;
05090
05091 ENTRY("PLUTO_force_rebar") ;
05092
05093 for( ii=0 ; ii < MAX_CONTROLLERS ; ii++ ){
05094 im3d = GLOBAL_library.controllers[ii] ;
05095 if( IM3D_OPEN(im3d) ){
05096 drive_MCW_imseq( im3d->s123 , isqDR_rebar , NULL ) ;
05097 drive_MCW_imseq( im3d->s231 , isqDR_rebar , NULL ) ;
05098 drive_MCW_imseq( im3d->s312 , isqDR_rebar , NULL ) ;
05099 }
05100 }
05101 EXRETURN ;
05102 }
|
|
|
Definition at line 5063 of file afni_plugin.c. References AFNI_set_viewpoint(), Three_D_View::anat_voxwarp, AFNI_library_type::controllers, ENTRY, Three_D_View::fim_voxwarp, GLOBAL_library, IM3D_OPEN, MAX_CONTROLLERS, REDISPLAY_ALL, and THD_warp::type. Referenced by AFNI_seq_send_CB(), CLUST_main(), CORD_main(), DSETN_main(), ENV_coorder(), and ENV_redisplay().
05064 {
05065 Three_D_View * im3d ;
05066 int ii ;
05067
05068 ENTRY("PLUTO_force_redisplay") ;
05069
05070 for( ii=0 ; ii < MAX_CONTROLLERS ; ii++ ){
05071 im3d = GLOBAL_library.controllers[ii] ;
05072 if( IM3D_OPEN(im3d) ){
05073 im3d->anat_voxwarp->type = /* 11 Jul 1997 */
05074 im3d->fim_voxwarp->type = ILLEGAL_TYPE ;
05075 AFNI_set_viewpoint( im3d , -1,-1,-1 , REDISPLAY_ALL ) ;
05076 }
05077 }
05078 EXRETURN ;
05079 }
|
|
||||||||||||||||||||||||||||||||||||||||
|
Definition at line 4836 of file afni_plugin.c. References AFNI_library_type::dc, MCW_DC::display, ENTRY, free, GLOBAL_library, malloc, plot_ts_lab(), and top. Referenced by BFIT_main(), CORREL_main(), and HISTO_main().
04839 {
04840 int ii , nx , ny,jj ;
04841 float * xar , * yar , * zar=NULL , ** yzar ;
04842 float dx ;
04843
04844 ENTRY("PLUTO_histoplot") ;
04845
04846 if( nbin < 2 || hist == NULL ) EXRETURN ;
04847 if( bot >= top ){ bot = 0.0 ; top = nbin ; }
04848
04849 nx = 2*(nbin+1) ;
04850 dx = (top-bot)/nbin ;
04851 xar = (float *) malloc(sizeof(float)*nx) ;
04852 yar = (float *) malloc(sizeof(float)*nx) ;
04853
04854 if( jist == NULL || njist < 0 ) njist = 0 ;
04855 ny = njist + 1 ;
04856
04857 yzar = (float **) malloc(sizeof(float *)*ny) ;
04858 yzar[0] = yar ;
04859 for( jj=0 ; jj < njist ; jj++ )
04860 yzar[jj+1] = (float *) malloc(sizeof(float)*nx) ;
04861
04862 xar[0] = bot ; yar[0] = 0.0 ;
04863 for( ii=0 ; ii < nbin ; ii++ ){
04864 xar[2*ii+1] = bot+ii*dx ; yar[2*ii+1] = (float) hist[ii] ;
04865 xar[2*ii+2] = bot+(ii+1)*dx ; yar[2*ii+2] = (float) hist[ii] ;
04866
04867 for( jj=0 ; jj < njist ; jj++ )
04868 yzar[jj+1][2*ii+1] = yzar[jj+1][2*ii+2] = (float) jist[jj][ii] ;
04869 }
04870 xar[2*nbin+1] = top ; yar[2*nbin+1] = 0.0 ;
04871 for( jj=0 ; jj < njist ; jj++ )
04872 yzar[jj+1][0] = yzar[jj+1][2*nbin+1] = 0.0 ;
04873
04874 plot_ts_lab( GLOBAL_library.dc->display ,
04875 nx , xar , ny , yzar ,
04876 xlab,ylab,tlab , NULL , NULL ) ;
04877
04878 for( jj=0 ; jj < njist ; jj++ ) free(yzar[jj+1]) ;
04879 free(yzar) ; free(xar) ; free(yar) ;
04880 EXRETURN ;
04881 }
|
|
||||||||||||||||
|
Definition at line 5236 of file afni_plugin.c. References mytimeout::cd, ENTRY, mytimeout::func, generic_func, myXtNew, PLUG_dotimeout_CB(), and PLUTO_Xt_appcontext. Referenced by PLUGIN_init().
05237 {
05238 mytimeout * myt ;
05239
05240 ENTRY("PLUTO_register_timeout") ;
05241
05242 if( func == NULL ){
05243 fprintf(stderr,"PLUTO_register_timeout: func=NULL on entry!\n") ;
05244 EXRETURN ;
05245 }
05246
05247 if( msec < 0 ) msec = 0 ;
05248
05249 myt = myXtNew(mytimeout) ;
05250 myt->func = func ;
05251 myt->cd = cd ;
05252
05253 (void) XtAppAddTimeOut( PLUTO_Xt_appcontext , msec ,
05254 PLUG_dotimeout_CB , (XtPointer) myt ) ;
05255
05256 EXRETURN ;
05257 }
|
|
||||||||||||
|
Definition at line 4760 of file afni_plugin.c. References AFNI_add_timeseries(), ENTRY, mri_add_name(), and mri_to_float(). Referenced by AFNI_finalize_read_1D_CB(), GRA_refstore_choose_CB(), MASKAVE_main(), PRIC_main(), TSGEN_main(), and VOLREG_main().
04761 {
04762 MRI_IMAGE * qim ;
04763
04764 ENTRY("PLUTO_register_timeseries") ;
04765
04766 if( tsim != NULL ){
04767 qim = mri_to_float( tsim ) ; /* a copy */
04768 mri_add_name( cname , qim ) ; /* the name */
04769 AFNI_add_timeseries( qim ) ; /* give it to AFNI */
04770 }
04771 EXRETURN ;
04772 }
|
|
||||||||||||
|
Definition at line 5112 of file afni_plugin.c. References datap, ENTRY, malloc, num_workp, PLUG_workprocess(), PLUTO_Xt_appcontext, realloc, workp, and wpid. Referenced by AFNI_init_niml(), AFNI_init_plugouts(), main(), PLUGIN_init(), and RT_startup().
05113 {
05114 ENTRY("PLUTO_register_workproc") ;
05115
05116 if( func == NULL ){
05117 fprintf(stderr,"PLUTO_register_workproc: func=NULL on entry!\n") ;
05118 EXRETURN ;
05119 }
05120
05121 if( num_workp == 0 ){
05122 workp = (XtWorkProc *) malloc( sizeof(XtWorkProc) ) ;
05123 datap = (XtPointer *) malloc( sizeof(XtPointer) ) ;
05124 wpid = XtAppAddWorkProc( PLUTO_Xt_appcontext, PLUG_workprocess, NULL ) ;
05125 #ifdef WPDEBUG
05126 fprintf(stderr,"PLUTO_register_workproc: wpid = %x\n",(int)wpid) ;
05127 #endif
05128 } else {
05129 workp = (XtWorkProc *) realloc( workp, sizeof(XtWorkProc)*(num_workp+1) ) ;
05130 datap = (XtPointer*) realloc( datap, sizeof(XtPointer) *(num_workp+1) ) ;
05131 }
05132
05133 workp[num_workp] = func ;
05134 datap[num_workp] = data ;
05135 num_workp++ ;
05136
05137 #ifdef WPDEBUG
05138 fprintf(stderr,"PLUTO_register_workproc: have %d workprocs\n",num_workp) ;
05139 #endif
05140
05141 EXRETURN ;
05142 }
|
|
|
Definition at line 5144 of file afni_plugin.c. References datap, ENTRY, free, num_workp, workp, and wpid.
05145 {
05146 int ii , ngood ;
05147
05148 ENTRY("PLUTO_remove_workproc") ;
05149
05150 if( func == NULL || num_workp == 0 ){
05151 fprintf(stderr,"*** PLUTO_remove_workproc: illegal parameters!\n") ;
05152 EXRETURN ;
05153 }
05154
05155 for( ii=0 ; ii < num_workp ; ii++ ){
05156 if( func == workp[ii] ) workp[ii] = NULL ;
05157 }
05158
05159 for( ii=0,ngood=0 ; ii < num_workp ; ii++ )
05160 if( workp[ii] != NULL ) ngood++ ;
05161
05162 if( ngood == 0 ){
05163 #ifdef WPDEBUG
05164 fprintf(stderr,"PLUTO_remove_workproc: No workprocs left\n") ;
05165 #endif
05166 XtRemoveWorkProc( wpid ) ;
05167 free(workp) ; workp = NULL ; free(datap) ; datap = NULL ;
05168 num_workp = 0 ;
05169 } else {
05170 #ifdef WPDEBUG
05171 fprintf(stderr,"PLUTO_remove_workproc: %d workprocs left\n",ngood) ;
05172 #endif
05173 }
05174
05175 EXRETURN ;
05176 }
|
|
||||||||||||||||||||||||||||||||||||
|
Definition at line 4912 of file afni_plugin.c. References a, AFNI_numenv(), create_memplot_surely(), AFNI_library_type::dc, MCW_DC::display, ENTRY, get_active_memplot(), GLOBAL_library, memplot_to_topshell(), mp, p10(), plotpak_line(), plotpak_periml(), plotpak_pwritf(), plotpak_set(), set_color_memplot(), set_thick_memplot(), and STGOOD. Referenced by SCAT_main().
04915 {
04916 int ii , np , nnax,mmax , nnay,mmay ;
04917 float xbot,xtop , ybot,ytop , pbot,ptop ,
04918 xobot,xotop,yobot,yotop , xa,xb,ya,yb , dx,dy ;
04919 float *xar , *yar , *zar=NULL , **yzar ;
04920 float dsq , rx,ry ;
04921 char str[32] ;
04922 MEM_plotdata * mp ;
04923
04924 ENTRY("PLUTO_scatterplot") ;
04925
04926 if( npt < 2 || x == NULL || y == NULL ) EXRETURN ;
04927
04928 /* find range of data */
04929
04930 xbot = xtop = x[0] ; ybot = ytop = y[0] ;
04931 for( ii=1 ; ii < npt ; ii++ ){
04932 if( x[ii] < xbot ) xbot = x[ii] ;
04933 else if( x[ii] > xtop ) xtop = x[ii] ;
04934
04935 if( y[ii] < ybot ) ybot = y[ii] ;
04936 else if( y[ii] > ytop ) ytop = y[ii] ;
04937 }
04938 if( xbot >= xtop || ybot >= ytop ){
04939 fprintf(stderr,"*** Data has no range in PLUTO_scatterplot!\n\a");
04940 EXRETURN ;
04941 }
04942
04943 /*-- push range of x outwards --*/
04944
04945 pbot = p10(xbot) ; ptop = p10(xtop) ; if( ptop < pbot ) ptop = pbot ;
04946 if( ptop != 0.0 ){
04947 np = (xtop-xbot) / ptop + 0.5 ;
04948 switch( np ){
04949 case 1: ptop *= 0.1 ; break ;
04950 case 2: ptop *= 0.2 ; break ;
04951 case 3: ptop *= 0.25 ; break ;
04952 case 4:
04953 case 5: ptop *= 0.5 ; break ;
04954 }
04955 xbot = floor( xbot/ptop ) * ptop ;
04956 xtop = ceil( xtop/ptop ) * ptop ;
04957 nnax = floor( (xtop-xbot) / ptop + 0.5 ) ;
04958 mmax = (nnax < 3) ? 10
04959 : (nnax < 6) ? 5 : 2 ;
04960 } else {
04961 nnax = 1 ; mmax = 10 ;
04962 }
04963
04964 /*-- push range of y outwards --*/
04965
04966 pbot = p10(ybot) ; ptop = p10(ytop) ; if( ptop < pbot ) ptop = pbot ;
04967 if( ptop != 0.0 ){
04968 np = (ytop-ybot) / ptop + 0.5 ;
04969 switch( np ){
04970 case 1: ptop *= 0.1 ; break ;
04971 case 2: ptop *= 0.2 ; break ;
04972 case 3: ptop *= 0.25 ; break ;
04973 case 4:
04974 case 5: ptop *= 0.5 ; break ;
04975 }
04976 ybot = floor( ybot/ptop ) * ptop ;
04977 ytop = ceil( ytop/ptop ) * ptop ;
04978 nnay = floor( (ytop-ybot) / ptop + 0.5 ) ;
04979 mmay = (nnay < 3) ? 10
04980 : (nnay < 6) ? 5 : 2 ;
04981 } else {
04982 nnay = 1 ; mmay = 10 ;
04983 }
04984
04985 /*-- setup to plot --*/
04986
04987 create_memplot_surely( "ScatPlot" , 1.3 ) ;
04988 set_thick_memplot( 0.0 ) ;
04989
04990 /*-- plot labels, if any --*/
04991
04992 xobot = 0.15 ; xotop = 1.27 ; /* set objective size of plot */
04993 yobot = 0.1 ; yotop = 0.95 ;
04994
04995 if( STGOOD(tlab) ){ yotop -= 0.02 ; yobot -= 0.01 ; }
04996
04997 /* x-axis label? */
04998
04999 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
05000 if( STGOOD(xlab) )
05001 plotpak_pwritf( 0.5*(xobot+xotop) , yobot-0.06 , xlab , 16 , 0 , 0 ) ;
05002
05003 /* y-axis label? */
05004
05005 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
05006 if( STGOOD(ylab) )
05007 plotpak_pwritf( xobot-0.12 , 0.5*(yobot+yotop) , ylab , 16 , 90 , 0 ) ;
05008
05009 /* label at top? */
05010
05011 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
05012 if( STGOOD(tlab) )
05013 plotpak_pwritf( xobot+0.01 , yotop+0.01 , tlab , 18 , 0 , -2 ) ;
05014
05015 /* plot axes */
05016
05017 set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
05018 plotpak_set( xobot,xotop , yobot,yotop , xbot,xtop , ybot,ytop , 1 ) ;
05019 plotpak_periml( nnax,mmax , nnay,mmay ) ;
05020
05021 /* plot data */
05022
05023 #define DSQ 0.001
05024
05025 dsq = AFNI_numenv( "AFNI_SCATPLOT_FRAC" ) ; /* 15 Feb 2005 */
05026 if( dsq <= 0.0 || dsq >= 0.01 ) dsq = DSQ ;
05027
05028 dx = dsq*(xtop-xbot) ;
05029 dy = dsq*(ytop-ybot) * (xotop-xobot)/(yotop-yobot) ;
05030 for( ii=0 ; ii < npt ; ii++ ){
05031
05032 #if 0
05033 rx = (drand48()-0.5)*dx ;
05034 ry = (drand48()-0.5)*dy ;
05035 #else
05036 rx = ry = 0.0 ;
05037 #endif
05038 xa = x[ii]+rx - dx ; xb = x[ii]+rx + dx ;
05039 ya = y[ii]+ry - dy ; yb = y[ii]+ry + dy ;
05040
05041 plotpak_line( xa,ya , xa,yb ) ;
05042 plotpak_line( xa,yb , xb,yb ) ;
05043 plotpak_line( xb,yb , xb,ya ) ;
05044 plotpak_line( xb,ya , xa,ya ) ;
05045 }
05046
05047 if( a != 0.0f || b != 0.0f ){ /* 02 May 2005 */
05048 set_color_memplot( 0.8 , 0.0 , 0.0 ) ;
05049 plotpak_line( xbot,a*xbot+b , xtop,a*xtop+b ) ;
05050 }
05051
05052 mp = get_active_memplot() ;
05053
05054 (void) memplot_to_topshell( GLOBAL_library.dc->display , mp , NULL ) ;
05055
05056 EXRETURN ;
05057 }
|