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  

thd_info.c File Reference

#include "mrilib.h"
#include "thd.h"
#include <stdarg.h>

Go to the source code of this file.


Defines

#define ZMAX   8000
#define SZMAX   "%.8000s"

Functions

char * THD_zzprintf (char *sss, char *fmt,...)
char * THD_dataset_info (THD_3dim_dataset *dset, int verbose)

Define Documentation

#define SZMAX   "%.8000s"
 

Definition at line 21 of file thd_info.c.

Referenced by THD_dataset_info().

#define ZMAX   8000
 

Inline version of 3dinfo.

  • You must free() the output string when done with it.
  • verbose is -1 (shortest output), 0, or 1 (longest output) ----------------------------------------------------------------------

Definition at line 20 of file thd_info.c.

Referenced by THD_dataset_info(), and THD_zzprintf().


Function Documentation

char* THD_dataset_info THD_3dim_dataset   dset,
int    verbose
 

Definition at line 25 of file thd_info.c.

References AFMALL, THD_3dim_dataset::anat_parent_idcode, THD_3dim_dataset::anat_parent_name, ATRNAME_BYTEORDER, THD_statistics::bstat, MCW_idcode::date, THD_3dim_dataset::daxes, DAXES_NUM, THD_3dim_dataset::dblk, THD_datablock::diskptr, DSET_BRICK_FACTOR, DSET_BRICK_KEYWORDS, DSET_BRICK_LAB, DSET_BRICK_STATCODE, DSET_BRICK_STATPAR, DSET_BRICK_TYPE, DSET_BRIKNAME, DSET_BYTEORDER, DSET_FILECODE, DSET_IS_BRIK, DSET_KEYWORDS, DSET_NUM_TIMES, DSET_NVALS_PER_TIME, THD_timeaxis::dz_sl, ENTRY, free, FUNC_IS_STAT, THD_3dim_dataset::func_type, i, THD_3dim_dataset::idcode, ATR_int::in, ISANAT, ISFUNC, ISVALID_3DIM_DATASET, ISVALID_STATISTIC, ISZERO_IDCODE, LOAD_FVEC3, LSB_FIRST_STRING, THD_brick_stats::max, THD_brick_stats::min, mmm, mri_short_order(), MSB_FIRST_STRING, n1, n2, THD_timeaxis::nsl, THD_usertaglist::num, THD_datablock::nvals, THD_dataxes::nxx, THD_dataxes::nyy, THD_dataxes::nzz, ORI_A2P_TYPE, ORI_I2S_TYPE, ORI_R2L_TYPE, RETURN, THD_usertag::set, THD_3dim_dataset::stat_aux, THD_3dim_dataset::stats, STORAGE_BY_1D, STORAGE_BY_3D, STORAGE_BY_ANALYZE, STORAGE_BY_BRICK, STORAGE_BY_CTFMRI, STORAGE_BY_CTFSAM, STORAGE_BY_MINC, STORAGE_BY_MPEG, STORAGE_BY_NIFTI, STORAGE_BY_VOLUMES, THD_diskptr::storage_mode, MCW_idcode::str, SZMAX, THD_usertaglist::tag, THD_3dim_dataset::tagset, THD_3dim_dataset::taxis, THD_3dmm_to_dicomm(), THD_find_int_atr(), THD_find_string_atr(), THD_zzprintf(), THD_timeaxis::toff_sl, tross_Get_History(), tross_Get_Note(), tross_Get_Notedate(), THD_timeaxis::ttdel, THD_timeaxis::ttorg, THD_timeaxis::units_type, UNITS_TYPE_LABEL, THD_3dim_dataset::warp_parent_idcode, THD_3dim_dataset::warp_parent_name, THD_dataxes::xxdel, THD_dataxes::xxorg, THD_dataxes::xxorient, THD_fvec3::xyz, THD_dataxes::yydel, THD_dataxes::yyorg, THD_dataxes::yyorient, ZMAX, THD_dataxes::zzdel, THD_dataxes::zzorg, and THD_dataxes::zzorient.

Referenced by AFNI_misc_CB(), and main().

00026 {
00027    THD_dataxes      *daxes ;
00028    THD_fvec3 fv1 , fv2 , fv3 ;
00029    THD_ivec3 iv ;
00030    int ival , ntimes , nval_per , n1,n2,n3 , kv,npar ;
00031    float tf ;
00032 
00033    static char *RR="[R]" , *LL="[L]" ,
00034                *PP="[P]" , *AA="[A]" ,
00035                *SS="[S]" , *II="[I]" , *ZZ="   " ;
00036    char *xlbot , *xltop , *ylbot , *yltop , *zlbot , *zltop , *cpt ;
00037    char str[256] ;
00038    int nstr ;
00039 
00040    char *outbuf = NULL ;
00041 
00042 ENTRY("THD_dataset_info") ;
00043 
00044    if( ! ISVALID_3DIM_DATASET(dset) ) RETURN(NULL) ;
00045 
00046    daxes = dset->daxes ;
00047 
00048    if( DSET_IS_BRIK(dset) )
00049      outbuf = THD_zzprintf(outbuf,"Dataset File:    %s\n" , DSET_FILECODE(dset) ) ;
00050    else
00051      outbuf = THD_zzprintf(outbuf,"Dataset File:    %s\n" , DSET_BRIKNAME(dset) ) ;
00052 
00053    outbuf = THD_zzprintf(outbuf,"Identifier Code: %s  Creation Date: %s\n" ,
00054              dset->idcode.str , dset->idcode.date ) ;
00055 
00056    if( ISANAT(dset) ){
00057       outbuf = THD_zzprintf(outbuf,"Dataset Type:    %s (-%s)\n",
00058                 ANAT_typestr[dset->func_type] , ANAT_prefixstr[dset->func_type] ) ;
00059    } else {
00060       outbuf = THD_zzprintf(outbuf,"Dataset Type:    %s (-%s)\n",
00061                 FUNC_typestr[dset->func_type] , FUNC_prefixstr[dset->func_type] ) ;
00062    }
00063 
00064    /* 25 April 1998: do byte order stuff */
00065 
00066    switch( DSET_BYTEORDER(dset) ){
00067       case LSB_FIRST:
00068          outbuf = THD_zzprintf(outbuf,"Byte Order:      %s" , LSB_FIRST_STRING) ;
00069       break ;
00070       case MSB_FIRST:
00071          outbuf = THD_zzprintf(outbuf,"Byte Order:      %s" , MSB_FIRST_STRING) ;
00072       break ;
00073    }
00074 
00075    if( THD_find_string_atr(dset->dblk,ATRNAME_BYTEORDER) == NULL ) /* 19 Sep 1999 */
00076       outbuf = THD_zzprintf(outbuf," {assumed}") ;
00077 
00078    kv = mri_short_order() ;
00079    switch( kv ){
00080       case LSB_FIRST:
00081          outbuf = THD_zzprintf(outbuf," [this CPU native = %s]\n" , LSB_FIRST_STRING) ;
00082       break ;
00083       case MSB_FIRST:
00084          outbuf = THD_zzprintf(outbuf," [this CPU native = %s]\n" , MSB_FIRST_STRING) ;
00085       break ;
00086    }
00087 
00088    /*-- 21 Jun 2002: print storage mode --*/
00089 
00090    switch( dset->dblk->diskptr->storage_mode ){
00091      default: 
00092        outbuf = THD_zzprintf(outbuf,"Storage Mode:    Undefined\n") ; break ;
00093 
00094      case STORAGE_BY_BRICK:
00095        outbuf = THD_zzprintf(outbuf,"Storage Mode:    BRIK file\n") ; break ;
00096 
00097      case STORAGE_BY_MINC:
00098        outbuf = THD_zzprintf(outbuf,"Storage Mode:    MINC file\n") ; break ;
00099 
00100      case STORAGE_BY_VOLUMES:
00101        outbuf = THD_zzprintf(outbuf,"Storage Mode:    Volume file(s)\n") ; break ;
00102 
00103      case STORAGE_BY_ANALYZE:
00104        outbuf = THD_zzprintf(outbuf,"Storage Mode:    ANALYZE files\n") ; break ;
00105 
00106      case STORAGE_BY_CTFMRI:
00107        outbuf = THD_zzprintf(outbuf,"Storage Mode:    CTF MRI file\n") ; break ;
00108 
00109      case STORAGE_BY_CTFSAM:
00110        outbuf = THD_zzprintf(outbuf,"Storage Mode:    CTF SAM file\n") ; break ;
00111 
00112      case STORAGE_BY_1D:
00113        outbuf = THD_zzprintf(outbuf,"Storage Mode:    AFNI .1D file\n") ; break ;
00114 
00115      case STORAGE_BY_3D:
00116        outbuf = THD_zzprintf(outbuf,"Storage Mode:    AFNI .3D file\n") ; break ;
00117 
00118      case STORAGE_BY_NIFTI:
00119        outbuf = THD_zzprintf(outbuf,"Storage Mode:    NIFTI file\n") ; break ;
00120 
00121      case STORAGE_BY_MPEG:
00122        outbuf = THD_zzprintf(outbuf,"Storage Mode:    MPEG file\n") ; break ;
00123    }
00124 
00125    /*-- keywords --*/
00126 
00127    if( verbose >= 0 ){
00128     cpt = DSET_KEYWORDS(dset) ;
00129     if( cpt != NULL && cpt[0] != '\0' )
00130        outbuf = THD_zzprintf(outbuf,"Keywords:        %s\n" , cpt ) ;
00131    }
00132 
00133    /*-- idcodes --*/
00134 
00135   if( verbose >= 0 ){
00136    if( ! ISZERO_IDCODE(dset->anat_parent_idcode) )
00137       outbuf = THD_zzprintf(outbuf,"Anatomy Parent:  %s [%s]\n" ,
00138                 dset->anat_parent_name , dset->anat_parent_idcode.str ) ;
00139    else if( strlen(dset->anat_parent_name) > 0 )
00140       outbuf = THD_zzprintf(outbuf,"Anatomy Parent:  %s\n" , dset->anat_parent_name ) ;
00141 
00142    if( ! ISZERO_IDCODE(dset->warp_parent_idcode) )
00143       outbuf = THD_zzprintf(outbuf,"Warp Parent:     %s [%s]\n" ,
00144                  dset->warp_parent_name , dset->warp_parent_idcode.str) ;
00145    else if( strlen(dset->warp_parent_name) > 0 )
00146       outbuf = THD_zzprintf(outbuf,"Warp Parent:     %s\n" , dset->warp_parent_name ) ;
00147   }
00148 
00149    /*-- tagset --*/
00150 
00151    if( verbose > 0 && dset->tagset != NULL && dset->tagset->num > 0 ){
00152       int ii , ns=0 ;
00153       for( ii=0 ; ii < dset->tagset->num ; ii++ )
00154          if( dset->tagset->tag[ii].set ) ns++ ;
00155 
00156       outbuf = THD_zzprintf(outbuf,"Tagset:          %d set [out of %d total]\n",
00157                             ns , dset->tagset->num ) ;
00158    }
00159 
00160    outbuf = THD_zzprintf(outbuf,
00161       "Data Axes Orientation:\n"
00162       "  first  (x) = %s\n"
00163       "  second (y) = %s\n"
00164       "  third  (z) = %s   [-orient %c%c%c]\n" ,
00165     ORIENT_typestr[daxes->xxorient] ,
00166       ORIENT_typestr[daxes->yyorient] ,
00167       ORIENT_typestr[daxes->zzorient] ,
00168     ORIENT_typestr[daxes->xxorient][0] ,
00169       ORIENT_typestr[daxes->yyorient][0] ,
00170       ORIENT_typestr[daxes->zzorient][0]  ) ;
00171 
00172    LOAD_FVEC3(fv1 , daxes->xxorg , daxes->yyorg , daxes->zzorg) ;
00173    fv1 = THD_3dmm_to_dicomm( dset , fv1 ) ;
00174 
00175    LOAD_FVEC3(fv2 , daxes->xxorg + (daxes->nxx-1)*daxes->xxdel ,
00176                     daxes->yyorg + (daxes->nyy-1)*daxes->yydel ,
00177                     daxes->zzorg + (daxes->nzz-1)*daxes->zzdel  ) ;
00178    fv2 = THD_3dmm_to_dicomm( dset , fv2 ) ;
00179 
00180    if( fv1.xyz[0] > fv2.xyz[0] ) FSWAP( fv1.xyz[0] , fv2.xyz[0] ) ;
00181    if( fv1.xyz[1] > fv2.xyz[1] ) FSWAP( fv1.xyz[1] , fv2.xyz[1] ) ;
00182    if( fv1.xyz[2] > fv2.xyz[2] ) FSWAP( fv1.xyz[2] , fv2.xyz[2] ) ;
00183 
00184    LOAD_FVEC3(fv3 , daxes->xxdel , daxes->yydel , daxes->zzdel) ;
00185    fv3 = THD_3dmm_to_dicomm( dset , fv3 ) ;
00186 
00187    XLAB(xlbot,fv1.xyz[0]) ; YLAB(ylbot,fv1.xyz[1]) ; ZLAB(zlbot,fv1.xyz[2]) ;
00188    XLAB(xltop,fv2.xyz[0]) ; YLAB(yltop,fv2.xyz[1]) ; ZLAB(zltop,fv2.xyz[2]) ;
00189 
00190    n1 = DAXES_NUM(daxes,ORI_R2L_TYPE) ;
00191    n2 = DAXES_NUM(daxes,ORI_A2P_TYPE) ;
00192    n3 = DAXES_NUM(daxes,ORI_I2S_TYPE) ;
00193 
00194    outbuf = THD_zzprintf(outbuf,
00195       "R-to-L extent: %9.3f %s -to- %9.3f %s -step- %9.3f mm [%3d voxels]\n"
00196       "A-to-P extent: %9.3f %s -to- %9.3f %s -step- %9.3f mm [%3d voxels]\n"
00197       "I-to-S extent: %9.3f %s -to- %9.3f %s -step- %9.3f mm [%3d voxels]\n" ,
00198     fv1.xyz[0],xlbot , fv2.xyz[0],xltop , fabs(fv3.xyz[0]) , n1 ,
00199     fv1.xyz[1],ylbot , fv2.xyz[1],yltop , fabs(fv3.xyz[1]) , n2 ,
00200     fv1.xyz[2],zlbot , fv2.xyz[2],zltop , fabs(fv3.xyz[2]) , n3  ) ;
00201 
00202    /*-- 01 Feb 2001: print the center of the dataset as well --*/
00203 
00204    if( verbose > 0 ){
00205     fv1.xyz[0] = 0.5*(fv1.xyz[0]+fv2.xyz[0]) ; XLAB(xlbot,fv1.xyz[0]) ;
00206     fv1.xyz[1] = 0.5*(fv1.xyz[1]+fv2.xyz[1]) ; YLAB(ylbot,fv1.xyz[1]) ;
00207     fv1.xyz[2] = 0.5*(fv1.xyz[2]+fv2.xyz[2]) ; ZLAB(zlbot,fv1.xyz[2]) ;
00208 
00209     outbuf = THD_zzprintf(outbuf,
00210                             "R-to-L center: %9.3f %s\n"
00211                             "A-to-P center: %9.3f %s\n"
00212                             "I-to-S center: %9.3f %s\n" ,
00213                           fv1.xyz[0],xlbot ,
00214                           fv1.xyz[1],ylbot ,
00215                           fv1.xyz[2],zlbot  ) ;
00216    }
00217 
00218    ntimes   = DSET_NUM_TIMES(dset) ;
00219    nval_per = DSET_NVALS_PER_TIME(dset) ;
00220    if( ntimes > 1 ){
00221       outbuf = THD_zzprintf(outbuf,
00222          "Number of time steps = %d  Number of values at each pixel = %d\n",
00223          ntimes , nval_per ) ;
00224 
00225       outbuf = THD_zzprintf(outbuf, "Time step = %.3f%s  Origin = %.3f%s" ,
00226                  dset->taxis->ttdel ,
00227                  UNITS_TYPE_LABEL(dset->taxis->units_type) ,
00228                  dset->taxis->ttorg ,
00229                  UNITS_TYPE_LABEL(dset->taxis->units_type)  ) ;
00230       if( dset->taxis->nsl > 0 )
00231         outbuf = THD_zzprintf(outbuf,"  Number time-offset slices = %d  Thickness = %.3f",
00232                   dset->taxis->nsl , fabs(dset->taxis->dz_sl) ) ;
00233       outbuf = THD_zzprintf(outbuf,"\n") ;
00234 
00235       if( verbose > 0 && dset->taxis->nsl > 0 ){
00236          outbuf = THD_zzprintf(outbuf,"Time-offsets per slice:") ;
00237          for( ival=0 ; ival < dset->taxis->nsl ; ival++ )
00238            outbuf = THD_zzprintf(outbuf, " %.3f" , dset->taxis->toff_sl[ival] ) ;
00239          outbuf = THD_zzprintf(outbuf,"\n") ;
00240       }
00241    } else {
00242       outbuf = THD_zzprintf(outbuf,
00243            "Number of values stored at each pixel = %d\n" , nval_per ) ;
00244    }
00245 
00246 #if 0
00247    if( verbose > 0 && ntimes > 1 ) nval_per = dset->dblk->nvals ;
00248    else                            nval_per = 1 ;                 /* 12 Feb 2002 */
00249 #else
00250    nval_per = dset->dblk->nvals ;
00251    if( verbose < 0 ) nval_per = 1 ;                               /* 27 Mar 2002 */
00252 #endif
00253 
00254    /* print out stuff for each sub-brick */
00255 
00256    for( ival=0 ; ival < nval_per ; ival++ ){
00257 
00258       sprintf( str ,
00259                "  -- At sub-brick #%d '%s' datum type is %s" ,
00260                ival , DSET_BRICK_LAB(dset,ival) ,
00261                MRI_TYPE_name[DSET_BRICK_TYPE(dset,ival)] ) ;
00262       nstr = strlen(str) ;
00263 
00264       tf = DSET_BRICK_FACTOR(dset,ival) ;
00265 
00266       if( ISVALID_STATISTIC(dset->stats) ){
00267 
00268          if( tf != 0.0 ){
00269             sprintf( str+nstr ,
00270                                 ":%13.6g to %13.6g [internal]\n"
00271                     "%*s[*%13.6g] %13.6g to %13.6g [scaled]\n" ,
00272                     dset->stats->bstat[ival].min/tf ,
00273                     dset->stats->bstat[ival].max/tf ,
00274                     nstr-16," " , tf ,
00275                     dset->stats->bstat[ival].min , dset->stats->bstat[ival].max ) ;
00276           } else {
00277             sprintf( str+nstr , ":%13.6g to %13.6g\n" ,
00278                     dset->stats->bstat[ival].min , dset->stats->bstat[ival].max ) ;
00279           }
00280       } else if( tf != 0.0 ){
00281          sprintf( str+nstr , " [*%g]\n",tf) ;
00282       } else {
00283          sprintf( str+nstr , "\n") ;
00284       }
00285       outbuf = THD_zzprintf(outbuf,"%s",str) ;
00286 
00287       /** 30 Nov 1997: print sub-brick stat params **/
00288 
00289       kv = DSET_BRICK_STATCODE(dset,ival) ;
00290       if( FUNC_IS_STAT(kv) ){
00291          outbuf = THD_zzprintf(outbuf,"     statcode = %s",FUNC_prefixstr[kv] ) ;
00292          npar = FUNC_need_stat_aux[kv] ;
00293          if( npar > 0 ){
00294             outbuf = THD_zzprintf(outbuf,";  statpar =") ;
00295             for( kv=0 ; kv < npar ; kv++ )
00296                outbuf = THD_zzprintf(outbuf," %g",DSET_BRICK_STATPAR(dset,ival,kv)) ;
00297          }
00298          outbuf = THD_zzprintf(outbuf,"\n") ;
00299       }
00300 
00301       cpt = DSET_BRICK_KEYWORDS(dset,ival) ;
00302       if( cpt != NULL && cpt[0] != '\0' )
00303          outbuf = THD_zzprintf(outbuf,"     keywords = %s\n",cpt) ;
00304    }
00305 
00306    /** print out dataset global statistical parameters **/
00307 
00308    if( ISFUNC(dset) && FUNC_need_stat_aux[dset->func_type] > 0 ){
00309       outbuf = THD_zzprintf(outbuf,"Auxiliary functional statistical parameters:\n %s\n",
00310              FUNC_label_stat_aux[dset->func_type] ) ;
00311       for( ival=0 ; ival < FUNC_need_stat_aux[dset->func_type] ; ival++ )
00312          outbuf = THD_zzprintf(outbuf," %g",dset->stat_aux[ival]) ;
00313       outbuf = THD_zzprintf(outbuf,"\n") ;
00314    }
00315 
00316    /** If present, print out History **/
00317 
00318    { char *chn ; int j,k ;
00319      chn = tross_Get_History(dset) ;
00320      if( chn != NULL ){
00321        j = strlen(chn) ;
00322        outbuf = THD_zzprintf(outbuf,"\n----- HISTORY -----\n") ;
00323        for( k=0 ; k < j ; k += ZMAX )
00324          outbuf = THD_zzprintf(outbuf,SZMAX,chn+k) ;
00325        free(chn) ;
00326        outbuf = THD_zzprintf(outbuf,"\n") ;
00327      }
00328    }
00329 
00330    /** If present, print out Notes **/
00331 
00332    if( verbose >= 0 ){
00333      ATR_int *notecount;
00334      ATR_string *note;
00335      int num_notes, i, j, num_char , mmm ;
00336      char note_name[20], *chn , *chd ;
00337 
00338      notecount = THD_find_int_atr(dset->dblk, "NOTES_COUNT");
00339      if( notecount != NULL ){
00340         num_notes = notecount->in[0] ;
00341         if( verbose == 0 && num_notes > 5 ) num_notes = 5 ;
00342         mmm = (verbose > 0) ? ZMAX : 400 ;
00343         for (i=1; i<= num_notes; i++) {
00344            chn = tross_Get_Note( dset , i ) ;
00345            if( chn != NULL ){
00346               j = strlen(chn) ; if( j > mmm ) chn[mmm] = '\0' ;
00347               chd = tross_Get_Notedate(dset,i) ;
00348               if( chd == NULL ){ chd = AFMALL(char,16) ; strcpy(chd,"no date") ; }
00349               outbuf = THD_zzprintf(outbuf,"\n----- NOTE %d [%s] -----\n%s\n",i,chd,chn) ;
00350               free(chn) ; free(chd) ;
00351            }
00352         }
00353      }
00354    }
00355 
00356    RETURN(outbuf) ;
00357 }

char* THD_zzprintf char *    sss,
char *    fmt,
...   
 

If present, print out Notes *

Definition at line 361 of file thd_info.c.

References AFMALL, free, malloc, and ZMAX.

Referenced by AFNI_misc_CB(), ENV_init(), huber_func(), PLUTO_commandstring(), RCREND_save_state(), REND_save_state(), and THD_dataset_info().

00362 {
00363    static char *sbuf = NULL ;
00364    char *zz ;
00365    int   nzz , nsbuf ;
00366    va_list vararg_ptr ;
00367 
00368    va_start( vararg_ptr , fmt ) ;
00369 
00370    if( sbuf == NULL ) sbuf = AFMALL(char, ZMAX+90) ;
00371 
00372    sbuf[0] = '\0' ;
00373    vsprintf( sbuf , fmt , vararg_ptr ) ;
00374    nsbuf = strlen(sbuf) ;
00375    if( nsbuf == 0 ) return sss ;
00376 
00377    if( sss == NULL ){
00378       zz = (char *) malloc( sizeof(char)*(nsbuf+2) ) ;
00379       strcpy(zz,sbuf) ;
00380    } else {
00381       nzz = strlen(sss) + nsbuf + 2 ;
00382       zz  = (char *) malloc( sizeof(char) * nzz ) ;
00383       strcpy(zz,sss) ; strcat(zz,sbuf) ;
00384       free(sss) ;
00385    }
00386    return zz ;
00387 }
 

Powered by Plone

This site conforms to the following standards: