Doxygen Source Code Documentation
dicom_hdr.c File Reference
#include "mrilib.h"
Go to the source code of this file.
Functions | |
int | main (int argc, char **argv) |
Function Documentation
|
Definition at line 3 of file dicom_hdr.c. References argc, free, machdep(), mainENTRY, mri_dicom_header(), mri_dicom_nohex(), mri_dicom_noname(), mri_dicom_pxlarr(), mri_dicom_seterr(), mri_dicom_setvm(), mri_dicom_sexinfo(), mri_imcount_dicom(), and STATUS.
00004 { 00005 char *ppp , *sin ; int ii, iarg=1 , do_sin=0 ; 00006 00007 if( argc < 2 || strcmp(argv[1],"-help") == 0 ){ 00008 printf("Usage: dicom_hdr [options] fname [...]\n" 00009 "Prints information from the DICOM file 'fname' to stdout.\n" 00010 "\n" 00011 "OPTIONS:\n" 00012 " -hex = Include hexadecimal printout for integer values.\n" 00013 " -noname = Don't include element names in the printout.\n" 00014 " -sexinfo = Dump Siemens EXtra INFO text (0029 1020), if present\n" 00015 " (can be VERY lengthy).\n" 00016 " -v n = Dump n words of binary data also.\n" 00017 "\n" 00018 "Based on program dcm_dump_file from the RSNA, developed at\n" 00019 "the Mallinckrodt Institute of Radiology. See the source\n" 00020 "code file mri_dicom_hdr.c for their Copyright and license.\n" 00021 "\n" 00022 "SOME SAMPLE OUTPUT LINES:\n" 00023 "\n" 00024 "0028 0010 2 [1234 ] // IMG Rows// 512\n" 00025 "0028 0011 2 [1244 ] // IMG Columns// 512\n" 00026 "0028 0030 18 [1254 ] // IMG Pixel Spacing//0.488281\\0.488281\n" 00027 "0028 0100 2 [1280 ] // IMG Bits Allocated// 16\n" 00028 "0028 0101 2 [1290 ] // IMG Bits Stored// 12\n" 00029 "0028 0102 2 [1300 ] // IMG High Bit// 11\n" 00030 "\n" 00031 "* The first 2 numbers on each line are the DICOM group and element tags,\n" 00032 " in hexadecimal.\n" 00033 "* The next number is the number of data bytes, in decimal.\n" 00034 "* The next number [in brackets] is the offset in the file of the data,\n" 00035 " in decimal. This is where the data bytes start, and does not include\n" 00036 " the tag, Value Representation, etc.\n" 00037 "* If -noname is NOT given, then the string in the '// ... //' region is\n" 00038 " the standard DICOM dictionary name for this data element. If this string\n" 00039 " is blank, then this element isn't in the dictionary (e.g., is a private\n" 00040 " tag, or an addition to DICOM that I don't know about, ...).\n" 00041 "* The value after the last '//' is the value of the data in the element.\n" 00042 "* In the example above, we have a 512x512 image with 0.488281 mm pixels,\n" 00043 " with 12 bits (stored in 16 bits) per pixel.\n" 00044 "* For vastly more detail on DICOM standard, you can start with the\n" 00045 " documents at ftp://afni.nimh.nih.gov/dicom/ (1000+ pages of PDF).\n" 00046 ); 00047 exit(0); 00048 } 00049 00050 mainENTRY("dicom_hdr main") ; machdep() ; 00051 00052 mri_dicom_nohex( 1 ) ; 00053 00054 while( argv[iarg][0] == '-' ){ 00055 00056 if( strcmp(argv[iarg],"-sexinfo") == 0 ){ /* 23 Dec 2002 */ 00057 do_sin++ ; iarg++ ; continue ; 00058 } 00059 00060 if( strcmp(argv[iarg],"-hex") == 0 ){ 00061 mri_dicom_nohex(0) ; iarg++ ; continue ; 00062 } 00063 00064 if( strcmp(argv[iarg],"-noname") == 0 ){ 00065 mri_dicom_noname(1) ; iarg++ ; continue ; 00066 } 00067 00068 if( strcmp(argv[iarg],"-v") == 0 ){ 00069 int vv = strtol( argv[++iarg] , NULL , 10 ) ; 00070 if( vv > 0 ) mri_dicom_setvm( vv ) ; 00071 else fprintf(stderr,"*** Illegal value after -v!\n") ; 00072 iarg++ ; continue ; 00073 } 00074 00075 fprintf(stderr,"*** Unknown option: %s\n",argv[iarg]) ; iarg++ ; 00076 } 00077 00078 for( ii=iarg ; ii < argc ; ii++ ){ 00079 if( ii > iarg ) 00080 printf("---------------------------------------------------------------\n"); 00081 00082 mri_dicom_seterr(-1) ; /* make sure all errors are printed - 07 May 2003 */ 00083 STATUS("calling funct mri_dicom_header()") ; 00084 ppp = mri_dicom_header( argv[ii] ) ; 00085 STATUS("returned from mri_dicom_header()") ; 00086 if( ppp != NULL ){ 00087 off_t poff ; unsigned int plen ; 00088 printf("%s",ppp) ; free(ppp) ; 00089 mri_dicom_pxlarr( &poff , &plen ) ; 00090 if( plen > 0 ) 00091 printf("Pixel array offset = %u (bytes)\n" 00092 "Pixel array length = %u (bytes)\n" , 00093 (unsigned int)poff , plen ) ; 00094 if( do_sin ){ 00095 (void) mri_imcount_dicom( argv[ii] ) ; /* only to get the sexinfo */ 00096 sin = mri_dicom_sexinfo() ; 00097 if( sin ){ 00098 printf("................... Siemens Extra Info [0029 1020] ...................\n" 00099 "%s\n" , sin ) ; 00100 } else { 00101 printf("........... Siemens Extra Info [0029 1020] = NOT PRESENT .............\n"); 00102 } 00103 } 00104 } else { 00105 printf("***\n*** ERROR: can't open %s as a DICOM file!\n***\n",argv[ii]) ; 00106 } 00107 } 00108 exit(0) ; 00109 } |