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  

3dinfo_OLD.c

Go to the documentation of this file.
00001 /*-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
00002   This software is Copyright 1994-1996 by
00003 
00004             Medical College of Wisconsin
00005             8701 Watertown Plank Road
00006             Milwaukee, WI 53226
00007 
00008   License is granted to use this program for nonprofit research purposes only.
00009   It is specifically against the license to use this program for any clinical
00010   application.  The Medical College of Wisconsin makes no warranty of usefulness
00011   of this program for any particular purpose.  The redistribution of this
00012   program for a fee, or the derivation of for-profit works from this program
00013   is not allowed.
00014 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+*/
00015 
00016 #include "mrilib.h"
00017 
00018 void Syntax(void)
00019 {
00020    printf(
00021     "Copyright 1994-6 Medical College of Wisconsin\n\n"
00022     "Prints out sort-of-useful information from a 3D dataset's header\n"
00023     "Usage: 3dinfo [-v] dataset [dataset ...]\n"
00024     "  The -v option means print out verbose information.  At present,\n"
00025     "  it just causes the printing of all the statistics for each time\n"
00026     "  in a time-dependent dataset.\n"
00027    ) ;
00028    exit(0) ;
00029 }
00030 
00031 int main( int argc , char * argv[] )
00032 {
00033    THD_3dim_dataset * dset ;
00034    THD_dataxes      * daxes ;
00035    THD_fvec3 fv1 , fv2 , fv3 ;
00036    THD_ivec3 iv ;
00037    int iarg , ival , ntimes , nval_per , n1,n2,n3 , verbose = 0 , kv,npar ;
00038    float tf ;
00039 
00040    static char * RR="[R]" , * LL="[L]" ,
00041                * PP="[P]" , * AA="[A]" ,
00042                * SS="[S]" , * II="[I]" , * ZZ="   " ;
00043    char * xlbot , * xltop , * ylbot , * yltop , * zlbot , * zltop , * cpt ;
00044    char str[256] ;
00045    int nstr ;
00046 
00047 #define XLAB(xl,xv) ((xl) = ((xv)==0.0) ? (ZZ) : ( ((xv)<0.0) ? (RR) : (LL) ))
00048 #define YLAB(yl,yv) ((yl) = ((yv)==0.0) ? (ZZ) : ( ((yv)<0.0) ? (AA) : (PP) ))
00049 #define ZLAB(zl,zv) ((zl) = ((zv)==0.0) ? (ZZ) : ( ((zv)<0.0) ? (II) : (SS) ))
00050 
00051 #define FSWAP(x,y) (tf=(x),(x)=(y),(y)=tf)
00052 
00053    if( argc < 2 || strncmp(argv[1],"-help",4) == 0 ) Syntax() ;
00054 
00055    iarg = 1 ;
00056 
00057    if( strcmp(argv[iarg],"-v") == 0 ){ verbose = 1 ; iarg++ ; }
00058 
00059    for( ; iarg < argc ; iarg++ ){
00060       dset = THD_open_one_dataset( argv[iarg] ) ;
00061       if( dset == NULL ) continue ;
00062       daxes = dset->daxes ;
00063 
00064       printf("\n"
00065          "Dataset File:    %s\n"
00066 #if 0
00067          "Dataset Name:    %s\n"
00068          "Dataset Label:   %s\n"
00069 #endif
00070        , argv[iarg]
00071 #if 0
00072        , dset->self_name , dset->label1
00073 #endif
00074       ) ;
00075 
00076 #ifndef OMIT_DATASET_IDCODES
00077        printf("Identifier Code: %s  Creation Date: %s\n" ,
00078               dset->idcode.str , dset->idcode.date ) ;
00079 #endif
00080 
00081       if( ISANAT(dset) ){
00082          printf("Dataset Type:    %s (-%s)\n",
00083                 ANAT_typestr[dset->func_type] , ANAT_prefixstr[dset->func_type] ) ;
00084       } else {
00085          printf("Dataset Type:    %s (-%s)\n",
00086                 FUNC_typestr[dset->func_type] , FUNC_prefixstr[dset->func_type] ) ;
00087       }
00088 
00089       cpt = DSET_KEYWORDS(dset) ;
00090       if( cpt != NULL && cpt[0] != '\0' )
00091          printf("Keywords:        %s\n" , cpt ) ;
00092 
00093 #ifdef OMIT_DATASET_IDCODES
00094       if( strlen(dset->anat_parent_name) > 0 )
00095          printf("Anatomy Parent:  %s\n" , dset->anat_parent_name ) ;
00096 
00097       if( strlen(dset->warp_parent_name) > 0 )
00098          printf("Warp Parent:     %s\n" , dset->warp_parent_name ) ;
00099 #else
00100       if( ! ISZERO_IDCODE(dset->anat_parent_idcode) )
00101          printf("Anatomy Parent:  %s [%s]\n" ,
00102                 dset->anat_parent_name , dset->anat_parent_idcode.str ) ;
00103       else if( strlen(dset->anat_parent_name) > 0 )
00104          printf("Anatomy Parent:  %s\n" , dset->anat_parent_name ) ;
00105 
00106       if( ! ISZERO_IDCODE(dset->warp_parent_idcode) )
00107          printf("Warp Parent:     %s [%s]\n" ,
00108                  dset->warp_parent_name , dset->warp_parent_idcode.str) ;
00109       else if( strlen(dset->warp_parent_name) > 0 )
00110          printf("Warp Parent:     %s\n" , dset->warp_parent_name ) ;
00111 #endif
00112 
00113       printf(
00114          "Data Axes Orientation:\n"
00115          "  first  (x) = %s\n"
00116          "  second (y) = %s\n"
00117          "  third  (z) = %s   [-orient %c%c%c]\n" ,
00118        ORIENT_typestr[daxes->xxorient] ,
00119          ORIENT_typestr[daxes->yyorient] ,
00120          ORIENT_typestr[daxes->zzorient] ,
00121        ORIENT_typestr[daxes->xxorient][0] ,
00122          ORIENT_typestr[daxes->yyorient][0] ,
00123          ORIENT_typestr[daxes->zzorient][0]  ) ;
00124 
00125       LOAD_FVEC3(fv1 , daxes->xxorg , daxes->yyorg , daxes->zzorg) ;
00126       fv1 = THD_3dmm_to_dicomm( dset , fv1 ) ;
00127 
00128       LOAD_FVEC3(fv2 , daxes->xxorg + (daxes->nxx-1)*daxes->xxdel ,
00129                        daxes->yyorg + (daxes->nyy-1)*daxes->yydel ,
00130                        daxes->zzorg + (daxes->nzz-1)*daxes->zzdel  ) ;
00131       fv2 = THD_3dmm_to_dicomm( dset , fv2 ) ;
00132 
00133       if( fv1.xyz[0] > fv2.xyz[0] ) FSWAP( fv1.xyz[0] , fv2.xyz[0] ) ;
00134       if( fv1.xyz[1] > fv2.xyz[1] ) FSWAP( fv1.xyz[1] , fv2.xyz[1] ) ;
00135       if( fv1.xyz[2] > fv2.xyz[2] ) FSWAP( fv1.xyz[2] , fv2.xyz[2] ) ;
00136 
00137       LOAD_FVEC3(fv3 , daxes->xxdel , daxes->yydel , daxes->zzdel) ;
00138       fv3 = THD_3dmm_to_dicomm( dset , fv3 ) ;
00139 
00140       XLAB(xlbot,fv1.xyz[0]) ; YLAB(ylbot,fv1.xyz[1]) ; ZLAB(zlbot,fv1.xyz[2]) ;
00141       XLAB(xltop,fv2.xyz[0]) ; YLAB(yltop,fv2.xyz[1]) ; ZLAB(zltop,fv2.xyz[2]) ;
00142 
00143       n1 = DAXES_NUM(daxes,daxes->xxorient) ;
00144       n2 = DAXES_NUM(daxes,daxes->yyorient) ;
00145       n3 = DAXES_NUM(daxes,daxes->zzorient) ;
00146 
00147       printf(
00148          "R-to-L extent: %9.3f %s -to- %9.3f %s -step- %9.3f mm [%3d voxels]\n"
00149          "A-to-P extent: %9.3f %s -to- %9.3f %s -step- %9.3f mm [%3d voxels]\n"
00150          "I-to-S extent: %9.3f %s -to- %9.3f %s -step- %9.3f mm [%3d voxels]\n" ,
00151        fv1.xyz[0],xlbot , fv2.xyz[0],xltop , fabs(fv3.xyz[0]) , n1 ,
00152        fv1.xyz[1],ylbot , fv2.xyz[1],yltop , fabs(fv3.xyz[1]) , n2 ,
00153        fv1.xyz[2],zlbot , fv2.xyz[2],zltop , fabs(fv3.xyz[2]) , n3  ) ;
00154 
00155       ntimes   = DSET_NUM_TIMES(dset) ;
00156       nval_per = DSET_NVALS_PER_TIME(dset) ;
00157       if( ntimes > 1 ){
00158          printf(
00159             "Number of time steps = %d  Number of values at each pixel = %d\n",
00160             ntimes , nval_per ) ;
00161 
00162          printf( "Time step = %.3f (%s)" ,
00163                  dset->taxis->ttdel ,
00164                  UNITS_TYPE_LABEL(dset->taxis->units_type) ) ;
00165          if( dset->taxis->nsl > 0 )
00166            printf("  Number time-offset slices = %d  Thickness = %.3f",
00167                   dset->taxis->nsl , fabs(dset->taxis->dz_sl) ) ;
00168          printf("\n") ;
00169 
00170          if( verbose && dset->taxis->nsl > 0 ){
00171             printf("Time-offsets per slice:") ;
00172             for( ival=0 ; ival < dset->taxis->nsl ; ival++ )
00173               printf( " %.3f" , dset->taxis->toff_sl[ival] ) ;
00174             printf("\n") ;
00175          }
00176       } else {
00177          printf(
00178            "Number of values stored at each pixel = %d\n" , nval_per ) ;
00179       }
00180 
00181       if( verbose && ntimes > 1 ) nval_per = dset->dblk->nvals ;
00182 
00183       for( ival=0 ; ival < nval_per ; ival++ ){
00184          sprintf( str ,
00185                   "  -- At sub-brick #%d [%s] datum type is %s" ,
00186                   ival , dset->dblk->brick_lab[ival] ,
00187                   MRI_TYPE_name[DSET_BRICK_TYPE(dset,ival)] ) ;
00188          nstr = strlen(str) ;
00189 
00190          tf = DSET_BRICK_FACTOR(dset,ival) ;
00191 
00192          if( ISVALID_STATISTIC(dset->stats) ){
00193             if( tf != 0.0 )
00194                sprintf( str+nstr ,
00195                                    ":%13.6g to %13.6g [internal]\n"
00196                        "%*s[*%13.6g] %13.6g to %13.6g [scaled]\n" ,
00197                        dset->stats->bstat[ival].min/tf ,
00198                        dset->stats->bstat[ival].max/tf ,
00199                        nstr-16," " , tf ,
00200                        dset->stats->bstat[ival].min , dset->stats->bstat[ival].max ) ;
00201              else
00202                sprintf( str+nstr , ":%13.6g to %13.6g\n" ,
00203                        dset->stats->bstat[ival].min , dset->stats->bstat[ival].max ) ;
00204          } else if( tf != 0.0 ){
00205             sprintf( str+nstr , " [*%g]\n",tf) ;
00206          } else {
00207             sprintf( str+nstr , "\n") ;
00208          }
00209          printf(str) ;
00210 
00211          /** 30 Nov 1997: print sub-brick stat params **/
00212 
00213          kv = DSET_BRICK_STATCODE(dset,ival) ;
00214          if( FUNC_IS_STAT(kv) ){
00215             printf("     statcode = %s",FUNC_prefixstr[kv] ) ;
00216             npar = FUNC_need_stat_aux[kv] ;
00217             if( npar > 0 ){
00218                printf(";  statpar =") ;
00219                for( kv=0 ; kv < npar ; kv++ )
00220                   printf(" %g",DSET_BRICK_STATPAR(dset,ival,kv)) ;
00221             }
00222             printf("\n") ;
00223          }
00224 
00225          cpt = DSET_BRICK_KEYWORDS(dset,ival) ;
00226          if( cpt != NULL && cpt[0] != '\0' )
00227             printf("     keywords = %s\n",cpt) ;
00228       }
00229 
00230       /** print out dataset global statistical parameters **/
00231 
00232       if( ISFUNC(dset) && FUNC_need_stat_aux[dset->func_type] > 0 ){
00233          printf("Auxiliary functional statistical parameters:\n %s\n",
00234                 FUNC_label_stat_aux[dset->func_type] ) ;
00235          for( ival=0 ; ival < FUNC_need_stat_aux[dset->func_type] ; ival++ )
00236             printf(" %g",dset->stat_aux[ival]) ;
00237          printf("\n") ;
00238       }
00239 
00240       THD_delete_3dim_dataset( dset , False ) ;
00241    }
00242    exit(0) ;
00243 }
 

Powered by Plone

This site conforms to the following standards: