00001 
00002 #include "mrilib.h"
00003 #include "r_idisp.h"
00004 
00005 
00006 
00007 
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 
00043 
00044 
00045 
00046 
00047 
00048 
00049 
00050 
00051 
00052 
00053 
00054 
00055 
00056 
00057 int r_idisp_vec3d( char * info, double * vec )
00058 {
00059     if ( info )
00060         fputs( info, stdout );
00061 
00062     if ( vec == NULL )
00063     {
00064         printf( "r_idisp_vec3d: vec == NULL" );
00065         return -1;
00066     }
00067 
00068     printf( "double vector at %p: <%f, %f, %f>\n",
00069             vec, vec[0], vec[1], vec[2] );
00070 
00071     return 0;
00072 }
00073 
00074 int r_idisp_vec3f( char * info, float * vec )
00075 {
00076     if ( info )
00077         fputs( info, stdout );
00078 
00079     if ( vec == NULL )
00080     {
00081         printf( "r_idisp_vec3f: vec == NULL" );
00082         return -1;
00083     }
00084 
00085     printf( "float vector at %p: <%f, %f, %f>\n",
00086             vec, vec[0], vec[1], vec[2] );
00087 
00088     return 0;
00089 }
00090 
00091 
00092 
00093 
00094 
00095 
00096 int r_idisp_fd_brick( char * info, FD_brick * bp )
00097 {
00098     if ( info )
00099         fputs( info, stdout );
00100 
00101     if ( bp == NULL )
00102     {
00103         printf( "r_idisp_fd_brick: bp == NULL\n" );
00104         return -1;
00105     }
00106 
00107     printf( "FD_brick structure at %p :\n", bp );
00108     r_idisp_vec3i( "   FD->nxyz : ", bp->nxyz.ijk );
00109     r_idisp_vec3i( "   FD->sxyz : ", bp->sxyz.ijk );
00110     r_idisp_vec3i( "   FD->a123 : ", bp->a123.ijk );
00111     printf( "   (n1, d1, e1)       = (%d, %d, %d)\n"
00112             "   (n2, d2, e2)       = (%d, %d, %d)\n"
00113             "   (n3, d3)           = (%d, %d)\n"
00114             "   start              = %d\n"
00115             "   (del1, del2, del3) = (%8.3f, %8.3f, %8.3f)\n"
00116             "   dset               = %p\n"
00117             "   resam_code         = %d\n"
00118             "   thr_resam_code     = %d\n"
00119             "   namecode           = <%s>\n"
00120             "   parent             = %p\n",
00121             bp->n1, bp->d1, bp->e1, bp->n2, bp->d2, bp->e2,
00122             bp->n3, bp->d3, bp->start,
00123             bp->del1, bp->del2, bp->del3,
00124             bp->dset, bp->resam_code, bp->thr_resam_code,
00125             CHECK_NULL_STR(bp->namecode), bp->parent );
00126 
00127     return 0;
00128 }
00129 
00130 int r_idisp_vec3i( char * info, int * vec )
00131 {
00132     if ( info )
00133         fputs( info, stdout );
00134 
00135     if ( vec == NULL )
00136     {
00137         printf( "r_idisp_vec3i: vec == NULL\n" );
00138         return -1;
00139     }
00140 
00141     printf( "int vec3 at %p: <%d, %d, %d>\n",
00142             vec, vec[0], vec[1], vec[2] );
00143 
00144     return 0;
00145 }
00146 
00147 int r_idisp_mri_image( char * info, MRI_IMAGE * ip )
00148 {
00149     if ( info )
00150         fputs( info, stdout );
00151 
00152     if ( ip == NULL )
00153     {
00154         printf( "r_idisp_mri_image: ip == NULL\n" );
00155         return -1;
00156     }
00157 
00158     printf( "r_idisp_mri_image structure at %p :\n"
00159             "   nx = %d, ny = %d, nz = %d\n"
00160             "   nt = %d, nu = %d, nv = %d, nw = %d\n"
00161             "   nxy = %d, nxyz = %d, nxyzt = %d\n"
00162             "   nvox = %d, pixel_size = %d\n"
00163             "   kind = %d, im = %p, name = %s\n"
00164             "   dx = %7.3f, dy = %7.3f, dz = %7.3f, dt = %7.3f\n"
00165             "   du = %7.3f, dv = %7.3f, dw = %7.3f\n"
00166             "   xo = %7.3f, yo = %7.3f, zo = %7.3f, to = %7.3f\n"
00167             "   uo = %7.3f, vo = %7.3f, wo = %7.3f\n"
00168             "   was_swapped = %d\n",
00169             ip,
00170             ip->nx, ip->ny, ip->nz, ip->nt, ip->nu, ip->nv, ip->nw,
00171             ip->nxy, ip->nxyz, ip->nxyzt, ip->nvox, ip->pixel_size,
00172             (int)ip->kind, ip->im.byte_data, CHECK_NULL_STR(ip->name),
00173             ip->dx, ip->dy, ip->dz, ip->dt, ip->du, ip->dv, ip->dw,
00174             ip->xo, ip->yo, ip->zo, ip->to, ip->uo, ip->vo, ip->wo,
00175             ip->was_swapped );
00176 
00177     return 0;
00178 }
00179 
00180 int r_idisp_mri_imarr( char * info, MRI_IMARR * ip, int images )
00181 {
00182     int c;
00183 
00184     if ( info )
00185         fputs( info, stdout );
00186 
00187     if ( ip == NULL )
00188     {
00189         printf( "r_idisp_mri_imarr: ip == NULL\n" );
00190         return -1;
00191     }
00192 
00193     printf( "r_idisp_mri_imarr structure at %p :\n"
00194             "      num = %d, nall (mem) = %d\n",
00195             ip, ip->num, ip->nall );
00196 
00197     if ( images )
00198     {
00199         for ( c = 0; c < ip->num; c++ )
00200         {
00201             r_idisp_mri_image( NULL, ip->imarr[c] );
00202         }
00203     }
00204 
00205     return 0;
00206 }
00207 
00208 int r_idisp_mat33f( char * info, float mat[3][3] )
00209 {
00210     if ( info )
00211         fputs( info, stdout );
00212 
00213     if ( mat == NULL )
00214     {
00215         printf( "r_idisp_mat33f: mat == NULL\n" );
00216         return -1;
00217     }
00218 
00219     printf( "mat33 float structure at %p :\n"
00220             "      %7.3f   %7.3f   %7.3f\n"
00221             "      %7.3f   %7.3f   %7.3f\n"
00222             "      %7.3f   %7.3f   %7.3f\n",
00223             mat,
00224             mat[0][0], mat[0][1], mat[0][2],
00225             mat[1][0], mat[1][1], mat[1][2],
00226             mat[2][0], mat[2][1], mat[2][2]
00227           );
00228     return 0;
00229 }
00230 
00231 int r_idisp_mat33d( char * info, double mat[3][3] )
00232 {
00233     if ( info )
00234         fputs( info, stdout );
00235 
00236     if ( mat == NULL )
00237     {
00238         printf( "r_idisp_mat33d: mat == NULL\n" );
00239         return -1;
00240     }
00241 
00242     printf( "mat33 double structure at %p :\n"
00243             "      %7.3f   %7.3f   %7.3f\n"
00244             "      %7.3f   %7.3f   %7.3f\n"
00245             "      %7.3f   %7.3f   %7.3f\n",
00246             mat,
00247             mat[0][0], mat[0][1], mat[0][2],
00248             mat[1][0], mat[1][1], mat[1][2],
00249             mat[2][0], mat[2][1], mat[2][2]
00250           );
00251     return 0;
00252 }
00253 
00254 int r_idisp_thd_3dim_dataset( char * info, THD_3dim_dataset * dp )
00255 {
00256     if ( info )
00257         fputs( info, stdout );
00258 
00259     if ( dp == NULL )
00260     {
00261         printf( "r_idisp_thd_3dim_dataset: dp == NULL\n" );
00262         return -1;
00263     }
00264 
00265     printf( "THD_3dim_dataset struct at %p\n"
00266             "   type         : %d\n"
00267             "   view_type    : %d\n"
00268             "   func_type    : %d\n"
00269             "   -------------------\n"
00270             "   dblk         : %p\n"
00271             "   daxes        : %p\n"
00272             "   wod_daxes    : %p\n"
00273             "   wod_flag     : %d\n"
00274             "   -------------------\n"
00275             "   taxis        : %p\n"
00276             "   markers      : %p\n"
00277             "   warp_parent  : %p\n"
00278             "   warp         : %p\n"
00279             "   vox_warp     : %p\n"
00280             "   -------------------\n"
00281             "   anat_parent  : %p\n"
00282             "   stats        : %p\n"
00283 #ifdef ALLOW_DATASET_VLIST
00284             "   pts          : %p\n"
00285             "   pts_original : %d\n"
00286 #endif
00287             "   death_mark   : %d\n"
00288             "   -------------------\n"
00289 #ifndef OMIT_DATASET_IDCODES
00290             "   idcode.str              : <%s>\n"
00291             "   idcode.date             : <%s>\n"
00292             "   anat_parent_idcode.str  : <%s>\n"
00293             "   anat_parent_idcode.date : <%s>\n"
00294             "   warp_parent_idcode.str  : <%s>\n"
00295             "   warp_parent_idcode.date : <%s>\n"
00296             "   -------------------\n"
00297 #endif
00298             "   keywords  : %p\n"
00299             "   tagset    : %p\n"
00300             "   -------------------\n"
00301             "   kl.num    : %d\n"
00302             "   kl.nalloc : %d\n"
00303             "   kl.kill   : %p\n"
00304             "   parent    : %p\n"
00305             "-------------------------------------------\n",
00306             dp, dp->type, dp->view_type, dp->func_type,
00307             dp->dblk, dp->daxes, dp->wod_daxes, dp->wod_flag,
00308             dp->taxis, dp->markers, dp->warp_parent, dp->warp, dp->vox_warp,
00309             dp->anat_parent, dp->stats,
00310 #ifdef ALLOW_DATASET_VLIST
00311             dp->pts, dp->pts_original,
00312 #endif
00313             dp->death_mark,
00314 #ifndef OMIT_DATASET_IDCODES
00315             CHECK_NULL_STR(dp->idcode.str),
00316             CHECK_NULL_STR(dp->idcode.date),
00317             CHECK_NULL_STR(dp->anat_parent_idcode.str),
00318             CHECK_NULL_STR(dp->anat_parent_idcode.date),
00319             CHECK_NULL_STR(dp->warp_parent_idcode.str),
00320             CHECK_NULL_STR(dp->warp_parent_idcode.date),
00321 #endif
00322             dp->keywords, dp->tagset,
00323             dp->kl.num, dp->kl.nalloc, dp->kl.kill, dp->parent
00324           );
00325 
00326     return 0;
00327 }
00328 
00329 
00330 int r_idisp_thd_diskptr( char * info, THD_diskptr * dp )
00331 {
00332     if ( info )
00333         fputs( info, stdout );
00334 
00335     if ( dp == NULL )
00336     {
00337         printf( "r_idisp_thd_diskptr: dp == NULL\n" );
00338         return -1;
00339     }
00340 
00341     printf( "THD_diskptr structure at %p\n"
00342             "   type (%2d)      : %d\n"
00343             "   rank (3)       : %d\n"
00344             "   dimsizes       : (%d,%d,%d)\n"
00345             "   storage_mode   : %d\n"
00346             "   byte_order     : %d\n"
00347             "   --------------------------------------\n"
00348             "   prefix         : %.60s\n"
00349             "   viewcode       : %.60s\n"
00350             "   filecode       : %.60s\n"
00351             "   --------------------------------------\n"
00352             "   directory_name : %.80s\n"
00353             "   header_name    : %.80s\n"
00354             "   brick_name     : %.80s\n"
00355             "   --------------------------------------\n",
00356             dp, DISKPTR_TYPE, dp->type, dp->rank,
00357             dp->dimsizes[0], dp->dimsizes[1], dp->dimsizes[2],
00358             dp->storage_mode, dp->byte_order,
00359             CHECK_NULL_STR(dp->prefix),      CHECK_NULL_STR(dp->viewcode),
00360             CHECK_NULL_STR(dp->filecode),    CHECK_NULL_STR(dp->directory_name),
00361             CHECK_NULL_STR(dp->header_name), CHECK_NULL_STR(dp->brick_name)
00362           );
00363 
00364     return 0;
00365 }
00366 
00367 
00368 int r_idisp_thd_datablock( char * info, THD_datablock * dp )
00369 {
00370     if ( info )
00371         fputs( info, stdout );
00372 
00373     if ( dp == NULL )
00374     {
00375         printf( "r_idisp_thd_datablock: dp == NULL\n" );
00376         return -1;
00377     }
00378 
00379     printf( "THD_datablock structure at %p\n"
00380             "   type        : %d\n"
00381             "   nvals       : %d\n"
00382             "   brick       : %p\n"
00383             "   brick_fac   : %p\n"
00384             "   brick_bytes : %p\n",
00385             dp, dp->type, dp->nvals, dp->brick,
00386             dp->brick_fac, dp->brick_bytes );
00387 
00388     if ( dp->nvals > 0 )
00389     {
00390         int c;
00391 
00392         printf( 
00393           "   ----------------------------------------\n"
00394           "   sub   fac        brick_bytes   brick_lab\n"
00395           "   ---   ---        -----------   ---------\n" );
00396         for ( c = 0; c < dp->nvals; c++ )
00397         {
00398             printf( "   %3d   ", c );
00399 
00400             if ( dp->brick_fac )
00401                 printf( "%f  ", dp->brick_fac[c] );
00402             else
00403                 printf( "         " );
00404 
00405             if ( dp->brick_bytes )
00406                 printf( " %10d    ", dp->brick_bytes[c] );
00407             else
00408                 printf( "%15s", "" );
00409 
00410             if ( dp->brick_lab )
00411                 printf( "%s\n", CHECK_NULL_STR(dp->brick_lab[c]) );
00412             else
00413                 printf( "\n" );
00414         }
00415     }
00416 
00417     printf( "   --------------------------------------\n"
00418             "   brick_keywords : %p\n"
00419             "   brick_statcode : %p\n"
00420             "   brick_stataux  : %p\n"
00421             "   --------------------------------------\n"
00422             "   total_bytes    : %d\n"
00423             "   malloc_type    : %d\n"
00424             "   locked         : %d\n"
00425             "   --------------------------------------\n"
00426             "   master_nvals   : %d\n"
00427             "   master_ival    : %p\n"
00428             "   master_bytes   : %p\n"
00429             "   master_bot     : %f\n"
00430             "   master_top     : %f\n"
00431             "   --------------------------------------\n"
00432             "   diskptr        : %p\n"
00433             "   natr           : %d\n"
00434             "   natr_alloc     : %d\n"
00435             "   atr            : %p\n"
00436             "   --------------------------------------\n"
00437             "   kl.num         : %d\n"
00438             "   kl.nalloc      : %d\n"
00439             "   kl.kill        : %p\n"
00440             "   parent         : %p\n"
00441             "-----------------------------------------\n",
00442             dp->brick_keywords, dp->brick_statcode, dp->brick_stataux,
00443             dp->total_bytes, dp->malloc_type, dp->locked,
00444             dp->master_nvals, dp->master_ival, dp->master_bytes,
00445             dp->master_bot, dp->master_top,
00446             dp->diskptr, dp->natr, dp->natr_alloc, dp->atr,
00447             dp->kl.num, dp->kl.nalloc, dp->kl.kill, dp->parent );
00448 
00449     return 0;
00450 }
00451 
00452 
00453 int r_idisp_thd_dataxes( char * info, THD_dataxes * dp )
00454 {
00455     if ( info )
00456         fputs( info, stdout );
00457 
00458     if ( dp == NULL )
00459     {
00460         printf( "r_idisp_thd_dataxes: dp == NULL\n" );
00461         return -1;
00462     }
00463 
00464     printf( "THD_dataxes structure at %p\n"
00465             "   type                  : %d\n"
00466             "   (nxx, nyy, nzz)       : (%d, %d, %d)\n"
00467             "   (xxorg, yyorg, zzorg) : (%8.3f, %8.3f, %8.3f)\n"
00468             "   (xxdel, yydel, zzdel) : (%8.3f, %8.3f, %8.3f)\n"
00469             "   (xxmin, yymin, zzmin) : (%8.3f, %8.3f, %8.3f)\n"
00470             "   (xxmax, yymax, zzmax) : (%8.3f, %8.3f, %8.3f)\n"
00471             "   (xxorient,yyorient,zzorient) : (%d, %d, %d)\n"
00472             "   parent                : %p\n"
00473             "   -----------------------\n",
00474             dp,
00475             dp->type, dp->nxx, dp->nyy, dp->nzz,
00476             dp->xxorg, dp->yyorg, dp->zzorg, dp->xxdel, dp->yydel, dp->zzdel,
00477             dp->xxmin, dp->yymin, dp->zzmin, dp->xxmax, dp->yymax, dp->zzmax,
00478             dp->xxorient, dp->yyorient, dp->zzorient, dp->parent
00479           );
00480 
00481     r_idisp_mat33f( "   to_dicomm[3][3] : ", dp->to_dicomm.mat );
00482 
00483     printf( "-------------------------------------------\n");
00484 
00485     return 0;
00486 }
00487 
00488 
00489 
00490 
00491 
00492 
00493 
00494 #ifdef _COX_RENDER_HEADER_        
00495 
00496 int r_idisp_cren_stuff( char * info, CREN_stuff * cp )
00497 {
00498     if ( info )
00499         fputs( info, stdout );
00500 
00501     if ( cp == NULL )
00502     {
00503         printf( "r_idisp_thd_dataxes: cp == NULL\n" );
00504         return -1;
00505     }
00506 
00507     printf( "CREN_stuff structure at %p\n"
00508             "   type = %d, nx = %d, ny = %d, nz = %d\n"
00509             "   dx = %7.3f, dy = %7.3f, dz = %7.3f\n"
00510             "   vox = %p, vtm = %p\n"
00511             "   nrgb = %d, opargb = %7.3f, min_opacity = %7.3f\n"
00512             
00513             "   ax1 = %d, ax2 = %d, ac3 = %d\n"
00514             "   th1 = %7.3f, th2 = %7.3f, th3 = %7.3f\n"
00515             
00516             "   newvox = %d, newopa = %d, newangles = %d\n"
00517             "   renmode = %d, intmode = %d\n",
00518             cp,
00519             cp->type, cp->nx, cp->ny, cp->nz, cp->dx, cp->dy, cp->dz,
00520             cp->vox, cp->vtm,
00521             cp->nrgb, cp->opargb, cp->min_opacity,
00522             cp->ax1, cp->ax2, cp->ax3, cp->th1, cp->th2, cp->th3,
00523             cp->newvox, cp->newopa, cp->newangles, cp->renmode, cp->intmode
00524           );
00525 
00526     return 0;
00527 }
00528 
00529 #endif