00001 #include "mrilib.h"
00002 #include "r_new_resam_dset.h"
00003 #include "r_idisp.h"
00004
00005 #define MAIN
00006
00007 #define VERSION "Version 1.8 <August 3, 2005>"
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 static char g_history[] =
00043 "----------------------------------------------------------------------\n"
00044 " history:\n"
00045 "\n"
00046 " 1.0 May 23, 2002 - initial release\n"
00047 " 1.1 Jul 02, 2002 - modified to fully align new data set grid to master\n"
00048 " 1.2 Jul 29, 2002\n"
00049 " - no change here, but updated r_new_resam_dset() for view type\n"
00050 " 1.3 January 14, 2003\n"
00051 " - clear warp information before writing to disk (fix uncommon problem)\n"
00052 " 1.4 Jul 27, 2003 - wrap unknown printed strings in NULL check\n"
00053 " 1.5 Jan 07, 2004\n"
00054 " - added suggestion of 3dfractionize to -help output\n"
00055 " - added '-hist' option\n"
00056 " 1.6 Mar 04, 2004\n"
00057 " - added check for RESAM_shortstr[] (to catch NN and Bk modes)\n"
00058 " - reversed order of history: recent at the bottom\n"
00059 " 1.7 Jul 26, 2004 - passed NULL sublist to r_new_resam_dset()\n"
00060 " 1.7a Mar 22, 2005 - removed tabs\n"
00061 " 1.8 Aug 02, 2005 - allow dxyz to override those from master\n"
00062 "----------------------------------------------------------------------\n";
00063
00064
00065
00066
00067 #define USE_LONG 1
00068 #define USE_SHORT 2
00069 #define USE_VERSION 3
00070 #define USE_HISTORY 4
00071
00072 #define DELTA_MIN 0.1
00073 #define DELTA_MAX 99.9
00074
00075 #define RL_DEBUG_OFF 0
00076 #define RL_DEBUG_LOW 1
00077 #define RL_DEBUG_HIGH 2
00078
00079 typedef struct
00080 {
00081 THD_3dim_dataset * dset;
00082 THD_3dim_dataset * mset;
00083 double dx, dy, dz;
00084 char * orient;
00085 char * prefix;
00086 int resam;
00087 int debug;
00088 } options_t;
00089
00090 int disp_opts_data ( char * info, options_t * opts );
00091 int init_options ( options_t * opts, int argc, char * argv [] );
00092 int resam_str2mode ( char * mode );
00093 int sync_master_opts ( options_t * opts );
00094 int usage ( char * prog, int level );
00095 int write_results ( THD_3dim_dataset * dout, options_t * opts,
00096 int argc, char * argv [] );
00097
00098
00099
00100 int main( int argc , char * argv[] )
00101 {
00102 THD_3dim_dataset * dout;
00103 options_t opts;
00104 int ret_val;
00105
00106 mainENTRY("3dresample"); machdep(); AFNI_logger("3dresample",argc,argv);
00107
00108
00109 if ( (ret_val = init_options(&opts, argc, argv)) != 0 )
00110 return ret_val;
00111
00112
00113 dout = r_new_resam_dset( opts.dset, opts.mset, opts.dx, opts.dy, opts.dz,
00114 opts.orient, opts.resam, NULL);
00115 if ( dout == NULL )
00116 {
00117 fprintf( stderr, "failure to resample dataset, exiting...\n" );
00118 return FAIL;
00119 }
00120
00121 return write_results( dout, &opts, argc, argv );
00122 }
00123
00124
00125
00126
00127
00128
00129 int init_options ( options_t * opts, int argc, char * argv [] )
00130 {
00131 int ac;
00132
00133
00134 memset( opts, 0, sizeof(options_t) );
00135 opts->orient = opts->prefix = NULL;
00136 opts->dset = opts->mset = NULL;
00137
00138 for ( ac = 1; ac < argc; ac++ )
00139 {
00140 if ( ! strncmp(argv[ac], "-help", 5) )
00141 {
00142 usage( argv[0], USE_LONG );
00143 return FAIL;
00144 }
00145 else if ( ! strncmp(argv[ac], "-hist", 5) )
00146 {
00147 usage( argv[0], USE_HISTORY );
00148 return FAIL;
00149 }
00150 else if ( ! strncmp(argv[ac], "-version", 2) )
00151 {
00152 usage( argv[0], USE_VERSION );
00153 return FAIL;
00154 }
00155 else if ( ! strncmp(argv[ac], "-debug", 6) )
00156 {
00157 if ( (ac+1) >= argc )
00158 {
00159 fputs( "option usage: -debug LEVEL\n", stderr );
00160 usage( argv[0], USE_SHORT );
00161 return FAIL;
00162 }
00163
00164 opts->debug = atoi(argv[++ac]);
00165 if ( opts->debug < 0 || opts->debug > RL_DEBUG_HIGH )
00166 {
00167 fprintf( stderr, "bad debug level <%d>, should be in [%d,%d]\n",
00168 opts->debug, RL_DEBUG_OFF, RL_DEBUG_HIGH );
00169 usage( argv[0], USE_SHORT );
00170 return FAIL;
00171 }
00172 }
00173 else if ( ! strncmp(argv[ac], "-dxyz", 3) )
00174 {
00175 if ( (ac+3) >= argc )
00176 {
00177 fputs( "option usage: -dxyz DX DY DZ\n", stderr );
00178 usage( argv[0], USE_SHORT );
00179 return FAIL;
00180 }
00181
00182 opts->dx = atof(argv[++ac]);
00183 opts->dy = atof(argv[++ac]);
00184 opts->dz = atof(argv[++ac]);
00185
00186 if ( (opts->dx < DELTA_MIN || opts->dx > DELTA_MAX) ||
00187 (opts->dy < DELTA_MIN || opts->dy > DELTA_MAX) ||
00188 (opts->dz < DELTA_MIN || opts->dz > DELTA_MAX) )
00189 {
00190 fprintf( stderr, "dxyz must be in [%.1f,%.1f]\n",
00191 DELTA_MIN, DELTA_MAX );
00192 return FAIL;
00193 }
00194 }
00195 else if ( ! strncmp(argv[ac], "-or", 3) )
00196 {
00197 if ( (ac+1) >= argc )
00198 {
00199 fputs( "option usage: -orient OR_STRING\n", stderr );
00200 usage( argv[0], USE_SHORT );
00201 return FAIL;
00202 }
00203
00204 opts->orient = argv[++ac];
00205 }
00206 else if ( ! strncmp(argv[ac], "-master", 5) )
00207 {
00208 if ( (ac+1) >= argc )
00209 {
00210 fputs( "option usage: -master MAST_DSET\n", stderr );
00211 usage( argv[0], USE_SHORT );
00212 return FAIL;
00213 }
00214
00215 opts->mset = THD_open_dataset( argv[++ac] );
00216 if ( ! ISVALID_DSET(opts->mset) )
00217 {
00218 fprintf( stderr, "invalid master dataset <%s>\n", argv[ac] );
00219 return FAIL;
00220 }
00221 }
00222 else if ( ! strncmp(argv[ac], "-zeropad", 5) )
00223 {
00224 fputs("warning: '-zeropad' is no longer a valid option\n", stderr);
00225
00226 }
00227 else if ( ! strncmp(argv[ac], "-rmode", 6) )
00228 {
00229 if ( (ac+1) >= argc )
00230 {
00231 fputs( "option usage: -rmode RESAMPLE_MODE\n", stderr );
00232 usage( argv[0], USE_SHORT );
00233 return FAIL;
00234 }
00235
00236 if ( ( (opts->resam = resam_str2mode(argv[++ac]) ) < 0 ) ||
00237 ( opts->resam > LAST_RESAM_TYPE ) )
00238 {
00239 fprintf( stderr, "invalid resample mode <%s>\n", argv[ac] );
00240 return FAIL;
00241 }
00242 }
00243 else if ( ! strncmp(argv[ac], "-prefix", 4) )
00244 {
00245 if ( (ac+1) >= argc )
00246 {
00247 fputs( "option usage: -prefix OUTPUT_PREFIX\n", stderr );
00248 usage( argv[0], USE_SHORT );
00249 return FAIL;
00250 }
00251
00252 opts->prefix = argv[++ac];
00253 if ( !THD_filename_ok(opts->prefix) )
00254 {
00255 fprintf( stderr, "invalid output prefix <%s>\n", opts->prefix );
00256 return usage( argv[0], USE_SHORT );
00257 }
00258 }
00259 else if ( ! strncmp(argv[ac], "-inset", 3) ||
00260 ! strncmp(argv[ac], "-input", 6) )
00261 {
00262 if ( (ac+1) >= argc )
00263 {
00264 fputs( "option usage: -inset INPUT_DSET\n", stderr );
00265 usage( argv[0], USE_SHORT );
00266 return FAIL;
00267 }
00268
00269 opts->dset = THD_open_dataset( argv[++ac] );
00270 if ( ! ISVALID_DSET(opts->dset) )
00271 {
00272 fprintf( stderr, "invalid input dataset <%s>\n", argv[ac] );
00273 return FAIL;
00274 }
00275 }
00276 else
00277 {
00278 fprintf( stderr, "invalid option <%s>\n", argv[ac] );
00279 usage( argv[0], USE_SHORT );
00280 return FAIL;
00281 }
00282 }
00283
00284 if ( !ISVALID_DSET(opts->dset) || (opts->prefix == NULL) )
00285 {
00286 fprintf( stderr, "missing prefix or input dset, exiting...\n" );
00287 usage( argv[0], USE_SHORT );
00288 return FAIL;
00289 }
00290
00291 if ( opts->debug >= RL_DEBUG_LOW )
00292 {
00293 disp_opts_data( "++ options initialized: ", opts );
00294
00295 if ( opts->debug >= RL_DEBUG_HIGH )
00296 {
00297 r_idisp_thd_3dim_dataset( "inset : ", opts->dset );
00298 r_idisp_thd_dataxes ( "inset : ", opts->dset->daxes );
00299 r_idisp_thd_datablock ( "inset : ", opts->dset->dblk );
00300 if ( opts->dset->dblk )
00301 r_idisp_thd_diskptr ( "inset : ", opts->dset->dblk->diskptr );
00302 }
00303 }
00304
00305 if ( sync_master_opts( opts ) )
00306 return FAIL;
00307
00308 return 0;
00309 }
00310
00311 #if 0
00312
00313
00314
00315
00316
00317
00318
00319
00320 int new_zeropad_dset ( options_t * opts, THD_3dim_dataset ** dout )
00321 {
00322 THD_3dim_dataset * tmp_dset;
00323 THD_dataxes * max = opts->mset->daxes, * iax = (*dout)->daxes;
00324 int nerr = 0;
00325 float mxbot,mybot,mzbot, mxtop,mytop,mztop, mdx,mdy,mdz;
00326 float ixbot,iybot,izbot, ixtop,iytop,iztop, idx,idy,idz;
00327 int mnx,mny,mnz, inx,iny,inz;
00328 int add_xb,add_xt, add_yb,add_yt, add_zb,add_zt;
00329 int add_I=0, add_S=0, add_A=0, add_P=0, add_L=0, add_R=0;
00330
00331
00332 if( max->xxorient != iax->xxorient ||
00333 max->yyorient != iax->yyorient ||
00334 max->zzorient != iax->zzorient )
00335 {
00336 fputs("error: orientation mismatch!\n", stderr );
00337 nerr++;
00338 }
00339
00340
00341 mdx = max->xxdel; mdy = max->yydel; mdz = max->zzdel;
00342 idx = iax->xxdel; idy = iax->yydel; idz = iax->zzdel;
00343 mnx = max->nxx; mny = max->nyy; mnz = max->nzz;
00344 inx = iax->nxx; iny = iax->nyy; inz = iax->nzz;
00345
00346 if( fabs(mdx-idx) > 0.01*fabs(mdx) ||
00347 fabs(mdy-idy) > 0.01*fabs(mdy) ||
00348 fabs(mdz-idz) > 0.01*fabs(mdz) )
00349 {
00350 fputs("error: voxel size mismatch!\n", stderr);
00351 nerr++;
00352 }
00353
00354 if ( nerr > 0 )
00355 return FAIL;
00356
00357
00358
00359
00360 mxbot = max->xxorg; mxtop = mxbot + mnx*mdx;
00361 mybot = max->yyorg; mytop = mybot + mny*mdy;
00362 mzbot = max->zzorg; mztop = mzbot + mnz*mdz;
00363
00364 ixbot = iax->xxorg; ixtop = ixbot + inx*idx;
00365 iybot = iax->yyorg; iytop = iybot + iny*idy;
00366 izbot = iax->zzorg; iztop = izbot + inz*idz;
00367
00368
00369 add_xb = (int) rint((ixbot-mxbot)/idx);
00370 add_xt = (int) rint((mxtop-ixtop)/idx);
00371 add_yb = (int) rint((iybot-mybot)/idy);
00372 add_yt = (int) rint((mytop-iytop)/idy);
00373 add_zb = (int) rint((izbot-mzbot)/idz);
00374 add_zt = (int) rint((mztop-iztop)/idz);
00375
00376
00377
00378 switch( iax->xxorient ){
00379 case ORI_R2L_TYPE: add_R = add_xb; add_L = add_xt; break;
00380 case ORI_L2R_TYPE: add_L = add_xb; add_R = add_xt; break;
00381 case ORI_I2S_TYPE: add_I = add_xb; add_S = add_xt; break;
00382 case ORI_S2I_TYPE: add_S = add_xb; add_I = add_xt; break;
00383 case ORI_A2P_TYPE: add_A = add_xb; add_P = add_xt; break;
00384 case ORI_P2A_TYPE: add_P = add_xb; add_A = add_xt; break;
00385 default : fputs("bad xxorient!\n", stderr); return FAIL;
00386 }
00387
00388 switch( iax->yyorient ){
00389 case ORI_R2L_TYPE: add_R = add_yb; add_L = add_yt; break;
00390 case ORI_L2R_TYPE: add_L = add_yb; add_R = add_yt; break;
00391 case ORI_I2S_TYPE: add_I = add_yb; add_S = add_yt; break;
00392 case ORI_S2I_TYPE: add_S = add_yb; add_I = add_yt; break;
00393 case ORI_A2P_TYPE: add_A = add_yb; add_P = add_yt; break;
00394 case ORI_P2A_TYPE: add_P = add_yb; add_A = add_yt; break;
00395 default : fputs("bad yyorient!\n", stderr); return FAIL;
00396 }
00397
00398 switch( iax->zzorient ){
00399 case ORI_R2L_TYPE: add_R = add_zb; add_L = add_zt; break;
00400 case ORI_L2R_TYPE: add_L = add_zb; add_R = add_zt; break;
00401 case ORI_I2S_TYPE: add_I = add_zb; add_S = add_zt; break;
00402 case ORI_S2I_TYPE: add_S = add_zb; add_I = add_zt; break;
00403 case ORI_A2P_TYPE: add_A = add_zb; add_P = add_zt; break;
00404 case ORI_P2A_TYPE: add_P = add_zb; add_A = add_zt; break;
00405 default : fputs("bad zzorient!\n", stderr); return FAIL;
00406 }
00407
00408 if ( opts->debug >= RL_DEBUG_LOW )
00409 {
00410 printf( "++ zeropad: (I,S,A,P,L,R) = (%d,%d,%d,%d,%d,%d)\n",
00411 add_I, add_S, add_A, add_P, add_L, add_R );
00412 }
00413
00414
00415 if ( add_I || add_S || add_A || add_P || add_L || add_R )
00416 {
00417 tmp_dset = THD_zeropad( *dout,
00418 add_I, add_S, add_A, add_P, add_L, add_R,
00419 opts->prefix, ZPAD_PURGE );
00420
00421 if ( !ISVALID_DSET( tmp_dset ) )
00422 {
00423 fputs( "THD_zeropad failed!\n", stderr );
00424 return FAIL;
00425 }
00426
00427 DSET_delete( *dout );
00428 *dout = tmp_dset;
00429 }
00430
00431 return 0;
00432 }
00433 #endif
00434
00435
00436 int usage ( char * prog, int level )
00437 {
00438 if ( level == USE_SHORT )
00439 {
00440 fprintf( stderr,
00441 "usage: %s [options] -prefix OUT_DSET -inset IN_DSET\n"
00442 "usage: %s -help\n",
00443 prog, prog );
00444 return 0;
00445 }
00446 else if ( level == USE_LONG )
00447 {
00448 printf(
00449 "\n"
00450 "%s - reorient and/or resample a dataset\n"
00451 "\n"
00452 " This program can be used to change the orientation of a\n"
00453 " dataset (via the -orient option), or the dx,dy,dz\n"
00454 " grid spacing (via the -dxyz option), or change them\n"
00455 " both to match that of a master dataset (via the -master\n"
00456 " option).\n"
00457 "\n"
00458 " Note: if both -master and -dxyz are used, the dxyz values\n"
00459 " will override those from the master dataset.\n"
00460 "\n"
00461 " ** Warning: this program is not meant to transform datasets\n"
00462 " between view types (such as '+orig' and '+tlrc').\n"
00463 "\n"
00464 " For that purpose, please see '3dfractionize -help'.\n"
00465 "\n"
00466 "------------------------------------------------------------\n"
00467 "\n"
00468 " usage: %s [options] -prefix OUT_DSET -inset IN_DSET\n"
00469 "\n"
00470 " examples:\n"
00471 "\n"
00472 " %s -orient asl -rmode NN -prefix asl.dset -inset in+orig\n"
00473 " %s -dxyz 1.0 1.0 0.9 -prefix 119.dset -inset in+tlrc\n"
00474 " %s -master master+orig -prefix new.dset -inset old+orig\n"
00475 "\n"
00476 " note:\n"
00477 "\n"
00478 " Information about a dataset's voxel size and orientation\n"
00479 " can be found in the output of program 3dinfo\n"
00480 "\n"
00481 "------------------------------------------------------------\n"
00482 "\n"
00483 " options: \n"
00484 "\n"
00485 " -help : show this help information\n"
00486 "\n"
00487 " -hist : output the history of program changes\n"
00488 "\n"
00489 " -debug LEVEL : print debug info along the way\n"
00490 " e.g. -debug 1\n"
00491 " default level is 0, max is 2\n"
00492 "\n"
00493 " -version : show version information\n"
00494 "\n"
00495 " -dxyz DX DY DZ : resample to new dx, dy and dz\n"
00496 " e.g. -dxyz 1.0 1.0 0.9\n"
00497 " default is to leave unchanged\n"
00498 "\n"
00499 " Each of DX,DY,DZ must be a positive real number,\n"
00500 " and will be used for a voxel delta in the new\n"
00501 " dataset (according to any new orientation).\n"
00502 "\n"
00503 " -orient OR_CODE : reorient to new axis order.\n"
00504 " e.g. -orient asl\n"
00505 " default is to leave unchanged\n"
00506 "\n"
00507 " The orientation code is a 3 character string,\n"
00508 " where the characters come from the respective\n"
00509 " sets {A,P}, {I,S}, {L,R}.\n"
00510 "\n"
00511 " For example OR_CODE = LPI is the standard\n"
00512 " 'neuroscience' orientation, where the x-axis is\n"
00513 " Left-to-Right, the y-axis is Posterior-to-Anterior,\n"
00514 " and the z-axis is Inferior-to-Superior.\n"
00515 "\n"
00516 " -rmode RESAM : use this resampling method\n"
00517 " e.g. -rmode Linear\n"
00518 " default is NN (nearest neighbor)\n"
00519 "\n"
00520 " The resampling method string RESAM should come\n"
00521 " from the set {'NN', 'Li', 'Cu', 'Bk'}. These\n"
00522 " are for 'Nearest Neighbor', 'Linear', 'Cubic'\n"
00523 " and 'Blocky' interpolation, respectively.\n"
00524 " See 'Anat resam mode' under the 'Define Markers'\n"
00525 " window in afni.\n"
00526 "\n"
00527 " -master MAST_DSET: align dataset grid to that of MAST_DSET\n"
00528 " e.g. -master master.dset+orig\n"
00529 "\n"
00530 " Get dxyz and orient from a master dataset. The\n"
00531 " resulting grid will match that of the master. This\n"
00532 " option can be used with -dxyz, but not with -orient.\n"
00533 "\n"
00534 " -prefix OUT_DSET : required prefix for output dataset\n"
00535 " e.g. -prefix reori.asl.pickle\n"
00536 "\n"
00537 " -inset IN_DSET : required input dataset to reorient\n"
00538 " e.g. -inset old.dset+orig\n"
00539 "\n"
00540 "------------------------------------------------------------\n"
00541 "\n"
00542 " Author: R. Reynolds - %s\n"
00543 "\n",
00544 prog, prog, prog, prog, prog, VERSION );
00545
00546 return 0;
00547 }
00548 else if ( level == USE_HISTORY )
00549 {
00550 fputs( g_history, stdout );
00551 return 0;
00552 }
00553 else if ( level == USE_VERSION )
00554 {
00555 printf( "%s %s, compile date: %s\n", prog, VERSION, __DATE__ );
00556 return 0;
00557 }
00558
00559 fprintf( stderr, "usage called with illegal level <%d>\n", level );
00560
00561 return FAIL;
00562 }
00563
00564
00565 int resam_str2mode ( char * modestr )
00566 {
00567 int mode;
00568
00569 for (mode = FIRST_RESAM_TYPE; mode <= LAST_RESAM_TYPE; mode++ )
00570 {
00571 if ( ! strncmp( modestr, RESAM_typestr[mode], 2 ) )
00572 return mode;
00573 else if ( ! strncmp( modestr, RESAM_shortstr[mode], 2 ) )
00574 return mode;
00575 }
00576
00577 return FAIL;
00578 }
00579
00580
00581
00582 int write_results ( THD_3dim_dataset * dout, options_t * opts,
00583 int argc, char * argv [] )
00584 {
00585
00586 EDIT_dset_items( dout, ADN_prefix, opts->prefix, ADN_none );
00587
00588 if ( THD_is_file(DSET_HEADNAME(dout)) )
00589 {
00590 fprintf( stderr, "error: cannot overwrite existing dataset <%s>\n",
00591 DSET_HEADNAME(dout) );
00592 return FAIL;
00593 }
00594
00595
00596 if( DSET_NUM_TTOFF(dout) > 0 )
00597 EDIT_dset_items( dout, ADN_nsl, 0, ADN_none );
00598
00599
00600 ZERO_IDCODE( dout->warp_parent_idcode );
00601 dout->warp_parent_name[0] = '\0';
00602 dout->warp = NULL;
00603
00604
00605 tross_Copy_History( opts->dset , dout );
00606 tross_Make_History( "3dresample", argc, argv, dout );
00607
00608
00609 if ( DSET_write( dout ) != True )
00610 {
00611 fputs( "failure: cannot write dataset, exiting...\n", stderr );
00612 return FAIL;
00613 }
00614
00615 if ( opts->debug >= RL_DEBUG_LOW )
00616 {
00617 printf( "dset <%s> has been written to disk\n", opts->prefix );
00618
00619 if ( opts->debug >= RL_DEBUG_HIGH )
00620 {
00621 r_idisp_thd_3dim_dataset( "final dset : ", dout );
00622 r_idisp_thd_dataxes ( "final daxes : ", dout->daxes );
00623 r_idisp_thd_datablock ( "final dblk : ", dout->dblk );
00624 if ( dout->dblk )
00625 r_idisp_thd_diskptr ( "final diskp : ", dout->dblk->diskptr );
00626 }
00627 }
00628
00629 return 0;
00630 }
00631
00632
00633
00634 int sync_master_opts ( options_t * opts )
00635 {
00636 THD_dataxes * dax;
00637
00638 if ( !opts->mset )
00639 return 0;
00640
00641 if ( ! ISVALID_DSET(opts->mset) ||
00642 ! ISVALID_DATAXES(opts->mset->daxes ) )
00643 {
00644 fputs( "error: master dset or daxes not valid, exiting...\n", stderr );
00645 return FAIL;
00646 }
00647
00648
00649 if ( opts->orient != NULL )
00650 {
00651 fputs( "error: -orient is not valid with -master option, exiting...\n",
00652 stderr );
00653 return FAIL;
00654 }
00655
00656
00657 dax = opts->mset->daxes;
00658
00659 if ( opts->debug >= RL_DEBUG_LOW )
00660 {
00661 if (opts->dx == 0.0) fprintf(stderr,"-d using dxyz from master\n");
00662 else fprintf(stderr,"-d overriding dxyz from master\n");
00663 }
00664
00665 if ( opts->dx == 0.0 )
00666 {
00667 opts->dx = fabs(dax->xxdel);
00668 opts->dy = fabs(dax->yydel);
00669 opts->dz = fabs(dax->zzdel);
00670 }
00671
00672 if ( opts->debug >= RL_DEBUG_LOW )
00673 {
00674 if (!opts->orient) fprintf(stderr,"-d using orient from master\n");
00675 else fprintf(stderr,"-d overriding orient from master\n");
00676 }
00677
00678 if ( opts->orient == NULL )
00679 {
00680
00681 if ( (opts->orient = (char *)malloc(4 * sizeof(char)) ) == NULL )
00682 {
00683 fputs( "failure: malloc failure for orient, exiting...\n", stderr );
00684 return FAIL;
00685 }
00686
00687 opts->orient[0] = ORIENT_typestr[dax->xxorient][0];
00688 opts->orient[1] = ORIENT_typestr[dax->yyorient][0];
00689 opts->orient[2] = ORIENT_typestr[dax->zzorient][0];
00690 opts->orient[3] = '\0';
00691 }
00692
00693 if ( opts->debug >= RL_DEBUG_LOW )
00694 {
00695 disp_opts_data( "++ mastered options : ", opts );
00696
00697 if ( opts->debug >= RL_DEBUG_HIGH )
00698 {
00699 r_idisp_thd_3dim_dataset("sync mset : ", opts->mset );
00700 r_idisp_thd_dataxes ("sync mset : ", opts->mset->daxes );
00701 r_idisp_thd_datablock ("sync mset : ", opts->mset->dblk );
00702 if ( opts->mset->dblk )
00703 r_idisp_thd_diskptr ("sync mset : ", opts->mset->dblk->diskptr);
00704 }
00705 }
00706
00707 return 0;
00708 }
00709
00710
00711 int disp_opts_data ( char * info, options_t * opts )
00712 {
00713 if ( info )
00714 fputs( info, stdout );
00715
00716 if ( opts == NULL )
00717 {
00718 printf( "disp_opts_data: opts == NULL\n" );
00719 return FAIL;
00720 }
00721
00722 printf( "options struct at %p :\n"
00723 " dset = %p (%s)\n"
00724 " mset = %p (%s)\n"
00725 " (dx,dy,dz) = (%6.3f, %6.3f, %6.3f)\n"
00726 " orient = %.6s\n"
00727 " prefix = %.60s\n"
00728 " resam = %d\n"
00729 " debug = %d\n",
00730 opts,
00731 opts->dset, ISVALID_DSET(opts->dset) ? "valid" : "invalid",
00732 opts->mset, ISVALID_DSET(opts->mset) ? "valid" : "invalid",
00733 opts->dx, opts->dy, opts->dz,
00734 CHECK_NULL_STR(opts->orient), CHECK_NULL_STR(opts->prefix),
00735 opts->resam, opts->debug );
00736
00737 return 0;
00738 }
00739