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  

to3d.c File Reference

#include "to3d.h"

Go to the source code of this file.


Defines

#define LABEL_ARG(str)   XtVaTypedArg , XmNlabelString , XmRString , (str) , strlen(str)+1
#define NZBOT   1
#define FatalError(str)   ( fprintf(stderr,"\n*** %s\n\n try 'to3d -help'\n",(str)) , exit(1) )
#define CURSOR_normalize
#define CURSOR_watchize
#define EMPTY_STRING(str)   ((str)[0] = '\0')
#define WarningError(str)   { fprintf(stderr,"\n***Warning: %s\n",(str)) ; nopt++ ; continue ; }
#define OUTERR   "*** ILLEGAL INPUTS (cannot save) ***\n\n"
#define DEBLANK(str)
#define INERR   "*** DATASET READ ERROR ***\n\n"
#define NAME2INT(nnn, iii, bot, top)
#define NAME2FLOAT(nnn, fff, bot, top)
#define NAME2STRING(nnn, sss)
#define BAD   -999

Functions

void AFNI_handler (char *msg)
void AFNI_startup_timeout_CB (XtPointer client_data, XtIntervalId *id)
int main (int argc, char *argv[])
void T3D_create_widgets (void)
void T3D_initialize_user_data (void)
void Syntax ()
void T3D_centered_CB (Widget w, XtPointer client_data, XtPointer call_data)
void T3D_set_dependent_geometries (void)
void T3D_voxshape_CB (Widget w, XtPointer client_data, XtPointer call_data)
char * T3D_text_display (MCW_arrowval *av, XtPointer cd)
void T3D_quit_timeout_CB (XtPointer client_data, XtIntervalId *id)
void T3D_quit_CB (Widget wcall, XtPointer client_data, XtPointer call_data)
void T3D_swap_CB (Widget w, XtPointer cd, XtPointer call_data)
void T3D_fov_av_CB (MCW_arrowval *av, XtPointer cd)
void T3D_orient_av_CB (MCW_arrowval *av, XtPointer cd)
void T3D_origin_av_CB (MCW_arrowval *av, XtPointer cd)
void T3D_size_av_CB (MCW_arrowval *av, XtPointer cd)
void T3D_type_av_CB (MCW_arrowval *av, XtPointer cd)
void T3D_fix_dataset_dimen (void)
void T3D_read_images (void)
void T3D_open_view_CB (Widget w, XtPointer client_data, XtPointer call_data)
XtPointer T3D_getim (int n, int type, FD_brick *br)
void T3D_imseq_CB (MCW_imseq *seq, FD_brick *br, ISQ_cbs *cbs)
void T3D_save_file_CB (Widget w, XtPointer client_data, XtPointer call_data)
void T3D_widgets_to_data (void)
void T3D_data_to_widgets (void)
Boolean T3D_check_data (Boolean perr)
void T3D_poperr (char *prefix_msg, char *msg)
void T3D_pointer_leave_EV (Widget w, XtPointer client_data, XEvent *ev, Boolean *continue_to_dispatch)
void T3D_geometry_parent_CB (Widget w, XtPointer client_data, XtPointer call_data)
void T3D_anatomy_parent_CB (Widget w, XtPointer client_data, XtPointer call_data)
void AFNI_load_defaults (Widget w)
void T3D_stat_aux_CB (Widget w, XtPointer client_data, XtPointer call_data)
void T3D_setup_stat_aux (void)
int decode_location (char *str, float *val, int *dcode)
void T3D_check_outliers (int opcode)

Variables

to3d_widget_set wset
to3d_data user_inputs
THD_3dim_datasetdset = NULL
THD_datablockdblk = NULL
THD_dataxesdaxes = NULL
THD_diskptrdkptr = NULL
THD_marker_setmarkers = NULL
THD_string_arrayimnames = NULL
int outliers_checked = 0
char * outliers_fname = NULL
int Argc
int First_Image_Arg = 1
char ** Argv
char * dbrick = NULL
int geomparent_loaded = 0
int geometry_loaded = 0
int negative_shorts = 0
int nvox_total = 0
int nfloat_err = 0
float imdx = 0.0
float imdy = 0.0
float imdz = 0.0
float zpad = 0
int zpad_mm = 0
float zoff
int use_zoff = 0
int af_type_set = 0
struct {
   int   ncolor
   float   gamma
   Boolean   xtwarns
   float   gsfac
   int   datum_all
   int   delay_input
   int   editing
   int   swap_two
   int   swap_four
   int   nofloatscan
   int   swap_eight
argopt
char * FALLback []
char * commandline = NULL
to3d_data default_user_inputs

Define Documentation

#define BAD   -999
 

Definition at line 5663 of file to3d.c.

#define CURSOR_normalize
 

Value:

do{ NORMAL_cursorize(wset.topshell) ;                \
      XSync( XtDisplay(wset.topshell), False ) ;       \
      XmUpdateDisplay( wset.topshell ) ; } while(0)

Definition at line 100 of file to3d.c.

Referenced by AFNI_startup_timeout_CB(), and T3D_check_outliers().

#define CURSOR_watchize
 

Value:

do{ WATCH_cursorize(wset.topshell) ;                 \
      XSync( XtDisplay(wset.topshell), False ) ;       \
      XmUpdateDisplay( wset.topshell ) ; } while(0)

Definition at line 105 of file to3d.c.

Referenced by T3D_check_outliers().

#define DEBLANK str   
 

Value:

{ int iq ;        \
     for( iq=strlen(str)-1; iq >= 0 && str[iq]==' '; iq-- )str[iq]='\0'; \
   }

Definition at line 5336 of file to3d.c.

Referenced by T3D_anatomy_parent_CB(), and T3D_geometry_parent_CB().

#define EMPTY_STRING str       ((str)[0] = '\0')
 

Definition at line 1935 of file to3d.c.

#define FatalError str       ( fprintf(stderr,"\n*** %s\n\n try 'to3d -help'\n",(str)) , exit(1) )
 

Definition at line 51 of file to3d.c.

#define INERR   "*** DATASET READ ERROR ***\n\n"
 

Definition at line 5341 of file to3d.c.

Referenced by T3D_anatomy_parent_CB(), and T3D_geometry_parent_CB().

#define LABEL_ARG str       XtVaTypedArg , XmNlabelString , XmRString , (str) , strlen(str)+1
 

Definition at line 9 of file to3d.c.

Referenced by T3D_create_widgets().

#define NAME2FLOAT nnn,
fff,
bot,
top   
 

Value:

{ xdef = RWC_getname(display,nnn) ;        \
    if( xdef != NULL ){                      \
       fval = strtod( xdef , &cpt ) ;        \
       if( *cpt == '\0' && fval >= (bot) && fval <= (top) ) (fff) = fval ; } }

Definition at line 5652 of file to3d.c.

#define NAME2INT nnn,
iii,
bot,
top   
 

Value:

{ xdef = RWC_getname(display,nnn) ;        \
    if( xdef != NULL ){                      \
       ival = strtol( xdef , &cpt , 10 ) ;   \
       if( *cpt == '\0' && ival >= (bot) && ival <= (top) ) (iii) = ival ; } }

Definition at line 5646 of file to3d.c.

#define NAME2STRING nnn,
sss   
 

Value:

{ xdef = RWC_getname(display,nnn) ;        \
    if( xdef != NULL ) sss  = XtNewString(xdef) ; }

Definition at line 5658 of file to3d.c.

#define NZBOT   1
 

Definition at line 12 of file to3d.c.

Referenced by Syntax(), T3D_initialize_user_data(), and T3D_read_images().

#define OUTERR   "*** ILLEGAL INPUTS (cannot save) ***\n\n"
 

Definition at line 5150 of file to3d.c.

Referenced by T3D_check_data().

#define WarningError str       { fprintf(stderr,"\n***Warning: %s\n",(str)) ; nopt++ ; continue ; }
 

Definition at line 1939 of file to3d.c.

Referenced by T3D_initialize_user_data().


Function Documentation

void AFNI_handler char *    msg
 

16 July 1997: orientation code change *

Definition at line 98 of file to3d.c.

Referenced by main().

00098 {}

void AFNI_load_defaults Widget    w
 

initialization values (static values are used in afni.c only) *

Definition at line 5665 of file to3d.c.

References BAD, BLUEST_COLOR, display, ENTRY, FIRST_RESAM_TYPE, INIT_bigscroll, INIT_crosshair_color, INIT_crosshair_gap, INIT_fim_polort, INIT_GR_backg_color, INIT_GR_boxes_color, INIT_GR_boxes_thick, INIT_GR_data_color, INIT_GR_data_thick, INIT_GR_dplot_color, INIT_GR_dplot_thick, INIT_GR_ggap, INIT_GR_gmat, INIT_GR_grid_color, INIT_GR_grid_thick, INIT_GR_gthick, INIT_GR_ideal_color, INIT_GR_ideal_thick, INIT_GR_ignore_color, INIT_GR_ort_color, INIT_GR_ort_thick, INIT_GR_text_color, INIT_ignore, INIT_marks1_color, INIT_marks2_color, INIT_marks_gap, INIT_marks_size, INIT_montage_periodic, INIT_ncolovr, INIT_ovin_pos, INIT_ovin_sgn, INIT_panes_hide, INIT_panes_pos, INIT_panes_sgn, INIT_posfunc, INIT_purge, INIT_pval_pos, INIT_pval_sgn, INIT_resam_anat, INIT_resam_func, INIT_resam_thr, INIT_resam_vox, INIT_tlrc_big, LAST_RESAM_TYPE, MAX_NCOLOVR, MAXOVSIZE, myXtFree, NAME2FLOAT, NAME2INT, NAME2STRING, NPANE_MAX, NPANE_MIN, and XtFree.

Referenced by main().

05666 {
05667    char    * xdef ;
05668    Display * display ;
05669    int       ival ;
05670    float     fval ;
05671    char *    cpt ;
05672 
05673 ENTRY("AFNI_load_defaults") ;
05674 
05675    if( w == NULL ) EXRETURN ;
05676    display = XtDisplay( w ) ;
05677 
05678    /** initialize display and overlay colors **/
05679 
05680    NAME2INT("ncolors",INIT_ngray,3,MAX_COLORS) ;
05681 
05682    NAME2FLOAT("gamma",INIT_gamma,0.1,9.9) ;
05683 
05684    NAME2FLOAT("init_fov",INIT_fov,1.0,1000.0) ;
05685    INIT_fov = 0.1 * ( (int)(10*INIT_fov) ) ;
05686 
05687    EXRETURN ;
05688 }

void AFNI_startup_timeout_CB XtPointer    client_data,
XtIntervalId *    id
 

Definition at line 110 of file to3d.c.

References AFNI_yesenv(), to3d_widget_set::anatomy_parent_label, client_data, CURSOR_normalize, to3d_widget_set::geometry_parent_label, MCW_help_CB(), MCW_popup_message(), MCW_TIMER_KILL, MCW_USER_KILL, myXtFree, myXtNew, negative_shorts, nfloat_err, THD_timeaxis::ntt, to3d_data::ntt, nvox_total, outliers_checked, T3D_check_outliers(), and THD_3dim_dataset::taxis.

Referenced by main().

00111 {
00112    char msg[512] ;
00113 
00114    MCW_help_CB(NULL,NULL,NULL) ;
00115    CURSOR_normalize ;
00116 
00117    if( negative_shorts && !AFNI_yesenv("AFNI_NO_NEGATIVES_WARNING") ){ /* 19 Jan 2000 */
00118       float perc = (100.0*negative_shorts)/nvox_total ;
00119       sprintf(msg , " \n"
00120                     " to3d WARNING: %d negative voxels (%g%%)\n"
00121                     "               were read in images of shorts.\n"
00122                     "               It is possible the input\n"
00123                     "               images need byte-swapping.\n \n"
00124                     " ** I recommend that you View Images. **\n" ,
00125               negative_shorts , perc ) ;
00126 
00127       (void) MCW_popup_message( wset.anatomy_parent_label , msg ,
00128                                 MCW_USER_KILL | MCW_TIMER_KILL ) ;
00129    }
00130 
00131    if( nfloat_err ){ /* 20 Jan 2000 */
00132       sprintf(msg , " \n"
00133                     " to3d WARNING: %d errors in floating point images\n"
00134                     "               were detected.  It is possible that\n"
00135                     "               the inputs need to be 4swap-ed, or\n"
00136                     "               otherwise repaired.\n \n"
00137                     " ** Erroneous values have been replaced by   **\n"
00138                     " ** zeros. I recommend that you View Images. **\n" ,
00139               nfloat_err ) ;
00140 
00141       (void) MCW_popup_message( wset.geometry_parent_label , msg ,
00142                                 MCW_USER_KILL | MCW_TIMER_KILL ) ;
00143    }
00144 
00145    if( user_inputs.ntt > 5 ){                 /* 15 Aug 2001 */
00146       dset->taxis = myXtNew( THD_timeaxis ) ;
00147       dset->taxis->ntt = user_inputs.ntt ;
00148       T3D_check_outliers(0) ; outliers_checked = 1 ;
00149       myXtFree(dset->taxis) ;
00150    }
00151 }

int decode_location char *    str,
float *    val,
int *    dcode
 

Definition at line 5743 of file to3d.c.

References ORCODE, and strtod().

Referenced by T3D_initialize_user_data().

05744 {
05745    char acod , * ptr , * sstr = str ;
05746 
05747    *val   = WAY_BIG ;
05748    *dcode = ILLEGAL_TYPE ;
05749    if( sstr == NULL || sstr[0] == '\0' ) return 0 ;
05750 
05751    /** see if we get a legal direction code here **/
05752 
05753    acod = toupper(sstr[0]) ; *dcode = ORCODE(acod) ;
05754    if( *dcode >= 0 ) sstr++ ;
05755 
05756    if( sstr[0] == '\0' ) return ((*dcode < 0) ? 0 : 1) ;
05757 
05758    /** get number here **/
05759 
05760    *val = strtod( sstr , &ptr ) ;
05761    if( *val == 0.0 && ptr == sstr ) return ((*dcode < 0) ? 0 : 1) ;
05762    sstr = ptr ;
05763 
05764    if( *dcode >= 0 || sstr[0] == '\0' ) return (sstr-str) ;
05765 
05766    acod = toupper(sstr[0]) ; *dcode = ORCODE(acod) ;
05767    if( *dcode >= 0 ) sstr++ ;
05768 
05769    return (sstr-str) ;
05770 }

int main int    argc,
char *    argv[]
 

Definition at line 157 of file to3d.c.

References addto_args(), AFNI_handler(), AFNI_load_defaults(), AFNI_noenv(), AFNI_startup_timeout_CB(), to3d_data::anatomy_parent_filename, Argc, argc, argopt, Argv, enable_mcw_malloc(), FALLback, to3d_data::fov, GAMMA, geometry_loaded, to3d_data::geometry_parent_filename, geomparent_loaded, to3d_widget_set::good, imdx, imdy, imdz, machdep(), mainENTRY, MCW_help_CB(), MCW_hint_toggle(), MCW_isitmwm, negative_shorts, NGRAY, to3d_data::nosave, to3d_data::ntt, nvox_total, to3d_data::nx, to3d_data::ny, to3d_data::nz, to3d_data::nzz, ORCODE, STATUS, T3D_anatomy_parent_CB(), T3D_check_data(), T3D_create_widgets(), T3D_geometry_parent_CB(), T3D_initialize_user_data(), T3D_read_images(), T3D_save_file_CB(), to3d_widget_set::topshell, to3d_data::tpattern, to3d_data::TR, to3d_data::tunits, UNITS_SEC_TYPE, UNITS_TYPE_LABEL, to3d_data::voxshape, VOXSHAPE_CUBICAL, VOXSHAPE_IRREGULAR, VOXSHAPE_SQUARE, XCENTERED, to3d_data::xincode, to3d_data::xorient, to3d_data::xorigin, to3d_data::xsize, to3d_data::xyz_centered, YCENTERED, to3d_data::yincode, to3d_data::yorient, to3d_data::yorigin, to3d_data::ysize, ZCENTERED, to3d_data::zincode, zoff, to3d_data::zorient, to3d_data::zorigin, and to3d_data::zsize.

00158 {
00159    XtAppContext   app ;
00160    XtErrorHandler old_handler ;
00161    Boolean        all_good ;
00162 
00163    mainENTRY("to3d:main") ;
00164    machdep() ; /* RWCox: 20 Apr 2001 */
00165 
00166    if( DBG_trace ){                              /* 10 Sep 2002 */
00167      fprintf(stderr,"Enabling mcw_malloc()\n") ;
00168      enable_mcw_malloc() ;
00169    }
00170 
00171    /* read the user data from the command line, if any */
00172 
00173    wset.topshell = NULL ;  /* flag that X has yet to start */
00174    wset.good     = 0 ;
00175 
00176    /* initialize defaults for command line arguments
00177       that aren't related to dataset construction    */
00178 
00179    INIT_ngray       = NGRAY ;
00180    INIT_gamma       = GAMMA ;
00181    INIT_fov         = 240.0 ;
00182    argopt.ncolor    = -1 ;
00183    argopt.gamma     = -1.0 ;
00184    argopt.xtwarns   = False ;         /* don't show Xt warnings */
00185    argopt.gsfac     = 0.0 ;           /* no global scaling factor */
00186    argopt.datum_all = ILLEGAL_TYPE ;  /* use first image type */
00187 #ifdef USE_MRI_DELAY
00188    argopt.delay_input = FALSE ;
00189 #endif
00190    argopt.editing     = FALSE ;
00191 
00192    argopt.swap_two = argopt.swap_four = 0 ;  /* 14 Sep 1998 */
00193    argopt.swap_eight = 0 ;                   /* 06 Feb 2003 */
00194 
00195    argopt.nofloatscan = 0 ;                  /* 14 Sep 1999 */
00196 
00197    /* read the inputs */
00198 
00199    printf("to3d: 2D slices into 3D datasets for AFNI, by RW Cox\n") ;
00200 
00201    /*-- 20 Apr 2001: addto the arglist, if user wants to --*/
00202 
00203    { int new_argc ; char ** new_argv ;
00204      addto_args( argc , argv , &new_argc , &new_argv ) ;
00205      if( new_argv != NULL ){ argc = new_argc ; argv = new_argv ; }
00206    }
00207 
00208    Argc = argc ; Argv = argv ;
00209 
00210    T3D_initialize_user_data() ;
00211 
00212    if( user_inputs.nosave ){
00213      printf("Opening X11 now") ; fflush(stdout) ;
00214      wset.topshell = XtVaAppInitialize( &app , "AFNI" , NULL , 0 ,
00215                                         &argc , argv , FALLback , NULL ) ;
00216      printf("..opened\n") ;
00217    }
00218 
00219    T3D_read_images() ;
00220 
00221    if( negative_shorts ){
00222       float perc = (100.0*negative_shorts)/nvox_total ;
00223       fprintf(stderr,
00224        "to3d WARNING: %d negative voxels (%g%%) were read in images of shorts.\n"
00225        "              It is possible the input images need byte-swapping.\n",
00226        negative_shorts , perc ) ;
00227    }
00228 
00229    if( strlen(user_inputs.geometry_parent_filename) > 0 )
00230       T3D_geometry_parent_CB( NULL , NULL , NULL ) ;
00231 
00232    if( strlen(user_inputs.anatomy_parent_filename) > 0 )
00233       T3D_anatomy_parent_CB( NULL , NULL , NULL ) ;
00234 
00235    /* 05 Feb 2001: [10 May 2001: moved up above auto-save]
00236       if geometry not loaded at all, maybe use globals imdx, etc. */
00237 
00238    if( ! (geomparent_loaded || geometry_loaded) ){
00239       if( imdx <= 0.0 || imdy <= 0.0 ){
00240 
00241 STATUS("setting default FOV") ;
00242 
00243          user_inputs.fov = INIT_fov ;    /* the old code */
00244 
00245       } else {                           /* the new code */
00246          float size ;
00247 
00248 STATUS("setting voxel size from imdx, etc.") ;
00249 
00250          user_inputs.xsize = imdx ;
00251          user_inputs.ysize = imdy ;
00252          if( imdz > 0.0 ) user_inputs.zsize = imdz ;
00253 
00254          /* 10 May 2001: make sure axes are centered */
00255 
00256          size = 0.5 * (user_inputs.nx-1) * user_inputs.xsize ;
00257          user_inputs.xorigin = size ;
00258 
00259          size = 0.5 * (user_inputs.ny-1) * user_inputs.ysize ;
00260          user_inputs.yorigin = size ;
00261 
00262          size = 0.5 * (user_inputs.nz-1) * user_inputs.zsize ;
00263          user_inputs.zorigin = size ;
00264 
00265          user_inputs.xyz_centered = (XCENTERED|YCENTERED|ZCENTERED) ;
00266 
00267          /* adjust voxel shape flag (for widget initialization) */
00268 
00269          if( user_inputs.xsize != user_inputs.ysize ){
00270             user_inputs.voxshape = VOXSHAPE_IRREGULAR ;
00271          } else {
00272             if( user_inputs.xsize != user_inputs.zsize ){
00273                user_inputs.voxshape = VOXSHAPE_SQUARE ;
00274             } else {
00275                user_inputs.voxshape = VOXSHAPE_CUBICAL ;
00276             }
00277          }
00278          user_inputs.fov = user_inputs.xsize * user_inputs.nx ;
00279       }
00280 
00281       /* 12 Mar 2001: MRILIB_ global variables may contain useful info */
00282 
00283       if( MRILIB_orients[0] != '\0'                  &&
00284           user_inputs.xorient == user_inputs.yorient &&
00285           user_inputs.xorient == user_inputs.zorient   ){
00286 
00287          char acod ; int icod ;
00288 
00289 STATUS("setting orientation from MRILIB_orients") ;
00290 
00291          acod=toupper(MRILIB_orients[0]); icod=ORCODE(acod); if(icod >= 0) user_inputs.xorient=icod;
00292          acod=toupper(MRILIB_orients[2]); icod=ORCODE(acod); if(icod >= 0) user_inputs.yorient=icod;
00293          acod=toupper(MRILIB_orients[4]); icod=ORCODE(acod); if(icod >= 0) user_inputs.zorient=icod;
00294 
00295          if( use_MRILIB_zoff ){                     /* use offset to voxel center from mri_read() */
00296             if( fabs(user_inputs.zorigin-MRILIB_zoff) > 0.01 ){
00297               user_inputs.zorigin = MRILIB_zoff ;
00298               user_inputs.xyz_centered &= ~ZCENTERED ;
00299             }
00300          }
00301 
00302          if( use_MRILIB_xoff ){                     /* 20 Dec 2001 */
00303             if( fabs(user_inputs.xorigin-MRILIB_xoff) > 0.01 ){
00304               user_inputs.xorigin = MRILIB_xoff ;
00305               user_inputs.xyz_centered &= ~XCENTERED ;
00306             }
00307          }
00308 
00309          if( use_MRILIB_yoff ){                     /* 20 Dec 2001 */
00310             if( fabs(user_inputs.yorigin-MRILIB_yoff) > 0.01 ){
00311               user_inputs.yorigin = MRILIB_yoff ;
00312               user_inputs.xyz_centered &= ~YCENTERED ;
00313             }
00314          }
00315       }
00316 
00317       /* 10 May 2001: use global zoff, if given [will override MRILIB_zoff] */
00318 
00319       if( use_zoff ){
00320          user_inputs.zorigin = zoff ;
00321          user_inputs.xyz_centered &= ~ZCENTERED ;
00322       }
00323    }
00324 
00325    all_good = T3D_check_data( False ) ;
00326 
00327    /** Mar 1997: if any FOV or SLAB command line inputs are used,
00328                  then require that they all be given.            **/
00329 
00330    if( all_good ){
00331       int iii =  (user_inputs.xincode > 0)
00332                + (user_inputs.yincode > 0) + (user_inputs.zincode > 0) ;
00333 
00334       if( iii > 0 && iii < 3 ) all_good = False ;
00335    }
00336 
00337    /* 03 Dec 2001: MRILIB_tr may have TR */
00338 
00339    if( user_inputs.ntt > 1 && MRILIB_tr > 0.0 ){
00340       if( user_inputs.TR <= 0.0 ){
00341          int ii ;
00342          user_inputs.TR     = MRILIB_tr ;
00343          user_inputs.tunits = UNITS_SEC_TYPE ;
00344          if( user_inputs.tpattern != NULL ){
00345            for( ii=0 ; ii < user_inputs.nzz ; ii++ ){
00346              user_inputs.tpattern[ii] *= MRILIB_tr ;
00347            }
00348          }
00349          printf("Setting TR=%gs from image header\n",MRILIB_tr) ;
00350 
00351       } else {
00352          printf("Command line TR=%g%s ; Images TR=%gs\n",
00353                 user_inputs.TR,UNITS_TYPE_LABEL(user_inputs.tunits),MRILIB_tr) ;
00354       }
00355    }
00356    if( user_inputs.ntt > 1 && user_inputs.TR <= 0.0 ){
00357       printf("Setting TR=1s by default\n") ;
00358       user_inputs.TR = 1.0 ; user_inputs.tunits = UNITS_SEC_TYPE ;
00359    }
00360 
00361    if( all_good && !user_inputs.nosave ){      /* done! */
00362       T3D_save_file_CB( NULL , NULL , NULL ) ;
00363       printf("3D dataset written to disk\n") ;
00364       exit(0) ;
00365    }
00366 
00367    /* Otherwise, initialize X11 and Xt */
00368 
00369    printf("Making widgets") ; fflush(stdout) ;
00370 
00371    if( wset.topshell == NULL )
00372      wset.topshell = XtVaAppInitialize( &app , "AFNI" , NULL , 0 ,
00373                                         &argc , argv , FALLback , NULL ) ;
00374 
00375    AFNI_load_defaults( wset.topshell ) ;
00376    if( argopt.ncolor <= 2   ) argopt.ncolor = INIT_ngray ;
00377    if( argopt.gamma  <= 0.0 ) argopt.gamma  = INIT_gamma ;
00378 
00379    if( argopt.xtwarns == False )
00380       old_handler = XtAppSetWarningHandler(app,AFNI_handler) ;  /* turn off */
00381 
00382    if( MCW_isitmwm(wset.topshell) ){
00383       XtVaSetValues( wset.topshell ,
00384                         XmNmwmDecorations ,
00385                         MWM_DECOR_ALL | MWM_DECOR_RESIZEH | MWM_DECOR_MAXIMIZE ,
00386                      NULL ) ;
00387 
00388       /* turn off Drag-n-Drop (courtesy the Motif FAQ) */
00389 
00390       XtVaSetValues( XmGetXmDisplay(XtDisplay(wset.topshell)) ,
00391                         XmNdragInitiatorProtocolStyle , XmDRAG_NONE ,
00392                         XmNdragReceiverProtocolStyle  , XmDRAG_NONE ,
00393                      NULL ) ;
00394    }
00395 
00396    /* make the rest of the widgets */
00397 
00398    T3D_create_widgets() ;
00399    MCW_help_CB(wset.topshell,NULL,NULL) ;  /* initialize help widget */
00400 
00401    printf("\n") ; fflush(stdout) ;
00402 
00403    if( AFNI_noenv("AFNI_HINTS") ) MCW_hint_toggle() ;
00404 
00405    /* let the user do the rest */
00406 
00407    (void) XtAppAddTimeOut( app , 999 , AFNI_startup_timeout_CB , NULL ) ;
00408    XtAppMainLoop(app) ;
00409    exit(0) ;
00410 }

void Syntax void   
 

31 July 1996: be more specific about errors *

Definition at line 2927 of file to3d.c.

References FIRST_ANAT_TYPE, FIRST_FUNC_TYPE, LAST_ANAT_TYPE, LAST_FUNC_TYPE, NO_NAMES, NZBOT, VIEW_ACPCALIGNED_CODE, VIEW_ORIGINAL_CODE, and VIEW_TALAIRACH_CODE.

02928 {
02929    int ii ;
02930 
02931    printf(
02932     "Usage: to3d [options] image_files ...\n"
02933     "       Creates 3D datasets for use with AFNI from 2D image files\n"
02934     "\n"
02935     "The available options are\n"
02936     "  -help   show this message\n"
02937     "  -'type' declare images to contain data of a given type\n"
02938     "          where 'type' is chosen from the following options:\n" ) ;
02939 
02940    printf("       ANATOMICAL TYPES\n") ;
02941    for( ii=FIRST_ANAT_TYPE ; ii <= LAST_ANAT_TYPE ; ii++ )
02942       printf("     %8s == %s\n",ANAT_prefixstr[ii],ANAT_typestr[ii] ) ;
02943 
02944    printf("       FUNCTIONAL TYPES\n") ;
02945    for( ii=FIRST_FUNC_TYPE ; ii <= LAST_FUNC_TYPE ; ii++ )
02946       printf("     %8s == %s\n",FUNC_prefixstr[ii],FUNC_typestr[ii] ) ;
02947 
02948    printf(
02949     "                 [for paired (+) types above, images are fim first,]\n"
02950     "                 [then followed by the threshold (etc.) image files]\n" ) ;
02951 
02952    printf(
02953     "\n"
02954     "  -statpar value value ... value [* NEW IN 1996 *]\n"
02955     "     This option is used to supply the auxiliary statistical parameters\n"
02956     "     needed for certain dataset types (e.g., 'fico' and 'fitt').  For\n"
02957     "     example, a correlation coefficient computed using program 'fim2'\n"
02958     "     from 64 images, with 1 ideal, and with 2 orts could be specified with\n"
02959     "       -statpar 64 1 2\n"
02960    ) ;
02961 
02962    printf(
02963     "\n"
02964 #ifndef NO_NAMES
02965     "  -dname   name      will make 3D dataset's name = 'name'\n"
02966     "  -dlabel  name      will make 3D dataset's short label = 'name'\n"
02967 #endif
02968     "  -prefix  name      will write 3D dataset using prefix 'name'\n"
02969     "  -session name      will write 3D dataset into session directory 'name'\n"
02970     "  -geomparent fname  will read geometry data from dataset file 'fname'\n"
02971     "                       N.B.: geometry data does NOT include time-dependence\n"
02972     "  -anatparent fname  will take anatomy parent from dataset file 'fname'\n"
02973     "\n"
02974     "  -nosave  will suppress autosave of 3D dataset, which normally occurs\n"
02975     "           when the command line options supply all needed data correctly\n"
02976     "\n"
02977     "  -view type [* NEW IN 1996 *]\n"
02978     "    Will set the dataset's viewing coordinates to 'type', which\n"
02979     "    must be one of these strings:  "
02980             VIEW_ORIGINAL_CODE    " "
02981             VIEW_ACPCALIGNED_CODE " "
02982             VIEW_TALAIRACH_CODE   "\n"
02983    ) ;
02984 
02985    printf(
02986     "\n"
02987     "TIME DEPENDENT DATASETS [* NEW IN 1996 *]\n"
02988     "  -time:zt nz nt TR tpattern  OR  -time:tz nt nz TR tpattern\n"
02989     "\n"
02990     "    These options are used to specify a time dependent dataset.\n"
02991     "    '-time:zt' is used when the slices are input in the order\n"
02992     "               z-axis first, then t-axis.\n"
02993     "    '-time:tz' is used when the slices are input in the order\n"
02994     "               t-axis first, then z-axis.\n"
02995     "\n"
02996     "    nz  =  number of points in the z-direction (minimum %d)\n"
02997     "    nt  =  number of points in the t-direction\n"
02998     "            (thus exactly nt * nz slices must be read in)\n"
02999     "    TR  =  repetition interval between acquisitions of the\n"
03000     "            same slice, in milliseconds (or other units, as given below)\n"
03001     "\n"
03002     "    tpattern = Code word that identifies how the slices (z-direction)\n"
03003     "               were gathered in time.  The values that can be used:\n"
03004     "\n"
03005     "       alt+z = altplus   = alternating in the plus direction\n"
03006     "       alt+z2            = alternating, starting at slice #1\n"
03007     "       alt-z = altminus  = alternating in the minus direction\n"
03008     "       alt-z2            = alternating, starting at slice #nz-2\n"
03009     "       seq+z = seqplus   = sequential in the plus direction\n"
03010     "       seq-z = seqminus  = sequential in the minus direction\n"
03011     "       zero  = simult    = simultaneous acquisition\n"
03012     "               @filename = read temporal offsets from 'filename'\n"\
03013     "\n"
03014     "    For example if nz = 5 and TR = 1000, then the inter-slice\n"
03015     "    time is taken to be dt = TR/nz = 200.  In this case, the\n"
03016     "    slices are offset in time by the following amounts:\n"
03017     "\n"
03018     "                    S L I C E   N U M B E R\n"
03019     "      tpattern        0    1    2    3    4  Comment\n"
03020     "      ----------   ---- ---- ---- ---- ----  -------------------------------\n"
03021     "      altplus         0  600  200  800  400  Alternating in the +z direction\n"
03022     "      alt+z2        400    0  600  200  800  Alternating, but starting at #1\n"
03023     "      altminus      400  800  200  600    0  Alternating in the -z direction\n"
03024     "      alt-z2        800  200  600    0  400  Alternating, starting at #nz-2 \n"
03025     "      seqplus         0  200  400  600  800  Sequential  in the +z direction\n"
03026     "      seqminus      800  600  400  200    0  Sequential  in the -z direction\n"
03027     "      simult          0    0    0    0    0  All slices acquired at once\n"
03028     "\n"
03029     "    If @filename is used for tpattern, then nz ASCII-formatted numbers are\n"
03030     "    read from the file.  These are used to indicate the time offsets (in ms)\n"
03031     "    for each slice. For example, if 'filename' contains\n"
03032     "       0 600 200 800 400\n"
03033     "    then this is equivalent to 'altplus' in the above example.\n"
03034     "\n"
03035     "    Notes:\n"
03036     "      * Time-dependent functional datasets are not yet supported by\n"
03037     "          to3d or any other AFNI package software.  For many users,\n"
03038     "          the proper dataset type for these datasets is '-epan'.\n"
03039     "      * Time-dependent datasets with more than one value per time point\n"
03040     "          (e.g., 'fith', 'fico', 'fitt') are also not allowed by to3d.\n"
03041     "      * If you use 'abut' to fill in gaps in the data and/or to\n"
03042     "          subdivide the data slices, you will have to use the @filename\n"
03043     "          form for tpattern, unless 'simult' or 'zero' is acceptable.\n"
03044     "      * At this time, the value of 'tpattern' is not actually used in\n"
03045     "          any AFNI program.  The values are stored in the dataset\n"
03046     "          .HEAD files, and will be used in the future.\n"
03047     "      * The values set on the command line can't be altered interactively.\n"
03048     "      * The units of TR can be specified by the command line options below:\n"
03049     "            -t=ms or -t=msec  -->  milliseconds (the default)\n"
03050     "            -t=s  or -t=sec   -->  seconds\n"
03051     "            -t=Hz or -t=Hertz -->  Hertz (for chemical shift images?)\n"
03052     "          Alternatively, the units symbol ('ms', 'msec', 's', 'sec',\n"
03053     "            'Hz', or 'Hertz') may be attached to TR in the '-time:' option,\n"
03054     "            as in '-time:zt 16 64 4.0sec alt+z'\n"
03055 
03056     "\n"
03057     "  -Torg ttt = set time origin of dataset to 'ttt' [default=0.0]\n"
03058 
03059       , NZBOT
03060    ) ;
03061 
03062    printf(
03063      "\n"
03064      "COMMAND LINE GEOMETRY SPECIFICATION [* NEW IN 1996 *]\n"
03065      "   -xFOV   <dimen1><direc1>-<dimen2><direc2>\n"
03066      "     or       or\n"
03067      "   -xSLAB  <dimen1><direc1>-<direc2>\n"
03068      "\n"
03069      "   (Similar -yFOV, -ySLAB, -zFOV and -zSLAB option are also present.)\n"
03070      "\n"
03071      " These options specify the size and orientation of the x-axis extent\n"
03072      " of the dataset.  <dimen#> means a dimension (in mm); <direc> is\n"
03073      " an anatomical direction code, chosen from\n"
03074      "      A (Anterior)    P (Posterior)    L (Left)\n"
03075      "      I (Inferior)    S (Superior)     R (Right)\n"
03076      " Thus, 20A-30P means that the x-axis of the input images runs from\n"
03077      " 20 mm Anterior to 30 mm Posterior.  For convenience, 20A-20P can be\n"
03078      " abbreviated as 20A-P.\n"
03079      "\n"
03080      " -xFOV  is used to mean that the distances are from edge-to-edge of\n"
03081      "          the outermost voxels in the x-direction.\n"
03082      " -xSLAB is used to mean that the distances are from center-to-center\n"
03083      "          of the outermost voxels in the x-direction.\n"
03084      "\n"
03085      " Under most circumstance, -xFOV , -yFOV , and -zSLAB would be the\n"
03086      " correct combination of geometry specifiers to use.  For example,\n"
03087      " a common type of run at MCW would be entered as\n"
03088      "    -xFOV 120L-R -yFOV 120A-P -zSLAB 60S-50I\n"
03089    ) ;
03090 
03091    printf(
03092      "\n"
03093      "Z-AXIS SLICE OFFSET ONLY\n"
03094      " -zorigin distz  Puts the center of the 1st slice off at the\n"
03095      "                 given distance ('distz' in mm).  This distance\n"
03096      "                 is in the direction given by the corresponding\n"
03097      "                 letter in the -orient code.  For example,\n"
03098      "                   -orient RAI -zorigin 30\n"
03099      "                 would set the center of the first slice at\n"
03100      "                 30 mm Inferior.\n"
03101      "    N.B.: This option has no effect if the FOV or SLAB options\n"
03102      "          described above are used.\n"
03103    ) ;
03104 
03105    printf(
03106     "\n"
03107     "INPUT IMAGE FORMATS [* SIGNIFICANTLY CHANGED IN 1996 *]\n"
03108     "  Image files may be single images of unsigned bytes or signed shorts\n"
03109     "  (64x64, 128x128, 256x256, 512x512, or 1024x1024) or may be grouped\n"
03110     "  images (that is, 3- or 4-dimensional blocks of data).\n"
03111     "  In the grouped case, the string for the command line file spec is like\n"
03112     "\n"
03113     "    3D:hglobal:himage:nx:ny:nz:fname   [16 bit input]\n"
03114     "    3Ds:hglobal:himage:nx:ny:nz:fname  [16 bit input, swapped bytes]\n"
03115     "    3Db:hglobal:himage:nx:ny:nz:fname  [ 8 bit input]\n"
03116     "    3Di:hglobal:himage:nx:ny:nz:fname  [32 bit input]\n"
03117     "    3Df:hglobal:himage:nx:ny:nz:fname  [floating point input]\n"
03118     "    3Dc:hglobal:himage:nx:ny:nz:fname  [complex input]\n"
03119     "    3Dd:hglobal:himage:nx:ny:nz:fname  [double input]\n"
03120     "\n"
03121     "  where '3D:' or '3Ds': signals this is a 3D input file of signed shorts\n"
03122     "        '3Db:'          signals this is a 3D input file of unsigned bytes\n"
03123     "        '3Di:'          signals this is a 3D input file of signed ints\n"
03124     "        '3Df:'          signals this is a 3D input file of floats\n"
03125     "        '3Dc:'          signals this is a 3D input file of complex numbers\n"
03126     "                         (real and imaginary pairs of floats)\n"
03127     "        '3Dd:'          signals this is a 3D input file of double numbers\n"
03128     "                         (will be converted to floats)\n"
03129     "        hglobal = number of bytes to skip at start of whole file\n"
03130     "        himage  = number of bytes to skip at start of each 2D image\n"
03131     "        nx      = x dimension of each 2D image in the file\n"
03132     "        ny      = y dimension of each 2D image in the file\n"
03133     "        nz      = number of 2D images in the file\n"
03134     "        fname   = actual filename on disk to read\n"
03135     "\n"
03136     "  * The ':' separators are required.  The k-th image starts at\n"
03137     "      BYTE offset hglobal+(k+1)*himage+vs*k*nx*ny in file 'fname'\n"
03138     "      for k=0,1,...,nz-1.\n"
03139     "  * Here, vs=voxel length=1 for bytes, 2 for shorts, 4 for ints and floats,\n"
03140     "      and 8 for complex numbers.\n"
03141     "  * As a special case, hglobal = -1 means read data starting at\n"
03142     "      offset len-nz*(vs*nx*ny+himage), where len=file size in bytes.\n"
03143     "      (That is, to read the needed data from the END of the file.)\n"
03144     "  * Note that there is no provision for skips between data rows inside\n"
03145     "      a 2D slice, only for skips between 2D slice images.\n"
03146     "  * The int, float, and complex formats presume that the data in\n"
03147     "      the image file are in the 'native' format for this CPU; that is,\n"
03148     "      there is no provision for data conversion (unlike the 3Ds: format).\n"
03149     "  * Double input will be converted to floats (or whatever -datum is)\n"
03150     "      since AFNI doesn't support double precision datasets.\n"
03151     "  * Whether the 2D image data is interpreted as a 3D block or a 3D+time\n"
03152     "      block depends on the rest of the command line parameters.  The\n"
03153     "      various 3D: input formats are just ways of inputting multiple 2D\n"
03154     "      slices from a single file.\n"
03155     "  * SPECIAL CASE: If fname is ALLZERO, then this means not to read\n"
03156     "      data from disk, but instead to create nz nx*ny images filled\n"
03157     "      with zeros.  One application of this is to make it easy to create\n"
03158     "      a dataset of a specified geometry for use with other programs.\n"
03159     "\n"
03160     "The 'raw pgm' image format is also supported; it reads data into 'byte' images.\n"
03161     "\n"
03162     "* ANALYZE (TM) .hdr/.img files can now be read - give the .hdr filename on\n"
03163     "  the command line.  The program will detect if byte-swapping is needed on\n"
03164     "  these images, and can also set the voxel grid sizes from the first .hdr file.\n"
03165     "  If the 'funused1' field in the .hdr is positive, it will be used to scale the\n"
03166     "  input values.  If the environment variable AFNI_ANALYZE_FLOATIZE is YES, then\n"
03167     "  .img files will be converted to floats on input.\n"
03168     "\n"
03169     "* Siemens .ima image files can now be read.  The program will detect if\n"
03170     "  byte-swapping is needed on these images, and can also set voxel grid\n"
03171     "  sizes and orientations (correctly, I hope).\n"
03172     "* Some Siemens .ima files seems to have their EPI slices stored in\n"
03173     "  spatial order, and some in acquisition (interleaved) order.  This\n"
03174     "  program doesn't try to figure this out.  You can use the command\n"
03175     "  line option '-sinter' to tell the program to assume that the images\n"
03176     "  in a single .ima file are interleaved; for example, if there are\n"
03177     "  7 images in a file, then without -sinter, the program will assume\n"
03178     "  their order is '0 1 2 3 4 5 6'; with -sinter, the program will\n"
03179     "  assume their order is '0 2 4 6 1 3 5' (here, the number refers\n"
03180     "  to the slice location in space).\n"
03181     "\n"
03182     "* GEMS I.* (IMGF) 16-bit files can now be read. The program will detect\n"
03183     "  if byte-swapping is needed on these images, and can also set voxel\n"
03184     "  grid sizes and orientations.  It can also detect the TR in the\n"
03185     "  image header.  If you wish to rely on this TR, you can set TR=0\n"
03186     "  in the -time:zt or -time:tz option.\n"
03187     "* If you use the image header's TR and also use @filename for the\n"
03188     "  tpattern, then the values in the tpattern file should be fractions\n"
03189     "  of the true TR; they will be multiplied by the true TR once it is\n"
03190     "  read from the image header.\n"
03191     "\n"
03192     " NOTES:\n"
03193     "  * Not all AFNI programs support all datum types.  Shorts and\n"
03194     "      floats are safest. (See the '-datum' option below.)\n"
03195     "  * If '-datum short' is used or implied, then int, float, and complex\n"
03196     "      data will be scaled to fit into a 16 bit integer.  If the '-gsfac'\n"
03197     "      option below is NOT used, then each slice will be SEPARATELY\n"
03198     "      scaled according to the following choice:\n"
03199     "      (a) If the slice values all fall in the range -32767 .. 32767,\n"
03200     "          then no scaling is performed.\n"
03201     "      (b) Otherwise, the image values are scaled to lie in the range\n"
03202     "          0 .. 10000 (original slice min -> 0, original max -> 10000).\n"
03203     "      This latter option is almost surely not what you want!  Therefore,\n"
03204     "      if you use the 3Di:, 3Df:, or 3Dc: input methods and store the\n"
03205     "      data as shorts, I suggest you supply a global scaling factor.\n"
03206     "      Similar remarks apply to '-datum byte' scaling, with even more force.\n"
03207     "  * To3d now incoporates POSIX filename 'globbing', which means that\n"
03208     "      you can input filenames using 'escaped wildcards', and then to3d\n"
03209     "      will internally do the expansion to the list of files.  This is\n"
03210     "      only desirable because some systems limit the number of command-line\n"
03211     "      arguments to a program.  It is possible that you would wish to input\n"
03212     "      more slice files than your computer supports.  For example,\n"
03213     "          to3d exp.?.*\n"
03214     "      might overflow the system command line limitations.  The way to do\n"
03215     "      this using internal globbing would be\n"
03216     "          to3d exp.\\?.\\*\n"
03217     "      where the \\ characters indicate to pass the wildcards ? and *\n"
03218     "      through to the program, rather than expand them in the shell.\n"
03219     "      (a) Note that if you choose to use this feature, ALL wildcards in\n"
03220     "          a filename must be escaped with \\ or NONE must be escaped.\n"
03221     "      (b) Using the C shell, it is possible to turn off shell globbing\n"
03222     "          by using the command 'set noglob' -- if you do this, then you\n"
03223     "          do not need to use the \\ character to escape the wildcards.\n"
03224     "      (c) Internal globbing of 3D: file specifiers is supported in to3d.\n"
03225     "          For example, '3D:0:0:64:64:100:sl.\\*' could be used to input\n"
03226     "          a series of 64x64x100 files with names 'sl.01', 'sl.02' ....\n"
03227     "          This type of expansion is specific to to3d; the shell will not\n"
03228     "          properly expand such 3D: file specifications.\n"
03229     "      (d) In the C shell (csh or tcsh), you can use forward single 'quotes'\n"
03230     "          to prevent shell expansion of the wildcards, as in the command\n"
03231     "              to3d '3D:0:0:64:64:100:sl.*'\n"
03232     "    The globbing code is adapted from software developed by the\n"
03233     "    University of California, Berkeley, and is copyrighted by the\n"
03234     "    Regents of the University of California (see file mcw_glob.c).\n"
03235     "\n"
03236     "RGB datasets [Apr 2002]\n"
03237     "-----------------------\n"
03238     "You can now create RGB-valued datasets.  Each voxel contains 3 byte values\n"
03239     "ranging from 0..255.  RGB values may be input to to3d in one of two ways:\n"
03240     " * Using raw PPM formatted 2D image files.\n"
03241     " * Using JPEG formatted 2D files.\n"
03242     " * Using TIFF, BMP, GIF, PNG formatted 2D files [if netpbm is installed].\n"
03243     " * Using the 3Dr: input format, analogous to 3Df:, etc., described above.\n"
03244     "RGB datasets can be created as functional FIM datasets, or as anatomical\n"
03245     "datasets:\n"
03246     " * RGB fim overlays are transparent in AFNI only where all three\n"
03247     "    bytes are zero - that is, you can't overlay solid black.\n"
03248     " * At present, there is limited support for RGB datasets.\n"
03249     "    About the only thing you can do is display them in 2D slice\n"
03250     "    viewers in AFNI.\n"
03251     "You can also create RGB-valued datasets using program 3dThreetoRGB.\n"
03252     "\n"
03253     "Other Data Options\n"
03254     "------------------\n"
03255     "  -2swap\n"
03256     "     This option will force all input 2 byte images to be byte-swapped\n"
03257     "     after they are read in.\n"
03258     "  -4swap\n"
03259     "     This option will force all input 4 byte images to be byte-swapped\n"
03260     "     after they are read in.\n"
03261     "  -8swap\n"
03262     "     This option will force all input 8 byte images to be byte-swapped\n"
03263     "     after they are read in.\n"
03264     "  BUT PLEASE NOTE:\n"
03265     "     Input images that are auto-detected to need byte-swapping\n"
03266     "     (GEMS I.*, Siemens *.ima, ANALYZE *.img, and 3Ds: files)\n"
03267     "     will NOT be swapped again by one of the above options.\n"
03268     "     If you want to swap them again for some bizarre reason,\n"
03269     "     you'll have to use the 'Byte Swap' button on the GUI.\n"
03270     "     That is, -2swap/-4swap will swap bytes on input files only\n"
03271     "     if they haven't already been swapped by the image input\n"
03272     "     function.\n"
03273     "\n"
03274     "  -zpad N   OR\n"
03275     "  -zpad Nmm \n"
03276     "     This option tells to3d to write 'N' slices of all zeros on each side\n"
03277     "     in the z-direction.  This will make the dataset 'fatter', but make it\n"
03278     "     simpler to align with datasets from other scanning sessions.  This same\n"
03279     "     function can be accomplished later using program 3dZeropad.\n"
03280     "   N.B.: The zero slices will NOT be visible in the image viewer in to3d, but\n"
03281     "          will be visible when you use AFNI to look at the dataset.\n"
03282     "   N.B.: If 'mm' follows the integer N, then the padding is measured in mm.\n"
03283     "          The actual number of slices of padding will be rounded up.  So if\n"
03284     "          the slice thickness is 5 mm, then '-zpad 16mm' would be the equivalent\n"
03285     "          of '-zpad 4' -- that is, 4 slices on each z-face of the volume.\n"
03286     "   N.B.: If the geometry parent dataset was created with -zpad, the spatial\n"
03287     "          location (origin) of the slices is set using the geometry dataset's\n"
03288     "          origin BEFORE the padding slices were added.  This is correct, since\n"
03289     "          you need to set the origin on the current dataset as if the padding\n"
03290     "          slices were not present.\n"
03291     "   N.B.: Unlike the '-zpad' option to 3drotate and 3dvolreg, this adds slices\n"
03292     "          only in the z-direction.\n"
03293     "   N.B.: You can set the environment variable 'AFNI_TO3D_ZPAD' to provide a\n"
03294     "          default for this option.\n"
03295     "\n"
03296     "  -gsfac value\n"
03297     "     will scale each input slice by 'value'.  For example,\n"
03298     "     '-gsfac 0.31830989' will scale by 1/Pi (approximately).\n"
03299     "     This option only has meaning if one of '-datum short' or\n"
03300     "     '-datum byte' is used or implied.  Otherwise, it is ignored.\n"
03301     "\n"
03302     "  -datum type\n"
03303     "     will set the voxel data to be stored as 'type', which is currently\n"
03304     "     allowed to be short, float, byte, or complex.\n"
03305     "     If -datum is not used, then the datum type of the first input image\n"
03306     "     will determine what is used.  In that case, the first input image will\n"
03307     "     determine the type as follows:\n"
03308     "        byte       --> byte\n"
03309     "        short      --> short\n"
03310     "        int, float --> float\n"
03311     "        complex    --> complex\n"
03312     "     If -datum IS specified, then all input images will be converted\n"
03313     "     to the desired type.  Note that the list of allowed types may\n"
03314     "     grow in the future, so you should not rely on the automatic\n"
03315     "     conversion scheme.  Also note that floating point datasets may\n"
03316     "     not be portable between CPU architectures.\n"
03317     "\n"
03318     "  -nofloatscan\n"
03319     "     tells to3d NOT to scan input float and complex data files for\n"
03320     "     illegal values - the default is to scan and replace illegal\n"
03321     "     floating point values with zeros (cf. program float_scan).\n"
03322 #ifdef USE_MRI_DELAY
03323     "\n"
03324     "  -in:1\n"
03325     "     Input of huge 3D: files (with all the data from a 3D+time run, say)\n"
03326     "     can cause to3d to fail from lack of memory.  The reason is that\n"
03327     "     the images are from a file are all read into RAM at once, and then\n"
03328     "     are scaled, converted, etc., as needed, then put into the final\n"
03329     "     dataset brick.  This switch will cause the images from a 3D: file\n"
03330     "     to be read and processed one slice at a time, which will lower the\n"
03331     "     amount of memory needed.  The penalty is somewhat more I/O overhead.\n"
03332 #endif
03333    ) ;
03334 
03335    printf(
03336     "\n"
03337     "NEW IN 1997:\n"
03338     "  -orient code\n"
03339     "     Tells the orientation of the 3D volumes.  The code must be 3 letters,\n"
03340     "     one each from the pairs {R,L} {A,P} {I,S}.  The first letter gives\n"
03341     "     the orientation of the x-axis, the second the orientation of the\n"
03342     "     y-axis, the third the z-axis:\n"
03343     "        R = right-to-left         L = left-to-right\n"
03344     "        A = anterior-to-posterior P = posterior-to-anterior\n"
03345     "        I = inferior-to-superior  S = superior-to-inferior\n"
03346     "     Note that the -xFOV, -zSLAB constructions can convey this information.\n"
03347    ) ;
03348 
03349    printf(
03350     "\n"
03351     "NEW IN 2001:\n"
03352     "  -skip_outliers\n"
03353     "     If present, this tells the program to skip the outlier check that is\n"
03354     "     automatically performed for 3D+time datasets.  You can also turn this\n"
03355     "     feature off by setting the environment variable AFNI_TO3D_OUTLIERS\n"
03356     "     to \"No\".\n"
03357     "  -text_outliers\n"
03358     "    If present, tells the program to only print out the outlier check\n"
03359     "     results in text form, not graph them.  You can make this the default\n"
03360     "     by setting the environment variable AFNI_TO3D_OUTLIERS to \"Text\".\n"
03361     "    N.B.: If to3d is run in batch mode, then no graph can be produced.\n"
03362     "          Thus, this option only has meaning when to3d is run with the\n"
03363     "          interactive graphical user interface.\n"
03364     "  -save_outliers fname\n"
03365     "    Tells the program to save the outliers count into a 1D file with\n"
03366     "    name 'fname'.  You could graph this file later with the command\n"
03367     "       1dplot -one fname\n"
03368     "    If this option is used, the outlier count will be saved even if\n"
03369     "    nothing appears 'suspicious' (whatever that means).\n"
03370     "  NOTES on outliers:\n"
03371     "    * See '3dToutcount -help' for a description of how outliers are\n"
03372     "       defined.\n"
03373     "    * The outlier count is not done if the input images are shorts\n"
03374     "       and there is a significant (> 1%%) number of negative inputs.\n"
03375     "    * There must be at least 6 time points for the outlier count to\n"
03376     "       be carried out.\n"
03377    ) ;
03378 
03379    printf(
03380     "\n"
03381     "OPTIONS THAT AFFECT THE X11 IMAGE DISPLAY\n"
03382     "   -gamma gg    the gamma correction factor for the\n"
03383     "                  monitor is 'gg' (default gg is 1.0; greater than\n"
03384     "                  1.0 makes the image contrast larger -- this may\n"
03385     "                  also be adjusted interactively)\n"
03386     "   -ncolors nn  use 'nn' gray levels for the image\n"
03387     "                  displays (default is %d)\n"
03388     "   -xtwarns     turn on display of Xt warning messages\n" ,
03389     INIT_ngray
03390    ) ;
03391 
03392    exit(0) ;
03393 }

void T3D_anatomy_parent_CB Widget    w,
XtPointer    client_data,
XtPointer    call_data
 

Definition at line 5543 of file to3d.c.

References to3d_data::anatomy_dataname, to3d_data::anatomy_parent_filename, to3d_data::anatomy_parent_idcode, client_data, DEBLANK, ENTRY, FILENAME_TO_PREFIX, THD_3dim_dataset::idcode, INERR, ISFUNC, MCW_strncpy, myXtFree, PATH_CONCAT, THD_3dim_dataset::self_name, to3d_widget_set::session_file_textfield, to3d_data::session_filename, T3D_poperr(), THD_delete_3dim_dataset(), THD_MAX_NAME, and THD_open_one_dataset().

Referenced by main(), and T3D_create_widgets().

05545 {
05546    static char * old_name = NULL ;
05547    char * new_name ;
05548    char new_path[THD_MAX_NAME] , new_pref[THD_MAX_NAME] ;
05549    Boolean isfunc ;
05550    THD_3dim_dataset * anat_dset ;
05551 
05552 ENTRY("T3D_anatomy_parent_CB") ;
05553 
05554    if( old_name == NULL ) old_name = XtNewString("Elvis Lives!!!") ;
05555 
05556    /* see if the new text is any different from the old one */
05557 
05558    if( w != NULL ){
05559       new_name = XmTextFieldGetString( w ) ;  /* get the new text */
05560    } else {
05561       new_name = XtNewString( user_inputs.anatomy_parent_filename ) ;
05562    }
05563    DEBLANK(new_name) ;
05564 
05565    if( strlen(new_name) == 0 )         { old_name = new_name ; EXRETURN ; }
05566    if( strcmp(new_name,old_name) == 0 ){ myXtFree(new_name) ; EXRETURN ; }
05567 
05568    /* have a new filename --> try to read dataset from it */
05569 
05570    myXtFree(old_name) ; old_name = new_name ;
05571 
05572    /* make a pathname to the anatomy dataset */
05573 
05574    if( strstr(new_name,"/") == NULL ){
05575       char * sess ;
05576       if( w != NULL ) sess = XmTextFieldGetString(wset.session_file_textfield);
05577       else            sess = XtNewString( user_inputs.session_filename ) ;
05578       DEBLANK(sess) ;
05579       if( strlen(sess) > 0 ){
05580          PATH_CONCAT( new_path , sess , new_name ) ;
05581       } else {
05582          strcpy( new_path , new_name ) ;
05583       }
05584       myXtFree(sess) ;
05585    } else {
05586       strcpy( new_path , new_name ) ;
05587    }
05588 
05589    FILENAME_TO_PREFIX(new_path,new_pref) ;
05590    if( strlen(new_pref) == 0 ) strcat(new_path,"+orig") ;
05591 
05592    anat_dset = THD_open_one_dataset( new_path ) ;
05593    if( anat_dset == NULL ){
05594       T3D_poperr( INERR ,
05595                   "Cannot read 3D dataset\nin anatomy parent file" ) ;
05596       EXRETURN ;
05597    }
05598 
05599    isfunc = ISFUNC(anat_dset) ;
05600    if( isfunc ){
05601       T3D_poperr( INERR ,
05602                   "Anatomy parent dataset\nis actually Function data!" ) ;
05603       THD_delete_3dim_dataset( anat_dset , False ) ;
05604       EXRETURN ;
05605    }
05606 
05607    /* at this point, the anat dataset seems OK, so use it */
05608 
05609    MCW_strncpy( user_inputs.anatomy_dataname ,
05610                 anat_dset->self_name , THD_MAX_NAME ) ;
05611    user_inputs.anatomy_parent_idcode = anat_dset->idcode ;
05612 
05613 #ifndef NO_NAMES
05614    if( w != NULL ) XmTextFieldSetString( wset.anatomy_dataname_textfield ,
05615                                          user_inputs.anatomy_dataname ) ;
05616 #endif
05617 
05618    MCW_strncpy( user_inputs.anatomy_parent_filename ,
05619                 new_name , THD_MAX_NAME ) ;
05620 
05621    THD_delete_3dim_dataset( anat_dset , False ) ;
05622 
05623    EXRETURN ;
05624 }

void T3D_centered_CB Widget    w,
XtPointer    client_data,
XtPointer    call_data
 

Definition at line 3399 of file to3d.c.

References AV_SENSITIZE, to3d_widget_set::centered_bbox, client_data, ENTRY, MCW_val_bbox(), RESET_QUIT, T3D_set_dependent_geometries(), XCENTERED, to3d_widget_set::xorigin_av, to3d_widget_set::xorigin_label, to3d_data::xyz_centered, YCENTERED, to3d_widget_set::yorigin_av, to3d_widget_set::yorigin_label, ZCENTERED, to3d_widget_set::zorigin_av, and to3d_widget_set::zorigin_label.

Referenced by T3D_create_widgets(), and T3D_data_to_widgets().

03401 {
03402    int val ;
03403    Boolean sens ;
03404 
03405 ENTRY("T3D_centered_CB") ;
03406 
03407    user_inputs.xyz_centered = val = MCW_val_bbox( wset.centered_bbox ) ;
03408 
03409    sens = (val & XCENTERED) == 0 ;
03410       AV_SENSITIZE( wset.xorigin_av , sens ) ;
03411       XtSetSensitive( wset.xorigin_label , sens ) ;
03412 
03413    sens = (val & YCENTERED) == 0 ;
03414       AV_SENSITIZE( wset.yorigin_av , sens ) ;
03415       XtSetSensitive( wset.yorigin_label , sens ) ;
03416 
03417    sens = (val & ZCENTERED) == 0 ;
03418       AV_SENSITIZE( wset.zorigin_av , sens ) ;
03419       XtSetSensitive( wset.zorigin_label , sens ) ;
03420 
03421    T3D_set_dependent_geometries() ;
03422    RESET_QUIT ;
03423    EXRETURN ;
03424 }

Boolean T3D_check_data Boolean    perr
 

Definition at line 5152 of file to3d.c.

References AFNI_GOOD_DTYPE, AFNI_GOOD_FUNC_DTYPE, to3d_data::anatomy_dataname, argopt, DATASET_HEADER_SUFFIX, to3d_data::dataset_name, to3d_data::dataset_type, ENTRY, to3d_data::function_type, ISFUNCTYPE, to3d_data::need_stat_aux, OUTERR, to3d_data::output_filename, PATH_CONCAT, RETURN, to3d_data::session_filename, to3d_data::stat_aux, STATUS, T3D_poperr(), T3D_setup_stat_aux(), THD_is_directory(), THD_is_file(), THD_MAX_NAME, to3d_data::xorient, to3d_data::yorient, and to3d_data::zorient.

Referenced by main(), and T3D_save_file_CB().

05153 {
05154    char xlab,ylab,zlab ;
05155    int ii , ll , ll_out , ll_sess ;
05156    Boolean good = True , isfunc ;
05157    char new_name[THD_MAX_NAME] ;
05158 
05159 ENTRY("T3D_check_data") ;
05160 
05161    /*-- check that orientations are legal --*/
05162 
05163    xlab = ORIENT_xyz[user_inputs.xorient] ;
05164    ylab = ORIENT_xyz[user_inputs.yorient] ;
05165    zlab = ORIENT_xyz[user_inputs.zorient] ;
05166 
05167    if( xlab == ylab || xlab == zlab || ylab == zlab ){
05168       if(perr)T3D_poperr( OUTERR , "Axes orientations are not consistent!" ) ;
05169       good = False ;
05170    }
05171 
05172    /*-- check that the output filename is acceptable --*/
05173 
05174 STATUS("check output filename") ;
05175 
05176    ll_out = ll = strlen( user_inputs.output_filename ) ;
05177    if( ll == 0 ){
05178       if(perr)T3D_poperr( OUTERR , "No output filename provided!" ) ;
05179       good = False ;
05180    } else {
05181       for( ii=0 ; ii < ll ; ii++ )
05182          if( iscntrl(user_inputs.output_filename[ii]) ||
05183              isspace(user_inputs.output_filename[ii]) ||
05184              user_inputs.output_filename[ii] == '/'     ) break ;
05185 
05186       if( ii < ll ){
05187          if(perr)T3D_poperr( OUTERR ,
05188                              "Output filename contains illegal character!" ) ;
05189          good = False ;
05190       }
05191    }
05192 
05193    /*-- check that the session filename is acceptable --*/
05194 
05195 STATUS("check session name") ;
05196 
05197    ll_sess = ll = strlen( user_inputs.session_filename ) ;
05198    if( ll == 0 ){
05199       if(perr)T3D_poperr( OUTERR , "No session directory name provided!" ) ;
05200       good = False ;
05201    } else {
05202       for( ii=0 ; ii < ll ; ii++ )
05203          if( iscntrl(user_inputs.session_filename[ii]) ||
05204              isspace(user_inputs.session_filename[ii])   ) break ;
05205 
05206       if( ii < ll ){
05207          if(perr)T3D_poperr( OUTERR ,
05208                              "Session filename contains illegal character!" ) ;
05209          good = False ;
05210       }
05211    }
05212 
05213    /* Check if the file already exists */
05214 
05215 STATUS("check if file exists") ;
05216 
05217    if( ll_sess > 0 && ll_out > 0 ){
05218       PATH_CONCAT( new_name , user_inputs.session_filename ,
05219                               user_inputs.output_filename   ) ;
05220       strcat(new_name , "+orig." DATASET_HEADER_SUFFIX ) ;
05221       ll = THD_is_file( new_name ) || THD_is_directory( new_name ) ;
05222       if( ll ){
05223        if(perr) T3D_poperr( OUTERR , "Output file already exists!" ) ;
05224        good = False ;
05225       }
05226    }
05227 
05228    /*-- if the image type is functional, check
05229         that the anatomy parent dataset name has been set --*/
05230 
05231    isfunc = ISFUNCTYPE(user_inputs.dataset_type) ;
05232 
05233 #ifdef REQUIRE_ANAT_PARENT
05234    if( isfunc && strlen(user_inputs.anatomy_dataname) == 0 ){
05235       if(perr)T3D_poperr( OUTERR , "Anatomy parent not properly set!" ) ;
05236       good = False ;
05237    }
05238 #endif
05239 
05240    /*-- check for good data types in the bricks --*/
05241 
05242 STATUS("check data types") ;
05243 
05244    if( isfunc ){
05245       if( ! AFNI_GOOD_FUNC_DTYPE(argopt.datum_all) ){
05246          if(perr)T3D_poperr(OUTERR , "Illegal functional datum type!" ) ;
05247          good = False ;
05248       }
05249    } else {
05250       if( ! AFNI_GOOD_DTYPE(argopt.datum_all) ){
05251          if(perr)T3D_poperr(OUTERR , "Illegal anatomical datum type!" ) ;
05252          good = False ;
05253       }
05254    }
05255 
05256    /*-- check if a dataset name has been defined --*/
05257 
05258 #ifndef NO_NAMES
05259    if( strlen(user_inputs.dataset_name) == 0 ){
05260       if(perr)T3D_poperr( OUTERR,"You **MUST** supply a name for the dataset!" ) ;
05261       good = False ;
05262    }
05263 #endif
05264 
05265    /*-- check if the stat_aux parameters are good --*/
05266 
05267 STATUS("check stat aux") ;
05268 
05269    T3D_setup_stat_aux() ;
05270    if( user_inputs.need_stat_aux ){
05271 
05272       for( ii=0 ; ii < FUNC_need_stat_aux[user_inputs.function_type] ; ii++ )
05273          if( user_inputs.stat_aux[ii] <= 0.0 ) break ;
05274 
05275       if( ii < FUNC_need_stat_aux[user_inputs.function_type] ){
05276          if(perr)T3D_poperr(OUTERR , "Invalid statistical parameters!" ) ;
05277          good = False ;
05278       }
05279    }
05280 
05281    /*-- return the status we found --*/
05282 
05283    RETURN( good );
05284 }

void T3D_check_outliers int    opcode
 

get number here *

Definition at line 5775 of file to3d.c.

References AFMALL, CURSOR_normalize, CURSOR_watchize, to3d_data::dataset_type, ENTRY, free, to3d_widget_set::good, ISANATTYPE, MCW_CALLER_KILL, MCW_popup_message(), MCW_TIMER_KILL, MCW_USER_KILL, my_getenv(), negative_shorts, THD_timeaxis::ntt, nvox_total, outliers_fname, to3d_data::output_filename, plot_ts_lab(), to3d_widget_set::save_file_pb, skip, THD_3dim_dataset::taxis, THD_outlier_count(), to3d_widget_set::topshell, MCW_arrowval::wrowcol, and to3d_widget_set::xsize_av.

Referenced by AFNI_startup_timeout_CB(), T3D_save_file_CB(), and T3D_swap_CB().

05776 {
05777    char *eee = my_getenv("AFNI_TO3D_OUTLIERS") ;
05778    int skip = (eee != NULL && (*eee == 'N' || *eee == 'n')) ;
05779    int text = (eee != NULL && (*eee == 'T' || *eee == 't')) ;
05780 
05781 ENTRY("T3D_check_outliers") ;
05782 
05783    if( dset->taxis != NULL                  &&
05784        dset->taxis->ntt > 5                 &&
05785        !skip                                &&
05786        ISANATTYPE(user_inputs.dataset_type) &&
05787        negative_shorts < 0.01*nvox_total      ){
05788 
05789      int *out_count, out_ctop , cc=0 ;
05790      Widget wmsg ;
05791 
05792      if( wset.topshell != NULL && wset.good ){
05793         wmsg = MCW_popup_message( wset.save_file_pb ,
05794                                    "****************\n"
05795                                    "* Checking for *\n"
05796                                    "* time series  *\n"
05797                                    "*   outliers   *\n"
05798                                    "****************" ,
05799                                 MCW_CALLER_KILL ) ;
05800         CURSOR_watchize ;
05801      } else {
05802         fprintf(stderr,"Checking for time series outliers\n") ;
05803      }
05804 
05805      THD_outlier_count( dset , 0.01 , &out_count , &out_ctop ) ;
05806 
05807      if( out_count != NULL && out_ctop > 0 ){  /* compute the output message */
05808         int iv,nvals=dset->taxis->ntt ; char *msg = AFMALL(char,2048+8*nvals) ;
05809 
05810         strcpy(msg," \nto3d WARNING:\nSignificant outliers detected in these sub-bricks:\n") ;
05811 
05812         for( iv=0 ; iv < nvals ; iv++ ){
05813            if( out_count[iv] > out_ctop ){
05814               sprintf(msg+strlen(msg)," %3d",iv) ; cc++ ;
05815               if( cc%12 == 0 ) strcat(msg,"\n") ;
05816            }
05817         }
05818 
05819         if( outliers_fname != NULL ){                    /* 26 Aug 2001 */
05820            FILE *fp = fopen( outliers_fname , "w" ) ;
05821            if( fp == NULL ){
05822              fprintf(stderr,"** Can't open -save_outliers %s\n",outliers_fname);
05823            } else {
05824              for( iv=0 ; iv < nvals ; iv++ )
05825                fprintf(fp,"%3d %3d\n",out_count[iv],out_ctop) ;
05826              fclose(fp) ;
05827            }
05828         }
05829 
05830         if( cc > 0 ){                             /* any sub-bricks fail? */
05831            if( cc%12 > 0 ) strcat(msg,"\n") ;
05832            strcat(msg,"You should inspect the dataset for possible corruption.\n");
05833            strcat(msg," [Outliers are defined as in program 3dToutcount.     ]\n");
05834            strcat(msg," [Outliers early in an EPI time series may be due to  ]\n");
05835            strcat(msg," [the longitudinal magnetization equilibration effect.]\n");
05836            strcat(msg," [Other causes are subject movement, scanner problems,]\n");
05837            strcat(msg," [or anything that makes a time series look irregular.]\n");
05838            strcat(msg," [  3dToutcount -save outnam dataset | 1dplot -stdin  ]\n");
05839            strcat(msg," [can be used to make a dataset 'outnam' that marks   ]\n");
05840            strcat(msg," [outlier voxels; see 3dToutcount -help for details.  ]\n");
05841 
05842            fprintf(stderr,"%s\n",msg) ;                        /* print message        */
05843            if( wset.topshell != NULL && !text && wset.good ){  /* graph outlier count  */
05844               float *y[2] ;
05845               y[0] = AFMALL(float, sizeof(float)*nvals) ;
05846               y[1] = AFMALL(float, sizeof(float)*nvals) ;
05847               for( iv=0 ; iv < nvals ; iv++ ){
05848                  y[0][iv] = out_count[iv] ; y[1][iv] = out_ctop ;
05849               }
05850               plot_ts_lab( XtDisplay(wset.topshell) ,              /* graph */
05851                            nvals , NULL , 2 , y ,
05852                            "Sub-brick Index" ,
05853                            "Outlier Count (and Threshold)" ,
05854                            user_inputs.output_filename , NULL , NULL ) ;
05855               free(y[0]); free(y[1]) ;
05856               (void) MCW_popup_message( wset.xsize_av->wrowcol , /* message */
05857                                         msg , MCW_USER_KILL     ) ;
05858            }
05859         }
05860         free(msg) ;
05861      }
05862 
05863      if( out_count != NULL ) free(out_count) ;
05864 
05865      if( wset.topshell != NULL && wset.good ){
05866         XtDestroyWidget(wmsg); CURSOR_normalize;
05867         if( cc == 0 )
05868           (void) MCW_popup_message( wset.save_file_pb ,
05869                                     " \n"
05870                                     "** No unusual outlier  **\n"
05871                                     "** concentration found **\n" ,
05872                                     MCW_USER_KILL | MCW_TIMER_KILL ) ;
05873      } else {
05874         if( cc == 0 )
05875           fprintf(stderr,"No unusual outlier concentration found\n") ;
05876      }
05877    }
05878 
05879    EXRETURN ;
05880 }

void T3D_create_widgets void   
 

Mar 1997: if any FOV or SLAB command line inputs are used, then require that they all be given. *

Definition at line 414 of file to3d.c.

References to3d_widget_set::action_frame, to3d_widget_set::action_rowcol, MCW_arrowval::allow_wrap, to3d_data::anatomy_parent_filename, to3d_widget_set::anatomy_parent_label, to3d_widget_set::anatomy_parent_textfield, to3d_data::anatomy_type, to3d_widget_set::anatomy_type_av, argopt, AV_SENSITIZE, to3d_widget_set::button_help_pb, to3d_widget_set::centered_bbox, DATASET_BRICK_SUFFIX, DATASET_HEADER_SUFFIX, to3d_data::dataset_name, to3d_data::dataset_type, to3d_widget_set::dataset_type_av, to3d_widget_set::datum_label, to3d_widget_set::dc, ENTRY, FIRST_3DIM_TYPE, FIRST_ANAT_TYPE, FIRST_FUNC_TYPE, FIRST_ORIENT_TYPE, FIRST_VIEW_TYPE, to3d_data::fov, to3d_widget_set::fov_av, to3d_data::function_type, to3d_widget_set::function_type_av, to3d_data::geometry_parent_filename, to3d_widget_set::geometry_parent_label, to3d_widget_set::geometry_parent_textfield, to3d_widget_set::good, LABEL_ARG, LAST_3DIM_TYPE, LAST_ANAT_TYPE, LAST_FUNC_TYPE, LAST_ORIENT_TYPE, LAST_VIEW_TYPE, LONGEST_3DIM_TYPESTR, LONGEST_ANAT_TYPESTR, LONGEST_FUNC_TYPESTR, LONGEST_ORIENT_TYPESTR, LONGEST_VIEW_TYPESTR, MCW_AV_downup, MCW_AV_editext, MCW_AV_readtext, MCW_BB_check, MCW_BB_frame, MCW_BB_radio_one, MCW_new_DC(), MCW_reghelp_children(), MCW_reghint_children(), MCW_register_help(), MCW_register_hint(), MCW_set_widget_bg(), mri_datum_size(), NCOLOVR, new_MCW_arrowval(), new_MCW_bbox(), NO_NAMES, to3d_data::ntt, to3d_data::nx, to3d_data::ny, to3d_data::nzz, to3d_widget_set::open_view_pb, to3d_widget_set::output_file_label, to3d_widget_set::output_file_textfield, to3d_data::output_filename, to3d_widget_set::quit_pb, to3d_widget_set::region_separator, to3d_widget_set::save_file_pb, to3d_widget_set::seq, to3d_widget_set::session_file_label, to3d_widget_set::session_file_textfield, to3d_data::session_filename, to3d_data::short_label1, to3d_widget_set::stat_aux_label, to3d_widget_set::stat_aux_textfield, to3d_widget_set::swap_pb, T3D_anatomy_parent_CB(), T3D_centered_CB(), T3D_data_to_widgets(), T3D_FORM_SPACING, T3D_fov_av_CB(), T3D_geometry_parent_CB(), T3D_NAME_WIDTH, T3D_open_view_CB(), T3D_orient_av_CB(), T3D_origin_av_CB(), T3D_pointer_leave_EV(), T3D_quit_CB(), T3D_save_file_CB(), T3D_set_dependent_geometries(), T3D_size_av_CB(), T3D_stat_aux_CB(), T3D_swap_CB(), T3D_text_display(), T3D_type_av_CB(), T3D_voxcontig_CB(), T3D_voxshape_CB(), THD_MAX_LABEL, THD_MAX_NAME, THD_MAX_PREFIX, to3d_widget_set::topform, to3d_widget_set::topshell, to3d_data::Torg, to3d_data::TR, to3d_widget_set::TR_label, tt, to3d_data::tunits, UNITS_TYPE_LABEL, VIEW_ORIGINAL_STR, to3d_data::view_type, to3d_widget_set::view_type_av, to3d_widget_set::voxcontig_bbox, to3d_data::voxshape, to3d_widget_set::voxshape_bbox, VOXSHAPE_CUBICAL, VOXSHAPE_IRREGULAR, VOXSHAPE_SQUARE, WAIT_for_window, MCW_bbox::wbut, MCW_arrowval::wrowcol, MCW_bbox::wrowcol, MCW_arrowval::wtext, MCW_bbox::wtop, to3d_data::xorient, to3d_widget_set::xorient_av, to3d_data::xorigin, to3d_widget_set::xorigin_av, to3d_widget_set::xorigin_label, to3d_data::xsize, to3d_widget_set::xsize_av, to3d_data::yorient, to3d_widget_set::yorient_av, to3d_data::yorigin, to3d_widget_set::yorigin_av, to3d_widget_set::yorigin_label, to3d_data::ysize, to3d_widget_set::ysize_av, to3d_data::zorient, to3d_widget_set::zorient_av, to3d_data::zorigin, to3d_widget_set::zorigin_av, to3d_widget_set::zorigin_label, to3d_data::zsize, to3d_widget_set::zsize_av, to3d_data::zspacing, and to3d_widget_set::zspacing_av.

Referenced by main().

00415 {
00416 ENTRY("T3D_create_widgets") ;
00417    wset.dc  = MCW_new_DC( wset.topshell, argopt.ncolor,
00418                           NCOLOVR,FD_colovr,FD_colovr, argopt.gamma , 0 );
00419    wset.seq = NULL ;  /* no viewing open now */
00420 
00421    /*---- form to hold all widgets ----*/
00422 
00423    wset.topform = XtVaCreateWidget(
00424                      "dialog" , xmFormWidgetClass , wset.topshell ,
00425                          XmNborderWidth , 0 ,
00426 #if 1
00427                          XmNtraversalOn , False ,
00428 #endif
00429                      NULL ) ;
00430 
00431    MCW_register_help( wset.topform ,
00432                       "I weep for Adonais--he is dead!\n"
00433                       "Oh, weep for Adonais! though our tears\n"
00434                       "Thaw not the frost which binds so dear a head!\n"
00435                       "And thou, sad Hour, selected from all years\n"
00436                       "To mourn our loss, rouse thy obscure compeers,\n"
00437                       "And teach them thine own sorrow, say: 'With me\n"
00438                       "Died Adonais; till the Future dares\n"
00439                       "Forget the Past, his fate and fame shall be\n"
00440                       "An echo and a light unto eternity!'"
00441                     ) ;
00442 
00443    /*---- 3 arrowvals for orientation ----*/
00444 
00445    wset.xorient_av = new_MCW_arrowval(
00446                       wset.topform ,                     /* parent */
00447                       "x orientation\n(across screen)" , /* label */
00448                       MCW_AV_downup ,                    /* arrows */
00449                       FIRST_ORIENT_TYPE ,                /* min */
00450                       LAST_ORIENT_TYPE ,                 /* max */
00451                       user_inputs.xorient ,              /* init */
00452                       MCW_AV_readtext ,                  /* text */
00453                       0 ,                                /* decimals */
00454                       T3D_orient_av_CB , NULL ,          /* callback */
00455                       T3D_text_display ,                 /* text maker */
00456                       ORIENT_typestr                     /* and data */
00457                      ) ;
00458 
00459    XtVaSetValues( wset.xorient_av->wrowcol ,
00460                      XmNleftAttachment , XmATTACH_FORM ,
00461                      XmNleftOffset     , T3D_FORM_SPACING ,
00462                      XmNtopAttachment  , XmATTACH_FORM ,
00463                      XmNtopOffset      , T3D_FORM_SPACING ,
00464                   NULL ) ;
00465 
00466    wset.yorient_av = new_MCW_arrowval(
00467                       wset.topform ,                     /* parent */
00468                       "y orientation\n (down screen) " , /* label */
00469                       MCW_AV_downup ,                    /* arrows */
00470                       FIRST_ORIENT_TYPE ,                /* min */
00471                       LAST_ORIENT_TYPE ,                 /* max */
00472                       user_inputs.yorient ,              /* init */
00473                       MCW_AV_readtext ,                  /* text */
00474                       0 ,                                /* decimals */
00475                       T3D_orient_av_CB , NULL ,          /* callback */
00476                       T3D_text_display ,                 /* text maker */
00477                       ORIENT_typestr                     /* and data */
00478                      ) ;
00479 
00480    XtVaSetValues( wset.yorient_av->wrowcol ,
00481                      XmNtopAttachment  , XmATTACH_WIDGET ,
00482                      XmNtopWidget      , wset.xorient_av->wrowcol ,
00483                      XmNtopOffset      , T3D_FORM_SPACING ,
00484                      XmNleftAttachment , XmATTACH_FORM ,
00485                      XmNleftOffset     , T3D_FORM_SPACING ,
00486                   NULL ) ;
00487 
00488    wset.zorient_av = new_MCW_arrowval(
00489                       wset.topform ,                     /* parent */
00490                       "z orientation\n(slices 0,1,..)" , /* label */
00491                       MCW_AV_downup ,                    /* arrows */
00492                       FIRST_ORIENT_TYPE ,                /* min */
00493                       LAST_ORIENT_TYPE ,                 /* max */
00494                       user_inputs.zorient ,              /* init */
00495                       MCW_AV_readtext ,                  /* text */
00496                       0 ,                                /* decimals */
00497                       T3D_orient_av_CB , NULL ,          /* callback */
00498                       T3D_text_display ,                 /* text maker */
00499                       ORIENT_typestr                     /* and data */
00500                      ) ;
00501 
00502    XtVaSetValues( wset.zorient_av->wrowcol ,
00503                      XmNtopAttachment  , XmATTACH_WIDGET ,
00504                      XmNtopWidget      , wset.yorient_av->wrowcol ,
00505                      XmNtopOffset      , T3D_FORM_SPACING ,
00506                      XmNleftAttachment , XmATTACH_FORM ,
00507                      XmNleftOffset     , T3D_FORM_SPACING ,
00508                   NULL ) ;
00509 
00510    XtVaSetValues( wset.xorient_av->wtext ,
00511                      XmNcolumns   , LONGEST_ORIENT_TYPESTR ,
00512                      XmNmaxLength , LONGEST_ORIENT_TYPESTR ,
00513                   NULL ) ;
00514 
00515    XtVaSetValues( wset.yorient_av->wtext ,
00516                      XmNcolumns   , LONGEST_ORIENT_TYPESTR ,
00517                      XmNmaxLength , LONGEST_ORIENT_TYPESTR ,
00518                   NULL ) ;
00519 
00520    XtVaSetValues( wset.zorient_av->wtext ,
00521                      XmNcolumns   , LONGEST_ORIENT_TYPESTR ,
00522                      XmNmaxLength , LONGEST_ORIENT_TYPESTR ,
00523                   NULL ) ;
00524 
00525    wset.xorient_av->allow_wrap = 1 ;
00526    wset.yorient_av->allow_wrap = 1 ;
00527    wset.zorient_av->allow_wrap = 1 ;
00528 
00529    MCW_reghelp_children( wset.xorient_av->wrowcol ,
00530       "Choose the anatomical orientation\n"
00531       "which fits the images when displayed\n"
00532       "in their ORIGINAL orientation:\n"
00533       "left->right, across the screen" ) ;
00534    MCW_reghint_children( wset.xorient_av->wrowcol ,
00535                          "Anatomical orientation across screen" ) ;
00536 
00537    MCW_reghelp_children( wset.yorient_av->wrowcol ,
00538       "Choose the anatomical orientation\n"
00539       "which fits the images when displayed\n"
00540       "in their ORIGINAL orientation:\n"
00541       "top->bottom, down the screen" ) ;
00542    MCW_reghint_children( wset.yorient_av->wrowcol ,
00543                          "Anatomical orientation down screen" ) ;
00544 
00545    MCW_reghelp_children( wset.zorient_av->wrowcol ,
00546       "Choose the anatomical orientation\n"
00547       "which fits the images when displayed\n"
00548       "in their ORIGINAL orientation:\n"
00549       "slice order, `thru' the screen" ) ;
00550    MCW_reghint_children( wset.zorient_av->wrowcol ,
00551                          "Anatomical orientation in slice direction" ) ;
00552 
00553    printf(".");fflush(stdout);
00554 
00555    /*---- bbox and arrowvals for voxel sizes ----*/
00556 
00557    wset.xsize_av = new_MCW_arrowval(
00558                       wset.topform ,                /* parent */
00559                       "x voxel\nsize (mm)" ,        /* label */
00560                       MCW_AV_downup ,               /* arrows */
00561                       1 ,                           /* min */
00562                       9999 ,                        /* max */
00563                       (int)(100*user_inputs.xsize), /* init */
00564                       MCW_AV_editext ,              /* text */
00565                       2 ,                           /* decimals */
00566                       T3D_size_av_CB , NULL ,       /* callback */
00567                       NULL , NULL                   /* text maker */
00568                      ) ;
00569 
00570    XtVaSetValues( wset.xsize_av->wrowcol ,
00571                      XmNtopAttachment  , XmATTACH_FORM ,
00572                      XmNtopOffset      , T3D_FORM_SPACING ,
00573                      XmNleftAttachment , XmATTACH_WIDGET ,
00574                      XmNleftWidget     , wset.xorient_av->wrowcol ,
00575                      XmNleftOffset     , T3D_FORM_SPACING ,
00576                   NULL ) ;
00577 
00578 /*
00579    AV_assign_fval( wset.xsize_av , user_inputs.xsize ) ;
00580 */
00581 
00582    wset.ysize_av = new_MCW_arrowval(
00583                       wset.topform ,                /* parent */
00584                       "y voxel\nsize (mm)" ,        /* label */
00585                       MCW_AV_downup ,               /* arrows */
00586                       1 ,                           /* min */
00587                       9999 ,                        /* max */
00588                       (int)(100*user_inputs.ysize), /* init */
00589                       MCW_AV_editext ,              /* text */
00590                       2 ,                           /* decimals */
00591                       T3D_size_av_CB , NULL ,       /* callback */
00592                       NULL , NULL                   /* text maker */
00593                      ) ;
00594 
00595    XtVaSetValues( wset.ysize_av->wrowcol ,
00596                      XmNtopAttachment  , XmATTACH_WIDGET ,
00597                      XmNtopWidget      , wset.xsize_av->wrowcol ,
00598                      XmNtopOffset      , T3D_FORM_SPACING ,
00599                      XmNleftAttachment , XmATTACH_WIDGET ,
00600                      XmNleftWidget     , wset.xorient_av->wrowcol ,
00601                      XmNleftOffset     , T3D_FORM_SPACING ,
00602                   NULL ) ;
00603 
00604    wset.zsize_av = new_MCW_arrowval(
00605                       wset.topform ,                /* parent */
00606                       "z voxel\nsize (mm)" ,        /* label */
00607                       MCW_AV_downup ,               /* arrows */
00608                       1 ,                           /* min */
00609                       9999 ,                        /* max */
00610                       (int)(100*user_inputs.zsize), /* init */
00611                       MCW_AV_editext ,              /* text */
00612                       2 ,                           /* decimals */
00613                       T3D_size_av_CB , NULL ,       /* callback */
00614                       NULL , NULL                   /* text maker */
00615                      ) ;
00616 
00617    XtVaSetValues( wset.zsize_av->wrowcol ,
00618                      XmNtopAttachment  , XmATTACH_WIDGET ,
00619                      XmNtopWidget      , wset.ysize_av->wrowcol ,
00620                      XmNtopOffset      , T3D_FORM_SPACING ,
00621                      XmNleftAttachment , XmATTACH_WIDGET ,
00622                      XmNleftWidget     , wset.xorient_av->wrowcol ,
00623                      XmNleftOffset     , T3D_FORM_SPACING ,
00624                   NULL ) ;
00625 
00626 #ifdef ALLOW_NONCONTIG
00627    wset.zspacing_av = new_MCW_arrowval(
00628                         wset.topform ,                    /* parent */
00629                         "z voxel\nspacing  " ,            /* label */
00630                         MCW_AV_downup ,                   /* arrows */
00631                         1 ,                               /* min */
00632                         9999 ,                            /* max */
00633                         (int)(100*user_inputs.zspacing),  /* init */
00634                         MCW_AV_editext ,                  /* text */
00635                         2 ,                               /* decimals */
00636                         T3D_size_av_CB , NULL ,           /* callback */
00637                         NULL , NULL                       /* text maker */
00638                       ) ;
00639 
00640    XtVaSetValues( wset.zspacing_av->wrowcol ,
00641                      XmNtopAttachment  , XmATTACH_WIDGET ,
00642                      XmNtopWidget      , wset.zsize_av->wrowcol ,
00643                      XmNtopOffset      , T3D_FORM_SPACING ,
00644                      XmNleftAttachment , XmATTACH_WIDGET ,
00645                      XmNleftWidget     , wset.xorient_av->wrowcol ,
00646                      XmNleftOffset     , T3D_FORM_SPACING ,
00647                   NULL ) ;
00648 #endif /* ALLOW_NONCONTIG */
00649 
00650    wset.fov_av = new_MCW_arrowval(
00651                       wset.topform ,             /* parent */
00652                       "Field of\nview (mm)" ,    /* label */
00653                       MCW_AV_downup ,            /* arrows */
00654                       1 ,                        /* min */
00655                       99999 ,                    /* max */
00656                       (int)(10*user_inputs.fov), /* init */
00657                       MCW_AV_editext ,           /* text */
00658                       1 ,                        /* decimals */
00659                       T3D_fov_av_CB , NULL ,     /* callback */
00660                       NULL , NULL                /* text maker */
00661                      ) ;
00662 
00663    XtVaSetValues( wset.fov_av->wrowcol ,
00664                      XmNtopAttachment  , XmATTACH_WIDGET ,
00665 #ifdef ALLOW_NONCONTIG
00666                      XmNtopWidget      , wset.zspacing_av->wrowcol ,
00667 #else
00668                      XmNtopWidget      , wset.zsize_av->wrowcol ,
00669 #endif
00670                      XmNtopOffset      , T3D_FORM_SPACING ,
00671                      XmNleftAttachment , XmATTACH_WIDGET ,
00672                      XmNleftWidget     , wset.xorient_av->wrowcol ,
00673                      XmNleftOffset     , T3D_FORM_SPACING ,
00674                   NULL ) ;
00675 
00676    wset.voxshape_bbox = new_MCW_bbox(
00677                           wset.topform ,        /* parent */
00678                           3 ,                   /* num buttons */
00679                           T3D_voxshape_label ,  /* labels */
00680                           MCW_BB_radio_one ,    /* bbox type */
00681                           MCW_BB_frame ,        /* use a frame */
00682                           T3D_voxshape_CB ,     /* callback */
00683                           NULL                  /* callback data */
00684                         ) ;
00685 
00686    XtVaSetValues( wset.voxshape_bbox->wtop ,
00687                      XmNrightAttachment  , XmATTACH_WIDGET ,
00688                      XmNrightWidget      , wset.fov_av->wrowcol ,
00689                      XmNrightOffset      , T3D_FORM_SPACING ,
00690                      XmNtopAttachment    , XmATTACH_OPPOSITE_WIDGET ,
00691                      XmNtopWidget        , wset.fov_av->wrowcol ,
00692                      XmNtopOffset        , 0 ,
00693                   NULL ) ;
00694 
00695 #ifdef ALLOW_NONCONTIG
00696    wset.voxcontig_bbox = new_MCW_bbox(
00697                           wset.topform ,        /* parent */
00698                           3 ,                   /* num buttons */
00699                           T3D_voxcontig_label , /* labels */
00700                           MCW_BB_radio_one ,    /* bbox type */
00701                           MCW_BB_frame ,        /* use a frame */
00702                           T3D_voxcontig_CB ,    /* callback */
00703                           NULL                  /* callback data */
00704                         ) ;
00705 
00706    XtSetSensitive( wset.voxcontig_bbox->wbut[1] , False ) ;
00707    XtSetSensitive( wset.voxcontig_bbox->wbut[2] , False ) ;
00708 
00709    XtVaSetValues( wset.voxcontig_bbox->wtop ,
00710                      XmNrightAttachment  , XmATTACH_WIDGET ,
00711                      XmNrightWidget      , wset.voxshape_bbox->wtop ,
00712                      XmNrightOffset      , T3D_FORM_SPACING ,
00713                      XmNtopAttachment    , XmATTACH_OPPOSITE_WIDGET ,
00714                      XmNtopWidget        , wset.voxshape_bbox->wtop ,
00715                      XmNtopOffset        , 0 ,
00716                   NULL ) ;
00717 #endif /* ALLOW_NONCONTIG */
00718 
00719    MCW_reghelp_children( wset.xsize_av->wrowcol ,
00720     "If in-slice voxel dimensions are\n"
00721     "not square, use this to set the\n"
00722     "x axis (across screen) dimension" ) ;
00723    MCW_reghint_children( wset.xsize_av->wrowcol ,
00724                          "Across screen voxel size" ) ;
00725 
00726    MCW_reghelp_children( wset.ysize_av->wrowcol ,
00727     "If in-slice voxel dimensions are\n"
00728     "not square, use this to set the\n"
00729     "y axis (down screen) dimension" ) ;
00730    MCW_reghint_children( wset.ysize_av->wrowcol ,
00731                          "Down screen voxel size" ) ;
00732 
00733    MCW_reghelp_children( wset.zsize_av->wrowcol ,
00734     "If voxels are not cubical,\n"
00735     "use this to set the z axis\n"
00736     "(slice direction) thickness" ) ;
00737    MCW_reghint_children( wset.ysize_av->wrowcol ,
00738                          "Slice direction voxel size" ) ;
00739 
00740 #ifdef ALLOW_NONCONTIG
00741    MCW_reghelp_children( wset.zspacing_av->wrowcol ,
00742     "If the slices are not\n"
00743     "contiguous, use this to\n"
00744     "set the center-to-center\n"
00745     "slice spacing" ) ;
00746 #endif /* ALLOW_NONCONTIG */
00747 
00748    MCW_reghelp_children( wset.fov_av->wrowcol ,
00749     "If the voxels are cubical,\n"
00750     "or at least square, use this\n"
00751     "to specify the sizes by giving\n"
00752     "the Field-Of-View dimension\n"
00753     "(the width across screen of images)" ) ;
00754    MCW_reghint_children( wset.fov_av->wrowcol ,
00755                          "In-slice width of entire image" ) ;
00756 
00757    MCW_reghelp_children( wset.voxshape_bbox->wrowcol ,
00758                          "Choose one button to\n"
00759                          "specify the voxel 'shape':\n"
00760                          " cubical  = all dimensions equal\n"
00761                          " square   = x & y dimensions\n"
00762                          "            equal, z different\n"
00763                          " irregular= all dimensions unequal" ) ;
00764    MCW_reghint_children( wset.voxshape_bbox->wrowcol ,
00765                          "Specify voxel shape" ) ;
00766 
00767 #ifdef ALLOW_NONCONTIG
00768    MCW_reghelp_children( wset.voxcontig_bbox->wrowcol ,
00769     "Pressed IN:  slices are contiguous\n"
00770     "Pressed OUT: slices are not contiguous\n"
00771     "(i.e., z size and z spacing differ)" ) ;
00772 #endif /* ALLOW_NONCONTIG */
00773 
00774    /*-- set the vox*_bbox values depending on initial sizes --*/
00775 
00776    if( user_inputs.xsize != user_inputs.ysize ){
00777       user_inputs.voxshape = VOXSHAPE_IRREGULAR ;
00778    } else {
00779       if( user_inputs.xsize != user_inputs.zsize ){
00780          user_inputs.voxshape = VOXSHAPE_SQUARE ;
00781       } else {
00782          user_inputs.voxshape = VOXSHAPE_CUBICAL ;
00783       }
00784    }
00785 
00786    printf(".");fflush(stdout);
00787 
00788    /*---- Label to show the TR (for 3D+time datasets) ----*/
00789 
00790    { char buf[96] ;
00791      XmString xstr ;
00792 
00793      sprintf( buf,"TR=%.3f%s Torg=%.3f\nNR=%d Nz=%d",
00794               user_inputs.TR  , UNITS_TYPE_LABEL(user_inputs.tunits) ,
00795               user_inputs.Torg,
00796               user_inputs.ntt , user_inputs.nzz ) ;
00797      xstr = XmStringCreateLtoR( buf , XmFONTLIST_DEFAULT_TAG ) ;
00798 
00799      wset.TR_label =
00800       XtVaCreateManagedWidget(
00801          "dialog" , xmLabelWidgetClass , wset.topform ,
00802             XmNlabelString      , xstr ,
00803             XmNrecomputeSize    , False ,
00804             XmNalignment        , XmALIGNMENT_BEGINNING ,
00805             XmNtopAttachment    , XmATTACH_WIDGET ,
00806             XmNtopWidget        , wset.fov_av->wrowcol ,
00807             XmNtopOffset        , T3D_FORM_SPACING ,
00808             XmNleftAttachment   , XmATTACH_WIDGET ,
00809             XmNleftWidget       , wset.voxshape_bbox->wtop ,
00810             XmNleftOffset       , T3D_FORM_SPACING ,
00811          NULL ) ;
00812 
00813       XmStringFree( xstr ) ;
00814 
00815       MCW_register_help( wset.TR_label ,
00816          "Shows the TR (inter-brick time), number\n"
00817          "of bricks NR, and number of slizes Nz,\n"
00818          "for time-dependent datasets.\n"
00819          "These CANNOT be changed interactively.\n"
00820          "They can only be set on the command line." ) ;
00821 
00822       MCW_register_hint( wset.TR_label , "3D+time parameters" ) ;
00823 
00824      if( user_inputs.ntt < 2 )
00825         XtUnmanageChild( wset.TR_label ) ;
00826    }
00827 
00828    /*---- arrowvals for origin ----*/
00829 
00830    wset.xorigin_av = new_MCW_arrowval(
00831                         wset.topform ,                  /* parent */
00832                         "x origin (mm)\n[left edge]" ,  /* label */
00833                         MCW_AV_downup ,                 /* arrows */
00834                        -99999 ,                         /* min */
00835                         99999 ,                         /* max */
00836                         (int)(100*user_inputs.xorigin), /* init */
00837                         MCW_AV_editext ,                /* text */
00838                         2 ,                             /* decimals */
00839                         T3D_origin_av_CB , NULL ,       /* callback */
00840                         NULL , NULL                     /* text maker */
00841                      ) ;
00842 
00843    XtVaSetValues( wset.xorigin_av->wrowcol ,
00844                      XmNleftAttachment , XmATTACH_WIDGET ,
00845                      XmNleftWidget     , wset.xsize_av->wrowcol ,
00846                      XmNleftOffset     , T3D_FORM_SPACING ,
00847                      XmNtopAttachment  , XmATTACH_FORM ,
00848                      XmNtopOffset      , T3D_FORM_SPACING ,
00849                   NULL ) ;
00850 
00851    wset.xorigin_label =
00852       XtVaCreateManagedWidget(
00853          "dialog" , xmLabelWidgetClass , wset.topform ,
00854             LABEL_ARG("X") ,
00855             XmNrecomputeSize  , False ,
00856             XmNleftAttachment , XmATTACH_WIDGET ,
00857             XmNleftWidget     , wset.xorigin_av->wrowcol ,
00858             XmNleftOffset     , 1 ,
00859             XmNtopAttachment  , XmATTACH_OPPOSITE_WIDGET ,
00860             XmNtopWidget      , wset.xorigin_av->wrowcol ,
00861             XmNtopOffset      , 2 ,
00862          NULL ) ;
00863 
00864    wset.yorigin_av = new_MCW_arrowval(
00865                         wset.topform ,                  /* parent */
00866                         "y origin (mm)\n[top edge]" ,   /* label */
00867                         MCW_AV_downup ,                 /* arrows */
00868                        -99999 ,                         /* min */
00869                         99999 ,                         /* max */
00870                         (int)(100*user_inputs.yorigin), /* init */
00871                         MCW_AV_editext ,                /* text */
00872                         2 ,                             /* decimals */
00873                         T3D_origin_av_CB , NULL ,       /* callback */
00874                         NULL , NULL                     /* text maker */
00875                      ) ;
00876 
00877    XtVaSetValues( wset.yorigin_av->wrowcol ,
00878                      XmNtopAttachment  , XmATTACH_WIDGET ,
00879                      XmNtopWidget      , wset.xorigin_av->wrowcol ,
00880                      XmNtopOffset      , T3D_FORM_SPACING ,
00881                      XmNleftAttachment , XmATTACH_WIDGET ,
00882                      XmNleftWidget     , wset.xsize_av->wrowcol ,
00883                      XmNleftOffset     , T3D_FORM_SPACING ,
00884                   NULL ) ;
00885 
00886    wset.yorigin_label =
00887       XtVaCreateManagedWidget(
00888          "dialog" , xmLabelWidgetClass , wset.topform ,
00889             LABEL_ARG("X") ,
00890             XmNrecomputeSize  , False ,
00891             XmNleftAttachment , XmATTACH_WIDGET ,
00892             XmNleftWidget     , wset.yorigin_av->wrowcol ,
00893             XmNleftOffset     , 1 ,
00894             XmNtopAttachment  , XmATTACH_OPPOSITE_WIDGET ,
00895             XmNtopWidget      , wset.yorigin_av->wrowcol ,
00896             XmNtopOffset      , 2 ,
00897          NULL ) ;
00898 
00899    wset.zorigin_av = new_MCW_arrowval(
00900                         wset.topform ,                  /* parent */
00901                         "z origin (mm)\n[slice 0]" ,    /* label */
00902                         MCW_AV_downup ,                 /* arrows */
00903                        -99999 ,                         /* min */
00904                         99999 ,                         /* max */
00905                         (int)(100*user_inputs.zorigin), /* init */
00906                         MCW_AV_editext ,                /* text */
00907                         2 ,                             /* decimals */
00908                         T3D_origin_av_CB , NULL ,       /* callback */
00909                         NULL , NULL                     /* text maker */
00910                      ) ;
00911 
00912    XtVaSetValues( wset.zorigin_av->wrowcol ,
00913                      XmNtopAttachment  , XmATTACH_WIDGET ,
00914                      XmNtopWidget      , wset.yorigin_av->wrowcol ,
00915                      XmNtopOffset      , T3D_FORM_SPACING ,
00916                      XmNleftAttachment , XmATTACH_WIDGET ,
00917                      XmNleftWidget     , wset.xsize_av->wrowcol ,
00918                      XmNleftOffset     , T3D_FORM_SPACING ,
00919                   NULL ) ;
00920 
00921    wset.zorigin_label =
00922       XtVaCreateManagedWidget(
00923          "dialog" , xmLabelWidgetClass , wset.topform ,
00924             LABEL_ARG("X") ,
00925             XmNrecomputeSize  , False ,
00926             XmNleftAttachment , XmATTACH_WIDGET ,
00927             XmNleftWidget     , wset.zorigin_av->wrowcol ,
00928             XmNleftOffset     , 1 ,
00929             XmNtopAttachment  , XmATTACH_OPPOSITE_WIDGET ,
00930             XmNtopWidget      , wset.zorigin_av->wrowcol ,
00931             XmNtopOffset      , 2 ,
00932          NULL ) ;
00933 
00934    wset.centered_bbox = new_MCW_bbox(
00935                           wset.topform ,       /* parent */
00936                           3 ,                  /* num buttons */
00937                           T3D_centered_label , /* labels */
00938                           MCW_BB_check ,       /* bbox type */
00939                           MCW_BB_frame ,       /* use a frame */
00940                           T3D_centered_CB ,    /* callback */
00941                           NULL                 /* callback data */
00942                         ) ;
00943 
00944    XtVaSetValues( wset.centered_bbox->wtop ,
00945 #if 0
00946                      XmNleftAttachment   , XmATTACH_WIDGET ,
00947                      XmNleftWidget       , wset.fov_av->wrowcol ,
00948                      XmNleftOffset       , T3D_FORM_SPACING ,
00949 #else
00950                      XmNrightAttachment  , XmATTACH_OPPOSITE_WIDGET ,
00951                      XmNrightWidget      , wset.zorigin_av->wrowcol ,
00952                      XmNrightOffset      , 0 ,
00953 #endif
00954                      XmNtopAttachment    , XmATTACH_OPPOSITE_WIDGET ,
00955                      XmNtopWidget        , wset.fov_av->wrowcol ,
00956                      XmNtopOffset        , 0 ,
00957                   NULL ) ;
00958 
00959    MCW_reghelp_children( wset.centered_bbox->wrowcol ,
00960     "Choose any combination of\n"
00961     "buttons to indicate whether\n"
00962     "each axis is centered\n"
00963     "in the gradient coil fields:\n"
00964     "Pressed IN means centered\n"
00965     "Pressed OUT means not centered" ) ;
00966    MCW_reghint_children( wset.centered_bbox->wrowcol ,
00967                          "Is data domain centered around 0?" ) ;
00968 
00969    MCW_reghelp_children( wset.xorigin_av->wrowcol ,
00970       "Use the arrows (or type) to enter\n"
00971       "the x-axis distance from the center of\n"
00972       "the first voxel to the\n"
00973       "gradient coil (0,0,0) point" ) ;
00974    MCW_reghint_children( wset.xorigin_av->wrowcol ,
00975                          "X-axis distance to 1st voxel center" ) ;
00976 
00977    MCW_reghelp_children( wset.yorigin_av->wrowcol ,
00978       "Use the arrows (or type) to enter\n"
00979       "the y-axis distance from the center of\n"
00980       "the first voxel to the\n"
00981       "gradient coil (0,0,0) point" ) ;
00982    MCW_reghint_children( wset.yorigin_av->wrowcol ,
00983                          "Y-axis distance to 1st voxel center" ) ;
00984 
00985    MCW_reghelp_children( wset.zorigin_av->wrowcol ,
00986       "Use the arrows (or type) to enter\n"
00987       "the z-axis distance from the center of\n"
00988       "the first voxel to the\n"
00989       "gradient coil (0,0,0) point" ) ;
00990    MCW_reghint_children( wset.zorigin_av->wrowcol ,
00991                          "Z-axis distance to 1st voxel center" ) ;
00992 
00993    MCW_register_help( wset.xorigin_label ,
00994                       "Shows the direction that the\n"
00995                       "x origin distance applies" ) ;
00996    MCW_register_hint( wset.xorigin_label ,
00997                       "Direction of x origin distance" ) ;
00998 
00999    MCW_register_help( wset.yorigin_label ,
01000                       "Shows the direction that the\n"
01001                       "y origin distance applies" ) ;
01002    MCW_register_hint( wset.yorigin_label ,
01003                       "Direction of y origin distance" ) ;
01004 
01005    MCW_register_help( wset.zorigin_label ,
01006                       "Shows the direction that the\n"
01007                       "z origin distance applies" ) ;
01008    MCW_register_hint( wset.zorigin_label ,
01009                       "Direction of z origin distance" ) ;
01010 
01011    printf(".");fflush(stdout);
01012 
01013    /*----- a separator to keep the geometry stuff separate -----*/
01014 
01015    wset.region_separator =
01016       XtVaCreateManagedWidget(
01017          "dialog" , xmSeparatorGadgetClass , wset.topform ,
01018             XmNseparatorType   , XmDOUBLE_LINE ,
01019             XmNmargin          , 3             ,
01020             XmNleftAttachment  , XmATTACH_FORM ,
01021             XmNrightAttachment , XmATTACH_FORM ,
01022             XmNtopAttachment   , XmATTACH_WIDGET ,
01023             XmNtopOffset       , T3D_FORM_SPACING ,
01024             XmNtopWidget       , wset.voxshape_bbox->wtop ,
01025          NULL ) ;
01026 
01027    MCW_register_help( wset.region_separator ,
01028                         "Thou art indeed just, Lord, if I contend\n"
01029                         "With thee; but, sir, so what I plead is just.\n"
01030                         "Why do sinners' ways prosper? and why must\n"
01031                         "Disappointment all I endeavour end?\n"
01032                         "Wert thou my enemy, O thou my friend,\n"
01033                         "How wouldst thou worse, I wonder, than thou dost\n"
01034                         "Defeat, thwart me? Oh, the sots and thralls of lust\n"
01035                         "Do in spare hours more thrive than I that spend,\n"
01036                         "Sir, life upon thy cause. See, banks and brakes\n"
01037                         "Now, leav`ed how thick! lac`ed they are again\n"
01038                         "With fretty chervil, look, and fresh wind shakes\n"
01039                         "Them; birds build -- but not I build; no, but strain,\n"
01040                         "Time's eunuch, and not breed one work that wakes.\n"
01041                         "Mine, O thou lord of life, send my roots rain."
01042                     ) ;
01043 
01044    /*---- April 1996: arrowval for view_type ----*/
01045 
01046    wset.view_type_av = new_MCW_arrowval(
01047                          wset.topform ,                   /* parent */
01048                          "View:  " ,                      /* label */
01049                          MCW_AV_downup ,                  /* arrows */
01050                          FIRST_VIEW_TYPE ,                /* min */
01051                          LAST_VIEW_TYPE ,                 /* max */
01052                          user_inputs.view_type ,          /* init */
01053                          MCW_AV_readtext ,                /* text */
01054                          0 ,                              /* decimals */
01055                          T3D_orient_av_CB , NULL ,        /* callback */
01056                          T3D_text_display ,               /* text maker */
01057                          VIEW_typestr                     /* and data */
01058                        ) ;
01059 
01060    XtVaSetValues( wset.view_type_av->wrowcol ,
01061                      XmNbottomAttachment , XmATTACH_WIDGET ,
01062                      XmNbottomWidget     , wset.region_separator ,
01063                      XmNbottomOffset     , T3D_FORM_SPACING ,
01064                      XmNleftAttachment   , XmATTACH_FORM ,
01065                      XmNleftOffset       , T3D_FORM_SPACING ,
01066                   NULL ) ;
01067 
01068    XtVaSetValues( wset.view_type_av->wtext ,
01069                      XmNcolumns   , LONGEST_VIEW_TYPESTR ,
01070                      XmNmaxLength , LONGEST_VIEW_TYPESTR ,
01071                   NULL ) ;
01072 
01073    MCW_reghelp_children( wset.view_type_av->wrowcol ,
01074       "Sets the view type for the\n"
01075       "dataset being created.  Except\n"
01076       "under unusual circumstances,\n"
01077       "this should be " VIEW_ORIGINAL_STR ) ;
01078 
01079    /*---- Label to show what kind of data is stored ----*/
01080 
01081    { char buf[32] ;
01082      sprintf( buf , "Datum: %s [%dx%d]\n" ,
01083               MRI_TYPE_name[argopt.datum_all], user_inputs.nx,user_inputs.ny ) ;
01084      wset.datum_label =
01085         XtVaCreateManagedWidget(
01086            "dialog" , xmLabelWidgetClass , wset.topform ,
01087               LABEL_ARG(buf)   ,
01088               XmNbottomAttachment , XmATTACH_WIDGET ,
01089               XmNbottomWidget     , wset.view_type_av->wrowcol ,
01090               XmNbottomOffset     , 1 ,
01091               XmNleftAttachment   , XmATTACH_FORM ,
01092               XmNleftOffset       , T3D_FORM_SPACING ,
01093               XmNmarginHeight     , 0 ,
01094               XmNmarginWidth      , 0 ,
01095            NULL ) ;
01096 
01097    }
01098    MCW_register_help( wset.datum_label ,
01099      "This shows the type of data stored\n"
01100      "in the images as read into to3d.\n"
01101      "You can only alter this by exiting\n"
01102      "the program and using the -datum\n"
01103      "option when you run to3d again." ) ;
01104    MCW_register_hint( wset.datum_label , "Type of data stored in images" ) ;
01105 
01106    /*----- textfield widgets below the bar -----*/
01107 
01108    /** name widgets not being used no more **/
01109 
01110 #ifndef NO_NAMES
01111    wset.dataset_name_label =
01112       XtVaCreateManagedWidget(
01113          "dialog" , xmLabelWidgetClass , wset.topform ,
01114             LABEL_ARG("Dataset name:  ") ,
01115             XmNtopAttachment   , XmATTACH_WIDGET ,
01116             XmNtopWidget       , wset.region_separator ,
01117             XmNtopOffset       , T3D_FORM_SPACING ,
01118             XmNleftAttachment  , XmATTACH_FORM ,
01119             XmNleftOffset      , T3D_FORM_SPACING ,
01120          NULL ) ;
01121 
01122    wset.dataset_name_textfield =
01123       XtVaCreateManagedWidget(
01124          "dialog" , xmTextFieldWidgetClass , wset.topform ,
01125             XmNcolumns         , 80 ,
01126             XmNeditable        , True ,
01127             XmNmaxLength       , THD_MAX_NAME-1 ,
01128             XmNresizeWidth     , False ,
01129             XmNcursorPositionVisible , True ,
01130             XmNblinkRate , 0 ,
01131 /*
01132             XmNmarginHeight    , 1 ,
01133             XmNmarginWidth     , 1 ,
01134 */
01135             XmNvalue           , user_inputs.dataset_name ,
01136 
01137             XmNleftAttachment , XmATTACH_WIDGET ,
01138             XmNleftWidget     , wset.dataset_name_label ,
01139             XmNleftOffset     , T3D_FORM_SPACING ,
01140             XmNtopAttachment  , XmATTACH_OPPOSITE_WIDGET ,
01141             XmNtopWidget      , wset.dataset_name_label ,
01142             XmNtopOffset      , 0 ,
01143          NULL ) ;
01144 
01145    MCW_register_help( wset.dataset_name_label ,
01146     "Every 3D dataset needs a name;\n"
01147     "Type in what you need to remind\n"
01148     "you of the subject/experiment" ) ;
01149 
01150    MCW_register_help( wset.dataset_name_textfield ,
01151     "Every 3D dataset needs a label;\n"
01152     "Type in what you need to remind\n"
01153     "you of the subject/experiment" ) ;
01154 
01155    wset.short_label1_label =
01156       XtVaCreateManagedWidget(
01157          "dialog" , xmLabelWidgetClass , wset.topform ,
01158             LABEL_ARG("Short label:   ") ,
01159             XmNleftAttachment  , XmATTACH_FORM ,
01160             XmNleftOffset      , T3D_FORM_SPACING ,
01161             XmNtopAttachment   , XmATTACH_WIDGET ,
01162             XmNtopWidget       , wset.dataset_name_textfield ,
01163             XmNtopOffset       , T3D_FORM_SPACING ,
01164          NULL ) ;
01165 
01166    wset.short_label1_textfield =
01167       XtVaCreateManagedWidget(
01168          "dialog" , xmTextFieldWidgetClass , wset.topform ,
01169             XmNcolumns         , T3D_NAME_WIDTH ,
01170             XmNeditable        , True ,
01171             XmNmaxLength       , THD_MAX_LABEL-1 ,
01172             XmNresizeWidth     , False ,
01173             XmNcursorPositionVisible , True ,
01174             XmNblinkRate , 0 ,
01175 /*
01176             XmNmarginHeight    , 1 ,
01177             XmNmarginWidth     , 1 ,
01178 */
01179             XmNvalue           , user_inputs.short_label1 ,
01180 
01181             XmNleftAttachment , XmATTACH_WIDGET ,
01182             XmNleftWidget     , wset.short_label1_label ,
01183             XmNleftOffset     , T3D_FORM_SPACING ,
01184             XmNtopAttachment  , XmATTACH_OPPOSITE_WIDGET ,
01185             XmNtopWidget      , wset.short_label1_label ,
01186             XmNtopOffset      , 0 ,
01187          NULL ) ;
01188 
01189    MCW_register_help( wset.short_label1_label ,
01190     "The short label is used\n"
01191     "for a compact reminder of\n"
01192     "the dataset contents;\n"
01193     "type your choice in" ) ;
01194 
01195    MCW_register_help( wset.short_label1_textfield ,
01196     "The short label is used\n"
01197     "for a compact reminder of\n"
01198     "the dataset contents;\n"
01199     "type your choice in" ) ;
01200 #endif  /* NO_NAMES */
01201 
01202    wset.geometry_parent_label =
01203       XtVaCreateManagedWidget(
01204          "dialog" , xmLabelWidgetClass , wset.topform ,
01205             LABEL_ARG("Copy geometry  \nof this dataset") ,
01206             XmNleftAttachment  , XmATTACH_FORM ,
01207             XmNleftOffset      , T3D_FORM_SPACING ,
01208             XmNtopAttachment   , XmATTACH_WIDGET ,
01209 #ifdef NO_NAMES
01210             XmNtopWidget       , wset.region_separator ,
01211 #else
01212             XmNtopWidget       , wset.short_label1_textfield ,
01213 #endif
01214             XmNtopOffset       , T3D_FORM_SPACING ,
01215          NULL ) ;
01216 
01217    wset.geometry_parent_textfield =
01218       XtVaCreateManagedWidget(
01219          "dialog" , xmTextFieldWidgetClass , wset.topform ,
01220             XmNcolumns         , T3D_NAME_WIDTH ,
01221             XmNeditable        , True ,
01222             XmNmaxLength       , THD_MAX_NAME-1 ,
01223             XmNresizeWidth     , False ,
01224             XmNcursorPositionVisible , True ,
01225             XmNblinkRate , 0 ,
01226 /*
01227             XmNmarginHeight    , 1 ,
01228             XmNmarginWidth     , 1 ,
01229 */
01230             XmNvalue           , user_inputs.geometry_parent_filename ,
01231 
01232             XmNleftAttachment , XmATTACH_WIDGET ,
01233             XmNleftWidget     , wset.geometry_parent_label ,
01234             XmNleftOffset     , T3D_FORM_SPACING ,
01235             XmNtopAttachment  , XmATTACH_OPPOSITE_WIDGET ,
01236             XmNtopWidget      , wset.geometry_parent_label ,
01237             XmNtopOffset      , 0 ,
01238          NULL ) ;
01239 
01240    XtAddCallback( wset.geometry_parent_textfield ,
01241                   XmNactivateCallback ,
01242                   T3D_geometry_parent_CB , NULL ) ;    /* return key */
01243 
01244    XtAddCallback( wset.geometry_parent_textfield ,
01245                   XmNlosingFocusCallback ,
01246                   T3D_geometry_parent_CB , NULL ) ;    /* Tab key */
01247 
01248    XtInsertEventHandler( wset.geometry_parent_textfield ,
01249                          LeaveWindowMask ,             /* pointer leaves */
01250                          FALSE ,
01251                          T3D_pointer_leave_EV , NULL ,
01252                          XtListTail ) ;                /* last in queue */
01253 
01254    MCW_register_help( wset.geometry_parent_label ,
01255     "If a previously created 3D dataset\n"
01256     "has the same geometry (voxel sizes,\n"
01257     "etc.), enter its header filename\n"
01258     "and press the Enter key" ) ;
01259    MCW_register_hint( wset.geometry_parent_label ,
01260                       "Use the geometry of another dataset" ) ;
01261 
01262    MCW_register_help( wset.geometry_parent_textfield ,
01263     "If a previously created 3D dataset\n"
01264     "has the same geometry (voxel sizes,\n"
01265     "etc.), enter its header filename name\n"
01266     "here and press the Enter key" ) ;
01267    MCW_register_hint( wset.geometry_parent_textfield ,
01268                       "Use the geometry of another dataset" ) ;
01269 
01270    wset.anatomy_parent_label =
01271       XtVaCreateManagedWidget(
01272          "dialog" , xmLabelWidgetClass , wset.topform ,
01273             LABEL_ARG("Anatomy parent \nis this dataset") ,
01274             XmNleftAttachment  , XmATTACH_WIDGET ,
01275             XmNleftWidget      , wset.geometry_parent_textfield ,
01276             XmNleftOffset      , T3D_FORM_SPACING ,
01277             XmNtopAttachment   , XmATTACH_WIDGET ,
01278 #ifdef NO_NAMES
01279             XmNtopWidget       , wset.region_separator ,
01280 #else
01281             XmNtopWidget       , wset.short_label1_textfield ,
01282 #endif
01283             XmNtopOffset       , T3D_FORM_SPACING ,
01284          NULL ) ;
01285 
01286    wset.anatomy_parent_textfield =
01287       XtVaCreateManagedWidget(
01288          "dialog" , xmTextFieldWidgetClass , wset.topform ,
01289             XmNcolumns         , T3D_NAME_WIDTH ,
01290             XmNeditable        , True ,
01291             XmNmaxLength       , THD_MAX_NAME-1 ,
01292             XmNresizeWidth     , False ,
01293             XmNcursorPositionVisible , True ,
01294             XmNblinkRate , 0 ,
01295 /*
01296             XmNmarginHeight    , 1 ,
01297             XmNmarginWidth     , 1 ,
01298 */
01299             XmNvalue           , user_inputs.anatomy_parent_filename ,
01300 
01301             XmNleftAttachment , XmATTACH_WIDGET ,
01302             XmNleftOffset     , T3D_FORM_SPACING ,
01303             XmNleftWidget     , wset.anatomy_parent_label ,
01304             XmNtopAttachment  , XmATTACH_OPPOSITE_WIDGET ,
01305             XmNtopWidget      , wset.anatomy_parent_label ,
01306             XmNtopOffset      , 0 ,
01307          NULL ) ;
01308 
01309    XtAddCallback( wset.anatomy_parent_textfield ,
01310                   XmNactivateCallback ,
01311                   T3D_anatomy_parent_CB , NULL ) ;    /* return key */
01312 
01313    XtAddCallback( wset.anatomy_parent_textfield ,
01314                   XmNlosingFocusCallback ,
01315                   T3D_anatomy_parent_CB , NULL ) ;    /* Tab key */
01316 
01317    XtInsertEventHandler( wset.anatomy_parent_textfield ,
01318                          LeaveWindowMask ,             /* pointer leaves */
01319                          FALSE ,
01320                          T3D_pointer_leave_EV , NULL ,
01321                          XtListTail ) ;                /* last in queue */
01322 
01323    MCW_register_help( wset.anatomy_parent_label ,
01324     "A dataset may optionally be attached\n"
01325     "to an 'anatomy parent' -- that is, an\n"
01326     "anatomical dataset which is aligned\n"
01327     "with the current dataset; usually, the\n"
01328     "anatomy parent should have been acquired\n"
01329     "during the same imaging session as the\n"
01330     "current dataset, so that this requisite\n"
01331     "alignment is assured.  If no anatomy parent\n"
01332     "is given, then at the time one is needed,\n"
01333     "an appropriate dataset will be chosen from\n"
01334     "the same session directory.\n"
01335     "\n"
01336 #ifdef REQUIRE_ANAT_PARENT
01337     "N.B.: Functional datasets require anatomy parents;\n"
01338     "      for anatomical datasets, anatomy parents are\n"
01339     "      optional."
01340 #else
01341     "N.B.: You only need specify an anatomy parent\n"
01342     "      here if a specific dataset is required."
01343 #endif
01344    ) ;
01345 
01346    MCW_register_help( wset.anatomy_parent_textfield ,
01347     "A dataset may optionally be attached\n"
01348     "to an 'anatomy parent' -- that is, an\n"
01349     "anatomical dataset which is aligned\n"
01350     "with the current dataset; usually, the\n"
01351     "anatomy parent should have been acquired\n"
01352     "during the same imaging session as the\n"
01353     "current dataset, so that this requisite\n"
01354     "alignment is assured.  If no anatomy parent\n"
01355     "is given, then at the time one is needed,\n"
01356     "an appropriate dataset will be chosen from\n"
01357     "the same session directory.\n"
01358     "\n"
01359 #ifdef REQUIRE_ANAT_PARENT
01360     "N.B.: functional datasets require anatomy parents;\n"
01361     "      for anatomical datasets, anatomy parents are\n"
01362     "      optional."
01363 #else
01364     "N.B.: You only need specify an anatomy parent\n"
01365     "      here if a specific dataset is required."
01366 #endif
01367    ) ;
01368 
01369 #ifndef NO_NAMES
01370    wset.geometry_dataname_label =
01371       XtVaCreateManagedWidget(
01372          "dialog" , xmLabelWidgetClass , wset.topform ,
01373             LABEL_ARG("Geometry parent\nDataset name   ") ,
01374             XmNleftAttachment  , XmATTACH_FORM ,
01375             XmNleftOffset      , T3D_FORM_SPACING ,
01376             XmNtopAttachment   , XmATTACH_WIDGET ,
01377             XmNtopWidget       , wset.geometry_parent_textfield ,
01378             XmNtopOffset       , T3D_FORM_SPACING ,
01379             XmNsensitive       , False ,
01380          NULL ) ;
01381 
01382    wset.geometry_dataname_textfield =
01383       XtVaCreateManagedWidget(
01384          "dialog" , xmTextFieldWidgetClass , wset.topform ,
01385             XmNcolumns         , T3D_NAME_WIDTH ,
01386             XmNeditable        , False ,
01387             XmNmaxLength       , THD_MAX_NAME-1 ,
01388             XmNresizeWidth     , False ,
01389 
01390             XmNcursorPositionVisible , False ,
01391             XmNsensitive       , False ,
01392 /*
01393             XmNmarginHeight    , 1 ,
01394             XmNmarginWidth     , 1 ,
01395 */
01396             XmNvalue           , " " ,
01397 
01398             XmNleftAttachment , XmATTACH_WIDGET ,
01399             XmNleftWidget     , wset.geometry_dataname_label ,
01400             XmNleftOffset     , T3D_FORM_SPACING ,
01401             XmNtopAttachment  , XmATTACH_OPPOSITE_WIDGET ,
01402             XmNtopWidget      , wset.geometry_dataname_label ,
01403             XmNtopOffset      , 0 ,
01404          NULL ) ;
01405 
01406    MCW_register_help( wset.geometry_dataname_label ,
01407     "This item just shows the\n"
01408     "dataset name of the 'geometry\n"
01409     "parent' you selected (e.g., to\n"
01410     "let you decide if you've got\n"
01411     "the right one)." ) ;
01412 
01413    MCW_register_help( wset.geometry_dataname_textfield ,
01414     "This item just shows the\n"
01415     "dataset name of the 'geometry\n"
01416     "parent' you selected (e.g., to\n"
01417     "let you decide if you've got\n"
01418     "the right one)." ) ;
01419 
01420    wset.anatomy_dataname_label =
01421       XtVaCreateManagedWidget(
01422          "dialog" , xmLabelWidgetClass , wset.topform ,
01423             LABEL_ARG("Anatomy parent \nDataset name   ") ,
01424             XmNleftAttachment  , XmATTACH_WIDGET ,
01425             XmNleftWidget      , wset.geometry_dataname_textfield ,
01426             XmNleftOffset      , T3D_FORM_SPACING ,
01427             XmNtopAttachment   , XmATTACH_WIDGET ,
01428             XmNtopWidget       , wset.geometry_parent_textfield ,
01429             XmNtopOffset       , T3D_FORM_SPACING ,
01430             XmNsensitive       , False ,
01431          NULL ) ;
01432 
01433    wset.anatomy_dataname_textfield =
01434       XtVaCreateManagedWidget(
01435          "dialog" , xmTextFieldWidgetClass , wset.topform ,
01436             XmNcolumns         , T3D_NAME_WIDTH ,
01437             XmNeditable        , False ,
01438             XmNmaxLength       , THD_MAX_NAME-1 ,
01439             XmNresizeWidth     , False ,
01440 
01441             XmNcursorPositionVisible , False ,
01442             XmNsensitive       , False ,
01443 /*
01444             XmNmarginHeight    , 1 ,
01445             XmNmarginWidth     , 1 ,
01446 */
01447             XmNvalue           , " " ,
01448 
01449             XmNleftAttachment , XmATTACH_WIDGET ,
01450             XmNleftWidget     , wset.anatomy_dataname_label ,
01451             XmNleftOffset     , T3D_FORM_SPACING ,
01452             XmNtopAttachment  , XmATTACH_OPPOSITE_WIDGET ,
01453             XmNtopWidget      , wset.anatomy_dataname_label ,
01454             XmNtopOffset      , 0 ,
01455          NULL ) ;
01456 
01457    MCW_register_help( wset.anatomy_dataname_label ,
01458     "This item just shows the\n"
01459     "dataset name of the 'anatomy\n"
01460     "parent' you selected" ) ;
01461 
01462    MCW_register_help( wset.anatomy_dataname_textfield ,
01463     "This item just shows the\n"
01464     "dataset name of the 'anatomy\n"
01465     "parent' you selected" ) ;
01466 
01467    printf(".");fflush(stdout);
01468 #endif  /* NO_NAMES */
01469 
01470    /*----- arrowvals for dataset and function types -----*/
01471 
01472    wset.dataset_type_av =
01473       new_MCW_arrowval(
01474              wset.topform ,                     /* parent */
01475              "Type of data\nin the images    ", /* label */
01476              MCW_AV_downup ,                    /* arrows */
01477              FIRST_3DIM_TYPE ,                  /* min */
01478              LAST_3DIM_TYPE ,                   /* max */
01479              user_inputs.dataset_type ,         /* init */
01480              MCW_AV_readtext ,                  /* text type */
01481              0 ,                                /* decimals */
01482              T3D_type_av_CB , NULL ,            /* callback */
01483              T3D_text_display ,                 /* text maker */
01484              DATASET_typestr                    /* and data */
01485        ) ;
01486 
01487    wset.dataset_type_av->allow_wrap = 1 ;
01488 
01489    XtVaSetValues( wset.dataset_type_av->wtext ,
01490                      XmNcolumns   , LONGEST_3DIM_TYPESTR ,
01491                      XmNmaxLength , LONGEST_3DIM_TYPESTR ,
01492                   NULL ) ;
01493 
01494    XtVaSetValues( wset.dataset_type_av->wrowcol ,
01495                      XmNleftAttachment , XmATTACH_FORM ,
01496                      XmNleftOffset     , T3D_FORM_SPACING ,
01497                      XmNtopAttachment  , XmATTACH_WIDGET ,
01498 #ifndef NO_NAMES
01499                      XmNtopWidget      , wset.geometry_dataname_label ,
01500 #else
01501                      XmNtopWidget      , wset.geometry_parent_label ,
01502 #endif
01503                      XmNtopOffset      , T3D_FORM_SPACING ,
01504                   NULL ) ;
01505 
01506    MCW_reghelp_children( wset.dataset_type_av->wrowcol ,
01507                           "Use the arrows to specify\n"
01508                           "the type of data stored\n"
01509                           "in the image files.\n"
01510                           "N.B.: 3D+time datasets\n"
01511                           " must be anatomical."     ) ;
01512    MCW_reghint_children( wset.dataset_type_av->wrowcol ,
01513                          "Type of data you acquired" ) ;
01514 
01515    if( user_inputs.ntt > 0 )
01516       AV_SENSITIZE( wset.dataset_type_av , False ) ;
01517 
01518    wset.function_type_av =
01519       new_MCW_arrowval(
01520              wset.topform ,                      /* parent */
01521              "Type of function \nin the images", /* label */
01522              MCW_AV_downup ,                     /* arrows */
01523              FIRST_FUNC_TYPE ,                   /* min */
01524              LAST_FUNC_TYPE ,                    /* max */
01525              user_inputs.function_type ,         /* init */
01526              MCW_AV_readtext ,                   /* text type */
01527              0 ,                                 /* decimals */
01528              T3D_type_av_CB , NULL ,             /* callback */
01529              T3D_text_display ,                  /* text maker */
01530              FUNC_typestr                        /* and data */
01531        ) ;
01532 
01533    wset.function_type_av->allow_wrap = 1 ;
01534 
01535    XtVaSetValues( wset.function_type_av->wtext ,
01536                      XmNcolumns   , LONGEST_FUNC_TYPESTR ,
01537                      XmNmaxLength , LONGEST_FUNC_TYPESTR ,
01538                   NULL ) ;
01539 
01540    XtVaSetValues( wset.function_type_av->wrowcol ,
01541                      XmNleftAttachment , XmATTACH_WIDGET ,
01542                      XmNleftOffset     , T3D_FORM_SPACING ,
01543                      XmNtopAttachment  , XmATTACH_WIDGET ,
01544                      XmNtopOffset      , T3D_FORM_SPACING ,
01545                      XmNleftWidget     , wset.geometry_parent_textfield ,
01546 #ifndef NO_NAMES
01547                      XmNtopWidget      , wset.geometry_dataname_textfield ,
01548 #else
01549                      XmNtopWidget      , wset.geometry_parent_textfield ,
01550 #endif
01551                      XtNmappedWhenManaged , False ,
01552                   NULL ) ;
01553 
01554    MCW_reghelp_children( wset.function_type_av->wrowcol ,
01555     "Use the arrows to specify\n"
01556     "the type of functional data\n"
01557     "stored in the image files" ) ;
01558    MCW_reghint_children( wset.function_type_av->wrowcol ,
01559                          "Type of functional data" ) ;
01560 
01561    wset.anatomy_type_av =
01562       new_MCW_arrowval(
01563              wset.topform ,                      /* parent */
01564              "Type of anatomy  \nin the images", /* label */
01565              MCW_AV_downup ,                     /* arrows */
01566              FIRST_ANAT_TYPE ,                   /* min */
01567              LAST_ANAT_TYPE ,                    /* max */
01568              user_inputs.anatomy_type ,          /* init */
01569              MCW_AV_readtext ,                   /* text type */
01570              0 ,                                 /* decimals */
01571              T3D_type_av_CB , NULL ,             /* callback */
01572              T3D_text_display ,                  /* text maker */
01573              ANAT_typestr                        /* and data */
01574        ) ;
01575 
01576    wset.anatomy_type_av->allow_wrap = 1 ;
01577 
01578    XtVaSetValues( wset.anatomy_type_av->wtext ,
01579                      XmNcolumns   , LONGEST_ANAT_TYPESTR ,
01580                      XmNmaxLength , LONGEST_ANAT_TYPESTR ,
01581                   NULL ) ;
01582 
01583    XtVaSetValues( wset.anatomy_type_av->wrowcol ,
01584                      XmNleftAttachment , XmATTACH_WIDGET ,
01585                      XmNleftWidget     , wset.geometry_parent_textfield ,
01586 #ifndef NO_NAMES
01587                      XmNtopWidget      , wset.geometry_dataname_textfield ,
01588 #else
01589                      XmNtopWidget      , wset.geometry_parent_textfield ,
01590 #endif
01591                      XmNleftOffset     , T3D_FORM_SPACING ,
01592                      XmNtopAttachment  , XmATTACH_WIDGET ,
01593                      XmNtopOffset      , T3D_FORM_SPACING ,
01594                      XtNmappedWhenManaged , False ,
01595                   NULL ) ;
01596 
01597    MCW_reghelp_children( wset.anatomy_type_av->wrowcol ,
01598     "Use the arrows to specify\n"
01599     "the type of anatomical data\n"
01600     "stored in the image files" ) ;
01601    MCW_reghint_children( wset.anatomy_type_av->wrowcol ,
01602                          "Type of anatomical data" ) ;
01603 
01604    /*----- stat_aux data fields -----*/
01605 
01606    wset.stat_aux_label =
01607       XtVaCreateManagedWidget(
01608          "dialog" , xmLabelWidgetClass , wset.topform ,
01609             XmNleftAttachment , XmATTACH_FORM ,
01610             XmNleftOffset     , T3D_FORM_SPACING ,
01611             XmNtopAttachment  , XmATTACH_WIDGET ,
01612             XmNtopWidget      , wset.dataset_type_av->wrowcol ,
01613             XmNtopOffset      , T3D_FORM_SPACING ,
01614          NULL ) ;
01615 
01616    wset.stat_aux_textfield =
01617       XtVaCreateManagedWidget(
01618          "dialog" , xmTextFieldWidgetClass , wset.topform ,
01619             XmNcolumns        , 80 ,
01620             XmNeditable       , True ,
01621             XmNmaxLength      , THD_MAX_NAME-1 ,
01622             XmNresizeWidth    , False ,
01623             XmNcursorPositionVisible , True ,
01624             XmNblinkRate , 0 ,
01625             XmNleftAttachment , XmATTACH_FORM ,
01626             XmNleftOffset     , T3D_FORM_SPACING ,
01627             XmNtopAttachment  , XmATTACH_WIDGET ,
01628             XmNtopWidget      , wset.stat_aux_label ,
01629             XmNtopOffset      , 1 ,
01630          NULL ) ;
01631 
01632     MCW_register_help( wset.stat_aux_label ,
01633       "Some types of functional data require input\n"
01634       "of extra statistical parameters.  These\n"
01635       "values should be entered in the text field\n"
01636       "below, separated by spaces and/or commas.\n"
01637       "\n"
01638       " Inten+Cor requires the number of\n"
01639       "   samples (images) used, the number of\n"
01640       "   fitting parameters, and the number of\n"
01641       "   orthogonalization parameters.\n"
01642       "\n"
01643       " Inten+Ttest requires the number of\n"
01644       "   degrees-of-freedom in the t-test."
01645     ) ;
01646 
01647     MCW_register_help( wset.stat_aux_textfield ,
01648       "Some types of functional data require input\n"
01649       "of extra statistical parameters.  These\n"
01650       "values should be entered in this text field,\n"
01651       "separated by spaces and/or commas.\n"
01652       "\n"
01653       " Inten+Cor requires the number of\n"
01654       "   samples (images) used, the number of\n"
01655       "   fitting parameters, and the number of\n"
01656       "   orthogonalization parameters.\n"
01657       "\n"
01658       " Inten+Ttest requires the number of\n"
01659       "   degrees-of-freedom in the t-test."
01660     ) ;
01661 
01662     MCW_register_hint( wset.stat_aux_label , "Extra statistical parameters" ) ;
01663     MCW_register_hint( wset.stat_aux_textfield , "Extra statistical parameters" ) ;
01664 
01665    /** The stuff below is commented out,
01666        since the textfield is scanned only at the write-out time **/
01667 
01668 #if 0
01669    XtAddCallback( wset.stat_aux_textfield ,
01670                   XmNactivateCallback ,
01671                   T3D_stat_aux_CB , NULL ) ;    /* return key */
01672 
01673    XtAddCallback( wset.stat_aux_textfield ,
01674                   XmNlosingFocusCallback ,
01675                   T3D_stat_aux_CB , NULL ) ;    /* Tab key */
01676 
01677    XtInsertEventHandler( wset.stat_aux_textfield ,
01678                          LeaveWindowMask ,             /* pointer leaves */
01679                          FALSE ,
01680                          T3D_pointer_leave_EV , NULL ,
01681                          XtListTail ) ;                /* last in queue */
01682 #endif
01683 
01684    /*--- output locations ---*/
01685 
01686    wset.output_file_label =
01687       XtVaCreateManagedWidget(
01688          "dialog" , xmLabelWidgetClass , wset.topform ,
01689             LABEL_ARG("Prefix for 3D  \nDataset file   ") ,
01690 
01691             XmNleftAttachment , XmATTACH_WIDGET ,
01692             XmNleftWidget     , wset.geometry_parent_textfield ,
01693             XmNleftOffset     , T3D_FORM_SPACING ,
01694             XmNtopAttachment  , XmATTACH_WIDGET ,
01695             XmNtopWidget      , wset.stat_aux_textfield ,
01696             XmNtopOffset      , T3D_FORM_SPACING ,
01697             XmNbottomAttachment , XmATTACH_FORM ,
01698             XmNbottomOffset     , T3D_FORM_SPACING ,
01699          NULL ) ;
01700 
01701    wset.output_file_textfield =
01702       XtVaCreateManagedWidget(
01703          "dialog" , xmTextFieldWidgetClass , wset.topform ,
01704             XmNcolumns         , T3D_NAME_WIDTH ,
01705             XmNeditable        , True ,
01706             XmNmaxLength       , THD_MAX_PREFIX-1 ,
01707             XmNresizeWidth     , False ,
01708             XmNcursorPositionVisible , True ,
01709             XmNblinkRate , 0 ,
01710 /*
01711             XmNmarginHeight    , 1 ,
01712             XmNmarginWidth     , 1 ,
01713 */
01714             XmNvalue           , user_inputs.output_filename ,
01715 
01716             XmNleftAttachment , XmATTACH_WIDGET ,
01717             XmNleftOffset     , T3D_FORM_SPACING ,
01718             XmNleftWidget     , wset.output_file_label ,
01719             XmNtopAttachment  , XmATTACH_OPPOSITE_WIDGET ,
01720             XmNtopWidget      , wset.output_file_label ,
01721             XmNtopOffset      , 0 ,
01722 
01723          NULL ) ;
01724 
01725    MCW_register_help( wset.output_file_label ,
01726     "Type in the 'prefix' for the filenames\n"
01727     "that the 3D dataset will be saved in.\n"
01728     "[The actual filenames will be of the\n"
01729     " form prefix+orig.suff, where suff =\n"
01730     " " DATASET_HEADER_SUFFIX " and " DATASET_BRICK_SUFFIX "]" ) ;
01731 
01732    MCW_register_help( wset.output_file_textfield ,
01733     "Type in the 'prefix' for the filenames\n"
01734     "that the 3D dataset will be saved in.\n"
01735     "[The actual filenames will be of the\n"
01736     " form prefix+orig.suff, where suff =\n"
01737     " " DATASET_HEADER_SUFFIX " and " DATASET_BRICK_SUFFIX "]" ) ;
01738 
01739    MCW_register_hint( wset.output_file_label ,
01740                       "New dataset's 'prefix' for filenames" ) ;
01741    MCW_register_hint( wset.output_file_textfield ,
01742                       "New dataset's 'prefix' for filenames" ) ;
01743 
01744    wset.session_file_label =
01745       XtVaCreateManagedWidget(
01746          "dialog" , xmLabelWidgetClass , wset.topform ,
01747             LABEL_ARG("Session direct.\nfor 3D Datasets") ,
01748 
01749             XmNleftAttachment , XmATTACH_FORM ,
01750             XmNleftOffset     , T3D_FORM_SPACING ,
01751             XmNtopAttachment  , XmATTACH_WIDGET ,
01752             XmNtopWidget      , wset.stat_aux_textfield ,
01753             XmNtopOffset      , T3D_FORM_SPACING ,
01754          NULL ) ;
01755 
01756    wset.session_file_textfield =
01757       XtVaCreateManagedWidget(
01758          "dialog" , xmTextFieldWidgetClass , wset.topform ,
01759             XmNcolumns         , T3D_NAME_WIDTH ,
01760             XmNeditable        , True ,
01761             XmNmaxLength       , THD_MAX_NAME-1 ,
01762             XmNresizeWidth     , False ,
01763             XmNcursorPositionVisible , True ,
01764             XmNblinkRate , 0 ,
01765 /*
01766             XmNmarginHeight    , 1 ,
01767             XmNmarginWidth     , 1 ,
01768 */
01769             XmNvalue           , user_inputs.session_filename ,
01770 
01771             XmNleftAttachment , XmATTACH_WIDGET ,
01772             XmNleftOffset     , T3D_FORM_SPACING ,
01773             XmNleftWidget     , wset.session_file_label ,
01774             XmNtopAttachment  , XmATTACH_OPPOSITE_WIDGET ,
01775             XmNtopWidget      , wset.session_file_label ,
01776             XmNtopOffset      , 0 ,
01777 
01778          NULL ) ;
01779 
01780    MCW_register_help( wset.session_file_label ,
01781     "Type in the name of the session\n"
01782     "directory in which to save this\n"
01783     "3D dataset, and in which to look\n"
01784     "for the 'parent' datasets" ) ;
01785 
01786    MCW_register_help( wset.session_file_textfield ,
01787     "Type in the name of the session\n"
01788     "directory in which to save this\n"
01789     "3D dataset, and in which to look\n"
01790     "for the 'parent' datasets" ) ;
01791 
01792    MCW_register_hint( wset.session_file_label , "New dataset's directory" ) ;
01793    MCW_register_hint( wset.session_file_textfield , "New dataset's directory" ) ;
01794 
01795    printf(".");fflush(stdout);
01796 
01797    /*----- action controls at lower right corner -----*/
01798 
01799    wset.action_frame =
01800       XtVaCreateManagedWidget(
01801          "dialog" , xmFrameWidgetClass , wset.topform ,
01802             XmNshadowType       , XmSHADOW_ETCHED_IN ,
01803             XmNleftAttachment   , XmATTACH_WIDGET ,
01804             XmNleftWidget       , wset.anatomy_parent_textfield ,
01805             XmNleftOffset       , T3D_FORM_SPACING ,
01806             XmNbottomAttachment , XmATTACH_FORM ,
01807             XmNbottomOffset     , T3D_FORM_SPACING ,
01808          NULL ) ;
01809 
01810    wset.action_rowcol =
01811       XtVaCreateWidget(
01812          "dialog" , xmRowColumnWidgetClass , wset.action_frame ,
01813             XmNorientation , XmVERTICAL ,
01814             XmNpacking     , XmPACK_TIGHT ,
01815          NULL ) ;
01816 
01817    /* 14 Sep 1998: add a button to swap bytes in the image data */
01818 
01819    { int    dd = mri_datum_size((MRI_TYPE)argopt.datum_all) ;
01820      char * tt = "Byte Swap[2]" ;
01821      char * ff = "Byte Swap[4]" ;
01822      if( dd == 2 || dd == 4 ){
01823         if( dd == 2 )
01824            wset.swap_pb =
01825             XtVaCreateManagedWidget(
01826                "dialog" , xmPushButtonWidgetClass , wset.action_rowcol ,
01827                   LABEL_ARG(tt) , NULL ) ;
01828          else
01829            wset.swap_pb =
01830             XtVaCreateManagedWidget(
01831                "dialog" , xmPushButtonWidgetClass , wset.action_rowcol ,
01832                   LABEL_ARG(ff) , NULL ) ;
01833 
01834          XtAddCallback( wset.swap_pb , XmNactivateCallback ,
01835                         T3D_swap_CB , NULL ) ;
01836          MCW_register_hint( wset.swap_pb , "Use if images need this" ) ;
01837      } else {
01838         wset.swap_pb = NULL ;
01839      }
01840    }
01841 
01842    wset.button_help_pb =
01843       XtVaCreateManagedWidget(
01844          "dialog" , xmPushButtonWidgetClass , wset.action_rowcol ,
01845             LABEL_ARG("button help") ,
01846          NULL ) ;
01847    XtAddCallback( wset.button_help_pb , XmNactivateCallback ,
01848                   MCW_click_help_CB , NULL ) ;
01849    MCW_register_help( wset.button_help_pb ,
01850      "Click the hand\non any button to get\na little help" ) ;
01851    MCW_register_hint( wset.button_help_pb , "Get more help" ) ;
01852 
01853    wset.open_view_pb =
01854       XtVaCreateManagedWidget(
01855          "dialog" , xmPushButtonWidgetClass , wset.action_rowcol ,
01856             LABEL_ARG("View Images") ,
01857          NULL ) ;
01858    XtAddCallback( wset.open_view_pb , XmNactivateCallback ,
01859                   T3D_open_view_CB , NULL ) ;
01860    MCW_register_help( wset.open_view_pb ,
01861     "Use this to open a window to see the images;\n"
01862     "N.B.: If you use the viewing controls to change the\n"
01863     "      orientation of the images, then you must be\n"
01864     "      aware that 'x' and 'y' in the geometry controls\n"
01865     "      above refer to the images in their ORIGINAL\n"
01866     "      orientation on the screen, NOT in the rotated\n"
01867     "      and/or mirrored orientation you will be viewing." ) ;
01868    MCW_register_hint( wset.open_view_pb , "See the input images" ) ;
01869 
01870    wset.save_file_pb =
01871       XtVaCreateManagedWidget(
01872          "dialog" , xmPushButtonWidgetClass , wset.action_rowcol ,
01873             LABEL_ARG("Save Dataset") ,
01874          NULL ) ;
01875    XtAddCallback( wset.save_file_pb , XmNactivateCallback ,
01876                   T3D_save_file_CB , NULL ) ;
01877    MCW_register_help( wset.save_file_pb ,
01878     "Use this to save the volume data\n"
01879     "into 3D dataset files when you\n"
01880     "have set all the control data." ) ;
01881    MCW_register_hint( wset.save_file_pb , "Write new dataset to disk" ) ;
01882 
01883    wset.quit_pb =
01884       XtVaCreateManagedWidget(
01885          "dialog" , xmPushButtonWidgetClass , wset.action_rowcol ,
01886             XmNrecomputeSize , False ,
01887             LABEL_ARG("quit") ,
01888          NULL ) ;
01889    XtAddCallback( wset.quit_pb , XmNactivateCallback ,
01890                   T3D_quit_CB , NULL ) ;
01891    MCW_register_help( wset.quit_pb ,
01892     "Press this button TWICE\nto exit the program" ) ;
01893    MCW_register_hint( wset.quit_pb , "Press twice to exit program" ) ;
01894 
01895    MCW_set_widget_bg( wset.quit_pb , MCW_hotcolor(wset.quit_pb) , 0 ) ;
01896 
01897    XtManageChild( wset.action_rowcol ) ;
01898 
01899    printf(".");fflush(stdout);
01900 
01901    /*----- all done -----*/
01902 
01903    XtManageChild( wset.topform ) ;
01904 
01905    XtRealizeWidget( wset.topshell ) ;
01906 
01907    WAIT_for_window( wset.topshell ) ;  /* 10 Sep 2002 */
01908    wset.good = 1 ;
01909 
01910    T3D_data_to_widgets() ;
01911    T3D_set_dependent_geometries() ;
01912 
01913    EXRETURN ;
01914 }

void T3D_data_to_widgets void   
 

scan thru string, converting to floats *

Definition at line 5055 of file to3d.c.

References to3d_data::anatomy_dataname, to3d_data::anatomy_parent_filename, to3d_widget_set::anatomy_parent_textfield, to3d_data::anatomy_type, to3d_widget_set::anatomy_type_av, AV_assign_fval(), AV_assign_ival(), to3d_widget_set::centered_bbox, to3d_data::dataset_name, to3d_data::dataset_type, to3d_widget_set::dataset_type_av, to3d_data::fov, to3d_widget_set::fov_av, to3d_data::function_type, to3d_widget_set::function_type_av, to3d_data::geometry_dataname, to3d_data::geometry_parent_filename, to3d_widget_set::geometry_parent_textfield, to3d_widget_set::good, MAX_STAT_AUX, MCW_set_bbox(), to3d_widget_set::output_file_textfield, to3d_data::output_filename, to3d_widget_set::session_file_textfield, to3d_data::session_filename, SET_ORIGIN_LABEL, to3d_data::short_label1, to3d_data::stat_aux, to3d_widget_set::stat_aux_textfield, T3D_centered_CB(), T3D_setup_stat_aux(), T3D_type_av_CB(), T3D_voxcontig_CB(), T3D_voxshape_CB(), to3d_widget_set::topshell, to3d_data::voxcontig, to3d_widget_set::voxcontig_bbox, to3d_data::voxshape, to3d_widget_set::voxshape_bbox, to3d_data::xorient, to3d_widget_set::xorient_av, to3d_data::xorigin, to3d_widget_set::xorigin_av, to3d_widget_set::xorigin_label, to3d_data::xsize, to3d_widget_set::xsize_av, to3d_data::xyz_centered, to3d_data::yorient, to3d_widget_set::yorient_av, to3d_data::yorigin, to3d_widget_set::yorigin_av, to3d_widget_set::yorigin_label, to3d_data::ysize, to3d_widget_set::ysize_av, to3d_data::zorient, to3d_widget_set::zorient_av, to3d_data::zorigin, to3d_widget_set::zorigin_av, to3d_widget_set::zorigin_label, to3d_data::zsize, to3d_widget_set::zsize_av, to3d_data::zspacing, and to3d_widget_set::zspacing_av.

Referenced by T3D_create_widgets(), and T3D_geometry_parent_CB().

05056 {
05057    if( wset.topshell == NULL || !wset.good ) return ;  /* no widgets! */
05058 
05059    AV_assign_ival( wset.xorient_av , user_inputs.xorient ) ;
05060    AV_assign_ival( wset.yorient_av , user_inputs.yorient ) ;
05061    AV_assign_ival( wset.zorient_av , user_inputs.zorient ) ;
05062 
05063    MCW_set_bbox( wset.voxshape_bbox  , user_inputs.voxshape     ) ;
05064 #ifdef ALLOW_NONCONTIG
05065    MCW_set_bbox( wset.voxcontig_bbox , user_inputs.voxcontig    ) ;
05066 #endif
05067    MCW_set_bbox( wset.centered_bbox  , user_inputs.xyz_centered ) ;
05068 
05069    AV_assign_ival( wset.dataset_type_av  , user_inputs.dataset_type ) ;
05070    AV_assign_ival( wset.function_type_av , user_inputs.function_type ) ;
05071    AV_assign_ival( wset.anatomy_type_av , user_inputs.anatomy_type ) ;
05072 
05073    AV_assign_fval( wset.fov_av       , user_inputs.fov ) ;
05074    AV_assign_fval( wset.xsize_av     , user_inputs.xsize ) ;
05075    AV_assign_fval( wset.ysize_av     , user_inputs.ysize ) ;
05076    AV_assign_fval( wset.zsize_av     , user_inputs.zsize ) ;
05077 #ifdef ALLOW_NONCONTIG
05078    AV_assign_fval( wset.zspacing_av  , user_inputs.zspacing ) ;
05079 #endif
05080    AV_assign_fval( wset.xorigin_av   , user_inputs.xorigin ) ;
05081    AV_assign_fval( wset.yorigin_av   , user_inputs.yorigin ) ;
05082    AV_assign_fval( wset.zorigin_av   , user_inputs.zorigin ) ;
05083 
05084    SET_ORIGIN_LABEL(wset.xorigin_label,user_inputs.xorient) ;
05085    SET_ORIGIN_LABEL(wset.yorigin_label,user_inputs.yorient) ;
05086    SET_ORIGIN_LABEL(wset.zorigin_label,user_inputs.zorient) ;
05087 
05088    T3D_voxshape_CB (NULL,NULL,NULL) ;  /* take actions based on */
05089 #ifdef ALLOW_NONCONTIG
05090    T3D_voxcontig_CB(NULL,NULL,NULL) ;  /* settings of these toggles */
05091 #endif
05092    T3D_centered_CB (NULL,NULL,NULL) ;
05093 
05094    T3D_type_av_CB( wset.dataset_type_av , NULL ) ;  /* set dataset type */
05095 
05096 #ifndef NO_NAMES
05097    XmTextFieldSetString( wset.dataset_name_textfield ,
05098                          user_inputs.dataset_name ) ;
05099 
05100    XmTextFieldSetString( wset.short_label1_textfield ,
05101                          user_inputs.short_label1 ) ;
05102 #endif
05103 
05104    XmTextFieldSetString( wset.geometry_parent_textfield ,
05105                          user_inputs.geometry_parent_filename ) ;
05106 
05107    XmTextFieldSetString( wset.anatomy_parent_textfield ,
05108                          user_inputs.anatomy_parent_filename ) ;
05109 
05110    XmTextFieldSetString( wset.output_file_textfield ,
05111                          user_inputs.output_filename ) ;
05112 
05113    XmTextFieldSetString( wset.session_file_textfield ,
05114                          user_inputs.session_filename ) ;
05115 
05116 #ifndef NO_NAMES
05117    XmTextFieldSetString( wset.geometry_dataname_textfield ,
05118                          user_inputs.geometry_dataname ) ;
05119 
05120    XmTextFieldSetString( wset.anatomy_dataname_textfield ,
05121                          user_inputs.anatomy_dataname ) ;
05122 #endif
05123 
05124    /* April 1996: stat_aux data fields */
05125 
05126    T3D_setup_stat_aux() ;
05127 
05128    { int ii,num,bl ; char buf[256] ;
05129 
05130      for( ii=MAX_STAT_AUX-1 ; ii>=0 && user_inputs.stat_aux[ii]==0.0 ; ii-- ) ; /* nada */
05131      num = ii+1 ;
05132 
05133      if( num > 0 ){
05134        buf[0] = '\0' ;
05135        for( ii=0 ; ii < num ; ii++ ){
05136           bl = strlen(buf) ; if( bl+12 > 256 ) break ;
05137           sprintf( buf+bl , "%g " , user_inputs.stat_aux[ii] ) ;
05138        }
05139        XmTextFieldSetString( wset.stat_aux_textfield , buf ) ;
05140      }
05141    }
05142 
05143    return ;
05144 }

void T3D_fix_dataset_dimen void   
 

Definition at line 3825 of file to3d.c.

References argopt, THD_datablock::brick_bytes, THD_datablock::brick_fac, DBLK_BRICK, dbrick, THD_diskptr::dimsizes, ENTRY, mri_clear_data_pointer, mri_datum_size(), mri_fix_data_pointer(), myXtFree, THD_datablock::nvals, THD_diskptr::nvals, to3d_data::nvals, to3d_data::nx, to3d_data::ny, nz, to3d_data::nz, THD_dataxes::nzz, and THD_init_datablock_brick().

Referenced by T3D_type_av_CB().

03826 {
03827    int nx , ny , nz , nv , ibr , bsize , nvold ;
03828 
03829 ENTRY("T3D_fix_dataset_dimen") ;
03830 
03831    nvold = dblk->nvals ;
03832 
03833    nv = dblk->nvals = dkptr->nvals  = user_inputs.nvals ;
03834    nx = user_inputs.nx ;
03835    ny = user_inputs.ny ;
03836    nz = daxes->nzz = dkptr->dimsizes[2]  = user_inputs.nz ;
03837 
03838    for( ibr=0 ; ibr < nvold ; ibr++ )
03839       mri_clear_data_pointer( DBLK_BRICK(dblk,ibr) ) ;
03840 
03841    myXtFree(dblk->brick_bytes) ; dblk->brick_bytes = NULL ;
03842    myXtFree(dblk->brick_fac  ) ; dblk->brick_fac   = NULL ;
03843 
03844    THD_init_datablock_brick( dblk , argopt.datum_all , NULL ) ;
03845 
03846    bsize = nx*ny*nz * mri_datum_size( argopt.datum_all ) ;
03847    for( ibr=0 ; ibr < nv ; ibr++ ){
03848       mri_fix_data_pointer( dbrick + ibr*bsize , DBLK_BRICK(dblk,ibr) ) ;
03849    }
03850 
03851    EXRETURN ;
03852 }

void T3D_fov_av_CB MCW_arrowval   av,
XtPointer    cd
 

Definition at line 3674 of file to3d.c.

References to3d_data::fov, to3d_widget_set::fov_av, MCW_arrowval::fval, RESET_QUIT, and T3D_set_dependent_geometries().

Referenced by T3D_create_widgets().

03675 {
03676    user_inputs.fov = wset.fov_av->fval ;
03677    T3D_set_dependent_geometries() ;
03678    RESET_QUIT ;
03679 }

void T3D_geometry_parent_CB Widget    w,
XtPointer    client_data,
XtPointer    call_data
 

Definition at line 5343 of file to3d.c.

References THD_3dim_dataset::anat_parent_idcode, THD_3dim_dataset::anat_parent_name, to3d_data::anatomy_dataname, to3d_data::anatomy_parent_idcode, client_data, THD_3dim_dataset::daxes, THD_3dim_dataset::dblk, DEBLANK, ENTRY, FILENAME_TO_PREFIX, to3d_data::fov, to3d_data::geometry_dataname, geometry_loaded, to3d_data::geometry_parent_filename, geomparent_loaded, ATR_int::in, INERR, MCW_strncpy, myXtFree, ATR_int::nin, to3d_data::nx, THD_dataxes::nxx, to3d_data::ny, THD_dataxes::nyy, to3d_data::nz, THD_dataxes::nzz, PATH_CONCAT, THD_3dim_dataset::self_name, to3d_widget_set::session_file_textfield, to3d_data::session_filename, T3D_data_to_widgets(), T3D_poperr(), T3D_widgets_to_data(), THD_delete_3dim_dataset(), THD_find_int_atr(), THD_MAX_NAME, THD_open_one_dataset(), to3d_data::voxcontig, VOXCONTIG_UNIF, VOXCONTIG_YES, to3d_data::voxshape, VOXSHAPE_CUBICAL, VOXSHAPE_IRREGULAR, VOXSHAPE_SQUARE, XCENTERED, to3d_data::xorient, to3d_data::xorigin, to3d_data::xsize, THD_dataxes::xxdel, THD_dataxes::xxorg, THD_dataxes::xxorient, to3d_data::xyz_centered, YCENTERED, to3d_data::yorient, to3d_data::yorigin, to3d_data::ysize, THD_dataxes::yydel, THD_dataxes::yyorg, THD_dataxes::yyorient, ZCENTERED, to3d_data::zorient, to3d_data::zorigin, zpad, to3d_data::zsize, to3d_data::zspacing, THD_dataxes::zzdel, THD_dataxes::zzorg, and THD_dataxes::zzorient.

Referenced by main(), and T3D_create_widgets().

05345 {
05346    static char * old_name = NULL ;
05347    char * new_name ;
05348    float size ;
05349    char new_path[THD_MAX_NAME] , new_pref[THD_MAX_NAME] ;
05350    THD_3dim_dataset * geom_dset ;
05351    THD_dataxes      * geom_daxes ;
05352 
05353    int xpad=0,ypad=0,zpad=0 ;  /* 05 Feb 2001 */
05354 
05355 ENTRY("T3D_geometry_parent_CB") ;
05356 
05357    if( old_name == NULL ) old_name = XtNewString("Elvis Lives!!!") ;
05358 
05359    if( w != NULL ){
05360       new_name = XmTextFieldGetString( w ) ;  /* get the new text */
05361    } else {
05362       new_name = XtNewString( user_inputs.geometry_parent_filename ) ;
05363    }
05364    DEBLANK(new_name) ;
05365 
05366    if( strlen(new_name) == 0 )         { old_name = new_name ; geomparent_loaded = 0 ; EXRETURN ; }
05367    if( strcmp(new_name,old_name) == 0 ){ myXtFree(new_name) ; geomparent_loaded = 0 ; EXRETURN ; }
05368 
05369    /* have a new filename --> try to read dataset from it */
05370 
05371    myXtFree(old_name) ; old_name = new_name ;
05372 
05373    /* make a pathname to the geometry dataset */
05374 
05375    if( strstr(new_name,"/") == NULL ){
05376       char * sess ;
05377       if( w != NULL ) sess = XmTextFieldGetString(wset.session_file_textfield);
05378       else            sess = XtNewString( user_inputs.session_filename ) ;
05379       DEBLANK(sess) ;
05380       if( strlen(sess) > 0 ){
05381          PATH_CONCAT( new_path , sess , new_name ) ;
05382       } else {
05383          strcpy( new_path , new_name ) ;
05384       }
05385       myXtFree(sess) ;
05386    } else {
05387       strcpy( new_path , new_name ) ;
05388    }
05389 
05390    FILENAME_TO_PREFIX(new_path,new_pref) ;
05391    if( strlen(new_pref) == 0 ) strcat(new_path,"+orig") ;
05392 
05393    /* read dataset from this path */
05394 
05395    geom_dset = THD_open_one_dataset( new_path ) ;
05396    if( geom_dset == NULL ){
05397       T3D_poperr( INERR ,
05398                   "Cannot read 3D dataset\nin geometry parent file" ) ;
05399       geomparent_loaded = 0 ; EXRETURN ;
05400    }
05401 
05402    /* 05 Feb 2001: set if this was a 'padded' dataset from an earlier to3d */
05403 
05404    { ATR_int * atr ;
05405      atr = THD_find_int_atr( geom_dset->dblk , "TO3D_ZPAD" ) ;
05406      if( atr != NULL && atr->nin >= 3 ){
05407         xpad = atr->in[0] ;
05408         ypad = atr->in[1] ;
05409         zpad = atr->in[2] ;
05410      }
05411    }
05412 
05413    geom_daxes = geom_dset->daxes ;
05414 
05415    if( geom_daxes->nxx - 2*xpad != user_inputs.nx ||
05416        geom_daxes->nyy - 2*ypad != user_inputs.ny ||
05417        geom_daxes->nzz - 2*zpad != user_inputs.nz   ){
05418 
05419        char msg[256] ;
05420 
05421        sprintf(msg,
05422                  "*** Shape mismatch!! ***\n"
05423                  "file   nx=%d ny=%d nz=%d (zpad=%d)\n"
05424                  "images nx=%d ny=%d nz=%d",
05425                geom_daxes->nxx,geom_daxes->nyy,geom_daxes->nzz,zpad,
05426                user_inputs.nx ,user_inputs.ny ,user_inputs.nz  ) ;
05427 
05428        T3D_poperr( INERR , msg ) ;
05429        THD_delete_3dim_dataset( geom_dset , False ) ;
05430        geomparent_loaded = 0 ; EXRETURN ;
05431    }
05432 
05433 #ifdef ALLOW_NONCONTIG
05434    if( geom_daxes->xxskip != 0.0 || geom_daxes->yyskip != 0.0 ){
05435       T3D_poperr( INERR , "Nonzero skip factors for x and y!" ) ;
05436       THD_delete_3dim_dataset( geom_dset , False ) ;
05437       geomparent_loaded = 0 ; EXRETURN ;
05438    }
05439 #endif
05440 
05441    /* at this point, the geom dataset seems OK, so copy its axes data */
05442 
05443    /* but first, load all data from the widgets into the user_inputs
05444       (this will mean that the T3D_data_to_widgets call later won't
05445        clobber any un-altered but currently un-saved data fields    */
05446 
05447    T3D_widgets_to_data() ;
05448 
05449 #ifdef REQUIRE_ANAT_PARENT
05450    if( strlen(geom_dset->anat_parent_name) > 0 ){
05451       MCW_strncpy( user_inputs.anatomy_dataname ,
05452                    geom_dset->anat_parent_name, THD_MAX_NAME ) ;
05453       user_inputs.anatomy_parent_idcode = geom_dset->anat_parent_idcode ;
05454    }
05455 #endif
05456 
05457    MCW_strncpy( user_inputs.geometry_dataname ,
05458                 geom_dset->self_name , THD_MAX_NAME ) ;
05459 
05460    MCW_strncpy( user_inputs.geometry_parent_filename ,
05461                 new_name , THD_MAX_NAME ) ;
05462 
05463    user_inputs.xorient = geom_daxes->xxorient ;
05464    user_inputs.yorient = geom_daxes->yyorient ;
05465    user_inputs.zorient = geom_daxes->zzorient ;
05466 
05467 #if 0  /* Bad stuff, replaced June 20, 1995 */
05468 
05469    user_inputs.xorigin = fabs(geom_daxes->xxorg) ;
05470    user_inputs.yorigin = fabs(geom_daxes->yyorg) ;
05471    user_inputs.zorigin = fabs(geom_daxes->zzorg) ;
05472 
05473 #else  /* newer stuff [05 Feb 2001] - allow for padding in to3d before */
05474 
05475    { float xorg = geom_daxes->xxorg + xpad * geom_daxes->xxdel ;
05476      float yorg = geom_daxes->yyorg + ypad * geom_daxes->yydel ;
05477      float zorg = geom_daxes->zzorg + zpad * geom_daxes->zzdel ;
05478 
05479      user_inputs.xorigin = (ORIENT_sign[user_inputs.xorient] == '+')
05480                            ? (-xorg) : (xorg) ;
05481      user_inputs.yorigin = (ORIENT_sign[user_inputs.yorient] == '+')
05482                            ? (-yorg) : (yorg) ;
05483      user_inputs.zorigin = (ORIENT_sign[user_inputs.zorient] == '+')
05484                            ? (-zorg) : (zorg) ;
05485    }
05486 #endif
05487 
05488    user_inputs.xsize    = fabs(geom_daxes->xxdel) ;
05489    user_inputs.ysize    = fabs(geom_daxes->yydel) ;
05490 #ifdef ALLOW_NONCONTIG
05491    user_inputs.zspacing = fabs(geom_daxes->zzdel) ;
05492    user_inputs.zsize    = user_inputs.zspacing - geom_daxes->zzskip ;
05493 #else
05494    user_inputs.zsize    = fabs(geom_daxes->zzdel) ;
05495 #endif
05496 
05497    /*-- set the vox*_bbox values depending on initial sizes --*/
05498 
05499    if( user_inputs.xsize != user_inputs.ysize ){
05500       user_inputs.voxshape = VOXSHAPE_IRREGULAR ;
05501    } else {
05502       if( user_inputs.xsize != user_inputs.zsize ){
05503          user_inputs.voxshape = VOXSHAPE_SQUARE ;
05504       } else {
05505          user_inputs.voxshape = VOXSHAPE_CUBICAL ;
05506       }
05507    }
05508    user_inputs.fov = user_inputs.xsize * user_inputs.nx ;
05509 
05510 #ifdef ALLOW_NONCONTIG
05511    if( geom_daxes->zzskip == 0 ) user_inputs.voxcontig = VOXCONTIG_YES ;
05512    else                          user_inputs.voxcontig = VOXCONTIG_UNIF ;
05513 #endif
05514 
05515    user_inputs.xyz_centered = 0 ;
05516 
05517    size = 0.5 * (user_inputs.nx-1) * user_inputs.xsize ;
05518    if( fabs(size - user_inputs.xorigin) < 0.01 )
05519       user_inputs.xyz_centered |= XCENTERED ;
05520 
05521    size = 0.5 * (user_inputs.ny-1) * user_inputs.ysize ;
05522    if( fabs(size - user_inputs.yorigin) < 0.01 )
05523       user_inputs.xyz_centered |= YCENTERED ;
05524 
05525    size = 0.5 * (user_inputs.nz-1) * user_inputs.zsize ;
05526    if( fabs(size - user_inputs.zorigin) < 0.01 )
05527       user_inputs.xyz_centered |= ZCENTERED ;
05528 
05529    T3D_data_to_widgets() ;
05530 
05531    THD_delete_3dim_dataset( geom_dset , False ) ;
05532 
05533    geometry_loaded   = 1 ;
05534    geomparent_loaded = 1 ;  /* flag that load was OK */
05535 
05536    EXRETURN ;
05537 }

XtPointer T3D_getim int    n,
int    type,
FD_brick   br
 

Definition at line 4601 of file to3d.c.

References MCW_imseq_status::aux, FD_brick_to_mri(), isqCR_getimage, isqCR_getoverlay, isqCR_getqimage, isqCR_getstatus, myXtNew, FD_brick::n3, MCW_imseq_status::num_series, MCW_imseq_status::num_total, MCW_imseq_status::parent, MCW_imseq_status::send_CB, MCW_imseq_status::slice_proj, T3D_imseq_CB(), MCW_imseq_status::transforms0D, and MCW_imseq_status::transforms2D.

Referenced by T3D_open_view_CB().

04602 {
04603    MCW_imseq_status * stat ;
04604 
04605    if( n < 0 || n >= br->n3 || type == isqCR_getoverlay ) return NULL ;
04606 
04607    if( type == isqCR_getstatus ){
04608       stat = myXtNew( MCW_imseq_status ) ;
04609 
04610       stat->num_total  = br->n3 ;
04611       stat->num_series = br->n3 ;
04612       stat->send_CB    = T3D_imseq_CB ;
04613       stat->parent     = (XtPointer) br ;
04614       stat->aux        = NULL ;
04615 
04616       stat->transforms0D = NULL ;
04617       stat->transforms2D = NULL ;
04618       stat->slice_proj   = NULL ;
04619 
04620       return (XtPointer) stat ;
04621    }
04622 
04623    if( type == isqCR_getimage || type == isqCR_getqimage ){
04624       return (XtPointer) FD_brick_to_mri( n , 0 , br ) ;
04625    }
04626 
04627    return NULL ; /* should never be reached */
04628 }

void T3D_imseq_CB MCW_imseq   seq,
FD_brick   br,
ISQ_cbs   cbs
 

Definition at line 4632 of file to3d.c.

References THD_string_array::ar, drive_MCW_imseq(), MCW_imseq::im_nr, isqCR_destroy, isqCR_force_redisplay, isqCR_newimage, isqDR_display, isqDR_rebar, isqDR_title, MCW_invert_widget(), myXtFree, ISQ_cbs::nim, to3d_widget_set::open_view_pb, ISQ_cbs::reason, and to3d_widget_set::seq.

Referenced by T3D_getim().

04633 {
04634    switch( cbs->reason ){
04635 
04636       case isqCR_destroy:
04637          myXtFree( seq ) ; wset.seq = NULL ;
04638          myXtFree( br ) ;
04639          MCW_invert_widget( wset.open_view_pb ) ;
04640       break ;
04641 
04642       case isqCR_newimage:
04643          drive_MCW_imseq( seq, isqDR_title, (XtPointer) imnames->ar[cbs->nim] ) ;
04644       break ;
04645 
04646       case isqCR_force_redisplay:{  /* 22 Aug 1998 */
04647          drive_MCW_imseq( seq , isqDR_display , (XtPointer) seq->im_nr ) ;
04648          drive_MCW_imseq( seq , isqDR_rebar   , (XtPointer) seq->im_nr ) ;
04649       }
04650 
04651    }
04652    return ;
04653 }

void T3D_initialize_user_data void   
 

Definition at line 1942 of file to3d.c.

References af_type_set, AFNI_log_string, ANAT_EPI_TYPE, to3d_data::anatomy_dataname, to3d_data::anatomy_parent_filename, to3d_data::anatomy_parent_idcode, to3d_data::anatomy_type, to3d_data::anatomy_type_string, Argc, argopt, Argv, commandline, to3d_data::dataset_name, to3d_data::dataset_type, to3d_data::dataset_type_string, decode_location(), EMPTY_STRING, ENTRY, FatalError, FIRST_ANAT_TYPE, FIRST_FUNC_TYPE, First_Image_Arg, FIRST_VIEW_TYPE, free, to3d_data::function_type, to3d_data::function_type_string, to3d_data::geometry_dataname, to3d_data::geometry_parent_filename, HEAD_ANAT_TYPE, HEAD_FUNC_TYPE, INCODE_FOV, INCODE_NONE, INCODE_SLAB, LAST_ANAT_TYPE, LAST_FUNC_TYPE, LAST_VIEW_TYPE, malloc, MAX_STAT_AUX, MCW_strncpy, my_getenv(), to3d_data::nosave, to3d_data::ntt, NZBOT, to3d_data::nzz, ORCODE, ORIENT_OPPOSITE, outliers_fname, to3d_data::output_filename, to3d_data::session_filename, to3d_data::short_label1, to3d_data::short_label2, to3d_data::stat_aux, strtod(), Syntax(), to3d_data::t_then_z, THD_filename_ok(), THD_MAX_LABEL, THD_MAX_NAME, THD_MAX_PREFIX, to3d_data::Torg, to3d_data::tpattern, to3d_data::TR, TR, tross_commandline(), to3d_data::tunits, UNITS_HZ_TYPE, UNITS_MSEC_TYPE, UNITS_SEC_TYPE, use_zoff, VIEW_ORIGINAL_TYPE, to3d_data::view_type, WarningError, to3d_data::xin_bot, to3d_data::xin_top, to3d_data::xincode, to3d_data::xorient, to3d_data::yin_bot, to3d_data::yin_top, to3d_data::yincode, to3d_data::yorient, ZERO_IDCODE, to3d_data::zin_bot, to3d_data::zin_top, to3d_data::zincode, zoff, to3d_data::zorient, zpad, and zpad_mm.

Referenced by main().

01943 {
01944    int nopt , ii ;
01945 
01946 ENTRY("T3D_initialize_user_data") ;
01947 
01948    user_inputs = default_user_inputs ;  /* copy defaults */
01949    user_inputs.nosave = 0 ;
01950 
01951    /*-- initialize strings --*/
01952 
01953    EMPTY_STRING( user_inputs.dataset_name ) ;
01954    EMPTY_STRING( user_inputs.short_label1 ) ;
01955    EMPTY_STRING( user_inputs.short_label2 ) ;
01956    EMPTY_STRING( user_inputs.geometry_parent_filename ) ;
01957    EMPTY_STRING( user_inputs.anatomy_parent_filename ) ;
01958    EMPTY_STRING( user_inputs.anatomy_dataname ) ;
01959    EMPTY_STRING( user_inputs.geometry_dataname ) ;
01960    EMPTY_STRING( user_inputs.output_filename ) ;
01961    ZERO_IDCODE( user_inputs.anatomy_parent_idcode ) ;
01962 
01963    strcpy( user_inputs.session_filename , "./" ) ;
01964 
01965    strcpy( user_inputs.dataset_type_string ,
01966            DATASET_typestr[user_inputs.dataset_type] ) ;
01967 
01968    strcpy( user_inputs.function_type_string ,
01969            FUNC_typestr[user_inputs.function_type] ) ;
01970 
01971    user_inputs.view_type = VIEW_ORIGINAL_TYPE ;
01972 
01973    for( ii=0 ; ii < MAX_STAT_AUX ; ii++ )
01974       user_inputs.stat_aux[ii] = 0.0 ;
01975 
01976    user_inputs.xincode = user_inputs.yincode = user_inputs.zincode = INCODE_NONE ;
01977 
01978    user_inputs.ntt      = 0 ;
01979    user_inputs.TR       = 1.0 ;
01980    user_inputs.Torg     = 0.0 ;  /* 23 Feb 2005 */
01981    user_inputs.nzz      = 0 ;
01982    user_inputs.t_then_z = 0 ;
01983    user_inputs.tpattern = NULL ;
01984    user_inputs.tunits   = UNITS_MSEC_TYPE ;
01985 
01986    /*-- 05 Feb 2000: zpad environment --*/
01987 
01988    { char *eee=my_getenv("AFNI_TO3D_ZPAD") , *fff ;
01989      if( eee != NULL ){
01990          zpad = strtod( eee , &fff ) ;
01991          if( zpad < 0.0 ) FatalError("AFNI_TO3D_ZPAD is negative") ;
01992          zpad_mm = (*fff == 'm') ;
01993      }
01994    }
01995 
01996    /*-- scan options --*/
01997 
01998    nopt = 1 ;
01999    while( nopt < Argc && Argv[nopt][0] == '-' ){
02000 
02001       if( strncmp(Argv[nopt],"-help",4) == 0 ){
02002          Syntax() ;
02003       }
02004 
02005       /* -type from the anatomy prefixes */
02006 
02007       for( ii=FIRST_ANAT_TYPE ; ii <= LAST_ANAT_TYPE ; ii++ )
02008          if( strncmp( &(Argv[nopt][1]) ,
02009                       ANAT_prefixstr[ii] , THD_MAX_PREFIX ) == 0 ) break ;
02010 
02011       if( ii <= LAST_ANAT_TYPE ){
02012          user_inputs.anatomy_type = ii ;
02013          user_inputs.dataset_type = HEAD_ANAT_TYPE ;
02014          strcpy( user_inputs.dataset_type_string ,
02015                  DATASET_typestr[user_inputs.dataset_type] ) ;
02016          strcpy( user_inputs.anatomy_type_string ,
02017                  ANAT_typestr[user_inputs.anatomy_type] ) ;
02018 
02019          af_type_set = 1 ; nopt++ ; continue ;
02020       }
02021 
02022       /* -type from the function prefixes */
02023 
02024       for( ii=FIRST_FUNC_TYPE ; ii <= LAST_FUNC_TYPE ; ii++ )
02025          if( strncmp( &(Argv[nopt][1]) ,
02026                       FUNC_prefixstr[ii] , THD_MAX_PREFIX ) == 0 ) break ;
02027 
02028       if( ii <= LAST_FUNC_TYPE ){
02029          user_inputs.function_type = ii ;
02030          user_inputs.dataset_type = HEAD_FUNC_TYPE ;
02031          strcpy( user_inputs.dataset_type_string ,
02032                  DATASET_typestr[user_inputs.dataset_type] ) ;
02033          strcpy( user_inputs.function_type_string ,
02034                  FUNC_typestr[user_inputs.function_type] ) ;
02035 
02036          af_type_set = 1 ; nopt++ ; continue ;
02037       }
02038 
02039 #ifdef USE_MRI_DELAY
02040       /*--- -in:1 ---*/
02041 
02042       if( strncmp(Argv[nopt],"-in:1",5) == 0 ){
02043          argopt.delay_input = TRUE ;
02044          nopt++ ; continue ;
02045       }
02046 #endif
02047 
02048       /*--- -view type ---*/
02049 
02050       if( strncmp(Argv[nopt],"-view",4) == 0 ){
02051          char * str ;
02052 
02053          if( ++nopt >= Argc ) FatalError("-view needs a type") ;
02054 
02055          str = Argv[nopt] ; if( str[0] == '+' ) str++ ;
02056 
02057          for( ii=FIRST_VIEW_TYPE ; ii <= LAST_VIEW_TYPE ; ii++ )
02058             if( strcmp(str,VIEW_codestr[ii]) == 0 ) break ;
02059 
02060          if( ii <= LAST_VIEW_TYPE ){
02061             user_inputs.view_type = ii ;
02062          } else {
02063             WarningError("Unknown view type after -view!") ;
02064          }
02065          nopt++ ; continue ;
02066       }
02067 
02068       /* 05 Feb 2001: -zpad option */
02069 
02070       if( strncmp(Argv[nopt],"-zpad",5) == 0 ){
02071          char * eee ;
02072          if( ++nopt >= Argc ) FatalError("-zpad needs a count") ;
02073          if( zpad > 0.0 ) fprintf(stderr,"+++ WARNING: second -zpad option found!\n") ;
02074          zpad = strtod( Argv[nopt] , &eee ) ;
02075          if( zpad < 0.0 ) FatalError("-zpad is negative") ;
02076          zpad_mm = (*eee == 'm') ;
02077          nopt++ ; continue ;
02078       }
02079 
02080       /*--- -session name ---*/
02081 
02082       if( strncmp(Argv[nopt],"-session",4) == 0 ){
02083          if( ++nopt >= Argc ) FatalError("-session needs a name") ;
02084          MCW_strncpy( user_inputs.session_filename, Argv[nopt], THD_MAX_NAME ) ;
02085          nopt++ ; continue ;
02086       }
02087 
02088       /*--- -prefix name ---*/
02089 
02090       if( strncmp(Argv[nopt],"-prefix",4) == 0 ){
02091          if( ++nopt >= Argc ) FatalError("-prefix needs a name") ;
02092          MCW_strncpy( user_inputs.output_filename , Argv[nopt] , THD_MAX_NAME ) ;
02093          nopt++ ; continue ;
02094       }
02095 
02096 #ifndef NO_NAMES
02097       /*--- -dname name ---*/
02098 
02099       if( strncmp(Argv[nopt],"-dname",4) == 0 ){
02100          if( ++nopt >= Argc ) FatalError("-dname needs a name") ;
02101          MCW_strncpy( user_inputs.dataset_name , Argv[nopt] , THD_MAX_NAME ) ;
02102          nopt++ ; continue ;
02103       }
02104 
02105       /*--- -dlabel name ---*/
02106 
02107       if( strncmp(Argv[nopt],"-dlabel",4) == 0 ){
02108          if( ++nopt >= Argc ) FatalError("-dlabel needs a name") ;
02109          MCW_strncpy( user_inputs.short_label1 , Argv[nopt] , THD_MAX_LABEL ) ;
02110          nopt++ ; continue ;
02111       }
02112 #endif
02113 
02114       /*--- -geomparent headerfile ---*/
02115 
02116       if( strncmp(Argv[nopt],"-geomparent",6) == 0 ){
02117          if( ++nopt >= Argc ) FatalError("-geomparent needs a headerfile" ) ;
02118          MCW_strncpy( user_inputs.geometry_parent_filename ,
02119                       Argv[nopt] , THD_MAX_NAME ) ;
02120          nopt++ ; continue ;
02121       }
02122 
02123       /*--- -anatparent headerfile ---*/
02124 
02125       if( strncmp(Argv[nopt],"-anatparent",6) == 0 ){
02126          if( ++nopt >= Argc ) FatalError("-anatparent needs a headerfile" ) ;
02127          MCW_strncpy( user_inputs.anatomy_parent_filename ,
02128                       Argv[nopt] , THD_MAX_NAME ) ;
02129          nopt++ ; continue ;
02130       }
02131 
02132       /*--- -nosave ---*/
02133 
02134       if( strncmp(Argv[nopt],"-nosave",4) == 0 ){
02135          user_inputs.nosave = 1 ;
02136          nopt++ ; continue ;
02137       }
02138 
02139       /*--- 25 Sep 2001: -sinter option ---*/
02140 
02141       if( strcmp(Argv[nopt],"-sinter") == 0 ){
02142          putenv("AFNI_SIEMENS_INTERLEAVE=Yes") ; nopt++ ; continue ;
02143       }
02144 
02145       /*--- 15 Aug 2001: -skip_outliers ---*/
02146 
02147       if( strcmp(Argv[nopt],"-skip_outliers") == 0 ){
02148          putenv("AFNI_TO3D_OUTLIERS=No") ; nopt++ ; continue ;
02149       }
02150 
02151       if( strcmp(Argv[nopt],"-text_outliers") == 0 ){
02152          putenv("AFNI_TO3D_OUTLIERS=Text") ; nopt++ ; continue ;
02153       }
02154 
02155       /*--- 26 Aug 2001: -save_outliers ---*/
02156 
02157       if( strcmp(Argv[nopt],"-save_outliers") == 0 ){
02158          if(++nopt > Argc) FatalError("-save_outliers needs a filename") ;
02159          outliers_fname = Argv[nopt] ;
02160          if( !THD_filename_ok(outliers_fname) )
02161             FatalError("-save_outliers filename is illegal") ;
02162          nopt++ ; continue ;
02163       }
02164 
02165       /*--- July 1997: -orient code ---*/
02166 
02167       if( strncmp(Argv[nopt],"-orient",4) == 0 ){
02168          char acod ;
02169 
02170          if( ++nopt >= Argc ) FatalError("-orient needs a code") ;
02171          if( strlen(Argv[nopt]) != 3 ) FatalError("Illegal -orient code") ;
02172          acod = toupper(Argv[nopt][0]) ; user_inputs.xorient = ORCODE(acod) ;
02173          acod = toupper(Argv[nopt][1]) ; user_inputs.yorient = ORCODE(acod) ;
02174          acod = toupper(Argv[nopt][2]) ; user_inputs.zorient = ORCODE(acod) ;
02175          nopt++ ; continue ;
02176       }
02177 
02178       if( strncmp(Argv[nopt],"-zorigin",7) == 0 ){
02179          if( ++nopt >= Argc ) FatalError("-zorigin needs a value") ;
02180          zoff = strtod( Argv[nopt] , NULL ) ;
02181          use_zoff = 1 ;
02182          nopt++ ; continue ;
02183       }
02184 
02185       /********** April 1996: new options for setting dimensions **********/
02186 
02187 /** 21 Nov 1997: alter the way dimensions are decoded **/
02188 #undef USE_OLD_DCODE
02189 
02190       /*--- -xFOV or -xSLAB ---*/
02191 
02192       if( strncmp(Argv[nopt],"-xFOV",5)==0 || strncmp(Argv[nopt],"-xSLAB",5)==0 ||
02193           strncmp(Argv[nopt],"-xfov",5)==0 || strncmp(Argv[nopt],"-xslab",5)==0   ){
02194          float val , xin_bot , xin_top ;
02195          char * ptr , * ptr2 , acod ;
02196          int dcod1 , dcod2 , xincode ;
02197 
02198          xincode = ( strncmp(Argv[nopt],"-xFOV",5)==0 ||
02199                      strncmp(Argv[nopt],"-xfov",5)==0   ) ? INCODE_FOV : INCODE_SLAB ;
02200 
02201          if( ++nopt >= Argc ) WarningError("need an argument after -xFOV/-xSLAB!") ;
02202 
02203          /* should now have something of one of the forms
02204                <number> <dircode> : <number> <dircode>
02205                <number> <dircode> - <number> <dircode>
02206                <number> <dircode> : <dircode>
02207                <number> <dircode> - <dircode>
02208 
02209             Step 1: get the first <number>   */
02210 
02211 #ifdef USE_OLD_DCODE
02212          val = strtod( Argv[nopt] , &ptr ) ;
02213          if( val < 0.0 || (val == 0.0 && ptr == Argv[nopt]) )
02214             WarningError("a nonegative number should follow -xFOV/-xSLAB!") ;
02215 
02216          xin_bot = val ;
02217 
02218          /* Step 2: get the first <dircode> */
02219 
02220          acod = toupper( *ptr ) ; dcod1 = ORCODE(acod) ; ptr++ ;
02221          if( dcod1 < 0 )
02222             WarningError("orientation code should follow first dimension in -xFOV/-xSLAB!") ;
02223 #else
02224          { int nused ;
02225            nused = decode_location( Argv[nopt] , &xin_bot , &dcod1 ) ;
02226            if( xin_bot < 0.0 || xin_bot == WAY_BIG )
02227              WarningError("a nonegative number should follow -xFOV/-xSLAB!") ;
02228            if( dcod1 < 0 )
02229              WarningError("1st orientation code illegal after -xFOV/-xSLAB!") ;
02230            ptr = Argv[nopt] + nused ;
02231          }
02232 #endif
02233 
02234 
02235          /* Step 3: get the separator */
02236 
02237          if( *ptr != ':' && *ptr != '-' )
02238 #ifdef USE_OLD_DCODE
02239             WarningError(": or - should follow orientation code in -xFOV/-xSLAB!") ;
02240 #else
02241             WarningError(": or - should follow 1st dimension in -xFOV/-xSLAB!") ;
02242 #endif
02243          ptr++ ;
02244          if( *ptr == '\0' )
02245             WarningError("orientation code or dimension should follow : or - in -xFOV/-xSLAB!") ;
02246 
02247          /* Step 4: try to get the second <dircode>.  If that fails, then get
02248                     the second <number> first, then the second <dircode>.
02249                     If the second <dircode> works, however, then the second
02250                     <number> is defined to be equal to the first <number>.   */
02251 
02252 #ifdef USE_OLD_DCODE
02253          acod = toupper( *ptr ) ; dcod2 = ORCODE(acod) ;
02254          if( dcod2 < 0 ){
02255             val = strtod( ptr , &ptr2 ) ;
02256             if( val < 0.0 || (val == 0.0 && ptr2 == ptr) )
02257               WarningError("orientation code or dimension should follow : or - in -xFOV/-xSLAB!") ;
02258             xin_top = val ;
02259             ptr = ptr2 ;
02260             acod = toupper( *ptr ) ; dcod2 = ORCODE(acod) ;
02261             if( dcod2 < 0 )
02262                WarningError("orientation code should follow second dimension in -xFOV/-xSLAB!") ;
02263          } else {
02264             xin_top = xin_bot ;
02265          }
02266 #else
02267          { int nused ;
02268            nused = decode_location( ptr , &xin_top , &dcod2 ) ;
02269            if( dcod2 < 0 )
02270              WarningError("need 2nd orientation code in -xFOV/-xSLAB!") ;
02271            if( xin_top < 0.0 )
02272              WarningError("need nonegative 2nd dimension in -xFOV/-xSLAB!") ;
02273            if( xin_top == WAY_BIG ) xin_top = xin_bot ;
02274          }
02275 #endif
02276 
02277          /* Now, check for consistency:
02278               Direction codes should be in the same or opposite directions;
02279               however, must be opposite if the two <number>s are identical.
02280               For example 120A-120A makes no sense,
02281               but 120A-120P is reasonable, and 10A-30A is also reasonable.  */
02282 
02283          if( xin_top == xin_bot && dcod1 != ORIENT_OPPOSITE(dcod2) )
02284             WarningError("zero thickness slab specified in -xFOV/-xSLAB!") ;
02285 
02286          if( dcod1 != dcod2 && dcod1 != ORIENT_OPPOSITE(dcod2) )
02287             WarningError("inconsistent directions given in -xFOV/-xSLAB!") ;
02288 
02289          /* If the direction codes are the same, then if the first <number>
02290             is smaller, reverse the first direction code and negate the
02291             first number.  For example, 10A:30A becomes -10P:30A, which is
02292             equivalent.  If the first number is larger, then reverse the
02293             second code and number.  For example, 30A:10A becomes 30A:-10P.
02294             Why do this?  Then the first direction code correctly expresses
02295             the sense of the input direction. The sum of numbers becomes
02296             the cross-slab thickness, needed to compute various stuff later. */
02297 
02298          if( dcod1 == dcod2 ){
02299             if( xin_bot < xin_top ){
02300                dcod1   = ORIENT_OPPOSITE(dcod1) ;
02301                xin_bot = -xin_bot ;
02302             } else {
02303                dcod2   = ORIENT_OPPOSITE(dcod2) ;
02304                xin_top = -xin_top ;
02305             }
02306          }
02307 
02308          /* All is OK, so store the results */
02309 
02310          user_inputs.xincode = xincode + dcod1 ;
02311          user_inputs.xin_bot = xin_bot ;
02312          user_inputs.xin_top = xin_top ;
02313 
02314 #if 0
02315 printf("decoded %s to give xincode=%d bot=%f top=%f\n",Argv[nopt],
02316        user_inputs.xincode, user_inputs.xin_bot, user_inputs.xin_top ) ;
02317 #endif
02318 
02319          nopt++ ; continue ;
02320       }
02321 
02322       /*--- -yFOV or -ySLAB ---*/
02323 
02324       if( strncmp(Argv[nopt],"-yFOV",5)==0 || strncmp(Argv[nopt],"-ySLAB",5)==0 ||
02325           strncmp(Argv[nopt],"-yfov",5)==0 || strncmp(Argv[nopt],"-yslab",5)==0   ){
02326 
02327          float val , yin_bot , yin_top ;
02328          char * ptr , * ptr2 , acod ;
02329          int dcod1 , dcod2 , yincode ;
02330 
02331          yincode = ( strncmp(Argv[nopt],"-yFOV",5)==0 ||
02332                      strncmp(Argv[nopt],"-yfov",5)==0   ) ? INCODE_FOV : INCODE_SLAB ;
02333 
02334          if( ++nopt >= Argc ) WarningError("need an argument after -yFOV/-ySLAB!") ;
02335 
02336          /* should now have something of one of the forms
02337                <number> <dircode> : <number> <dircode>
02338                <number> <dircode> - <number> <dircode>
02339                <number> <dircode> : <dircode>
02340                <number> <dircode> - <dircode>
02341 
02342             Step 1: get the first <number>   */
02343 
02344 #ifdef USE_OLD_DCODE
02345          val = strtod( Argv[nopt] , &ptr ) ;
02346          if( val < 0.0 || (val == 0.0 && ptr == Argv[nopt]) )
02347             WarningError("a nonegative number should follow -yFOV/-ySLAB!") ;
02348 
02349          yin_bot = val ;
02350 
02351          /* Step 2: get the first <dircode> */
02352 
02353          acod = toupper( *ptr ) ; dcod1 = ORCODE(acod) ; ptr++ ;
02354          if( dcod1 < 0 )
02355             WarningError("orientation code should follow first dimension in -yFOV/-ySLAB!") ;
02356 #else
02357          { int nused ;
02358            nused = decode_location( Argv[nopt] , &yin_bot , &dcod1 ) ;
02359            if( yin_bot < 0.0 || yin_bot == WAY_BIG )
02360              WarningError("a nonegative number should follow -yFOV/-ySLAB!") ;
02361            if( dcod1 < 0 )
02362              WarningError("1st orientation code illegal after -yFOV/-ySLAB!") ;
02363            ptr = Argv[nopt] + nused ;
02364          }
02365 #endif
02366 
02367          /* Step 3: get the separator */
02368 
02369          if( *ptr != ':' && *ptr != '-' )
02370 #ifdef USE_OLD_DCODE
02371             WarningError(": or - should follow orientation code in -yFOV/-ySLAB!") ;
02372 #else
02373             WarningError(": or - should follow 1st dimension in -yFOV/-ySLAB!") ;
02374 #endif
02375 
02376          ptr++ ;
02377          if( *ptr == '\0' )
02378             WarningError("orientation code or dimension should follow : or - in -yFOV/-ySLAB!") ;
02379 
02380          /* Step 4: try to get the second <dircode>.  If that fails, then get
02381                     the second <number> first, then the second <dircode>.
02382                     If the second <dircode> works, however, then the second
02383                     <number> is defined to be equal to the first <number>.   */
02384 
02385 #ifdef USE_OLD_DCODE
02386          acod = toupper( *ptr ) ; dcod2 = ORCODE(acod) ;
02387          if( dcod2 < 0 ){
02388             val = strtod( ptr , &ptr2 ) ;
02389             if( val < 0.0 || (val == 0.0 && ptr2 == ptr) )
02390               WarningError("orientation code or dimension should follow : or - in -yFOV/-ySLAB!") ;
02391             yin_top = val ;
02392             ptr = ptr2 ;
02393             acod = toupper( *ptr ) ; dcod2 = ORCODE(acod) ;
02394             if( dcod2 < 0 )
02395                WarningError("orientation code should follow second dimension in -yFOV/-ySLAB!") ;
02396          } else {
02397             yin_top = yin_bot ;
02398          }
02399 #else
02400          { int nused ;
02401            nused = decode_location( ptr , &yin_top , &dcod2 ) ;
02402            if( dcod2 < 0 )
02403              WarningError("need 2nd orientation code in -yFOV/-ySLAB!") ;
02404            if( yin_top < 0.0 )
02405              WarningError("need nonegative 2nd dimension in -yFOV/-ySLAB!") ;
02406            if( yin_top == WAY_BIG ) yin_top = yin_bot ;
02407          }
02408 #endif
02409 
02410          /* Now, check for consistency:
02411               Direction codes should be in the same or opposite directions;
02412               however, must be opposite if the two <number>s are identical.
02413               For example 120A-120A makes no sense,
02414               but 120A-120P is reasonable, and 10A-30A is also reasonable.  */
02415 
02416          if( yin_top == yin_bot && dcod1 != ORIENT_OPPOSITE(dcod2) )
02417             WarningError("zero thickness slab specified in -yFOV/-ySLAB!") ;
02418 
02419          if( dcod1 != dcod2 && dcod1 != ORIENT_OPPOSITE(dcod2) )
02420             WarningError("inconsistent directions given in -yFOV/-ySLAB!") ;
02421 
02422          /* If the direction codes are the same, then if the first <number>
02423             is smaller, reverse the first direction code and negate the
02424             first number.  For example, 10A:30A becomes -10P:30A, which is
02425             equivalent.  If the first number is larger, then reverse the
02426             second code and number.  For example, 30A:10A becomes 30A:-10P.
02427             Why do this?  Then the first direction code correctly expresses
02428             the sense of the input direction. The sum of numbers becomes
02429             the cross-slab thickness, needed to compute various stuff later. */
02430 
02431          if( dcod1 == dcod2 ){
02432             if( yin_bot < yin_top ){
02433                dcod1   = ORIENT_OPPOSITE(dcod1) ;
02434                yin_bot = -yin_bot ;
02435             } else {
02436                dcod2   = ORIENT_OPPOSITE(dcod2) ;
02437                yin_top = -yin_top ;
02438             }
02439          }
02440 
02441          /* All is OK, so store the results */
02442 
02443          user_inputs.yincode = yincode + dcod1 ;
02444          user_inputs.yin_bot = yin_bot ;
02445          user_inputs.yin_top = yin_top ;
02446 
02447 #if 0
02448 printf("decoded %s to give yincode=%d bot=%f top=%f\n",Argv[nopt],
02449        user_inputs.yincode, user_inputs.yin_bot, user_inputs.yin_top ) ;
02450 #endif
02451 
02452          nopt++ ; continue ;
02453       }
02454 
02455       /*--- -zFOV or -zSLAB ---*/
02456 
02457       if( strncmp(Argv[nopt],"-zFOV",5)==0 || strncmp(Argv[nopt],"-zSLAB",5)==0 ||
02458           strncmp(Argv[nopt],"-zfov",5)==0 || strncmp(Argv[nopt],"-zslab",5)==0   ){
02459 
02460          float val , zin_bot , zin_top ;
02461          char * ptr , * ptr2 , acod ;
02462          int dcod1 , dcod2 , zincode ;
02463 
02464          zincode = ( strncmp(Argv[nopt],"-zFOV",5)==0 ||
02465                      strncmp(Argv[nopt],"-zfov",5)==0   ) ? INCODE_FOV : INCODE_SLAB ;
02466 
02467          if( ++nopt >= Argc ) WarningError("need an argument after -zFOV/-zSLAB!") ;
02468 
02469          /* should now have something of one of the forms
02470                <number> <dircode> : <number> <dircode>
02471                <number> <dircode> - <number> <dircode>
02472                <number> <dircode> : <dircode>
02473                <number> <dircode> - <dircode>
02474 
02475             Step 1: get the first <number>   */
02476 
02477 #ifdef USE_OLD_DCODE
02478          val = strtod( Argv[nopt] , &ptr ) ;
02479          if( val < 0.0 || (val == 0.0 && ptr == Argv[nopt]) )
02480             WarningError("a nonegative number should follow -zFOV/-zSLAB!") ;
02481 
02482          zin_bot = val ;
02483 
02484          /* Step 2: get the first <dircode> */
02485 
02486          acod = toupper( *ptr ) ; dcod1 = ORCODE(acod) ; ptr++ ;
02487          if( dcod1 < 0 )
02488             WarningError("orientation code should follow first dimension in -zFOV/-zSLAB!") ;
02489 #else
02490          { int nused ;
02491            nused = decode_location( Argv[nopt] , &zin_bot , &dcod1 ) ;
02492            if( zin_bot < 0.0 || zin_bot == WAY_BIG )
02493              WarningError("a nonegative number should follow -yFOV/-ySLAB!") ;
02494            if( dcod1 < 0 )
02495              WarningError("1st orientation code illegal after -yFOV/-ySLAB!") ;
02496            ptr = Argv[nopt] + nused ;
02497          }
02498 #endif
02499 
02500          /* Step 3: get the separator */
02501 
02502          if( *ptr != ':' && *ptr != '-' )
02503 #ifdef USE_OLD_DCODE
02504             WarningError(": or - should follow orientation code in -zFOV/-zSLAB!") ;
02505 #else
02506             WarningError(": or - should follow 1st dimension in -zFOV/-zSLAB!") ;
02507 #endif
02508 
02509          ptr++ ;
02510          if( *ptr == '\0' )
02511             WarningError("orientation code or dimension should follow : or - in -zFOV/-zSLAB!") ;
02512 
02513          /* Step 4: try to get the second <dircode>.  If that fails, then get
02514                     the second <number> first, then the second <dircode>.
02515                     If the second <dircode> works, however, then the second
02516                     <number> is defined to be equal to the first <number>.   */
02517 
02518 #ifdef USE_OLD_DCODE
02519          acod = toupper( *ptr ) ; dcod2 = ORCODE(acod) ;
02520          if( dcod2 < 0 ){
02521             val = strtod( ptr , &ptr2 ) ;
02522             if( val < 0.0 || (val == 0.0 && ptr2 == ptr) )
02523               WarningError("orientation code or dimension should follow : or - in -zFOV/-zSLAB!") ;
02524             zin_top = val ;
02525             ptr = ptr2 ;
02526             acod = toupper( *ptr ) ; dcod2 = ORCODE(acod) ;
02527             if( dcod2 < 0 )
02528                WarningError("orientation code should follow second dimension in -zFOV/-zSLAB!") ;
02529          } else {
02530             zin_top = zin_bot ;
02531          }
02532 #else
02533          { int nused ;
02534            nused = decode_location( ptr , &zin_top , &dcod2 ) ;
02535            if( dcod2 < 0 )
02536              WarningError("need 2nd orientation code in -zFOV/-zSLAB!") ;
02537            if( zin_top < 0.0 )
02538              WarningError("need nonegative 2nd dimension in -zFOV/-zSLAB!") ;
02539            if( zin_top == WAY_BIG ) zin_top = zin_bot ;
02540          }
02541 #endif
02542 
02543          /* Now, check for consistency:
02544               Direction codes should be in the same or opposite directions;
02545               however, must be opposite if the two <number>s are identical.
02546               For example 120A-120A makes no sense,
02547               but 120A-120P is reasonable, and 10A-30A is also reasonable.  */
02548 
02549          if( zin_top == zin_bot && dcod1 != ORIENT_OPPOSITE(dcod2) )
02550             WarningError("zero thickness slab specified in -zFOV/-zSLAB!") ;
02551 
02552          if( dcod1 != dcod2 && dcod1 != ORIENT_OPPOSITE(dcod2) )
02553             WarningError("inconsistent directions given in -zFOV/-zSLAB!") ;
02554 
02555          /* If the direction codes are the same, then if the first <number>
02556             is smaller, reverse the first direction code and negate the
02557             first number.  For example, 10A:30A becomes -10P:30A, which is
02558             equivalent.  If the first number is larger, then reverse the
02559             second code and number.  For example, 30A:10A becomes 30A:-10P.
02560             Why do this?  Then the first direction code correctly expresses
02561             the sense of the input direction. The sum of numbers becomes
02562             the cross-slab thickness, needed to compute various stuff later. */
02563 
02564          if( dcod1 == dcod2 ){
02565             if( zin_bot < zin_top ){
02566                dcod1   = ORIENT_OPPOSITE(dcod1) ;
02567                zin_bot = -zin_bot ;
02568             } else {
02569                dcod2   = ORIENT_OPPOSITE(dcod2) ;
02570                zin_top = -zin_top ;
02571             }
02572          }
02573 
02574          /* All is OK, so store the results */
02575 
02576          user_inputs.zincode = zincode + dcod1 ;
02577          user_inputs.zin_bot = zin_bot ;
02578          user_inputs.zin_top = zin_top ;
02579 
02580 #if 0
02581 printf("decoded %s to give zincode=%d bot=%f top=%f\n",Argv[nopt],
02582        user_inputs.zincode, user_inputs.zin_bot, user_inputs.zin_top ) ;
02583 #endif
02584 
02585          nopt++ ; continue ;
02586       }
02587 
02588       /*---- -statpar x x x ----*/
02589 
02590       if( strncmp(Argv[nopt],"-statpar",5) == 0 ){
02591          float val ;
02592          char * ptr ;
02593 
02594          if( ++nopt >= Argc ) FatalError("need an argument after -statpar!") ;
02595 
02596          ii = 0 ;
02597          do{
02598             val = strtod( Argv[nopt] , &ptr ) ;
02599             if( *ptr != '\0' ) break ;
02600             user_inputs.stat_aux[ii++] = val ;
02601             nopt++ ;
02602          } while( nopt < Argc ) ;
02603 
02604          if( ii == 0 )
02605             WarningError("No numbers given after -statpar?") ;
02606          continue ;
02607       }
02608 
02609       /***** 21 Oct 1996: options for time units *****/
02610 
02611       if( strcmp(Argv[nopt],"-t=ms")==0 || strcmp(Argv[nopt],"-t=msec")==0 ){
02612          user_inputs.tunits = UNITS_MSEC_TYPE ;
02613          nopt++ ; continue ;
02614       }
02615 
02616       if( strcmp(Argv[nopt],"-t=s")==0 || strcmp(Argv[nopt],"-t=sec")==0 ){
02617          user_inputs.tunits = UNITS_SEC_TYPE ;
02618          nopt++ ; continue ;
02619       }
02620 
02621       if( strcmp(Argv[nopt],"-t=Hz")==0 || strcmp(Argv[nopt],"-t=Hertz")==0 ){
02622          user_inputs.tunits = UNITS_HZ_TYPE ;
02623          nopt++ ; continue ;
02624       }
02625 
02626       /**** 23 Feb 2005: -Torg option ****/
02627 
02628       if( strncmp(Argv[nopt],"-Torg",5) == 0 ){
02629         if( nopt+1 >= Argc ) FatalError("need 1 argument after -Torg") ;
02630         user_inputs.Torg = strtod( Argv[++nopt] , NULL ) ;
02631         nopt++ ; continue ;
02632       }
02633 
02634       /************* Aprille 1996: New options for specifying time ***********/
02635 
02636       if( strncmp(Argv[nopt],"-time:zt",8)==0 || strncmp(Argv[nopt],"-time:tz",8)==0 ){
02637          int   t_then_z , ntt , nzz , nerr ;
02638          float TR , tframe , tsl ;
02639          char *tpattern , *eptr ;
02640 
02641          if( nopt+4 >= Argc ) FatalError("need 4 arguments after -time: options") ;
02642 
02643          t_then_z = ( strncmp(Argv[nopt],"-time:tz",8)==0 ) ;
02644 
02645          ntt = strtol( Argv[++nopt] , NULL , 10 ) ;
02646          nzz = strtol( Argv[++nopt] , NULL , 10 ) ;
02647          if( ! t_then_z ){ ii = ntt ; ntt = nzz ; nzz = ii ; }
02648 
02649          TR       = strtod( Argv[++nopt] , &eptr ) ;
02650          tpattern = Argv[++nopt] ;
02651 
02652          /** 03 Nov 1996: allow units to be written after TR **/
02653 
02654          if( strcmp(eptr,"ms")==0 || strcmp(eptr,"msec")==0 ){
02655             user_inputs.tunits = UNITS_MSEC_TYPE ;
02656          } else if( strcmp(eptr,"s")==0 || strcmp(eptr,"sec")==0 ){
02657             user_inputs.tunits = UNITS_SEC_TYPE ;
02658          } else if( strcmp(eptr,"Hz")==0 || strcmp(eptr,"Hertz")==0 ){
02659             user_inputs.tunits = UNITS_HZ_TYPE ;
02660          }
02661 
02662          /** 31 July 1996: be more specific about errors **/
02663 
02664          nerr = 0 ;
02665          if( ntt < 2 ){
02666             fprintf(stderr,"Illegal value of nt after -time: option\n") ; nerr++ ;
02667          }
02668          if( nzz < NZBOT ){
02669             fprintf(stderr,"Illegal value of nz after -time: option\n") ; nerr++ ;
02670          }
02671          if( TR < 0.0 ){
02672             fprintf(stderr,"Illegal value of TR after -time: option\n") ; nerr++ ;
02673          }
02674          if( nerr > 0 ){
02675             nopt++ ; continue ;  /* skip on to next option, this one is bad! */
02676          }
02677 
02678          user_inputs.tpattern = (float *) malloc( sizeof(float) * nzz ) ;
02679          for( ii=0 ; ii < nzz ; ii++ ) user_inputs.tpattern[ii] = 0.0 ;
02680 
02681          user_inputs.ntt      = ntt ;
02682          user_inputs.nzz      = nzz ;
02683          user_inputs.t_then_z = t_then_z ;
02684          user_inputs.TR       = TR ;
02685 
02686          if( TR == 0.0 ){ TR = 1.0; user_inputs.tunits = UNITS_SEC_TYPE; }
02687 
02688          tframe = TR / nzz ;  /* time per slice */
02689 
02690          if( nzz > 1 && tpattern[0] == '@' ){
02691             FILE * fp ;
02692 
02693             /*--- read pattern file (ignore EOFs!) ---*/
02694 
02695             fp = fopen( tpattern+1 , "r" ) ;
02696             if( fp == NULL ){
02697                fprintf(stderr,"Cannot open tpattern file %s\n",tpattern+1) ;
02698             } else {
02699                for( ii=0 ; ii < nzz ; ii++ )
02700                   fscanf( fp , "%f" , user_inputs.tpattern + ii ) ;
02701                fclose( fp ) ;
02702             }
02703          } else if( nzz > 1 &&
02704                    (strcmp(tpattern,"alt+z")==0 || strcmp(tpattern,"altplus")==0) ){
02705 
02706             /*--- set up alternating in the +z direction ---*/
02707 
02708             tsl = 0.0 ;
02709             for( ii=0 ; ii < nzz ; ii+=2 ){
02710                user_inputs.tpattern[ii] = tsl ; tsl += tframe ;
02711             }
02712             for( ii=1 ; ii < nzz ; ii+=2 ){
02713                user_inputs.tpattern[ii] = tsl ; tsl += tframe ;
02714             }
02715          } else if( nzz > 1 && strcmp(tpattern,"alt+z2")==0 ){  /* 22 Feb 2005 */
02716 
02717             /*--- set up alternating in the +z direction ---*/
02718 
02719             tsl = 0.0 ;
02720             for( ii=1 ; ii < nzz ; ii+=2 ){
02721                user_inputs.tpattern[ii] = tsl ; tsl += tframe ;
02722             }
02723             for( ii=0 ; ii < nzz ; ii+=2 ){
02724                user_inputs.tpattern[ii] = tsl ; tsl += tframe ;
02725             }
02726          } else if( nzz > 1 &&
02727                    (strcmp(tpattern,"alt-z")==0 || strcmp(tpattern,"altminus")==0) ){
02728 
02729             /*--- set up alternating in the -z direction ---*/
02730 
02731             tsl = 0.0 ;
02732             for( ii=nzz-1 ; ii >=0 ; ii-=2 ){
02733                user_inputs.tpattern[ii] = tsl ; tsl += tframe ;
02734             }
02735             for( ii=nzz-2 ; ii >=0 ; ii-=2 ){
02736                user_inputs.tpattern[ii] = tsl ; tsl += tframe ;
02737             }
02738          } else if( nzz > 1 && strcmp(tpattern,"alt-z2")==0 ){  /* 22 Feb 2005 */
02739 
02740             /*--- set up alternating in the -z direction ---*/
02741 
02742             tsl = 0.0 ;
02743             for( ii=nzz-2 ; ii >=0 ; ii-=2 ){
02744                user_inputs.tpattern[ii] = tsl ; tsl += tframe ;
02745             }
02746             for( ii=nzz-1 ; ii >=0 ; ii-=2 ){
02747                user_inputs.tpattern[ii] = tsl ; tsl += tframe ;
02748             }
02749          } else if( nzz > 1 &&
02750                    (strcmp(tpattern,"seq+z")==0 || strcmp(tpattern,"seqplus")==0) ){
02751 
02752             /*--- set up sequential in the +z direction ---*/
02753 
02754             tsl = 0.0 ;
02755             for( ii=0 ; ii < nzz ; ii++ ){
02756                user_inputs.tpattern[ii] = tsl ; tsl += tframe ;
02757             }
02758          } else if( nzz > 1 &&
02759                    (strcmp(tpattern,"seq-z")==0 || strcmp(tpattern,"seqminus")==0) ){
02760 
02761             /*--- set up sequential in the -z direction ---*/
02762 
02763             tsl = 0.0 ;
02764             for( ii=nzz-1 ; ii >=0 ; ii-- ){
02765                user_inputs.tpattern[ii] = tsl ; tsl += tframe ;
02766             }
02767          } else if( nzz == 1 ||
02768                    (strcmp(tpattern,"zero")==0 || strcmp(tpattern,"simult")==0) ){
02769 
02770             /*--- delete the tpattern ---*/
02771 
02772             free(user_inputs.tpattern) ;
02773             user_inputs.tpattern = NULL ;
02774 
02775          } else {
02776             fprintf(stderr,"Unknown tpattern = %s\n",tpattern) ;
02777          }
02778 
02779          nopt++ ; continue ;
02780       }
02781 
02782       /********** non-dataset arguments ************/
02783 
02784       /*----- -gamma # option -----*/
02785 
02786       if( strncmp(Argv[nopt],"-gamma",4) == 0 ){
02787          float val ;
02788          if( nopt+1 >= Argc ) FatalError("need an argument after -gamma!");
02789 
02790          val = strtod( Argv[++nopt] , NULL ) ;
02791          if( val > 0 ) argopt.gamma = val ;
02792          else fprintf(stderr,
02793                 "\n*** warning: -gamma value %s illegal\n", Argv[nopt]);
02794 
02795          nopt++ ; continue ;  /* go to next arg */
02796       }
02797 
02798       /*----- -gsfac value option -----*/
02799 
02800       if( strncmp(Argv[nopt],"-gsfac",4) == 0 ){
02801          float val ;
02802          if( nopt+1 >= Argc ) FatalError("need an argument after -gsfac!");
02803 
02804          val = strtod( Argv[++nopt] , NULL ) ;
02805          if( val != 0.0 ) argopt.gsfac = val ;
02806          else fprintf(stderr,
02807                 "\n*** warning: -gsfac value %s illegal\n", Argv[nopt]);
02808 
02809          nopt++ ; continue ;  /* go to next arg */
02810       }
02811 
02812       /*----- -datum type option -----*/
02813 
02814       if( strncmp(Argv[nopt],"-datum",6) == 0 ){
02815          if( ++nopt >= Argc ) FatalError("need an argument after -datum!") ;
02816 
02817          if( strcmp(Argv[nopt],"short") == 0 ){
02818             argopt.datum_all = MRI_short ;
02819          } else if( strcmp(Argv[nopt],"float") == 0 ){
02820             argopt.datum_all = MRI_float ;
02821          } else if( strcmp(Argv[nopt],"complex") == 0 ){
02822             argopt.datum_all = MRI_complex ;
02823          } else if( strcmp(Argv[nopt],"byte") == 0 ){
02824             argopt.datum_all = MRI_byte ;
02825          } else if( strcmp(Argv[nopt],"rgb") == 0 ){
02826             argopt.datum_all = MRI_rgb ;
02827          } else {
02828             char buf[256] ;
02829             sprintf(buf,"-datum of type '%s' is not supported in AFNI!",
02830                     Argv[nopt] ) ;
02831             FatalError(buf) ;
02832          }
02833 
02834          nopt++ ; continue ;  /* go to next arg */
02835       }
02836 
02837       /*----- -ncolor # option -----*/
02838 
02839       if( strncmp(Argv[nopt],"-ncolor",4) == 0 ){
02840          float val ;
02841          if( nopt+1 >= Argc ) FatalError("need an argument after -ncolor!");
02842 
02843          val = strtod( Argv[++nopt] , NULL ) ;
02844          if( val > 4 ) argopt.ncolor = val ;
02845          else fprintf(stderr,
02846                 "\n*** warning: -ncolor value %s illegal\n", Argv[nopt]);
02847 
02848          nopt++ ; continue ;  /* go to next arg */
02849       }
02850 
02851       /*----- -xtwarns option -----*/
02852 
02853       if( strncmp(Argv[nopt],"-xtwarns",6) == 0 ){
02854          argopt.xtwarns = True ;
02855          nopt++ ; continue ;  /* go to next arg */
02856       }
02857 
02858       /*----- -2swap and -4swap options -----*/
02859 
02860       if( strncmp(Argv[nopt],"-2swap",4) == 0 ){
02861          argopt.swap_two = 1 ;
02862          nopt++ ; continue ;  /* go to next arg */
02863       }
02864 
02865       if( strncmp(Argv[nopt],"-4swap",4) == 0 ){
02866          argopt.swap_four = 1 ;
02867          nopt++ ; continue ;  /* go to next arg */
02868       }
02869 
02870       if( strncmp(Argv[nopt],"-8swap",4) == 0 ){    /* 06 Feb 2003 */
02871          argopt.swap_eight = 1 ;
02872          nopt++ ; continue ;  /* go to next arg */
02873       }
02874 
02875       /*----- -nofloatscan -----*/
02876 
02877       if( strncmp(Argv[nopt],"-nofloatscan",6) == 0 ){
02878          argopt.nofloatscan = 1 ;
02879          nopt++ ; continue ;  /* go to next arg */
02880       }
02881 
02882       /*--- illegal option ---*/
02883 
02884       printf("*** ILLEGAL OPTION: %s\n\n",Argv[nopt]) ;
02885       FatalError("cannot continue") ;
02886 
02887    }
02888 
02889    if( user_inputs.ntt > 1 && !af_type_set ){
02890       user_inputs.anatomy_type = ANAT_EPI_TYPE ; /* 20 Dec 2001 */
02891    }
02892 
02893    First_Image_Arg = nopt ;
02894 
02895    /* 14 Sep 1999: manufacture a command line for History,
02896                    but with (possibly) fewer image inputs */
02897 
02898    { int nim=Argc-First_Image_Arg , ii ;
02899      char ** qargv ;
02900 
02901      if( nim < 9 ){     /* 8 or fewer images ==> copy them all */
02902 
02903         qargv = Argv ;
02904 
02905      } else {           /* im0 im1 im2 ... im<last-1> im<last> */
02906 
02907         qargv = (char **) malloc( sizeof(char *) * Argc ) ;   /* copy all */
02908         for( ii=0 ; ii < Argc ; ii++ ) qargv[ii] = Argv[ii] ; /* argv's   */
02909 
02910         qargv[First_Image_Arg+3] = "..." ;   /* notice of omission */
02911 
02912         for( ii=First_Image_Arg+4 ; ii < Argc-2 ; ii++ ) /* these will */
02913            qargv[ii] = NULL ;                            /* be omitted */
02914      }
02915 
02916      commandline = tross_commandline( "to3d" , Argc , qargv ) ;
02917      AFNI_log_string(commandline) ; /* 14 Aug 2001 */
02918 
02919      if( qargv != Argv ) free(qargv) ;
02920    }
02921 
02922    EXRETURN ;
02923 }

void T3D_open_view_CB Widget    w,
XtPointer    client_data,
XtPointer    call_data
 

--- fix dimensions if user input axes stuff ---*

Definition at line 4543 of file to3d.c.

References THD_string_array::ar, client_data, to3d_widget_set::dc, drive_MCW_imseq(), ISQ_REALZ, isqDR_display, isqDR_getimnr, isqDR_opacitybut, isqDR_penbbox, isqDR_realize, isqDR_record_disable, isqDR_title, isqDR_winfosides, isqDR_zoombut, MCW_invert_widget(), NORMAL_cursorize, open_MCW_imseq(), to3d_widget_set::open_view_pb, RESET_QUIT, to3d_widget_set::seq, T3D_getim(), THD_3dim_dataset_to_brick(), to3d_widget_set::topshell, MCW_imseq::wimage, MCW_imseq::wtop, to3d_data::xsize, THD_dataxes::xxdel, to3d_data::ysize, THD_dataxes::yydel, to3d_data::zsize, to3d_data::zspacing, and THD_dataxes::zzdel.

Referenced by T3D_create_widgets().

04545 {
04546    FD_brick * br ;
04547    char * title = "to3d" ;
04548    int nim ;
04549 
04550    if( wset.seq != NULL ){
04551       if( ISQ_REALZ(wset.seq) )
04552          XMapRaised( XtDisplay(wset.topshell) , XtWindow(wset.seq->wtop) ) ;
04553       else
04554          XBell( XtDisplay(wset.topshell) , 100 ) ; /* should never happen */
04555       return ;
04556    }
04557 
04558    daxes->xxdel = user_inputs.xsize ;  /* these are here to make */
04559    daxes->yydel = user_inputs.ysize ;  /* the aspect ratio work  */
04560 #ifdef ALLOW_NONCONTIG
04561    daxes->zzdel = user_inputs.zspacing ;
04562 #else
04563    daxes->zzdel = user_inputs.zsize ;
04564 #endif
04565 
04566    br = THD_3dim_dataset_to_brick( dset , 1,2,3 ) ;
04567 
04568    if( br == NULL ){
04569       XBell( XtDisplay(wset.topshell) , 100 ) ;
04570       fprintf(stderr,"\n*** bad data in THD_3dim_dataset_to_brick!\n");
04571       return ;
04572    }
04573 
04574    wset.seq = open_MCW_imseq( wset.dc , T3D_getim , br ) ;
04575    drive_MCW_imseq( wset.seq,isqDR_realize , NULL ) ;
04576    NORMAL_cursorize( wset.seq->wimage ) ;                       /* 07 Dec 2001 */
04577 
04578    drive_MCW_imseq(wset.seq,isqDR_getimnr, (XtPointer) &nim ) ;
04579    drive_MCW_imseq(wset.seq,isqDR_title  , (XtPointer) imnames->ar[nim] ) ;
04580 
04581    drive_MCW_imseq(wset.seq,isqDR_opacitybut    ,(XtPointer)0); /* 07 Mar 2001 */
04582    drive_MCW_imseq(wset.seq,isqDR_record_disable,(XtPointer)0); /* 24 Apr 2001 */
04583    drive_MCW_imseq(wset.seq,isqDR_zoombut       ,(XtPointer)0); /* 12 Mar 2002 */
04584    drive_MCW_imseq(wset.seq,isqDR_penbbox       ,(XtPointer)0); /* 12 Mar 2002 */
04585 
04586    /* 01 Dec 1999: add "sides" markers for image viewer */
04587 
04588    { static char * ws[4] = { "-x" , "-y" , "+x" , "+y" } ;
04589      drive_MCW_imseq( wset.seq, isqDR_winfosides, (XtPointer)ws ) ;
04590    }
04591 
04592    drive_MCW_imseq( wset.seq , isqDR_display , (XtPointer)-1 ) ;
04593 
04594    MCW_invert_widget( wset.open_view_pb ) ;
04595 
04596    RESET_QUIT ;
04597 }

void T3D_orient_av_CB MCW_arrowval   av,
XtPointer    cd
 

Definition at line 3683 of file to3d.c.

References MCW_arrowval::ival, RESET_QUIT, SET_ORIGIN_LABEL, to3d_widget_set::topshell, to3d_data::view_type, to3d_widget_set::view_type_av, to3d_data::xorient, to3d_widget_set::xorient_av, to3d_widget_set::xorigin_label, to3d_data::yorient, to3d_widget_set::yorient_av, to3d_widget_set::yorigin_label, to3d_data::zorient, to3d_widget_set::zorient_av, and to3d_widget_set::zorigin_label.

Referenced by T3D_create_widgets().

03684 {
03685    int ior = av->ival ;
03686 
03687    if( av == wset.xorient_av ){
03688       user_inputs.xorient = ior ;
03689       SET_ORIGIN_LABEL(wset.xorigin_label,user_inputs.xorient) ;
03690    } else if( av == wset.yorient_av ){
03691       user_inputs.yorient = ior ;
03692       SET_ORIGIN_LABEL(wset.yorigin_label,user_inputs.yorient) ;
03693    } else if( av == wset.zorient_av ){
03694       user_inputs.zorient = ior ;
03695       SET_ORIGIN_LABEL(wset.zorigin_label,user_inputs.zorient) ;
03696    } else if( av == wset.view_type_av ){
03697       user_inputs.view_type = ior ;
03698    } else {
03699       XBell( XtDisplay(wset.topshell) , 100 ) ;
03700       fprintf(stderr,"\n*** illegal call to T3D_orient_av_CB!\n") ;
03701    }
03702    RESET_QUIT ;
03703 }

void T3D_origin_av_CB MCW_arrowval   av,
XtPointer    cd
 

Definition at line 3707 of file to3d.c.

References MCW_arrowval::fval, RESET_QUIT, to3d_widget_set::topshell, to3d_data::xorigin, to3d_widget_set::xorigin_av, to3d_data::yorigin, to3d_widget_set::yorigin_av, to3d_data::zorigin, and to3d_widget_set::zorigin_av.

Referenced by T3D_create_widgets().

03708 {
03709    float size = av->fval ;
03710 
03711    if( av == wset.xorigin_av ){
03712       user_inputs.xorigin = size ;
03713    } else if( av == wset.yorigin_av ){
03714       user_inputs.yorigin = size ;
03715    } else if( av == wset.zorigin_av ){
03716       user_inputs.zorigin = size ;
03717    } else {
03718       XBell( XtDisplay(wset.topshell) , 100 ) ;
03719       fprintf(stderr,"\n*** illegal call to T3D_origin_av_CB!\n") ;
03720    }
03721    RESET_QUIT ;
03722 }

void T3D_pointer_leave_EV Widget    w,
XtPointer    client_data,
XEvent *    ev,
Boolean *    continue_to_dispatch
 

Definition at line 5319 of file to3d.c.

References client_data, and ev.

Referenced by T3D_create_widgets().

05321 {
05322    XLeaveWindowEvent * lev = (XLeaveWindowEvent *) ev ;
05323    XmAnyCallbackStruct cbs ;
05324 
05325    if( lev->type != LeaveNotify || w == NULL ) return ;
05326 
05327    cbs.reason = XmCR_ACTIVATE ;  /* simulate a return press */
05328    cbs.event  = ev ;
05329    XtCallCallbacks( w , XmNactivateCallback , &cbs ) ;
05330 }

void T3D_poperr char *    prefix_msg,
char *    msg
 

Definition at line 5288 of file to3d.c.

References to3d_widget_set::action_frame, ENTRY, to3d_widget_set::good, MCW_popup_message(), MCW_TIMER_KILL, MCW_USER_KILL, to3d_widget_set::topshell, and XtRealloc.

Referenced by T3D_anatomy_parent_CB(), T3D_check_data(), T3D_geometry_parent_CB(), T3D_save_file_CB(), and T3D_type_av_CB().

05289 {
05290    static char * total_msg = NULL ;
05291    static int    len_total = 0 ;
05292    int len_needed ;
05293 
05294 ENTRY("T3D_poperr") ;
05295 
05296    len_needed = strlen(prefix_msg) + strlen(msg) + 2 ;
05297    if( len_needed > len_total ){
05298       total_msg = (char*)XtRealloc( total_msg , len_needed ) ;
05299       len_total = len_needed ;
05300    }
05301    strcpy( total_msg , prefix_msg ) ;
05302    strcat( total_msg , msg ) ;
05303 
05304    if( wset.topshell != NULL && wset.good ){
05305       (void) MCW_popup_message( wset.action_frame,
05306                                 total_msg, MCW_USER_KILL | MCW_TIMER_KILL ) ;
05307       XFlush( XtDisplay(wset.topshell) ) ;
05308       sleep(1) ;
05309    } else {
05310       fprintf(stderr,"%s\n",total_msg) ;
05311    }
05312    EXRETURN ;
05313 }

void T3D_quit_CB Widget    wcall,
XtPointer    client_data,
XtPointer    call_data
 

Definition at line 3592 of file to3d.c.

References AFNI_speak(), client_data, ENTRY, MCW_set_widget_label(), and T3D_quit_timeout_CB().

Referenced by T3D_create_widgets().

03594 {
03595    static Boolean first = True ;
03596    static Widget wquit  = NULL ;
03597 
03598 ENTRY("T3D_quit_CB") ;
03599 
03600   if( wcall == NULL ){
03601     if( wquit == NULL ) return ;
03602     MCW_set_widget_label( wquit , "quit" ) ;
03603     first = True ;
03604     EXRETURN ;
03605   }
03606 
03607   if( first ){
03608      if( wquit == NULL ) wquit = wcall ;
03609      first = False ;
03610      MCW_set_widget_label( wquit , "QUIT" ) ;
03611 
03612      (void) XtAppAddTimeOut( XtWidgetToApplicationContext(wcall) ,
03613                              5000 , T3D_quit_timeout_CB , NULL ) ;
03614 
03615      EXRETURN ;
03616   }
03617   AFNI_speak("Done",0) ;
03618   exit(0) ;
03619 }

void T3D_quit_timeout_CB XtPointer    client_data,
XtIntervalId *    id
 

Definition at line 3585 of file to3d.c.

References client_data, ENTRY, and RESET_QUIT.

Referenced by T3D_quit_CB().

03586 {
03587    ENTRY("T3D_quit_timeout_CB") ;
03588    RESET_QUIT ;
03589    EXRETURN ;
03590 }

void T3D_read_images void   
 

Definition at line 3859 of file to3d.c.

References ADDTO_SARR, to3d_data::anatomy_type, Argc, argopt, Argv, THD_datablock::atr, THD_datablock::brick, THD_datablock::brick_bytes, THD_datablock::brick_fac, THD_diskptr::brick_name, THD_diskptr::byte_order, CLEAR_MRILIB_globals, commandline, DATABLOCK_MEM_MALLOC, DATABLOCK_TYPE, to3d_data::dataset_type, DATAXES_TYPE, THD_3dim_dataset::daxes, THD_3dim_dataset::dblk, DBLK_BRICK, dbrick, THD_3dim_dataset::death_mark, THD_diskptr::dimsizes, THD_diskptr::directory_name, THD_datablock::diskptr, DISKPTR_TYPE, MRI_IMAGE::dw, MRI_IMAGE::dx, MRI_IMAGE::dy, MRI_IMAGE::dz, EMPTY_STRING, ENTRY, FatalError, THD_diskptr::filecode, First_Image_Arg, MRI_IMAGE::fname, to3d_data::fov, FREE_IMARR, THD_3dim_dataset::func_type, to3d_data::function_type, geometry_loaded, THD_diskptr::header_name, complex::i, MRI_IMARR::imarr, imdx, imdy, imdz, INCODE_FOV, INCODE_SLAB, INIT_KILL, INIT_SARR, ISANAT, ISFUNCTYPE, KILL_1MRI, MRI_IMAGE::kind, THD_3dim_dataset::kl, THD_datablock::kl, LAST_ORIENT_TYPE, THD_datablock::malloc_type, THD_3dim_dataset::markers, THD_datablock::master_bytes, THD_datablock::master_ival, THD_datablock::master_nvals, MAX, MCW_file_expand(), MCW_free_expand(), MCW_warn_expand(), MIN, MRI_COMPLEX_PTR, mri_data_pointer(), mri_datum_size(), mri_fix_data_pointer(), MRI_FLOAT_PTR, mri_imcount(), mri_max(), mri_min(), mri_read_file(), mri_read_file_delay(), MRI_SHORT_PTR, mri_to_byte_scl(), mri_to_complex(), mri_to_float(), mri_to_rgb(), mri_to_short(), mri_to_short_scl(), myXtNew, THD_datablock::natr, THD_datablock::natr_alloc, negative_shorts, nfloat_err, to3d_data::nimage, to3d_data::ntt, MRI_IMARR::num, THD_diskptr::nvals, THD_datablock::nvals, to3d_data::nvals, MRI_IMAGE::nvox, nvox_total, MRI_IMAGE::nx, to3d_data::nx, THD_dataxes::nxx, MRI_IMAGE::ny, to3d_data::ny, THD_dataxes::nyy, nz, to3d_data::nz, NZBOT, to3d_data::nzz, THD_dataxes::nzz, MRI_IMAGE::pixel_size, THD_diskptr::prefix, complex::r, THD_diskptr::rank, THD_3dim_dataset::stats, STORAGE_BY_BRICK, THD_diskptr::storage_mode, swap_eightbytes(), swap_fourbytes(), swap_twobytes(), to3d_data::t_then_z, THD_3dim_dataset::tagset, THD_3dim_dataset::taxis, THD_3dim_dataset::tcat_len, THD_3dim_dataset::tcat_list, THD_3dim_dataset::tcat_num, thd_complexscan(), thd_floatscan(), THD_get_write_order(), THD_init_datablock_brick(), THD_MAX_NAME, THD_null_datablock_auxdata, tross_Append_History(), THD_diskptr::type, THD_datablock::type, THD_dataxes::type, THD_3dim_dataset::type, THD_3dim_dataset::view_type, to3d_data::view_type, THD_diskptr::viewcode, MRI_IMAGE::was_swapped, THD_3dim_dataset::wod_daxes, THD_3dim_dataset::wod_flag, XCENTERED, to3d_data::xin_bot, to3d_data::xin_top, to3d_data::xincode, to3d_data::xorient, to3d_data::xorigin, to3d_data::xsize, XtMalloc, THD_dataxes::xxdel, THD_dataxes::xxorg, THD_dataxes::xxorient, to3d_data::xyz_centered, YCENTERED, to3d_data::yin_bot, to3d_data::yin_top, to3d_data::yincode, to3d_data::yorient, to3d_data::yorigin, to3d_data::ysize, THD_dataxes::yydel, THD_dataxes::yyorg, THD_dataxes::yyorient, ZCENTERED, ZERO_STAT_AUX, to3d_data::zin_bot, to3d_data::zin_top, to3d_data::zincode, to3d_data::zorient, to3d_data::zorigin, to3d_data::zsize, to3d_data::zspacing, THD_dataxes::zzdel, THD_dataxes::zzorg, and THD_dataxes::zzorient.

Referenced by main().

03860 {
03861    MRI_IMAGE * im , * shim ;
03862    char * bar ;
03863    int npix , ii , bb , dsize ;
03864    int nx , ny , nz , nim , lf , isfunc , nvals , kz,kim , bsize,ibr ;
03865    MRI_IMARR * arr ;
03866    char iname[THD_MAX_NAME] ;
03867    float nonshort_min=1.E38 , nonshort_max=-1.E38 ;
03868    float nonbyte_min =1.E38 , nonbyte_max =-1.E38 ;
03869    int   nonshort_num=0 , nonfloat_num=0 , noncomplex_num=0 , nonbyte_num=0 ;
03870    int     gnim ;
03871    char ** gname ;
03872    int time_dep , ltt,kzz , ntt,nzz , nvoxt ;
03873    int kzmod ;  /* 06 Nov 2002 */
03874 
03875 ENTRY("T3D_read_images") ;
03876 
03877    nim = Argc - First_Image_Arg ;  /* = number of files, not images! */
03878 
03879    INIT_SARR( imnames ) ;  /* image name for each slice */
03880 
03881    MCW_warn_expand(1) ;
03882    MCW_file_expand( nim , Argv+First_Image_Arg , &gnim , &gname ) ;
03883    MCW_warn_expand(0) ;
03884 #ifdef AFNI_DEBUG
03885 printf("T3D_read_images: input file count = %d; expanded = %d\n",nim,gnim) ;
03886 #endif
03887 
03888    if( gnim < 1 ){ FatalError("NO INPUT IMAGE FILES?") ; }
03889 
03890    /**--- count up the actual number of images into nz ---**/
03891 
03892 #ifndef AFNI_DEBUG
03893    printf("Counting images: ");fflush(stdout);
03894 #endif
03895 
03896    nz = 0 ;
03897    for( lf=0 ; lf < gnim ; lf++ ){
03898       ii = mri_imcount( gname[lf] ) ;
03899       if( ii == 0 ){
03900          fprintf(stderr,"*** bad file specifier %s\n",gname[lf]) ;
03901          exit(1) ;
03902       }
03903       nz += ii ;
03904    }
03905 #ifdef AFNI_DEBUG
03906    printf("T3D_read_images: mri_imcount totals nz=%d\n",nz) ;
03907 #else
03908    printf(" total=%d 2D slices\n",nz) ;
03909 #endif
03910 
03911    if( nz < NZBOT ){
03912       fprintf(stderr,"*** Must have at least %d input images! ***\n",NZBOT) ;
03913       exit(1) ;
03914    }
03915 
03916    /**------ Perform various sanity checks if the user is
03917              trying to create a time dependent dataset.  ------**/
03918 
03919    time_dep = (user_inputs.ntt > 0) ;
03920    if( time_dep ){ ntt = user_inputs.ntt ; nzz = user_inputs.nzz ; }
03921 
03922    if( time_dep && nz != ntt * nzz ){
03923       fprintf(stderr,"*** Number of slices on command line   = %d\n"
03924                      "*** Number of slices needed for -time: = %d\n"
03925                      "*** Something is wrong with your command line!\n" ,
03926               nz , ntt * nzz ) ;
03927       exit(1) ;
03928    }
03929 
03930    if( time_dep ){
03931       isfunc = ISFUNCTYPE(user_inputs.dataset_type) ;
03932       nvals  = (isfunc) ? FUNC_nvals[user_inputs.function_type]
03933                         : ANAT_nvals[user_inputs.anatomy_type]  ;
03934 
03935       if( nvals != 1 ){
03936          fprintf(stderr,"*** Sorry: time dependent datasets with more than one\n"
03937                         "***        value per time point are not yet supported!\n" ) ;
03938          exit(1) ;
03939       }
03940 
03941 #if 0
03942       if( isfunc ){
03943          fprintf(stderr,"*** Sorry: time dependent functional\n"
03944                         "***        datasets are not yet supported!\n" ) ;
03945          exit(1) ;
03946       }
03947 #endif
03948    }
03949 
03950    /*--- read 1st file to get sizes ---*/
03951 
03952    CLEAR_MRILIB_globals ;  /* 12 Mar 2001 */
03953 
03954 #ifdef USE_MRI_DELAY
03955    if( argopt.delay_input )
03956       arr = mri_read_file_delay( gname[0] ) ;
03957    else
03958 #endif
03959       arr = mri_read_file( gname[0] ) ;
03960 
03961    if( arr == NULL || arr->num == 0 ){
03962       fprintf(stderr,"*** cannot read first file! ***\n") ; exit(1) ;
03963    }
03964    im = arr->imarr[0] ;
03965 
03966    nx = im->nx ;
03967    ny = im->ny ; npix = nx * ny ;
03968 
03969    /* 05 Feb 2001: set voxel sizes, if available */
03970 
03971    if( im->dw > 0.0 ){
03972       imdx = im->dx ; imdy = im->dy ; imdz = im->dz ;  /* globals */
03973    }
03974 
03975    /**--- use 1st file to set default datum type, if not set already ---**/
03976 
03977    if( argopt.datum_all < 0 ){
03978       switch( im->kind ){
03979          case MRI_byte:     argopt.datum_all = MRI_byte    ; break ;
03980 
03981          default:
03982          case MRI_short:    argopt.datum_all = MRI_short   ; break ;
03983 
03984          case MRI_int:
03985          case MRI_double:
03986          case MRI_float:    argopt.datum_all = MRI_float   ; break ;
03987 
03988          case MRI_complex:  argopt.datum_all = MRI_complex ; break ;
03989 
03990          case MRI_rgb:      argopt.datum_all = MRI_rgb     ; break ;
03991       }
03992    }
03993 
03994    /**--- allocate storage for all slices to be input ---**/
03995 
03996    dsize  = mri_datum_size( (MRI_TYPE) argopt.datum_all ) ;
03997    dbrick = bar = (char*)XtMalloc( dsize * nx * ny * nz ) ;
03998    nvoxt  = nx * ny * nz ;
03999 
04000 #if 0
04001 printf("T3D_read_images: first file (%s) has nx=%d ny=%d #im=%d\n",
04002        gname[0],nx,ny,arr->num) ;
04003 #endif
04004 
04005    /*--- read all files, convert to desired type if needed, put in the brick ---*/
04006 
04007 #ifndef AFNI_DEBUG
04008    printf("Reading images: ");fflush(stdout);
04009    kzmod = (int)(0.0234567*nz)+1 ;                /* 06 Nov 2002 */
04010 #endif
04011 
04012    kz = 0 ; if( time_dep ){ ltt = kzz = 0 ; }
04013 
04014    for( lf=0 ; lf < gnim ; lf++ ){  /** loop over files **/
04015 
04016       /*--- open this file, if not the first (which we read in a minute ago) ---*/
04017 
04018       if( lf != 0 ){
04019 #ifdef USE_MRI_DELAY
04020          if( argopt.delay_input )
04021             arr = mri_read_file_delay( gname[0] ) ;
04022          else
04023 #endif
04024             arr = mri_read_file( gname[lf] ) ;
04025 
04026          if( arr == NULL || arr->num == 0 ){
04027             fprintf(stderr,"*** cannot read file %s\n",gname[lf]) ;
04028             exit(1) ;
04029          }
04030 #ifdef AFNI_DEBUG
04031 printf("T3D_read_images: file %d (%s) has #im=%d\n",lf,gname[lf],arr->num) ;
04032 #endif
04033       }
04034 
04035       for( kim=0 ; kim < arr->num ; kim++ ){  /** loop over 2D images in file **/
04036 
04037          /*--- set string for this slice for display in image viewing window ---*/
04038 
04039          if( arr->num == 1 ){
04040             strcpy( iname , gname[lf] ) ;
04041          } else {
04042             sprintf( iname , "%s#%d" , gname[lf],kim) ;
04043          }
04044          ADDTO_SARR(imnames,iname) ;
04045 
04046          /*--- get the image and check if it fits the first image dimensions ---*/
04047 
04048          im = arr->imarr[kim] ;
04049          if( im->nx != nx || im->ny != ny ){
04050             fprintf(stderr,"*** file %s has nonconforming images: first=%dx%d this=%dx%d\n",
04051                    gname[lf] , nx,ny , im->nx,im->ny) ;
04052             exit(1) ;
04053          }
04054 
04055 #ifdef USE_MRI_DELAY
04056          if( argopt.delay_input )
04057             (void) mri_data_pointer( im ) ;  /* force load of image from disk */
04058 #endif
04059 
04060          /* 14 Sep 1998: swap bytes if ordered */
04061          /* 07 Mar 2002: but only if it wasn't already swapped */
04062 
04063          if( im->pixel_size == 2 && argopt.swap_two ){
04064             if( im->was_swapped ){  /* don't swap me */
04065               static int first=1 ;
04066               if( first ){          /* but print a message */
04067                 fprintf(stderr,"++ Ignoring -2swap on input image [%s...]\n",
04068                         (im->fname == NULL) ? "." : im->fname ) ;
04069                 first = 0 ;
04070               }
04071             } else {                /* swap me */
04072               static int first=1 ;
04073               if( first ){          /* and print a message */
04074                 fprintf(stderr,"++ Executing -2swap on input image [%s...]\n",
04075                         (im->fname == NULL) ? "." : im->fname ) ;
04076                 first = 0 ;
04077               }
04078               swap_twobytes( im->nvox , mri_data_pointer(im) ) ;
04079             }
04080          } else if( im->pixel_size == 4 && argopt.swap_four ){
04081             if( im->was_swapped ){  /* don't swap me again */
04082               static int first=1 ;
04083               if( first ){          /* but print a missive */
04084                 fprintf(stderr,"++ Ignoring -4swap on input image [%s...]\n",
04085                         (im->fname == NULL) ? "" : im->fname ) ;
04086                 first = 0 ;
04087               }
04088             } else {                /* swap me, swap me */
04089               static int first=1 ;
04090               if( first ){          /* and print a message */
04091                 fprintf(stderr,"++ Executing -4swap on input image [%s...]\n",
04092                         (im->fname == NULL) ? "." : im->fname ) ;
04093                 first = 0 ;
04094               }
04095               swap_fourbytes( im->nvox , mri_data_pointer(im) ) ;
04096             }
04097          } else if( im->pixel_size == 8 && argopt.swap_eight ){   /* 06 Feb 2003 */
04098             if( im->was_swapped ){  /* don't swap me again */
04099               static int first=1 ;
04100               if( first ){          /* but print a missive */
04101                 fprintf(stderr,"++ Ignoring -8swap on input image [%s...]\n",
04102                         (im->fname == NULL) ? "" : im->fname ) ;
04103                 first = 0 ;
04104               }
04105             } else {                /* swap me, swap me */
04106               static int first=1 ;
04107               if( first ){          /* and print a message */
04108                 fprintf(stderr,"++ Executing -8swap on input image [%s...]\n",
04109                         (im->fname == NULL) ? "." : im->fname ) ;
04110                 first = 0 ;
04111               }
04112               swap_eightbytes( im->nvox , mri_data_pointer(im) ) ;
04113             }
04114          }
04115 
04116          /* 14 Sep 1999: check float inputs for errors */
04117 
04118          if( !argopt.nofloatscan && im->kind == MRI_float )
04119             nfloat_err += thd_floatscan( im->nvox , MRI_FLOAT_PTR(im) ) ;
04120          else if( !argopt.nofloatscan && im->kind == MRI_complex )
04121             nfloat_err += thd_complexscan( im->nvox , MRI_COMPLEX_PTR(im) ) ;
04122 
04123          /*--- convert input image to desired type:  im --> shim ---*/
04124 
04125          if( im->kind == argopt.datum_all ){    /* data is desired type */
04126             shim = im ;
04127 
04128          } else {                               /* must convert data */
04129             switch( argopt.datum_all ){
04130 
04131                default: FatalError("Illegal argopt.datum_all!") ;
04132 
04133                case MRI_short:{                 /** convert to shorts **/
04134                   short * shar ;
04135 
04136                   if( argopt.gsfac == 0.0 ){      /* scale each slice by itself */
04137                      float immin , immax ;
04138                      immin = mri_min( im ) ; immax = mri_max( im ) ;
04139                      if( immin >= -32767.0 && immax <= 32767.0 )
04140                         shim = mri_to_short( 1.0 , im ) ;   /* no need to scale */
04141                      else
04142                         shim = mri_to_short_scl( 0.0 , 10000.0 , im ) ;  /* scale */
04143 
04144                      nonshort_min = MIN(immin,nonshort_min) ;
04145                      nonshort_max = MAX(immax,nonshort_max) ; nonshort_num++ ;
04146                      KILL_1MRI(im) ;
04147                   } else {                         /* use global scaling factor */
04148                      float immin , immax ;
04149                      shim = mri_to_short( argopt.gsfac , im ) ;
04150                      immin = mri_min( im ) ; immax = mri_max( im ) ;
04151                      nonshort_min = MIN(immin,nonshort_min) ;
04152                      nonshort_max = MAX(immax,nonshort_max) ; nonshort_num++ ;
04153                      KILL_1MRI(im) ;
04154                   }
04155 
04156                   /* correct for oddities of FIM */
04157 
04158                   shar = MRI_SHORT_PTR( shim ) ;  /* image of shorts */
04159                   if( shar[1] == -10000 && shar[2] == 10000 ) shar[1] = shar[2] = 0 ;
04160                }
04161                break ;  /* end of conversion to shorts */
04162 
04163                case MRI_byte:{                 /** convert to bytes **/
04164 
04165                   if( argopt.gsfac == 0.0 ){      /* scale each slice by itself */
04166                      float immin , immax ;
04167                      immin = mri_min( im ) ; immax = mri_max( im ) ;
04168                      if( immin >= 0 && immax <= 255.0 )
04169                         shim = mri_to_byte_scl( 1.0 , 0.0 , im ) ; /* no scale */
04170                      else
04171                         shim = mri_to_byte_scl( 0.0 , 255.0 , im ) ;  /* scale */
04172 
04173                      nonbyte_min = MIN(immin,nonbyte_min) ;
04174                      nonbyte_max = MAX(immax,nonbyte_max) ; nonbyte_num++ ;
04175                      KILL_1MRI(im) ;
04176                   } else {                         /* use global scaling factor */
04177                      float immin , immax ;
04178                      shim = mri_to_byte_scl( argopt.gsfac , 0.0 , im ) ;
04179                      immin = mri_min( im ) ; immax = mri_max( im ) ;
04180                      nonbyte_min = MIN(immin,nonbyte_min) ;
04181                      nonbyte_max = MAX(immax,nonbyte_max) ; nonbyte_num++ ;
04182                      KILL_1MRI(im) ;
04183                   }
04184 
04185                }
04186                break ;  /* end of conversion to bytes */
04187 
04188                case MRI_float:{            /** convert to floats **/
04189                   float * shar ;
04190 
04191                   shim = mri_to_float( im ) ;  nonfloat_num++ ;
04192                   KILL_1MRI(im) ;
04193 
04194                   shar = MRI_FLOAT_PTR( shim ) ;  /* image of floats */
04195                   if( shar[1]==-10000.0 && shar[2]==10000.0 ) shar[1]=shar[2]=0.0 ;
04196                }
04197                break ;  /* end of conversion to floats */
04198 
04199                case MRI_complex:{         /** convert to complexes **/
04200                   complex * shar ;
04201 
04202                   shim = mri_to_complex( im ) ;  noncomplex_num++ ;
04203                   KILL_1MRI(im) ;
04204 
04205                   shar = MRI_COMPLEX_PTR( shim ) ;  /* image of complexes */
04206                   if( shar[1].r == -10000.0 && shar[2].r == 10000.0 &&
04207                       shar[1].i ==      0.0 && shar[2].i ==     0.0   ){
04208 
04209                      shar[1].r=shar[2].r=0.0 ;
04210                   }
04211                }
04212                break ;  /* end of conversion to complexes */
04213 
04214                case MRI_rgb:{             /** convert to RGB **/
04215                   shim = mri_to_rgb( im ) ;
04216                   KILL_1MRI(im) ;
04217                }
04218                break ;
04219 
04220             }
04221          }  /**-- end of conversion: desired image is in shim --**/
04222 
04223 #ifdef AFNI_DEBUG
04224 printf("T3D_read_images: putting data into slice %d\n",kz) ;
04225 #endif
04226 
04227          if( ! time_dep ){
04228 
04229             /**-- copy data from shim into the kz-th slice in bar --**/
04230 
04231             bb = npix * dsize * kz ;
04232             memcpy( bar+bb , mri_data_pointer(shim) , npix*dsize ) ;
04233          } else {
04234 
04235             /**-- copy data from shim into the (kzz,ltt)-th slice in bar --**/
04236 
04237             bb = npix * dsize * ( kzz + ltt * nzz ) ;
04238             memcpy( bar+bb , mri_data_pointer(shim) , npix*dsize ) ;
04239 
04240             /*-- step the kzz,ltt indices forward, depending on the
04241                  order in which the slices are coming in (-time:zt or :tz) --*/
04242 
04243             if( user_inputs.t_then_z ){
04244               ltt++ ; if( ltt == ntt ){ ltt = 0 ; kzz++ ; }
04245             } else {
04246               kzz++ ; if( kzz == nzz ){ kzz = 0 ; ltt++ ; }
04247             }
04248          }
04249          kz++ ;
04250 
04251          KILL_1MRI(shim) ;
04252 #ifndef AFNI_DEBUG
04253          if( kz%kzmod == 0 ){ printf(".") ; fflush(stdout); }
04254 #endif
04255       }  /** end of loop over images from 1 file **/
04256 
04257       FREE_IMARR(arr) ;
04258    }  /** end of loop over files **/
04259 #ifndef AFNI_DEBUG
04260    printf("\n");fflush(stdout);
04261 #endif
04262 
04263    if( nfloat_err > 0 )  /* 14 Sep 1999 */
04264       printf("*** Found %d float errors in inputs - see program float_scan!\n",
04265              nfloat_err) ;
04266 
04267    MCW_free_expand( gnim , gname ) ;
04268 
04269    /**-- 10 Jan 2004: set slice thickness to slice spacing, if given --**/
04270 
04271    if( use_MRILIB_slicespacing && fabs(MRILIB_slicespacing-imdz) > 0.01l ){
04272      fprintf(stderr,"Using slice spacing=%g",MRILIB_slicespacing) ;
04273      if( imdz > 0.0 ) fprintf(stderr," instead of slice thickness=%g",imdz) ;
04274      fprintf(stderr,"\n") ;
04275      imdz = MRILIB_slicespacing ;
04276    }
04277 
04278    /**-- 19 Jan 2000: check inputs shorts for negativity --**/
04279 
04280    if( argopt.datum_all == MRI_short ){
04281       short * sar = (short *) dbrick ;
04282       for( ii=0 ; ii < nvoxt ; ii++ )
04283          if( sar[ii] < 0 ) negative_shorts++ ;
04284    }
04285    nvox_total = nvoxt ; /* 24 Aug 2001 */
04286 
04287    /**--- print conversion information ---**/
04288 
04289    if( nonshort_num > 0 )
04290       printf( "Number of non-short slices converted to shorts = %d\n"
04291               "Smallest value in them                         = %f\n"
04292               "Largest value in them                          = %f\n" ,
04293              nonshort_num , nonshort_min , nonshort_max ) ;
04294 
04295    if( nonbyte_num > 0 )
04296       printf( "Number of non-byte slices converted to bytes = %d\n"
04297               "Smallest value in them                       = %f\n"
04298               "Largest value in them                        = %f\n" ,
04299              nonbyte_num , nonbyte_min , nonbyte_max ) ;
04300 
04301    if( nonfloat_num > 0 )
04302       printf( "Number of non-float slices converted to floats = %d\n",
04303              nonfloat_num ) ;
04304 
04305    if( noncomplex_num > 0 )
04306       printf( "Number of non-complex slices converted to complexes = %d\n",
04307              noncomplex_num ) ;
04308 
04309    /*--- now create the rest of the data structures, as far as we can ---*/
04310 
04311    isfunc = ISFUNCTYPE(user_inputs.dataset_type) ;
04312    nvals  = (isfunc) ? FUNC_nvals[user_inputs.function_type]
04313                      : ANAT_nvals[user_inputs.anatomy_type]  ;
04314 
04315    nim    = kz ;  /* number of images actually processed above */
04316 
04317    if( time_dep ){
04318       nvals = ntt ;
04319       if( nim != ntt * nzz ){
04320          fprintf(stderr,
04321                   "\n"
04322                   "***** TIME-DEPENDENCE ERROR *****\n"
04323                   " Number of images input does not\n"
04324                   " match number specified in -time:\n"
04325                   " option on command line!\n" ) ;
04326          exit(1) ;
04327       }
04328    }
04329 
04330 #ifdef AFNI_DEBUG
04331 printf("T3D_read_images: nvals set to %d\n",nvals) ;
04332 #endif
04333 
04334    nz = nim / nvals ;           /* number of slices */
04335    if( nz * nvals != nim ){
04336       fprintf(stderr,
04337                "\n"
04338                "***** DATA TYPE ERROR *****\n"
04339                " Number of images not an even\n"
04340                " multiple of number of values\n"
04341                " required for chosen data type\n" ) ;
04342       exit(1) ;
04343    }
04344 
04345    dset    =                 myXtNew( THD_3dim_dataset ) ;  /* these are */
04346    dblk    = dset->dblk    = myXtNew( THD_datablock ) ;     /* globals */
04347    daxes   = dset->daxes   = myXtNew( THD_dataxes ) ;
04348    markers = dset->markers = NULL ;                       /* later, dude */
04349    dkptr   = dblk->diskptr = myXtNew( THD_diskptr ) ;
04350 
04351    dset->tagset = NULL ;  /* Oct 1998 */
04352 
04353    INIT_KILL(dset->kl) ; INIT_KILL(dblk->kl) ;
04354 
04355    dkptr->type         = DISKPTR_TYPE ;
04356    dkptr->rank         = 3 ;
04357    dkptr->nvals        = nvals ;
04358    dkptr->dimsizes[0]  = nx ;
04359    dkptr->dimsizes[1]  = ny ;
04360    dkptr->dimsizes[2]  = nz ;
04361    dkptr->storage_mode = STORAGE_BY_BRICK ;
04362    dkptr->byte_order   = THD_get_write_order() ;  /* 25 April 1998 */
04363    EMPTY_STRING(dkptr->prefix) ;
04364    EMPTY_STRING(dkptr->viewcode) ;
04365    EMPTY_STRING(dkptr->filecode) ;
04366    EMPTY_STRING(dkptr->directory_name) ;
04367    EMPTY_STRING(dkptr->header_name) ;
04368    EMPTY_STRING(dkptr->brick_name) ;
04369 
04370    dblk->type        = DATABLOCK_TYPE ;
04371    dblk->nvals       = dkptr->nvals ;
04372    dblk->malloc_type = DATABLOCK_MEM_MALLOC ;
04373    dblk->natr        = 0 ;
04374    dblk->natr_alloc  = 0 ;
04375    dblk->atr         = NULL ;
04376    dblk->brick       = NULL ;
04377    dblk->brick_fac   = NULL ;
04378    dblk->brick_bytes = NULL ;
04379 
04380    THD_init_datablock_brick( dblk , argopt.datum_all , NULL ) ;
04381    THD_null_datablock_auxdata( dblk ) ;
04382 
04383    dblk->master_nvals = 0 ;     /* 11 Jan 1999 */
04384    dblk->master_ival  = NULL ;
04385    dblk->master_bytes = NULL ;
04386 
04387    bsize = nx*ny*nz * mri_datum_size( argopt.datum_all ) ;
04388    for( ibr=0 ; ibr < nvals ; ibr++ ){
04389       mri_fix_data_pointer( dbrick + ibr*bsize , DBLK_BRICK(dblk,ibr) ) ;
04390    }
04391 
04392    daxes->type     = DATAXES_TYPE ;
04393    daxes->nxx      = nx ;
04394    daxes->nyy      = ny ;
04395    daxes->nzz      = nz ;
04396    daxes->xxorg    = - user_inputs.xorigin ;
04397    daxes->yyorg    = - user_inputs.yorigin ;
04398    daxes->zzorg    = - user_inputs.zorigin ;
04399    daxes->xxdel    =   user_inputs.xsize ;
04400    daxes->yydel    =   user_inputs.ysize ;
04401 #ifdef ALLOW_NONCONTIG
04402    daxes->zzdel    =   user_inputs.zspacing ;
04403 #else
04404    daxes->zzdel    =   user_inputs.zsize ;
04405 #endif
04406    daxes->xxorient = user_inputs.xorient ;
04407    daxes->yyorient = user_inputs.yorient ;
04408    daxes->zzorient = user_inputs.zorient ;
04409 
04410    dset->type      = user_inputs.dataset_type ;
04411    dset->view_type = user_inputs.view_type ;
04412    dset->func_type = ISANAT(dset) ? (user_inputs.anatomy_type)
04413                                   : (user_inputs.function_type) ;
04414 
04415    dset->wod_daxes   = NULL ;
04416    dset->wod_flag    = 0 ;
04417    dset->stats       = NULL ;
04418 #ifdef ALLOW_DATASET_VLIST
04419    dset->pts         = NULL ;
04420 #endif
04421    dset->death_mark  = 0 ;
04422    dset->tcat_list   = NULL ;
04423    dset->tcat_num    = 0 ;
04424    dset->tcat_len    = NULL ;
04425 
04426    ZERO_STAT_AUX( dset ) ;
04427 
04428    user_inputs.nx     = nx ;
04429    user_inputs.ny     = ny ;
04430    user_inputs.nz     = nz ;
04431    user_inputs.nimage = nim ;
04432    user_inputs.nvals  = nvals ;
04433 
04434    /**--- fix dimensions if user input axes stuff ---**/
04435 
04436    if( user_inputs.xincode > 0 ){
04437       int dcode , fov ;
04438       float dx , xorg , size ;
04439 
04440       fov   = 1 ;
04441       dcode = user_inputs.xincode - INCODE_FOV ;
04442 
04443       if( dcode < FIRST_ORIENT_TYPE || dcode > LAST_ORIENT_TYPE ){
04444          dcode = user_inputs.xincode - INCODE_SLAB ;
04445          fov   = 0 ;
04446       }
04447 
04448       if( fov ){
04449          dx   = (user_inputs.xin_bot + user_inputs.xin_top) / nx ;
04450          xorg =  user_inputs.xin_bot - 0.5*dx ;
04451       } else {
04452          dx   = (user_inputs.xin_bot + user_inputs.xin_top) / (nx-1) ;
04453          xorg =  user_inputs.xin_bot ;
04454       }
04455       user_inputs.xorient = dcode ;
04456       user_inputs.xsize   = dx ;
04457       user_inputs.xorigin = xorg ;
04458       user_inputs.fov     = nx * dx ; geometry_loaded = 1 ;
04459 
04460       size = 0.5 * (nx-1) * dx ;
04461       if( fabs(size-xorg) < 0.01 )
04462          user_inputs.xyz_centered |= XCENTERED ;
04463       else
04464          user_inputs.xyz_centered &= ~XCENTERED ;
04465    }
04466 
04467    if( user_inputs.yincode > 0 ){
04468       int dcode , fov ;
04469       float dy , yorg , size ;
04470 
04471       fov   = 1 ;
04472       dcode = user_inputs.yincode - INCODE_FOV ;
04473 
04474       if( dcode < FIRST_ORIENT_TYPE || dcode > LAST_ORIENT_TYPE ){
04475          dcode = user_inputs.yincode - INCODE_SLAB ;
04476          fov   = 0 ;
04477       }
04478 
04479       if( fov ){
04480          dy   = (user_inputs.yin_bot + user_inputs.yin_top) / ny ;
04481          yorg =  user_inputs.yin_bot - 0.5*dy ;
04482       } else {
04483          dy   = (user_inputs.yin_bot + user_inputs.yin_top) / (ny-1) ;
04484          yorg =  user_inputs.yin_bot ;
04485       }
04486       user_inputs.yorient = dcode ;
04487       user_inputs.ysize   = dy ;
04488       user_inputs.yorigin = yorg ;
04489       user_inputs.fov     = ny * dy ; geometry_loaded = 1 ;
04490 
04491       size = 0.5 * (ny-1) * dy ;
04492       if( fabs(size-yorg) < 0.01 )
04493          user_inputs.xyz_centered |= YCENTERED ;
04494       else
04495          user_inputs.xyz_centered &= ~YCENTERED ;
04496    }
04497 
04498    if( user_inputs.zincode > 0 ){
04499       int dcode , fov ;
04500       float dz , zorg , size ;
04501 
04502       fov   = 1 ;
04503       dcode = user_inputs.zincode - INCODE_FOV ;
04504 
04505       if( dcode < FIRST_ORIENT_TYPE || dcode > LAST_ORIENT_TYPE ){
04506          dcode = user_inputs.zincode - INCODE_SLAB ;
04507          fov   = 0 ;
04508       }
04509 
04510       if( fov ){
04511          dz   = (user_inputs.zin_bot + user_inputs.zin_top) / nz ;
04512          zorg =  user_inputs.zin_bot - 0.5*dz ;
04513       } else {
04514          if( nz == 1 ){
04515             fprintf(stderr,"*** -zSLAB illegal with only 1 slice! ***\n") ;
04516             exit(1) ;
04517          }
04518          dz   = (user_inputs.zin_bot + user_inputs.zin_top) / (nz-1) ;
04519          zorg =  user_inputs.zin_bot ;
04520       }
04521       user_inputs.zorient = dcode ;
04522       user_inputs.zsize   = dz ;
04523       user_inputs.zorigin = zorg ;
04524 
04525       size = 0.5 * (nz-1) * dz ;
04526       if( fabs(size-zorg) < 0.01 )
04527          user_inputs.xyz_centered |= ZCENTERED ;
04528       else
04529          user_inputs.xyz_centered &= ~ZCENTERED ;
04530    }
04531 
04532    dset->taxis = NULL ;  /* will be patched later, if necessary */
04533 
04534    if( commandline != NULL ) tross_Append_History( dset , commandline ) ;
04535 
04536    /*********** DONE **********/
04537 
04538    EXRETURN ;
04539 }

void T3D_save_file_CB Widget    w,
XtPointer    client_data,
XtPointer    call_data
 

Definition at line 4659 of file to3d.c.

References THD_marker_set::aflags, AFNI_speak(), THD_3dim_dataset::anat_parent_idcode, THD_3dim_dataset::anat_parent_name, to3d_data::anatomy_dataname, to3d_data::anatomy_parent_idcode, to3d_data::anatomy_type, THD_datablock::brick_fac, client_data, commandline, to3d_data::dataset_name, to3d_data::dataset_type, THD_3dim_dataset::dblk, DBLK_BRICK_TYPE, DSET_delete, DSET_NUM_TIMES, THD_timeaxis::dz_sl, EMPTY_STRING, FUNC_HAVE_THR, THD_3dim_dataset::func_type, to3d_data::function_type, to3d_widget_set::good, HEAD_ANAT_TYPE, THD_marker_set::help, THD_3dim_dataset::idcode, INIT_STAT_AUX, ISFUNC, THD_3dim_dataset::keywords, THD_marker_set::label, THD_3dim_dataset::label1, THD_3dim_dataset::label2, THD_3dim_dataset::markers, MARKS_MAXFLAG, MARKS_MAXHELP, MARKS_MAXLAB, MARKS_MAXNUM, MCW_CALLER_KILL, MCW_new_idcode, MCW_popup_message(), MCW_strncpy, MCW_TIMER_KILL, MCW_USER_KILL, myXtNew, to3d_data::need_stat_aux, NMARK_ALIGN, THD_timeaxis::nsl, to3d_data::ntt, THD_timeaxis::ntt, THD_marker_set::numdef, THD_dataxes::nxx, THD_dataxes::nyy, THD_dataxes::nzz, ORI_A2P_TYPE, ORI_I2S_TYPE, ORI_L2R_TYPE, ORI_P2A_TYPE, ORI_R2L_TYPE, ORI_S2I_TYPE, outliers_checked, to3d_data::output_filename, to3d_widget_set::save_file_pb, THD_3dim_dataset::self_name, to3d_data::session_filename, to3d_data::short_label1, to3d_data::short_label2, to3d_data::stat_aux, T3D_check_data(), T3D_check_outliers(), T3D_poperr(), T3D_widgets_to_data(), THD_3dim_dataset::taxis, THD_load_statistics(), THD_MAX_LABEL, THD_MAX_NAME, THD_set_int_atr(), THD_write_3dim_dataset(), THD_zeropad(), TIMEAXIS_TYPE, THD_timeaxis::toff_sl, to3d_widget_set::topshell, to3d_data::Torg, to3d_data::tpattern, to3d_data::TR, tross_Append_History(), THD_timeaxis::ttdel, THD_timeaxis::ttdur, THD_timeaxis::ttorg, to3d_data::tunits, THD_3dim_dataset::type, THD_timeaxis::type, THD_timeaxis::units_type, THD_marker_set::valid, VIEW_ORIGINAL_TYPE, THD_3dim_dataset::view_type, to3d_data::view_type, THD_3dim_dataset::warp, THD_3dim_dataset::warp_parent_idcode, THD_3dim_dataset::warp_parent_name, WATCH_cursorize, to3d_data::xorient, to3d_data::xorigin, to3d_data::xsize, THD_dataxes::xxdel, THD_dataxes::xxorg, THD_dataxes::xxorient, to3d_data::yorient, to3d_data::yorigin, to3d_data::ysize, THD_dataxes::yydel, THD_dataxes::yyorg, THD_dataxes::yyorient, ZERO_IDCODE, THD_timeaxis::zorg_sl, to3d_data::zorient, to3d_data::zorigin, zpad, ZPAD_MM, to3d_data::zsize, to3d_data::zspacing, THD_dataxes::zzdel, THD_dataxes::zzorg, and THD_dataxes::zzorient.

Referenced by main(), and T3D_create_widgets().

04661 {
04662    Boolean good , isfunc ;
04663    int ii , jj , bigfile ;
04664    Widget wmsg = NULL ;
04665    int npad ;
04666 
04667    /*-- store all control data in the user_inputs data struct --*/
04668 
04669    if( wset.topshell != NULL && wset.good ) T3D_widgets_to_data() ;
04670 
04671    /*-- check for legal values --*/
04672 
04673    good = T3D_check_data( True ) ;
04674    if( !good ) return ;
04675 
04676    AFNI_speak("Saving",0) ;
04677 
04678    /*-- store values in dataset --*/
04679 
04680    dset->type      = user_inputs.dataset_type ;
04681    dset->view_type = user_inputs.view_type ;
04682 
04683    isfunc = ISFUNC(dset) ;
04684 
04685    dset->func_type = (isfunc) ? (user_inputs.function_type)
04686                               : (user_inputs.anatomy_type) ;
04687 
04688    if( isfunc && FUNC_HAVE_THR(dset->func_type) ){
04689       int iv = FUNC_ival_thr[dset->func_type] ;
04690       switch( DBLK_BRICK_TYPE(dblk,iv) ){
04691          default:
04692             dblk->brick_fac[iv] = 0.0 ;
04693          break ;
04694 
04695          case MRI_short:
04696             dblk->brick_fac[iv] = 1.0 / FUNC_scale_short[dset->func_type] ;
04697          break ;
04698 
04699          case MRI_byte:
04700             dblk->brick_fac[iv] = 1.0 / FUNC_scale_byte[dset->func_type] ;
04701          break ;
04702       }
04703    }
04704 
04705    if( user_inputs.need_stat_aux ){
04706       INIT_STAT_AUX( dset ,
04707                      FUNC_need_stat_aux[user_inputs.function_type] ,
04708                      user_inputs.stat_aux ) ;
04709    }
04710 
04711    dset->warp = NULL ;
04712 
04713    MCW_strncpy( dset->label1 , user_inputs.short_label1 , THD_MAX_LABEL ) ;
04714    MCW_strncpy( dset->label2 , user_inputs.short_label2 , THD_MAX_LABEL ) ;
04715    dset->keywords = NULL ;
04716 
04717    if( strlen(dset->label1) == 0 ){
04718       MCW_strncpy( dset->label1 , user_inputs.output_filename , THD_MAX_LABEL ) ;
04719    }
04720 
04721    EMPTY_STRING( dset->warp_parent_name ) ;
04722    ZERO_IDCODE(dset->warp_parent_idcode) ;
04723 
04724    if( strlen(user_inputs.anatomy_dataname) > 0 ){
04725       MCW_strncpy( dset->anat_parent_name ,
04726                    user_inputs.anatomy_dataname , THD_MAX_NAME ) ;
04727       dset->anat_parent_idcode = user_inputs.anatomy_parent_idcode ;
04728    } else {
04729       EMPTY_STRING( dset->anat_parent_name ) ;
04730       ZERO_IDCODE(dset->anat_parent_idcode) ;
04731    }
04732 
04733    MCW_strncpy( dset->self_name, user_inputs.dataset_name, THD_MAX_NAME ) ;
04734 
04735    daxes->xxorient = user_inputs.xorient ;
04736    daxes->yyorient = user_inputs.yorient ;
04737    daxes->zzorient = user_inputs.zorient ;
04738 
04739    daxes->xxorg = (ORIENT_sign[user_inputs.xorient] == '+')
04740                   ? (-user_inputs.xorigin) : ( user_inputs.xorigin) ;
04741 
04742    daxes->yyorg = (ORIENT_sign[user_inputs.yorient] == '+')
04743                   ? (-user_inputs.yorigin) : ( user_inputs.yorigin) ;
04744 
04745    daxes->zzorg = (ORIENT_sign[user_inputs.zorient] == '+')
04746                   ? (-user_inputs.zorigin) : ( user_inputs.zorigin) ;
04747 
04748    daxes->xxdel = (ORIENT_sign[user_inputs.xorient] == '+')
04749                   ? ( user_inputs.xsize) : (-user_inputs.xsize) ;
04750 
04751    daxes->yydel = (ORIENT_sign[user_inputs.yorient] == '+')
04752                   ? ( user_inputs.ysize) : (-user_inputs.ysize) ;
04753 
04754 #ifdef ALLOW_NONCONTIG
04755    daxes->zzdel = (ORIENT_sign[user_inputs.zorient] == '+')
04756                   ? ( user_inputs.zspacing) : (-user_inputs.zspacing) ;
04757 #else
04758    daxes->zzdel = (ORIENT_sign[user_inputs.zorient] == '+')
04759                   ? ( user_inputs.zsize) : (-user_inputs.zsize) ;
04760 #endif
04761 
04762    /*-- this stuff is no longer used --*/
04763 
04764 #ifdef ALLOW_NONCONTIG
04765    daxes->xxskip = 0.0 ;
04766    daxes->yyskip = 0.0 ;
04767    daxes->zzskip = user_inputs.zspacing - user_inputs.zsize ;
04768 #endif
04769 
04770    dset->taxis = NULL ;
04771 
04772    if( user_inputs.ntt > 0 ){
04773       dset->taxis = myXtNew( THD_timeaxis ) ;
04774 
04775       dset->taxis->type       = TIMEAXIS_TYPE ;
04776       dset->taxis->ntt        = user_inputs.ntt ;
04777       dset->taxis->ttdel      = user_inputs.TR ;
04778       dset->taxis->ttdur      = 0.0 ;
04779       dset->taxis->units_type = user_inputs.tunits ;  /* 21 Oct 1996 */
04780       dset->taxis->ttorg      = user_inputs.Torg ;    /* 23 Feb 2005 */
04781 
04782       if( user_inputs.tpattern != NULL ){
04783          dset->taxis->nsl     = daxes->nzz ;
04784          dset->taxis->zorg_sl = daxes->zzorg ;
04785          dset->taxis->dz_sl   = daxes->zzdel ;
04786          dset->taxis->toff_sl = user_inputs.tpattern ;
04787       } else {
04788          dset->taxis->nsl     = 0 ;
04789          dset->taxis->zorg_sl = 0.0 ;
04790          dset->taxis->dz_sl   = 0.0 ;
04791          dset->taxis->toff_sl = NULL ;
04792       }
04793    }
04794 
04795    /*-- get the dataset statistics --*/
04796 
04797    if( dset->taxis == NULL )
04798       bigfile = (daxes->nxx * daxes->nyy * daxes->nzz > 9999999) ;
04799    else
04800       bigfile = (daxes->nxx * daxes->nyy * daxes->nzz * dset->taxis->ntt > 9999999) ;
04801 
04802    if( wset.topshell != NULL && bigfile && wset.good ){
04803       wmsg = MCW_popup_message( wset.save_file_pb ,
04804                                    "***************\n"
04805                                    "*  Computing  *\n"
04806                                    "*  dataset    *\n"
04807                                    "*  statistics *\n"
04808                                    "***************" ,
04809                                 MCW_CALLER_KILL ) ;
04810       WATCH_cursorize( wmsg ) ;
04811       XFlush( XtDisplay(wmsg) ) ;
04812    } else {
04813       wmsg = NULL ;
04814    }
04815 
04816    THD_load_statistics( dset ) ;
04817 
04818    if( !outliers_checked ){    /* 15 Aug 2001 */
04819       T3D_check_outliers(0) ; outliers_checked = 1 ;
04820    }
04821 
04822    if( wmsg != NULL ) XtDestroyWidget( wmsg ) ;
04823 
04824    /*-- maybe some Talairach markers, too --*/
04825 
04826    if( dset->type      == HEAD_ANAT_TYPE     &&
04827        dset->view_type == VIEW_ORIGINAL_TYPE &&
04828        DSET_NUM_TIMES(dset) == 1                ){  /* no markers on 3D+t datasets! */
04829 
04830       markers = dset->markers = myXtNew( THD_marker_set ) ;
04831       markers->numdef = 0 ;
04832 
04833       for( ii=0 ; ii < MARKS_MAXNUM ; ii++ ){       /* null all data out */
04834          markers->valid[ii] = 0 ;
04835          for( jj=0 ; jj < MARKS_MAXLAB  ; jj++ )
04836             markers->label[ii][jj] = '\0';
04837          for( jj=0 ; jj < MARKS_MAXHELP ; jj++ )
04838             markers->help[ii][jj]  = '\0';
04839       }
04840 
04841       for( ii=0 ; ii < NMARK_ALIGN ; ii++ ){       /* copy strings in */
04842          MCW_strncpy( &(markers->label[ii][0]) ,
04843                       THD_align_label[ii] , MARKS_MAXLAB ) ;
04844          MCW_strncpy( &(markers->help[ii][0]) ,
04845                       THD_align_help[ii] , MARKS_MAXHELP ) ;
04846       }
04847 
04848       for( ii=0 ; ii < MARKS_MAXFLAG ; ii++ )     /* copy flags in */
04849          markers->aflags[ii] = THD_align_aflags[ii] ;
04850 
04851    } /* end of markers (for HEAD_ANAT_TYPE) */
04852 
04853    /*----- actually write the dataset out! -----*/
04854 
04855    if( wset.topshell != NULL && bigfile && wset.good ){
04856       wmsg = MCW_popup_message( wset.save_file_pb ,
04857                                    "********************\n"
04858                                    "*  Please wait for *\n"
04859                                    "*  disk operation  *\n"
04860                                    "********************" ,
04861                                 MCW_CALLER_KILL ) ;
04862       WATCH_cursorize( wmsg ) ;
04863       XFlush( XtDisplay(wmsg) ) ;
04864    } else {
04865       wmsg = NULL ;
04866    }
04867 
04868    /** make up a new idcode for this new output dataset **/
04869 
04870    dset->idcode = MCW_new_idcode() ;
04871 
04872    npad = (int) zpad ;
04873    if( npad == 0 ){   /* the old code */
04874 
04875       good = THD_write_3dim_dataset( user_inputs.session_filename ,
04876                                      user_inputs.output_filename , dset , True ) ;
04877 
04878    } else {           /* 05 Feb 2001: allow for zero-padding in z-direction */
04879       THD_3dim_dataset * qset=NULL ;
04880       int flag=0 ;
04881 
04882       if( zpad_mm ) flag = ZPAD_MM ;
04883 
04884       switch( daxes->zzorient ){
04885          case ORI_R2L_TYPE:
04886          case ORI_L2R_TYPE:
04887             qset = THD_zeropad( dset, 0,0,0,0,npad,npad, user_inputs.output_filename,flag ) ;
04888          break ;
04889 
04890          case ORI_P2A_TYPE:
04891          case ORI_A2P_TYPE:
04892             qset = THD_zeropad( dset, 0,0,npad,npad,0,0, user_inputs.output_filename,flag ) ;
04893          break ;
04894 
04895          case ORI_I2S_TYPE:
04896          case ORI_S2I_TYPE:
04897             qset = THD_zeropad( dset, npad,npad,0,0,0,0, user_inputs.output_filename,flag ) ;
04898          break ;
04899 
04900          default:
04901             fprintf(stderr,"*** Can't zpad: zzorient=%d\n",daxes->zzorient) ;
04902          break ;
04903       }
04904 
04905       if( commandline != NULL ) tross_Append_History( qset , commandline ) ;
04906 
04907       { int ppad[3] ;
04908         ppad[0] = ppad[1] = 0 ; ppad[2] = npad ;
04909         THD_set_int_atr( qset->dblk , "TO3D_ZPAD" , 3 , ppad ) ;
04910       }
04911 
04912       THD_load_statistics( qset ) ;
04913       good = THD_write_3dim_dataset( user_inputs.session_filename ,
04914                                      user_inputs.output_filename , qset , True ) ;
04915       DSET_delete(qset) ;
04916    }
04917 
04918    if( wmsg != NULL ) XtDestroyWidget( wmsg ) ;
04919 
04920    if( !good ) T3D_poperr("*******************\n\n" ,
04921                           "Some error occurred\n"
04922                           "while trying to write file") ;
04923 
04924    else if( wset.topshell != NULL && wset.good )
04925       wmsg = MCW_popup_message( wset.save_file_pb ,
04926                                  "*********************\n"
04927                                  "*  Dataset written  *\n"
04928                                  "*  out to disk.     *\n"
04929                                  "*********************" ,
04930                                 MCW_USER_KILL | MCW_TIMER_KILL ) ;
04931 
04932    return ;
04933 }

void T3D_set_dependent_geometries void   
 

Definition at line 3449 of file to3d.c.

References AV_assign_fval(), ENTRY, to3d_data::fov, to3d_data::nx, to3d_data::ny, to3d_data::nz, to3d_widget_set::topshell, to3d_data::voxcontig, VOXCONTIG_YES, to3d_data::voxshape, VOXSHAPE_CUBICAL, VOXSHAPE_IRREGULAR, XCENTERED, to3d_data::xorigin, to3d_widget_set::xorigin_av, to3d_data::xsize, to3d_widget_set::xsize_av, to3d_data::xyz_centered, YCENTERED, to3d_data::yorigin, to3d_widget_set::yorigin_av, to3d_data::ysize, to3d_widget_set::ysize_av, ZCENTERED, to3d_data::zorigin, to3d_widget_set::zorigin_av, to3d_data::zsize, to3d_widget_set::zsize_av, to3d_data::zspacing, and to3d_widget_set::zspacing_av.

Referenced by T3D_centered_CB(), T3D_create_widgets(), T3D_fov_av_CB(), T3D_size_av_CB(), T3D_type_av_CB(), and T3D_voxshape_CB().

03450 {
03451    float size ;
03452 
03453 ENTRY("T3D_set_dependent_geometries") ;
03454 
03455    if( ! XtIsRealized( wset.topshell ) ) EXRETURN ;
03456 
03457    /* Voxel shapes not irregular?  Then set them appropriately. */
03458 
03459    if( user_inputs.voxshape != VOXSHAPE_IRREGULAR && user_inputs.nx > 0 ){
03460 
03461       size = user_inputs.fov / user_inputs.nx ;
03462 
03463       if( user_inputs.xsize != size ){
03464          AV_assign_fval( wset.xsize_av , size ) ;
03465          user_inputs.xsize = size ;
03466       }
03467 
03468       if( user_inputs.ysize != size ){
03469          AV_assign_fval( wset.ysize_av , size ) ;
03470          user_inputs.ysize = size ;
03471       }
03472 
03473       if( user_inputs.voxshape == VOXSHAPE_CUBICAL &&
03474           user_inputs.zsize    != size ){
03475          AV_assign_fval( wset.zsize_av , size ) ;
03476          user_inputs.zsize = size ;
03477       }
03478    }
03479 
03480 #ifdef ALLOW_NONCONTIG
03481    /* contiguous voxels turned on? Then set zspacing to zsize. */
03482 
03483    if( user_inputs.voxcontig == VOXCONTIG_YES &&
03484        user_inputs.zspacing  != user_inputs.zsize ){
03485       AV_assign_fval( wset.zspacing_av , user_inputs.zsize ) ;
03486       user_inputs.zspacing = user_inputs.zsize ;
03487    }
03488 #endif /* ALLOW_NONCONTIG */
03489 
03490    /* centered axes?  Then set origins from sizes. */
03491 
03492    if( (user_inputs.xyz_centered & XCENTERED) != 0 && user_inputs.nx != 0 ){
03493       size = 0.5 * (user_inputs.nx-1) * user_inputs.xsize ;
03494       if( size != user_inputs.xorigin ){
03495          AV_assign_fval( wset.xorigin_av , size ) ;
03496          user_inputs.xorigin = size ;
03497       }
03498    }
03499 
03500    if( (user_inputs.xyz_centered & YCENTERED) != 0 && user_inputs.ny != 0 ){
03501       size = 0.5 * (user_inputs.ny-1) * user_inputs.ysize ;
03502       if( size != user_inputs.yorigin ){
03503          AV_assign_fval( wset.yorigin_av , size ) ;
03504          user_inputs.yorigin = size ;
03505       }
03506    }
03507 
03508    if( (user_inputs.xyz_centered & ZCENTERED) != 0 && user_inputs.nz != 0 ){
03509 #ifdef ALLOW_NONCONTIG
03510       size = 0.5 * (user_inputs.nz-1) * user_inputs.zspacing ;
03511 #else
03512       size = 0.5 * (user_inputs.nz-1) * user_inputs.zsize ;
03513 #endif
03514       if( size != user_inputs.zorigin ){
03515          AV_assign_fval( wset.zorigin_av , size ) ;
03516          user_inputs.zorigin = size ;
03517       }
03518    }
03519 
03520    EXRETURN ;
03521 }

void T3D_setup_stat_aux void   
 

Definition at line 5698 of file to3d.c.

References to3d_data::dataset_type, ENTRY, to3d_data::function_type, to3d_widget_set::good, ISFUNCTYPE, MCW_set_widget_label(), to3d_data::need_stat_aux, to3d_widget_set::stat_aux_label, to3d_widget_set::stat_aux_textfield, THD_MAX_NAME, and to3d_widget_set::topshell.

Referenced by T3D_check_data(), T3D_data_to_widgets(), and T3D_type_av_CB().

05699 {
05700    char lbuf[THD_MAX_NAME] ;
05701    Boolean needit ;
05702 
05703 ENTRY("T3D_setup_stat_aux") ;
05704 
05705    user_inputs.need_stat_aux =
05706        ( ISFUNCTYPE(user_inputs.dataset_type) &&
05707          FUNC_need_stat_aux[user_inputs.function_type] > 0 ) ;
05708 
05709    if( wset.topshell != NULL && wset.good ){
05710       needit = (Boolean) user_inputs.need_stat_aux ;
05711 
05712       if( needit ){
05713          sprintf( lbuf , "%s: statistical parameters for %s" ,
05714                   FUNC_label_stat_aux[user_inputs.function_type] ,
05715                   FUNC_typestr[user_inputs.function_type] ) ;
05716       } else {
05717          sprintf( lbuf , "Field below not applicable" ) ;
05718       }
05719       XtSetSensitive( wset.stat_aux_label , needit ) ;
05720       XtSetSensitive( wset.stat_aux_textfield , needit ) ;
05721       MCW_set_widget_label( wset.stat_aux_label , lbuf ) ;
05722    }
05723 
05724    EXRETURN ;
05725 }

void T3D_size_av_CB MCW_arrowval   av,
XtPointer    cd
 

Definition at line 3726 of file to3d.c.

References MCW_arrowval::fval, RESET_QUIT, T3D_set_dependent_geometries(), to3d_widget_set::topshell, to3d_data::xsize, to3d_widget_set::xsize_av, to3d_data::ysize, to3d_widget_set::ysize_av, to3d_data::zsize, to3d_widget_set::zsize_av, to3d_data::zspacing, and to3d_widget_set::zspacing_av.

Referenced by T3D_create_widgets().

03727 {
03728    float size = av->fval ;
03729 
03730    if( av == wset.xsize_av ){
03731       user_inputs.xsize = size ;
03732    } else if( av == wset.ysize_av ){
03733       user_inputs.ysize = size ;
03734    } else if( av == wset.zsize_av ){
03735       user_inputs.zsize = size ;
03736 #ifdef ALLOW_NONCONTIG
03737    } else if( av == wset.zspacing_av ){
03738       user_inputs.zspacing = size ;
03739 #endif
03740    } else {
03741       XBell( XtDisplay(wset.topshell) , 100 ) ;
03742       fprintf(stderr,"\n*** illegal call to T3D_size_av_CB!\n") ;
03743    }
03744    T3D_set_dependent_geometries() ;
03745    RESET_QUIT ;
03746 }

void T3D_stat_aux_CB Widget    w,
XtPointer    client_data,
XtPointer    call_data
 

initialize display and overlay colors *

Definition at line 5692 of file to3d.c.

References client_data.

Referenced by T3D_create_widgets().

05694 {
05695    return ;
05696 }

void T3D_swap_CB Widget    w,
XtPointer    cd,
XtPointer    call_data
 

Definition at line 3623 of file to3d.c.

References AFNI_yesenv(), to3d_widget_set::anatomy_parent_label, argopt, THD_3dim_dataset::daxes, dbrick, drive_MCW_imseq(), ENTRY, ISQ_REALZ, isqDR_clearstat, isqDR_display, MCW_popup_message(), MCW_TIMER_KILL, MCW_USER_KILL, mri_datum_size(), myXtFree, myXtNew, negative_shorts, to3d_data::ntt, THD_timeaxis::ntt, THD_datablock::nvals, nvox_total, THD_dataxes::nxx, THD_dataxes::nyy, nz, THD_dataxes::nzz, outliers_checked, to3d_widget_set::seq, swap_eightbytes(), swap_fourbytes(), swap_twobytes(), T3D_check_outliers(), and THD_3dim_dataset::taxis.

Referenced by T3D_create_widgets().

03624 {
03625    int dd = mri_datum_size((MRI_TYPE)argopt.datum_all) ;
03626    int nx , ny , nz , nv , nvox ;
03627 
03628 ENTRY("T3D_swap_CB") ;
03629 
03630    nx = dset->daxes->nxx ; ny = dset->daxes->nyy ;
03631    nz = dset->daxes->nzz ; nv = dblk->nvals      ; nvox = nx*ny*nz*nv ;
03632 
03633    switch( dd ){
03634       case 2: swap_twobytes  ( nvox , dbrick ) ; break ;
03635       case 4: swap_fourbytes ( nvox , dbrick ) ; break ;
03636       case 8: swap_eightbytes( nvox , dbrick ) ; break ;
03637    }
03638 
03639    if( argopt.datum_all == MRI_short && !AFNI_yesenv("AFNI_NO_NEGATIVES_WARNING") ){ /* 24 Aug 2001 */
03640       short * sar = (short *) dbrick ; int ii ;
03641       negative_shorts = 0 ;
03642       for( ii=0 ; ii < nvox_total ; ii++ )
03643          if( sar[ii] < 0 ) negative_shorts++ ;
03644 
03645       if( negative_shorts ){
03646          float perc = (100.0*negative_shorts)/nvox_total ; char msg[512] ;
03647          sprintf(msg , " \n"
03648                        " to3d WARNING: %d negative voxels (%g%%)\n"
03649                        "               after byte-swapping.\n"     ,
03650                  negative_shorts , perc ) ;
03651 
03652          (void) MCW_popup_message( wset.anatomy_parent_label , msg ,
03653                                    MCW_USER_KILL | MCW_TIMER_KILL ) ;
03654       }
03655    }
03656 
03657    if( ISQ_REALZ(wset.seq) ){
03658       drive_MCW_imseq( wset.seq , isqDR_clearstat , NULL ) ;
03659       drive_MCW_imseq( wset.seq , isqDR_display   , (XtPointer)-1 ) ;
03660    }
03661 
03662    if( user_inputs.ntt > 5 ){                 /* 15 Aug 2001 */
03663       dset->taxis = myXtNew( THD_timeaxis ) ;
03664       dset->taxis->ntt = user_inputs.ntt ;
03665       T3D_check_outliers(0) ; outliers_checked = 1 ;
03666       myXtFree(dset->taxis) ;
03667    }
03668 
03669    EXRETURN ;
03670 }

char* T3D_text_display MCW_arrowval   av,
XtPointer    cd
 

Definition at line 3573 of file to3d.c.

References ENTRY, MCW_arrowval::ival, and RETURN.

Referenced by T3D_create_widgets().

03574 {
03575    char ** tar = (char **) cd ;
03576    int  ii = av->ival ;
03577 
03578 ENTRY("T3D_text_display") ;
03579 
03580    RETURN( tar[ii] ) ;
03581 }

void T3D_type_av_CB MCW_arrowval   av,
XtPointer    cd
 

Definition at line 3750 of file to3d.c.

References to3d_widget_set::anatomy_parent_label, to3d_widget_set::anatomy_parent_textfield, to3d_data::anatomy_type, to3d_widget_set::anatomy_type_av, to3d_data::dataset_type, to3d_widget_set::dataset_type_av, to3d_data::function_type, to3d_widget_set::function_type_av, ISFUNCTYPE, MCW_arrowval::ival, to3d_data::nimage, to3d_data::ntt, to3d_data::nvals, nz, to3d_data::nz, RESET_QUIT, SENSITIZE, T3D_fix_dataset_dimen(), T3D_poperr(), T3D_set_dependent_geometries(), T3D_setup_stat_aux(), to3d_widget_set::topshell, and MCW_arrowval::wrowcol.

Referenced by T3D_create_widgets(), and T3D_data_to_widgets().

03751 {
03752    int itype = av->ival ;
03753    Boolean isfunc ;
03754    int nvals_old , nvals_new ;
03755 
03756    isfunc    = ISFUNCTYPE(user_inputs.dataset_type) ;
03757    nvals_old = (isfunc) ? FUNC_nvals[user_inputs.function_type]
03758                         : ANAT_nvals[user_inputs.anatomy_type]  ;
03759 
03760    if( av == wset.dataset_type_av ){
03761       user_inputs.dataset_type = itype ;
03762 
03763       isfunc = ISFUNCTYPE(itype) ;
03764 
03765 #ifdef FUNCTION_ONLY_ANAT_PARENT
03766       SENSITIZE( wset.anatomy_parent_label     , isfunc ) ;
03767       SENSITIZE( wset.anatomy_parent_textfield , isfunc ) ;
03768 #endif
03769 
03770       if( isfunc ){
03771          XtUnmapWidget( wset.anatomy_type_av->wrowcol ) ;
03772          XtMapWidget  ( wset.function_type_av->wrowcol ) ;
03773       } else {
03774          XtUnmapWidget( wset.function_type_av->wrowcol ) ;
03775          XtMapWidget  ( wset.anatomy_type_av->wrowcol ) ;
03776       }
03777 
03778    } else if( av == wset.function_type_av ){
03779       user_inputs.function_type = itype ;
03780    } else if( av == wset.anatomy_type_av ){
03781       user_inputs.anatomy_type = itype ;
03782    } else {
03783       XBell( XtDisplay(wset.topshell) , 100 ) ;
03784       fprintf(stderr,"\n*** illegal call to T3D_type_av_CB!\n") ;
03785    }
03786 
03787    /*--- check if # of values/pixel has altered ---*/
03788 
03789    isfunc    = ISFUNCTYPE(user_inputs.dataset_type) ;
03790    nvals_new = (isfunc) ? FUNC_nvals[user_inputs.function_type]
03791                         : ANAT_nvals[user_inputs.anatomy_type]  ;
03792 
03793    /*-- time-dependent data can have only 1 value per time point! --*/
03794 
03795    if( user_inputs.ntt > 0 && nvals_new != 1 ){
03796       T3D_poperr("***** DATA TYPE WARNING *****\n",
03797                  "New data type is not allowed\n"
03798                  "with time-dependent datatset!" ) ;
03799       return ;
03800    }
03801 
03802    if( nvals_new != nvals_old ){
03803       int nz = user_inputs.nimage / nvals_new ;
03804       if( nz * nvals_new != user_inputs.nimage ){
03805          T3D_poperr("**** DATA TYPE WARNING *****\n",
03806                     "Number of images not an even\n"
03807                     "multiple of # of data values" ) ;
03808       }
03809 
03810       user_inputs.nz    = nz ;
03811       user_inputs.nvals = nvals_new ;
03812       T3D_set_dependent_geometries() ;
03813       T3D_fix_dataset_dimen() ;
03814    }
03815 
03816    T3D_setup_stat_aux() ;
03817 
03818    RESET_QUIT ;
03819 }

void T3D_voxshape_CB Widget    w,
XtPointer    client_data,
XtPointer    call_data
 

Definition at line 3528 of file to3d.c.

References AV_SENSITIZE, client_data, ENTRY, to3d_widget_set::fov_av, MCW_val_bbox(), RESET_QUIT, T3D_set_dependent_geometries(), to3d_widget_set::topshell, to3d_data::voxshape, to3d_widget_set::voxshape_bbox, VOXSHAPE_CUBICAL, VOXSHAPE_IRREGULAR, VOXSHAPE_SQUARE, to3d_widget_set::xsize_av, to3d_widget_set::ysize_av, and to3d_widget_set::zsize_av.

Referenced by T3D_create_widgets(), and T3D_data_to_widgets().

03530 {
03531    int val ;
03532    Boolean fov_sens , xsize_sens , ysize_sens , zsize_sens ;
03533 
03534 ENTRY("T3D_voxshape_CB") ;
03535 
03536    user_inputs.voxshape = val = MCW_val_bbox( wset.voxshape_bbox ) ;
03537 
03538    switch( val ){
03539 
03540       default:  XBell( XtDisplay(wset.topshell) , 100 ) ; return ;
03541 
03542       case VOXSHAPE_CUBICAL:
03543          fov_sens   = True ;
03544          xsize_sens = ysize_sens = zsize_sens = False ;
03545       break ;
03546 
03547       case VOXSHAPE_SQUARE:
03548          fov_sens   = True ;
03549          xsize_sens = ysize_sens = False ;
03550          zsize_sens = True ;
03551       break ;
03552 
03553       case VOXSHAPE_IRREGULAR:
03554          fov_sens   = False ;
03555          xsize_sens = ysize_sens = zsize_sens = True ;
03556       break ;
03557 
03558    }
03559    AV_SENSITIZE( wset.fov_av   , fov_sens   ) ;
03560    AV_SENSITIZE( wset.xsize_av , xsize_sens ) ;
03561    AV_SENSITIZE( wset.ysize_av , ysize_sens ) ;
03562    AV_SENSITIZE( wset.zsize_av , zsize_sens ) ;
03563 
03564    T3D_set_dependent_geometries() ;
03565    RESET_QUIT ;
03566    EXRETURN ;
03567 }

void T3D_widgets_to_data void   
 

make up a new idcode for this new output dataset *

Definition at line 4939 of file to3d.c.

References to3d_data::anatomy_dataname, to3d_data::anatomy_parent_filename, to3d_widget_set::anatomy_parent_textfield, to3d_data::anatomy_type, to3d_widget_set::anatomy_type_av, to3d_data::anatomy_type_string, to3d_widget_set::centered_bbox, to3d_data::dataset_name, to3d_data::dataset_type, to3d_widget_set::dataset_type_av, to3d_data::dataset_type_string, to3d_data::fov, to3d_widget_set::fov_av, to3d_data::function_type, to3d_widget_set::function_type_av, to3d_data::function_type_string, MCW_arrowval::fval, to3d_data::geometry_dataname, to3d_data::geometry_parent_filename, to3d_widget_set::geometry_parent_textfield, to3d_widget_set::good, MCW_arrowval::ival, MAX_STAT_AUX, MCW_strncpy, MCW_val_bbox(), myXtFree, to3d_data::need_stat_aux, to3d_widget_set::output_file_textfield, to3d_data::output_filename, to3d_widget_set::session_file_textfield, to3d_data::session_filename, to3d_data::short_label1, to3d_data::stat_aux, to3d_widget_set::stat_aux_textfield, strtod(), THD_MAX_LABEL, THD_MAX_NAME, to3d_widget_set::topshell, to3d_data::voxcontig, to3d_widget_set::voxcontig_bbox, to3d_data::voxshape, to3d_widget_set::voxshape_bbox, to3d_data::xorient, to3d_widget_set::xorient_av, to3d_data::xorigin, to3d_widget_set::xorigin_av, to3d_data::xsize, to3d_widget_set::xsize_av, to3d_data::xyz_centered, to3d_data::yorient, to3d_widget_set::yorient_av, to3d_data::yorigin, to3d_widget_set::yorigin_av, to3d_data::ysize, to3d_widget_set::ysize_av, to3d_data::zorient, to3d_widget_set::zorient_av, to3d_data::zorigin, to3d_widget_set::zorigin_av, to3d_data::zsize, to3d_widget_set::zsize_av, to3d_data::zspacing, and to3d_widget_set::zspacing_av.

Referenced by T3D_geometry_parent_CB(), and T3D_save_file_CB().

04940 {
04941    char * str ;
04942 
04943    if( wset.topshell == NULL || !wset.good ) return ;
04944 
04945    user_inputs.xorient = wset.xorient_av->ival ;
04946    user_inputs.yorient = wset.yorient_av->ival ;
04947    user_inputs.zorient = wset.zorient_av->ival ;
04948 
04949    user_inputs.voxshape     = MCW_val_bbox( wset.voxshape_bbox ) ;
04950 #ifdef ALLOW_NONCONTIG
04951    user_inputs.voxcontig    = MCW_val_bbox( wset.voxcontig_bbox ) ;
04952 #endif
04953    user_inputs.xyz_centered = MCW_val_bbox( wset.centered_bbox ) ;
04954 
04955    user_inputs.dataset_type  = wset.dataset_type_av->ival ;
04956    user_inputs.function_type = wset.function_type_av->ival ;
04957    user_inputs.anatomy_type  = wset.anatomy_type_av->ival ;
04958 
04959    MCW_strncpy( user_inputs.dataset_type_string ,
04960                 DATASET_typestr[user_inputs.dataset_type] ,
04961                 THD_MAX_NAME ) ;
04962 
04963    MCW_strncpy( user_inputs.function_type_string ,
04964                 FUNC_typestr[user_inputs.function_type] ,
04965                 THD_MAX_NAME ) ;
04966 
04967    MCW_strncpy( user_inputs.anatomy_type_string ,
04968                 ANAT_typestr[user_inputs.anatomy_type] ,
04969                 THD_MAX_NAME ) ;
04970 
04971    user_inputs.fov      = wset.fov_av->fval ;
04972    user_inputs.xsize    = wset.xsize_av->fval ;
04973    user_inputs.ysize    = wset.ysize_av->fval ;
04974    user_inputs.zsize    = wset.zsize_av->fval ;
04975 #ifdef ALLOW_NONCONTIG
04976    user_inputs.zspacing = wset.zspacing_av->fval ;
04977 #endif
04978    user_inputs.xorigin  = wset.xorigin_av->fval ;
04979    user_inputs.yorigin  = wset.yorigin_av->fval ;
04980    user_inputs.zorigin  = wset.zorigin_av->fval ;
04981 
04982 #ifndef NO_NAMES
04983    str = XmTextFieldGetString( wset.dataset_name_textfield ) ;
04984    MCW_strncpy( user_inputs.dataset_name, str, THD_MAX_NAME ) ;
04985    myXtFree(str) ;
04986 
04987    str = XmTextFieldGetString( wset.short_label1_textfield ) ;
04988    MCW_strncpy( user_inputs.short_label1, str, THD_MAX_LABEL ) ;
04989    myXtFree(str) ;
04990 #endif
04991 
04992    str = XmTextFieldGetString( wset.geometry_parent_textfield ) ;
04993    MCW_strncpy( user_inputs.geometry_parent_filename, str, THD_MAX_NAME ) ;
04994    myXtFree(str) ;
04995 
04996    str = XmTextFieldGetString( wset.anatomy_parent_textfield ) ;
04997    MCW_strncpy( user_inputs.anatomy_parent_filename, str, THD_MAX_NAME ) ;
04998    myXtFree(str) ;
04999 
05000    str = XmTextFieldGetString( wset.output_file_textfield ) ;
05001    MCW_strncpy( user_inputs.output_filename, str, THD_MAX_NAME ) ;
05002    myXtFree(str) ;
05003 
05004    str = XmTextFieldGetString( wset.session_file_textfield ) ;
05005    MCW_strncpy( user_inputs.session_filename, str, THD_MAX_NAME ) ;
05006    myXtFree(str) ;
05007 
05008 #ifndef NO_NAMES
05009    str = XmTextFieldGetString( wset.geometry_dataname_textfield ) ;
05010    MCW_strncpy( user_inputs.geometry_dataname , str, THD_MAX_NAME ) ;
05011    myXtFree(str) ;
05012 
05013    str = XmTextFieldGetString( wset.anatomy_dataname_textfield ) ;
05014    MCW_strncpy( user_inputs.anatomy_dataname , str, THD_MAX_NAME ) ;
05015    myXtFree(str) ;
05016 #endif
05017 
05018    if( user_inputs.need_stat_aux ){
05019       int ii ;
05020       char * endptr , * sstr ;
05021 
05022       for( ii=0 ; ii < MAX_STAT_AUX ; ii++ )
05023          user_inputs.stat_aux[ii] = 0.0 ;
05024 
05025       sstr = XmTextFieldGetString( wset.stat_aux_textfield ) ;
05026       if( sstr != NULL ){
05027 
05028          /** scan thru string, converting to floats **/
05029 
05030          str = sstr ;
05031          ii  = 0 ;
05032          do{
05033             /* skip ahead over whitespace or commas */
05034 
05035             while( *str != '\0' && ( isspace(*str) || *str == ',' ) ) str++ ;
05036             if( *str == '\0' ) break ;  /* end of scanning */
05037 
05038             user_inputs.stat_aux[ii++] = strtod(str,&endptr) ;
05039 
05040             if( endptr == str || *endptr == '\0' ) break ; /* end of scanning */
05041 
05042             str = endptr ; /* otherwise, move to next location */
05043          } while ( ii < MAX_STAT_AUX ) ;
05044          myXtFree(sstr) ;
05045       }
05046    }
05047 
05048    return ;
05049 }

Variable Documentation

int af_type_set = 0 [static]
 

Definition at line 47 of file to3d.c.

Referenced by T3D_initialize_user_data().

int Argc [static]
 

Definition at line 29 of file to3d.c.

Referenced by main(), T3D_initialize_user_data(), and T3D_read_images().

struct { ... } argopt [static]
 

Referenced by main(), T3D_check_data(), T3D_create_widgets(), T3D_fix_dataset_dimen(), T3D_initialize_user_data(), T3D_read_images(), and T3D_swap_CB().

char** Argv [static]
 

Definition at line 30 of file to3d.c.

Referenced by main(), T3D_initialize_user_data(), and T3D_read_images().

char* commandline = NULL [static]
 

Definition at line 155 of file to3d.c.

Referenced by T3D_initialize_user_data(), T3D_read_images(), and T3D_save_file_CB().

int datum_all
 

Definition at line 59 of file to3d.c.

Referenced by EDIT_dset_items().

THD_dataxes* daxes = NULL [static]
 

Definition at line 21 of file to3d.c.

THD_datablock* dblk = NULL [static]
 

Definition at line 20 of file to3d.c.

char* dbrick = NULL [static]
 

Definition at line 31 of file to3d.c.

Referenced by T3D_fix_dataset_dimen(), T3D_read_images(), and T3D_swap_CB().

to3d_data default_user_inputs [static]
 

Initial value:

