Doxygen Source Code Documentation
3dAttribute.c File Reference
#include "mrilib.h"
Go to the source code of this file.
Functions | |
void | atr_print (ATR_any *atr) |
int | main (int argc, char *argv[]) |
Variables | |
int | do_all = 0 |
int | do_name = 0 |
Function Documentation
|
Definition at line 76 of file 3dAttribute.c. References ATR_FLOAT_TYPE, ATR_INT_TYPE, ATR_STRING_TYPE, ATR_string::ch, ATR_float::fl, free, ATR_int::in, malloc, MV_format_fval(), ATR_string::name, ATR_int::name, ATR_float::name, ATR_string::nch, ATR_float::nfl, ATR_int::nin, tross_Expand_String(), and ATR_any::type. Referenced by main().
00077 { 00078 int ii ; 00079 00080 switch( atr->type ){ 00081 00082 default: 00083 fprintf(stderr,"*** Illegal attribute type found: %d\n",atr->type); 00084 exit(1) ; 00085 00086 case ATR_FLOAT_TYPE:{ 00087 ATR_float * aa = (ATR_float *) atr ; 00088 if( do_name ) printf("%s = ",aa->name) ; 00089 for( ii=0 ; ii < aa->nfl ; ii++ ) 00090 printf("%s ",MV_format_fval(aa->fl[ii])) ; 00091 printf("\n") ; 00092 } 00093 return ; 00094 00095 case ATR_INT_TYPE:{ 00096 ATR_int * aa = (ATR_int *) atr ; 00097 if( do_name ) printf("%s = ",aa->name) ; 00098 for( ii=0 ; ii < aa->nin ; ii++ ) 00099 printf("%d ",aa->in[ii]) ; 00100 printf("\n") ; 00101 } 00102 return ; 00103 00104 case ATR_STRING_TYPE:{ 00105 ATR_string * aa = (ATR_string *) atr ; 00106 char *str = (char *)malloc(sizeof(char)*(aa->nch+1)) ; 00107 char *eee ; 00108 memcpy(str,aa->ch,aa->nch) ; str[aa->nch] = '\0' ; 00109 #if 0 00110 eee = tross_Expand_String(str) ; 00111 #else 00112 eee = NULL ; 00113 #endif 00114 if( do_name ) printf("%s = ",aa->name) ; 00115 if( eee != NULL ){ 00116 printf("%s\n",eee) ; free(eee) ; 00117 } else if( str[0] != '\0' ){ 00118 printf("%s\n",str) ; 00119 } else { 00120 printf("(null)\n") ; 00121 } 00122 free(str) ; 00123 } 00124 return ; 00125 } 00126 } |
|
compute the overall minimum and maximum voxel values for a dataset Definition at line 13 of file 3dAttribute.c. References argc, THD_datablock::atr, atr_print(), THD_3dim_dataset::dblk, do_all, do_name, ISVALID_DSET, THD_datablock::natr, THD_find_atr(), and THD_open_one_dataset().
00014 { 00015 int nopt=1 , ia ; 00016 THD_3dim_dataset * dset ; 00017 char * aname ; 00018 ATR_any * atr ; 00019 00020 if( argc < 3 || strcmp(argv[1],"-help") == 0 ){ 00021 printf("Usage: 3dAttribute [options] aname dset\n" 00022 "Prints (to stdout) the value of the attribute 'aname' from\n" 00023 "the header of dataset 'dset'. If the attribute doesn't exist,\n" 00024 "prints nothing and sets the exit status to 1.\n" 00025 "\n" 00026 "Options:\n" 00027 " -name = Include attribute name in printout\n" 00028 " -all = Print all attributes [don't put aname on command line]\n" 00029 " Also implies '-name'. Attributes print in whatever order\n" 00030 " they are in the .HEAD file, one per line. You may want\n" 00031 " to do '3dAttribute -all elvis+orig | sort' to get them\n" 00032 " in alphabetical order.\n" 00033 ) ; 00034 exit(0) ; 00035 } 00036 00037 while( nopt < argc && argv[nopt][0] == '-' ){ 00038 00039 if( strcmp(argv[nopt],"-all") == 0 ){ 00040 do_all = do_name = 1 ; 00041 nopt++ ; continue ; 00042 } 00043 00044 if( strcmp(argv[nopt],"-name") == 0 ){ 00045 do_name = 1 ; 00046 nopt++ ; continue ; 00047 } 00048 00049 fprintf(stderr,"*** Illegal option: %s\n",argv[nopt]) ; exit(1) ; 00050 } 00051 00052 if( !do_all ) aname = argv[nopt++] ; 00053 00054 dset = THD_open_one_dataset( argv[nopt] ) ; 00055 if( !ISVALID_DSET(dset) ){ 00056 fprintf(stderr,"*** Can't open dataset %s\n",argv[nopt]); exit(1); 00057 } 00058 00059 if( !do_all ){ 00060 atr = THD_find_atr( dset->dblk , aname ) ; 00061 if( atr == NULL ) exit(1) ; /* failure */ 00062 atr_print( atr ) ; 00063 exit(0) ; 00064 } 00065 00066 for( ia=0 ; ia < dset->dblk->natr ; ia++ ){ 00067 atr = &(dset->dblk->atr[ia]) ; 00068 atr_print(atr) ; 00069 } 00070 00071 exit(0) ; 00072 } |
Variable Documentation
|
Definition at line 10 of file 3dAttribute.c. Referenced by main(). |
|
Definition at line 11 of file 3dAttribute.c. Referenced by main(). |