Doxygen Source Code Documentation
mayo_analyze.c File Reference
#include "mrilib.h"
#include "mayo_analyze.h"
Go to the source code of this file.
Functions | |
void | ShowHdr (char *, struct dsr *) |
void | swap_long (void *) |
void | swap_short (void *) |
int | main (int argc, char *argv[]) |
swap_hdr (struct dsr *pntr) | |
Variables | |
int | swapped |
Function Documentation
|
\** File : SUMA.c
Input paramters :
Definition at line 11 of file mayo_analyze.c. References argc, image_dimension::dim, dsr::dime, ShowHdr(), swap_hdr(), and swapped.
00012 { 00013 struct dsr hdr; 00014 int size, nn ; 00015 double cmax, cmin; 00016 FILE *fp; 00017 00018 if( argc < 2 || strcmp(argv[1],"-help") == 0 ){ 00019 printf("Usage: mayo_analyze file.hdr ...\n" 00020 "Prints out info from the Mayo Analyze 7.5 header file(s)\n" 00021 ) ; 00022 exit(0) ; 00023 } 00024 00025 for( nn=1 ; nn < argc ; nn++ ){ 00026 00027 if((fp=fopen(argv[nn],"r"))==NULL){ 00028 fprintf(stderr,"Can't open:<%s>\n", argv[1]); 00029 continue ; 00030 } 00031 fread(&hdr,1,sizeof(struct dsr),fp); 00032 00033 if(hdr.dime.dim[0] < 0 || hdr.dime.dim[0] > 15){ 00034 printf("Byte swapping header %s\n",argv[nn]) ; 00035 swap_hdr(&hdr); swapped = 1 ; 00036 } else { 00037 swapped = 0 ; 00038 } 00039 00040 ShowHdr(argv[nn], &hdr); 00041 fclose(fp) ; 00042 if( nn < argc-1 ) 00043 printf("======================================================\n") ; 00044 } 00045 exit(0) ; 00046 } |
|
Definition at line 49 of file mayo_analyze.c. References data_history::aux_file, image_dimension::bitpix, image_dimension::cal_max, image_dimension::cal_min, image_dimension::compressed, header_key::data_type, image_dimension::datatype, header_key::db_name, data_history::descrip, image_dimension::dim, dsr::dime, data_history::exp_date, data_history::exp_time, header_key::extents, data_history::field_skip, fileName, image_dimension::funused1, image_dimension::funused2, image_dimension::funused3, data_history::generated, image_dimension::glmax, image_dimension::glmin, dsr::hist, data_history::hist_un0, dsr::hk, header_key::hkey_un0, i, data_history::omax, data_history::omin, data_history::orient, data_history::originator, data_history::patient_id, image_dimension::pixdim, header_key::regular, data_history::scannum, header_key::session_error, header_key::sizeof_hdr, data_history::smax, data_history::smin, data_history::start_field, swap_short(), image_dimension::verified, data_history::views, data_history::vols_added, and image_dimension::vox_offset. Referenced by main().
00050 { 00051 int i; 00052 char string[128]; 00053 printf("Analyze Header Dump of: <%s> \n", fileName); 00054 /* Header Key */ 00055 printf("sizeof_hdr: <%d> \n", hdr->hk.sizeof_hdr); 00056 printf("data_type: <%s> \n", hdr->hk.data_type); 00057 printf("db_name: <%s> \n", hdr->hk.db_name); 00058 printf("extents: <%d> \n", hdr->hk.extents); 00059 printf("session_error: <%d> \n", hdr->hk.session_error); 00060 printf("regular: <%c> \n", hdr->hk.regular); 00061 printf("hkey_un0: <%c> \n", hdr->hk.hkey_un0); 00062 00063 /* Image Dimension */ 00064 for(i=0;i<8;i++) 00065 printf("dim[%d]: <%d> \n", i, hdr->dime.dim[i]); 00066 00067 #if 0 00068 strncpy(string,hdr->dime.vox_units,4); 00069 printf("vox_units: <%s> \n", string); 00070 #endif 00071 00072 #if 0 00073 strncpy(string,hdr->dime.cal_units,8); 00074 printf("cal_units: <%s> \n", string); 00075 printf("unused1: <%d> \n", hdr->dime.unused1); 00076 #endif 00077 printf("datatype: <%d> \n", hdr->dime.datatype); 00078 printf("bitpix: <%d> \n", hdr->dime.bitpix); 00079 00080 for(i=0;i<8;i++) 00081 printf("pixdim[%d]: <%6.4f> \n",i, hdr->dime.pixdim[i]); 00082 00083 printf("vox_offset: <%6.4f> \n", hdr->dime.vox_offset); 00084 printf("funused1: <%6.4f> \n", hdr->dime.funused1); 00085 printf("funused2: <%6.4f> \n", hdr->dime.funused2); 00086 printf("funused3: <%6.4f> \n", hdr->dime.funused3); 00087 printf("cal_max: <%6.4f> \n", hdr->dime.cal_max); 00088 printf("cal_min: <%6.4f> \n", hdr->dime.cal_min); 00089 printf("compressed: <%6.4f> \n", hdr->dime.compressed); 00090 printf("verified: <%6.4f> \n", hdr->dime.verified); 00091 printf("glmax: <%d> \n", hdr->dime.glmax); 00092 printf("glmin: <%d> \n", hdr->dime.glmin); 00093 00094 /* Data History */ 00095 strncpy(string,hdr->hist.descrip,80); 00096 printf("descrip: <%s> \n", string); 00097 strncpy(string,hdr->hist.aux_file,24); 00098 printf("aux_file: <%s> \n", string); 00099 printf("orient: <%d> \n", (int) hdr->hist.orient); 00100 00101 /* 28 Nov 2001: attempt to decode originator a la SPM */ 00102 00103 { short xyzuv[5] , xx,yy,zz ; 00104 memcpy( xyzuv , hdr->hist.originator , 10 ) ; 00105 if( xyzuv[3] == 0 && xyzuv[4] == 0 ){ 00106 xx = xyzuv[0] ; yy = xyzuv[1] ; zz = xyzuv[2] ; 00107 if( swapped ){ swap_short(&xx); swap_short(&yy); swap_short(&zz); } 00108 if( xx > 0 && xx < hdr->dime.dim[1] && 00109 yy > 0 && yy < hdr->dime.dim[2] && 00110 zz > 0 && zz < hdr->dime.dim[3] ){ 00111 00112 printf("SPM originator decodes to %d %d %d\n",xx,yy,zz) ; 00113 } 00114 } 00115 } 00116 00117 strncpy(string,hdr->hist.originator,10); 00118 printf("originator: <%s> \n", string); 00119 00120 strncpy(string,hdr->hist.generated,10); 00121 printf("generated: <%s> \n", string); 00122 00123 strncpy(string,hdr->hist.scannum,10); 00124 printf("scannum: <%s> \n", string); 00125 00126 strncpy(string,hdr->hist.patient_id,10); 00127 printf("patient_id: <%s> \n", string); 00128 00129 strncpy(string,hdr->hist.exp_date,10); 00130 printf("exp_date: <%s> \n", string); 00131 00132 strncpy(string,hdr->hist.exp_time,10); 00133 printf("exp_time: <%s> \n", string); 00134 00135 strncpy(string,hdr->hist.hist_un0,10); 00136 printf("hist_un0: <%s> \n", string); 00137 00138 printf("views: <%d> \n", hdr->hist.views); 00139 printf("vols_added: <%d> \n", hdr->hist.vols_added); 00140 printf("start_field:<%d> \n", hdr->hist.start_field); 00141 printf("field_skip: <%d> \n", hdr->hist.field_skip); 00142 printf("omax: <%d> \n", hdr->hist.omax); 00143 printf("omin: <%d> \n", hdr->hist.omin); 00144 printf("smin: <%d> \n", hdr->hist.smax); 00145 printf("smin: <%d> \n", hdr->hist.smin); 00146 00147 } |
|
|
Definition at line 187 of file mayo_analyze.c. Referenced by swap_hdr().
00188 { 00189 unsigned char *pntr = (unsigned char *) ppp ; 00190 unsigned char b0, b1, b2, b3; 00191 00192 b0 = *pntr; 00193 b1 = *(pntr+1); 00194 b2 = *(pntr+2); 00195 b3 = *(pntr+3); 00196 00197 *pntr = b3; 00198 *(pntr+1) = b2; 00199 *(pntr+2) = b1; 00200 *(pntr+3) = b0; 00201 } |
|
Definition at line 203 of file mayo_analyze.c. Referenced by ShowHdr(), and swap_hdr().
00204 { 00205 unsigned char *pntr = (unsigned char *) ppp ; 00206 unsigned char b0, b1; 00207 00208 b0 = *pntr; 00209 b1 = *(pntr+1); 00210 00211 *pntr = b1; 00212 *(pntr+1) = b0; 00213 } |
Variable Documentation
|
Definition at line 9 of file mayo_analyze.c. Referenced by main(). |