 {
   ORI_R2L_TYPE , ORI_R2L_TYPE , ORI_R2L_TYPE ,      
   VOXSHAPE_IRREGULAR ,                              
   VOXCONTIG_YES ,                                   
   (XCENTERED | YCENTERED | ZCENTERED) ,             
   VIEW_ORIGINAL_TYPE ,                              
   HEAD_ANAT_TYPE , ANAT_SPGR_TYPE , FUNC_FIM_TYPE , 
   0,0,0 ,                                           

   240.0 , 0.9375 , 0.9375 , 0.9375 , 0.9375 ,  

   120.0 , 120.0 , 120.0   
}
The stuff below is commented out, since the textfield is scanned only at the write-out time *

Definition at line 1921 of file to3d.c.

int delay_input
 

Definition at line 62 of file to3d.c.

THD_diskptr* dkptr = NULL [static]
 

Definition at line 22 of file to3d.c.

THD_3dim_dataset* dset = NULL [static]
 

Definition at line 19 of file to3d.c.

int editing
 

Definition at line 65 of file to3d.c.

char* FALLback[] [static]
 

Initial value:

  {   "AFNI*fontList:        9x15bold=charset1" ,
      "AFNI*background:      gray40"            ,
      "AFNI*menu*background: gray40"            ,
      "AFNI*borderColor:     gray40"            ,
      "AFNI*foreground:      yellow"            ,
      "AFNI*borderWidth:     0"                 ,
      "AFNI*troughColor:     green"             ,
      "AFNI*XmLabel.translations: #override<Btn2Down>:" ,
      "AFNI*help*background:      black"                ,
      "AFNI*help*foreground:      yellow"               ,
      "AFNI*cluefont:             9x15bold"             ,
      "AFNI*help*waitPeriod:      1066"                 ,
      "AFNI*help*cancelWaitPeriod: 50"                  ,
   NULL }

Definition at line 76 of file to3d.c.

Referenced by main().

int First_Image_Arg = 1 [static]
 

Definition at line 29 of file to3d.c.

Referenced by T3D_initialize_user_data(), and T3D_read_images().

float gamma
 

Definition at line 56 of file to3d.c.

Referenced by AFNI_make_warp(), and AFNI_marks_quality_check().

int geometry_loaded = 0 [static]
 

Definition at line 33 of file to3d.c.

Referenced by main(), T3D_geometry_parent_CB(), and T3D_read_images().

int geomparent_loaded = 0 [static]
 

Definition at line 32 of file to3d.c.

Referenced by main(), and T3D_geometry_parent_CB().

float gsfac
 

Definition at line 58 of file to3d.c.

float imdx = 0.0 [static]
 

Definition at line 39 of file to3d.c.

Referenced by main(), and T3D_read_images().

float imdy = 0.0 [static]
 

Definition at line 39 of file to3d.c.

Referenced by main(), and T3D_read_images().

float imdz = 0.0 [static]
 

Definition at line 39 of file to3d.c.

Referenced by main(), and T3D_read_images().

THD_string_array* imnames = NULL [static]
 

Definition at line 24 of file to3d.c.

THD_marker_set* markers = NULL [static]
 

Definition at line 23 of file to3d.c.

int ncolor
 

Definition at line 55 of file to3d.c.

Referenced by load_closest().

int negative_shorts = 0 [static]
 

Definition at line 35 of file to3d.c.

Referenced by AFNI_startup_timeout_CB(), main(), T3D_check_outliers(), T3D_read_images(), and T3D_swap_CB().

int nfloat_err = 0 [static]
 

Definition at line 37 of file to3d.c.

Referenced by AFNI_startup_timeout_CB(), and T3D_read_images().

int nofloatscan
 

Definition at line 69 of file to3d.c.

int nvox_total = 0 [static]
 

Definition at line 36 of file to3d.c.

Referenced by AFNI_startup_timeout_CB(), main(), T3D_check_outliers(), T3D_read_images(), and T3D_swap_CB().

int outliers_checked = 0 [static]
 

Definition at line 26 of file to3d.c.

Referenced by AFNI_startup_timeout_CB(), T3D_save_file_CB(), and T3D_swap_CB().

char* outliers_fname = NULL [static]
 

Definition at line 27 of file to3d.c.

Referenced by T3D_check_outliers(), and T3D_initialize_user_data().

int swap_eight
 

Definition at line 71 of file to3d.c.

int swap_four
 

Definition at line 67 of file to3d.c.

int swap_two
 

Definition at line 67 of file to3d.c.

int use_zoff = 0 [static]
 

Definition at line 45 of file to3d.c.

Referenced by T3D_initialize_user_data().

to3d_data user_inputs [static]
 

Definition at line 17 of file to3d.c.

to3d_widget_set wset [static]
 

Definition at line 16 of file to3d.c.

Boolean xtwarns
 

Definition at line 57 of file to3d.c.

float zoff [static]
 

Definition at line 44 of file to3d.c.

Referenced by main(), and T3D_initialize_user_data().

float zpad = 0 [static]
 

Definition at line 41 of file to3d.c.

Referenced by T3D_geometry_parent_CB(), T3D_initialize_user_data(), and T3D_save_file_CB().

int zpad_mm = 0 [static]
 

Definition at line 42 of file to3d.c.

Referenced by T3D_initialize_user_data().

 

Powered by Plone

This site conforms to the following standards: