00001 #ifndef vil_dicom_header_h_
00002 #define vil_dicom_header_h_
00003 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00004 #pragma interface
00005 #endif
00006
00007
00008
00009
00010
00011
00012 #include <vcl_ostream.h>
00013 #include <vcl_string.h>
00014 #include <vxl_config.h>
00015 #include <vil/vil_stream.h>
00016 #include <vcl_vector.h>
00017
00018
00019
00020
00021
00022
00023 enum vil_dicom_header_type
00024 {
00025 VIL_DICOM_HEADER_DTUNKNOWN=0,
00026 VIL_DICOM_HEADER_DTPART10,
00027 VIL_DICOM_HEADER_DTNON_PART10
00028 };
00029
00030
00031 enum vil_dicom_header_endian
00032 {
00033 VIL_DICOM_HEADER_DEUNKNOWN=0,
00034 VIL_DICOM_HEADER_DELITTLEENDIAN,
00035 VIL_DICOM_HEADER_DEBIGENDIAN
00036 };
00037
00038
00039 enum vil_dicom_header_image_type
00040 {
00041 VIL_DICOM_HEADER_DITUNKNOWN=0,
00042 VIL_DICOM_HEADER_DITJPEGBASE,
00043 VIL_DICOM_HEADER_DITJPEGEXTLOSSY,
00044 VIL_DICOM_HEADER_DITJPEGSPECNH,
00045 VIL_DICOM_HEADER_DITJPEGFULLNH,
00046 VIL_DICOM_HEADER_DITJPEGLOSSLNH,
00047 VIL_DICOM_HEADER_DITJPEGEXTHIER,
00048 VIL_DICOM_HEADER_DITJPEGSPECHIER,
00049 VIL_DICOM_HEADER_DITJPEGFULLHIER,
00050 VIL_DICOM_HEADER_DITJPEGLOSSLHIER,
00051 VIL_DICOM_HEADER_DITJPEGLOSSLDEF,
00052 VIL_DICOM_HEADER_DITRLE
00053 };
00054
00055
00056 const unsigned VIL_DICOM_HEADER_MAXHEADERSIZE =100;
00057
00058
00059 const vxl_uint_16 VIL_DICOM_HEADER_COMMANDGROUP =0x0000;
00060 const vxl_uint_16 VIL_DICOM_HEADER_METAFILEGROUP =0x0002;
00061 const vxl_uint_16 VIL_DICOM_HEADER_BASICDIRGROUP =0x0004;
00062 const vxl_uint_16 VIL_DICOM_HEADER_IDENTIFYINGGROUP =0x0008;
00063 const vxl_uint_16 VIL_DICOM_HEADER_PATIENTINFOGROUP =0x0010;
00064 const vxl_uint_16 VIL_DICOM_HEADER_ACQUISITIONGROUP =0x0018;
00065 const vxl_uint_16 VIL_DICOM_HEADER_RELATIONSHIPGROUP =0x0020;
00066 const vxl_uint_16 VIL_DICOM_HEADER_IMAGEGROUP =0x0028;
00067 const vxl_uint_16 VIL_DICOM_HEADER_STUDYGROUP =0x0032;
00068 const vxl_uint_16 VIL_DICOM_HEADER_VISITGROUP =0x0038;
00069 const vxl_uint_16 VIL_DICOM_HEADER_WAVEFORMGROUP =0x003a;
00070 const vxl_uint_16 VIL_DICOM_HEADER_PROCEDUREGROUP =0x0040;
00071 const vxl_uint_16 VIL_DICOM_HEADER_DEVICEGROUP =0x0050;
00072 const vxl_uint_16 VIL_DICOM_HEADER_NMIMAGEGROUP =0x0054;
00073 const vxl_uint_16 VIL_DICOM_HEADER_MEDIAGROUP =0x0088;
00074 const vxl_uint_16 VIL_DICOM_HEADER_BASICFILMSESSIONGROUP =0x2000;
00075 const vxl_uint_16 VIL_DICOM_HEADER_BASICFILMBOXGROUP =0x2010;
00076 const vxl_uint_16 VIL_DICOM_HEADER_BASICIMAGEBOXGROUP =0x2020;
00077 const vxl_uint_16 VIL_DICOM_HEADER_BASICANNOTATIONBOXGROUP =0x2030;
00078 const vxl_uint_16 VIL_DICOM_HEADER_BASICIMAGEOVERLAYBOXGROUP=0x2040;
00079 const vxl_uint_16 VIL_DICOM_HEADER_PRINTJOBGROUP =0x2100;
00080 const vxl_uint_16 VIL_DICOM_HEADER_PRINTERGROUP =0x2110;
00081 const vxl_uint_16 VIL_DICOM_HEADER_TEXTGROUP =0x4000;
00082 const vxl_uint_16 VIL_DICOM_HEADER_RESULTSGROUP =0x4008;
00083 const vxl_uint_16 VIL_DICOM_HEADER_CURVEGROUP =0x5000;
00084 const vxl_uint_16 VIL_DICOM_HEADER_OVERLAYGROUP =0x6000;
00085 const vxl_uint_16 VIL_DICOM_HEADER_PIXELGROUP =0x7fe0;
00086 const vxl_uint_16 VIL_DICOM_HEADER_PADGROUP =0xfffc;
00087 const vxl_uint_16 VIL_DICOM_HEADER_DELIMITERGROUP =0xfffe;
00088
00089
00090 const vxl_uint_16 VIL_DICOM_HEADER_MFGROUPLENGTH =0x0000;
00091 const vxl_uint_16 VIL_DICOM_HEADER_MFTRANSFERSYNTAX =0x0010;
00092
00093
00094 const vxl_uint_16 VIL_DICOM_HEADER_IDGROUPLENGTH =0x0000;
00095 const vxl_uint_16 VIL_DICOM_HEADER_IDLENGTHTOEND =0x0001;
00096 const vxl_uint_16 VIL_DICOM_HEADER_IDSPECIFICCHARACTER =0x0005;
00097 const vxl_uint_16 VIL_DICOM_HEADER_IDIMAGETYPE =0x0008;
00098 const vxl_uint_16 VIL_DICOM_HEADER_IDSOPCLASSID =0x0016;
00099 const vxl_uint_16 VIL_DICOM_HEADER_IDSOPINSTANCEID =0x0018;
00100 const vxl_uint_16 VIL_DICOM_HEADER_IDSTUDYDATE =0x0020;
00101 const vxl_uint_16 VIL_DICOM_HEADER_IDSERIESDATE =0x0021;
00102 const vxl_uint_16 VIL_DICOM_HEADER_IDACQUISITIONDATE =0x0022;
00103 const vxl_uint_16 VIL_DICOM_HEADER_IDIMAGEDATE =0x0023;
00104 const vxl_uint_16 VIL_DICOM_HEADER_IDSTUDYTIME =0x0030;
00105 const vxl_uint_16 VIL_DICOM_HEADER_IDSERIESTIME =0x0031;
00106 const vxl_uint_16 VIL_DICOM_HEADER_IDACQUISITIONTIME =0x0032;
00107 const vxl_uint_16 VIL_DICOM_HEADER_IDIMAGETIME =0x0033;
00108 const vxl_uint_16 VIL_DICOM_HEADER_IDACCESSIONNUMBER =0x0050;
00109 const vxl_uint_16 VIL_DICOM_HEADER_IDMODALITY =0x0060;
00110 const vxl_uint_16 VIL_DICOM_HEADER_IDMANUFACTURER =0x0070;
00111 const vxl_uint_16 VIL_DICOM_HEADER_IDINSTITUTIONNAME =0x0080;
00112 const vxl_uint_16 VIL_DICOM_HEADER_IDINSTITUTIONADDRESS =0x0081;
00113 const vxl_uint_16 VIL_DICOM_HEADER_IDREFERRINGPHYSICIAN =0x0090;
00114 const vxl_uint_16 VIL_DICOM_HEADER_IDSTATIONNAME =0x1010;
00115 const vxl_uint_16 VIL_DICOM_HEADER_IDSTUDYDESCRIPTION =0x1030;
00116 const vxl_uint_16 VIL_DICOM_HEADER_IDSERIESDESCRIPTION =0x103E;
00117 const vxl_uint_16 VIL_DICOM_HEADER_IDATTENDINGPHYSICIAN =0x1050;
00118 const vxl_uint_16 VIL_DICOM_HEADER_IDOPERATORNAME =0x1070;
00119 const vxl_uint_16 VIL_DICOM_HEADER_IDMANUFACTURERMODEL =0x1090;
00120
00121
00122 const vxl_uint_16 VIL_DICOM_HEADER_PIGROUPLENGTH =0x0000;
00123 const vxl_uint_16 VIL_DICOM_HEADER_PIPATIENTNAME =0x0010;
00124 const vxl_uint_16 VIL_DICOM_HEADER_PIPATIENTID =0x0020;
00125 const vxl_uint_16 VIL_DICOM_HEADER_PIPATIENTBIRTHDATE =0x0030;
00126 const vxl_uint_16 VIL_DICOM_HEADER_PIPATIENTSEX =0x0040;
00127 const vxl_uint_16 VIL_DICOM_HEADER_PIPATIENTAGE =0x1010;
00128 const vxl_uint_16 VIL_DICOM_HEADER_PIPATIENTWEIGHT =0x1030;
00129 const vxl_uint_16 VIL_DICOM_HEADER_PIPATIENTHISTORY =0x21B0;
00130
00131
00132 const vxl_uint_16 VIL_DICOM_HEADER_AQSCANNINGSEQUENCE =0x0020;
00133 const vxl_uint_16 VIL_DICOM_HEADER_AQSEQUENCEVARIANT =0x0021;
00134 const vxl_uint_16 VIL_DICOM_HEADER_AQSCANOPTIONS =0x0022;
00135 const vxl_uint_16 VIL_DICOM_HEADER_AQMRACQUISITIONTYPE =0x0023;
00136 const vxl_uint_16 VIL_DICOM_HEADER_AQSEQUENCENAME =0x0024;
00137 const vxl_uint_16 VIL_DICOM_HEADER_AQANGIOFLAG =0x0025;
00138 const vxl_uint_16 VIL_DICOM_HEADER_AQSLICETHICKNESS =0x0050;
00139 const vxl_uint_16 VIL_DICOM_HEADER_AQREPETITIONTIME =0x0080;
00140 const vxl_uint_16 VIL_DICOM_HEADER_AQECHOTIME =0x0081;
00141 const vxl_uint_16 VIL_DICOM_HEADER_AQINVERSIONTIME =0x0082;
00142 const vxl_uint_16 VIL_DICOM_HEADER_AQNUMBEROFAVERAGES =0x0083;
00143 const vxl_uint_16 VIL_DICOM_HEADER_AQECHONUMBERS =0x0086;
00144 const vxl_uint_16 VIL_DICOM_HEADER_AQMAGNETICFIELDSTRENGTH =0x0087;
00145 const vxl_uint_16 VIL_DICOM_HEADER_AQSLICESPACING =0x0088;
00146 const vxl_uint_16 VIL_DICOM_HEADER_AQECHOTRAINLENGTH =0x0091;
00147 const vxl_uint_16 VIL_DICOM_HEADER_AQPIXELBANDWIDTH =0x0095;
00148 const vxl_uint_16 VIL_DICOM_HEADER_AQSOFTWAREVERSION =0x1020;
00149 const vxl_uint_16 VIL_DICOM_HEADER_AQPROTOCOLNAME =0x1030;
00150 const vxl_uint_16 VIL_DICOM_HEADER_AQHEARTRATE =0x1088;
00151 const vxl_uint_16 VIL_DICOM_HEADER_AQCARDIACNUMBEROFIMAGES =0x1090;
00152 const vxl_uint_16 VIL_DICOM_HEADER_AQTRIGGERWINDOW =0x1094;
00153 const vxl_uint_16 VIL_DICOM_HEADER_AQRECONTRUCTIONDIAMETER =0x1100;
00154 const vxl_uint_16 VIL_DICOM_HEADER_AQRECEIVINGCOIL =0x1250;
00155 const vxl_uint_16 VIL_DICOM_HEADER_AQPHASEENCODINGDIRECTION =0x1312;
00156 const vxl_uint_16 VIL_DICOM_HEADER_AQFLIPANGLE =0x1314;
00157 const vxl_uint_16 VIL_DICOM_HEADER_AQSAR =0x1316;
00158 const vxl_uint_16 VIL_DICOM_HEADER_AQPATIENTPOSITION =0x5100;
00159
00160
00161 const vxl_uint_16 VIL_DICOM_HEADER_RSSTUDYINSTANCEUID =0x000D;
00162 const vxl_uint_16 VIL_DICOM_HEADER_RSSERIESINSTANCEUID =0x000E;
00163 const vxl_uint_16 VIL_DICOM_HEADER_RSSTUDYID =0x0010;
00164 const vxl_uint_16 VIL_DICOM_HEADER_RSSERIESNUMBER =0x0011;
00165 const vxl_uint_16 VIL_DICOM_HEADER_RSAQUISITIONNUMBER =0x0012;
00166 const vxl_uint_16 VIL_DICOM_HEADER_RSIMAGENUMBER =0x0013;
00167 const vxl_uint_16 VIL_DICOM_HEADER_RSPATIENTORIENTATION =0x0020;
00168 const vxl_uint_16 VIL_DICOM_HEADER_RSIMAGEPOSITION =0x0032;
00169 const vxl_uint_16 VIL_DICOM_HEADER_RSIMAGEORIENTATION =0x0037;
00170 const vxl_uint_16 VIL_DICOM_HEADER_RSFRAMEOFREFERENCEUID =0x0052;
00171 const vxl_uint_16 VIL_DICOM_HEADER_RSIMAGESINACQUISITION =0x1002;
00172 const vxl_uint_16 VIL_DICOM_HEADER_RSPOSITIONREFERENCE =0x1040;
00173 const vxl_uint_16 VIL_DICOM_HEADER_RSSLICELOCATION =0x1041;
00174 const vxl_uint_16 VIL_DICOM_HEADER_RSIMAGECOMMENTS =0x4000;
00175
00176
00177 const vxl_uint_16 VIL_DICOM_HEADER_IMSAMPLESPERPIXEL =0x0002;
00178 const vxl_uint_16 VIL_DICOM_HEADER_IMPHOTOMETRICINTERP =0x0004;
00179 const vxl_uint_16 VIL_DICOM_HEADER_IMROWS =0x0010;
00180 const vxl_uint_16 VIL_DICOM_HEADER_IMCOLUMNS =0x0011;
00181 const vxl_uint_16 VIL_DICOM_HEADER_IMPLANES =0x0012;
00182 const vxl_uint_16 VIL_DICOM_HEADER_IMPIXELSPACING =0x0030;
00183 const vxl_uint_16 VIL_DICOM_HEADER_IMBITSALLOCATED =0x0100;
00184 const vxl_uint_16 VIL_DICOM_HEADER_IMBITSSTORED =0x0101;
00185 const vxl_uint_16 VIL_DICOM_HEADER_IMHIGHBIT =0x0102;
00186 const vxl_uint_16 VIL_DICOM_HEADER_IMPIXELREPRESENTATION =0x0103;
00187 const vxl_uint_16 VIL_DICOM_HEADER_IMSMALLIMPIXELVALUE =0x0106;
00188 const vxl_uint_16 VIL_DICOM_HEADER_IMLARGEIMPIXELVALUE =0x0107;
00189 const vxl_uint_16 VIL_DICOM_HEADER_IMPIXELPADDINGVALUE =0x0120;
00190 const vxl_uint_16 VIL_DICOM_HEADER_IMWINDOWCENTER =0x1050;
00191 const vxl_uint_16 VIL_DICOM_HEADER_IMWINDOWWIDTH =0x1051;
00192 const vxl_uint_16 VIL_DICOM_HEADER_IMRESCALEINTERCEPT =0x1052;
00193 const vxl_uint_16 VIL_DICOM_HEADER_IMRESCALESLOPE =0x1053;
00194
00195
00196 const vxl_uint_16 VIL_DICOM_HEADER_PXGROUPLENGTH =0x0000;
00197 const vxl_uint_16 VIL_DICOM_HEADER_PXPIXELDATA =0x0010;
00198
00199
00200 const vxl_uint_16 VIL_DICOM_HEADER_DLITEM =0xe000;
00201 const vxl_uint_16 VIL_DICOM_HEADER_DLITEMDELIMITATIONITEM =0xe00d;
00202 const vxl_uint_16 VIL_DICOM_HEADER_DLSEQDELIMITATIONITEM =0xe0dd;
00203
00204
00205
00206 const char * const VIL_DICOM_HEADER_APPLICATIONENTRY ="AE";
00207 const char * const VIL_DICOM_HEADER_AGESTRING ="AS";
00208 const char * const VIL_DICOM_HEADER_ATTRIBUTETAG ="AT";
00209 const char * const VIL_DICOM_HEADER_CODESTRING ="CS";
00210 const char * const VIL_DICOM_HEADER_DATE ="DA";
00211 const char * const VIL_DICOM_HEADER_DECIMALSTRING ="DS";
00212 const char * const VIL_DICOM_HEADER_DATETIME ="DT";
00213 const char * const VIL_DICOM_HEADER_FLOATINGPOINTDOUBLE ="FD";
00214 const char * const VIL_DICOM_HEADER_FLOATINGPOINTSINGLE ="FL";
00215 const char * const VIL_DICOM_HEADER_INTEGERSTRING ="IS";
00216 const char * const VIL_DICOM_HEADER_LONGSTRING ="LO";
00217 const char * const VIL_DICOM_HEADER_LONGTEXT ="LT";
00218 const char * const VIL_DICOM_HEADER_OTHERBYTE ="OB";
00219 const char * const VIL_DICOM_HEADER_OTHERWORD ="OW";
00220 const char * const VIL_DICOM_HEADER_PERSONNAME ="PN";
00221 const char * const VIL_DICOM_HEADER_SHORTSTRING ="SH";
00222 const char * const VIL_DICOM_HEADER_SIGNEDLONG ="SL";
00223 const char * const VIL_DICOM_HEADER_SEQUENCE ="SQ";
00224 const char * const VIL_DICOM_HEADER_SIGNEDSHORT ="SS";
00225 const char * const VIL_DICOM_HEADER_SHORTTEXT ="ST";
00226 const char * const VIL_DICOM_HEADER_TIME ="TM";
00227 const char * const VIL_DICOM_HEADER_UNIQUEIDENTIFIER ="UI";
00228 const char * const VIL_DICOM_HEADER_UNSIGNEDLONG ="UL";
00229 const char * const VIL_DICOM_HEADER_UNKNOWN ="UN";
00230 const char * const VIL_DICOM_HEADER_UNSIGNEDSHORT ="US";
00231 const char * const VIL_DICOM_HEADER_UNLIMITEDTEXT ="UT";
00232
00233
00234 enum vil_dicom_header_vr_type
00235 {
00236 vil_dicom_header_AE,
00237 vil_dicom_header_AS,
00238 vil_dicom_header_AT,
00239 vil_dicom_header_CS,
00240 vil_dicom_header_DA,
00241 vil_dicom_header_DS,
00242 vil_dicom_header_DT,
00243 vil_dicom_header_FD,
00244 vil_dicom_header_FL,
00245 vil_dicom_header_IS,
00246 vil_dicom_header_LO,
00247 vil_dicom_header_LT,
00248 vil_dicom_header_OB,
00249 vil_dicom_header_OW,
00250 vil_dicom_header_PN,
00251 vil_dicom_header_SH,
00252 vil_dicom_header_SL,
00253 vil_dicom_header_SQ,
00254 vil_dicom_header_SS,
00255 vil_dicom_header_ST,
00256 vil_dicom_header_TM,
00257 vil_dicom_header_UI,
00258 vil_dicom_header_UL,
00259 vil_dicom_header_UN,
00260 vil_dicom_header_US,
00261 vil_dicom_header_UT
00262 };
00263
00264
00265 template <int T >
00266 struct vil_dicom_header_type_of
00267 {
00268 typedef vcl_string type;
00269 };
00270
00271 #define vr_macro( VR, CPPT ) \
00272 VCL_DEFINE_SPECIALIZATION struct vil_dicom_header_type_of<VR> { typedef CPPT type; }
00273
00274 vr_macro( vil_dicom_header_AE, vcl_string );
00275 vr_macro( vil_dicom_header_AS, vcl_string );
00276 vr_macro( vil_dicom_header_AT, vcl_string );
00277 vr_macro( vil_dicom_header_CS, vcl_string );
00278 vr_macro( vil_dicom_header_DA, long );
00279 vr_macro( vil_dicom_header_DS, float );
00280 vr_macro( vil_dicom_header_FD, double );
00281 vr_macro( vil_dicom_header_FL, float );
00282 vr_macro( vil_dicom_header_IS, long );
00283 vr_macro( vil_dicom_header_LO, vcl_string );
00284 vr_macro( vil_dicom_header_LT, vcl_string );
00285 vr_macro( vil_dicom_header_OB, vcl_string );
00286 vr_macro( vil_dicom_header_OW, vcl_string );
00287 vr_macro( vil_dicom_header_PN, vcl_string );
00288 vr_macro( vil_dicom_header_SH, vcl_string );
00289 vr_macro( vil_dicom_header_SL, vxl_sint_32 );
00290 vr_macro( vil_dicom_header_SQ, vcl_string );
00291 vr_macro( vil_dicom_header_SS, vxl_sint_16 );
00292 vr_macro( vil_dicom_header_ST, vcl_string );
00293 vr_macro( vil_dicom_header_TM, float );
00294 vr_macro( vil_dicom_header_UI, vcl_string );
00295 vr_macro( vil_dicom_header_UL, vxl_uint_32 );
00296 vr_macro( vil_dicom_header_UN, vcl_string );
00297 vr_macro( vil_dicom_header_US, vxl_uint_16 );
00298 vr_macro( vil_dicom_header_UT, vcl_string );
00299 #undef vr_macro
00300
00301
00302 const vxl_uint_32 VIL_DICOM_HEADER_ALLSET = 0xffffffff;
00303
00304
00305 const char * const VIL_DICOM_HEADER_IMPLICITLITTLE ="1.2.840.10008.1.2";
00306 const char * const VIL_DICOM_HEADER_EXPLICITLITTLE ="1.2.840.10008.1.2.1";
00307 const char * const VIL_DICOM_HEADER_EXPLICITBIG ="1.2.840.10008.1.2.2";
00308 const char * const VIL_DICOM_HEADER_JPEGBASELINE_P1 ="1.2.840.10008.1.2.4.50";
00309 const char * const VIL_DICOM_HEADER_JPEGDEFLOSSY_P2_4 ="1.2.840.10008.1.2.4.51";
00310 const char * const VIL_DICOM_HEADER_JPEGEXTENDED_P3_5 ="1.2.840.10008.1.2.4.52";
00311 const char * const VIL_DICOM_HEADER_JPEGSPECTRAL_P6_8 ="1.2.840.10008.1.2.4.53";
00312 const char * const VIL_DICOM_HEADER_JPEGSPECTRAL_P7_9 ="1.2.840.10008.1.2.4.54";
00313 const char * const VIL_DICOM_HEADER_JPEGFULLPROG_P10_12 ="1.2.840.10008.1.2.4.55";
00314 const char * const VIL_DICOM_HEADER_JPEGFULLPROG_P11_13 ="1.2.840.10008.1.2.4.56";
00315 const char * const VIL_DICOM_HEADER_JPEGLOSSLESS_P14 ="1.2.840.10008.1.2.4.57";
00316 const char * const VIL_DICOM_HEADER_JPEGLOSSLESS_P15 ="1.2.840.10008.1.2.4.58";
00317 const char * const VIL_DICOM_HEADER_JPEGEXTHIER_P16_18 ="1.2.840.10008.1.2.4.59";
00318 const char * const VIL_DICOM_HEADER_JPEGEXTHIER_P17_19 ="1.2.840.10008.1.2.4.60";
00319 const char * const VIL_DICOM_HEADER_JPEGSPECHIER_P20_22 ="1.2.840.10008.1.2.4.61";
00320 const char * const VIL_DICOM_HEADER_JPEGSPECHIER_P21_23 ="1.2.840.10008.1.2.4.62";
00321 const char * const VIL_DICOM_HEADER_JPEGFULLHIER_P24_26 ="1.2.840.10008.1.2.4.63";
00322 const char * const VIL_DICOM_HEADER_JPEGFULLHIER_P25_27 ="1.2.840.10008.1.2.4.64";
00323 const char * const VIL_DICOM_HEADER_JPEGLLESSHIER_P28 ="1.2.840.10008.1.2.4.65";
00324 const char * const VIL_DICOM_HEADER_JPEGLLESSHIER_P29 ="1.2.840.10008.1.2.4.66";
00325 const char * const VIL_DICOM_HEADER_JPEGLLESSDEF_P14_SV1 ="1.2.840.10008.1.2.4.70";
00326 const char * const VIL_DICOM_HEADER_RLELOSSLESS ="1.2.840.10008.1.2.5";
00327
00328
00329
00330
00331
00332
00333
00334 struct vil_dicom_header_info
00335 {
00336
00337 bool header_valid_;
00338 vil_dicom_header_type file_type_;
00339 vil_dicom_header_endian sys_endian_;
00340 vil_dicom_header_endian file_endian_;
00341 vil_dicom_header_image_type image_type_;
00342
00343
00344 vil_dicom_header_type_of<vil_dicom_header_CS>::type image_id_type_;
00345 vil_dicom_header_type_of<vil_dicom_header_UI>::type sop_cl_uid_;
00346 vil_dicom_header_type_of<vil_dicom_header_UI>::type sop_in_uid_;
00347 vil_dicom_header_type_of<vil_dicom_header_DA>::type study_date_;
00348 vil_dicom_header_type_of<vil_dicom_header_DA>::type series_date_;
00349 vil_dicom_header_type_of<vil_dicom_header_DA>::type acquisition_date_;
00350 vil_dicom_header_type_of<vil_dicom_header_DA>::type image_date_;
00351 vil_dicom_header_type_of<vil_dicom_header_TM>::type study_time_;
00352 vil_dicom_header_type_of<vil_dicom_header_TM>::type series_time_;
00353 vil_dicom_header_type_of<vil_dicom_header_TM>::type acquisition_time_;
00354 vil_dicom_header_type_of<vil_dicom_header_TM>::type image_time_;
00355 vil_dicom_header_type_of<vil_dicom_header_SH>::type accession_number_;
00356 vil_dicom_header_type_of<vil_dicom_header_CS>::type modality_;
00357 vil_dicom_header_type_of<vil_dicom_header_LO>::type manufacturer_;
00358 vil_dicom_header_type_of<vil_dicom_header_LO>::type institution_name_;
00359 vil_dicom_header_type_of<vil_dicom_header_ST>::type institution_addr_;
00360 vil_dicom_header_type_of<vil_dicom_header_PN>::type ref_phys_name_;
00361 vil_dicom_header_type_of<vil_dicom_header_SH>::type station_name_;
00362 vil_dicom_header_type_of<vil_dicom_header_LO>::type study_desc_;
00363 vil_dicom_header_type_of<vil_dicom_header_LO>::type series_desc_;
00364 vil_dicom_header_type_of<vil_dicom_header_PN>::type att_phys_name_;
00365 vil_dicom_header_type_of<vil_dicom_header_PN>::type operator_name_;
00366 vil_dicom_header_type_of<vil_dicom_header_LO>::type model_name_;
00367
00368
00369 vil_dicom_header_type_of<vil_dicom_header_PN>::type patient_name_;
00370 vil_dicom_header_type_of<vil_dicom_header_LO>::type patient_id_;
00371 vil_dicom_header_type_of<vil_dicom_header_DA>::type patient_dob_;
00372 vil_dicom_header_type_of<vil_dicom_header_CS>::type patient_sex_;
00373 vil_dicom_header_type_of<vil_dicom_header_AS>::type patient_age_;
00374 vil_dicom_header_type_of<vil_dicom_header_DS>::type patient_weight_;
00375 vil_dicom_header_type_of<vil_dicom_header_LT>::type patient_hist_;
00376
00377
00378 vil_dicom_header_type_of<vil_dicom_header_CS>::type scanning_seq_;
00379 vil_dicom_header_type_of<vil_dicom_header_CS>::type sequence_var_;
00380 vil_dicom_header_type_of<vil_dicom_header_CS>::type scan_options_;
00381 vil_dicom_header_type_of<vil_dicom_header_CS>::type mr_acq_type_;
00382 vil_dicom_header_type_of<vil_dicom_header_SH>::type sequence_name_;
00383 vil_dicom_header_type_of<vil_dicom_header_CS>::type angio_flag_;
00384 vil_dicom_header_type_of<vil_dicom_header_DS>::type slice_thickness_;
00385 vil_dicom_header_type_of<vil_dicom_header_DS>::type repetition_time_;
00386 vil_dicom_header_type_of<vil_dicom_header_DS>::type echo_time_;
00387 vil_dicom_header_type_of<vil_dicom_header_DS>::type inversion_time_;
00388 vil_dicom_header_type_of<vil_dicom_header_DS>::type number_of_averages_;
00389 vil_dicom_header_type_of<vil_dicom_header_IS>::type echo_numbers_;
00390 vil_dicom_header_type_of<vil_dicom_header_DS>::type mag_field_strength_;
00391 vil_dicom_header_type_of<vil_dicom_header_IS>::type echo_train_length_;
00392 vil_dicom_header_type_of<vil_dicom_header_DS>::type pixel_bandwidth_;
00393 vil_dicom_header_type_of<vil_dicom_header_LO>::type software_vers_;
00394 vil_dicom_header_type_of<vil_dicom_header_LO>::type protocol_name_;
00395 vil_dicom_header_type_of<vil_dicom_header_IS>::type heart_rate_;
00396 vil_dicom_header_type_of<vil_dicom_header_IS>::type card_num_images_;
00397 vil_dicom_header_type_of<vil_dicom_header_IS>::type trigger_window_;
00398 vil_dicom_header_type_of<vil_dicom_header_DS>::type reconst_diameter_;
00399 vil_dicom_header_type_of<vil_dicom_header_SH>::type receiving_coil_;
00400 vil_dicom_header_type_of<vil_dicom_header_CS>::type phase_enc_dir_;
00401 vil_dicom_header_type_of<vil_dicom_header_DS>::type flip_angle_;
00402 vil_dicom_header_type_of<vil_dicom_header_DS>::type sar_;
00403 vil_dicom_header_type_of<vil_dicom_header_CS>::type patient_pos_;
00404
00405
00406 vil_dicom_header_type_of<vil_dicom_header_UI>::type stud_ins_uid_;
00407 vil_dicom_header_type_of<vil_dicom_header_UI>::type ser_ins_uid_;
00408 vil_dicom_header_type_of<vil_dicom_header_SH>::type study_id_;
00409 vil_dicom_header_type_of<vil_dicom_header_IS>::type series_number_;
00410 vil_dicom_header_type_of<vil_dicom_header_IS>::type acquisition_number_;
00411 vil_dicom_header_type_of<vil_dicom_header_IS>::type image_number_;
00412 vil_dicom_header_type_of<vil_dicom_header_CS>::type pat_orient_;
00413 vcl_vector<vil_dicom_header_type_of<vil_dicom_header_DS>::type> image_pos_;
00414 vcl_vector<vil_dicom_header_type_of<vil_dicom_header_DS>::type> image_orient_;
00415 vil_dicom_header_type_of<vil_dicom_header_UI>::type frame_of_ref_;
00416 vil_dicom_header_type_of<vil_dicom_header_IS>::type images_in_acq_;
00417 vil_dicom_header_type_of<vil_dicom_header_LO>::type pos_ref_ind_;
00418 vil_dicom_header_type_of<vil_dicom_header_DS>::type slice_location_;
00419 vil_dicom_header_type_of<vil_dicom_header_LT>::type image_comments_;
00420
00421
00422 vil_dicom_header_type_of<vil_dicom_header_US>::type pix_samps_;
00423 vil_dicom_header_type_of<vil_dicom_header_CS>::type photo_interp_;
00424 vil_dicom_header_type_of<vil_dicom_header_US>::type size_x_;
00425 vil_dicom_header_type_of<vil_dicom_header_US>::type size_y_;
00426 vil_dicom_header_type_of<vil_dicom_header_US>::type size_z_;
00427 vil_dicom_header_type_of<vil_dicom_header_US>::type high_bit_;
00428 vil_dicom_header_type_of<vil_dicom_header_US>::type small_im_pix_val_;
00429 vil_dicom_header_type_of<vil_dicom_header_US>::type large_im_pix_val_;
00430 vil_dicom_header_type_of<vil_dicom_header_US>::type pixel_padding_val_;
00431 vil_dicom_header_type_of<vil_dicom_header_DS>::type window_centre_;
00432 vil_dicom_header_type_of<vil_dicom_header_DS>::type window_width_;
00433
00434
00435 vil_dicom_header_type_of<vil_dicom_header_DS>::type spacing_x_;
00436 vil_dicom_header_type_of<vil_dicom_header_DS>::type spacing_y_;
00437 vil_dicom_header_type_of<vil_dicom_header_DS>::type spacing_slice_;
00438 vil_dicom_header_type_of<vil_dicom_header_DS>::type res_intercept_;
00439 vil_dicom_header_type_of<vil_dicom_header_DS>::type res_slope_;
00440 vil_dicom_header_type_of<vil_dicom_header_US>::type pix_rep_;
00441 vil_dicom_header_type_of<vil_dicom_header_US>::type stored_bits_;
00442 vil_dicom_header_type_of<vil_dicom_header_US>::type allocated_bits_;
00443 };
00444
00445
00446
00447
00448 void vil_dicom_header_info_clear( vil_dicom_header_info& info );
00449
00450
00451 const short VIL_DICOM_HEADER_UNSPECIFIED = -1;
00452 const unsigned short VIL_DICOM_HEADER_UNSPECIFIED_UNSIGNED = (unsigned short) -1;
00453 const double VIL_DICOM_HEADER_DEFAULTSIZE = 1.0;
00454 const float VIL_DICOM_HEADER_DEFAULTSIZE_FLOAT = 1.0f;
00455 const float VIL_DICOM_HEADER_DEFAULTINTERCEPT = 0.0f;
00456 const float VIL_DICOM_HEADER_DEFAULTSLOPE = 1.0f;
00457
00458
00459
00460
00461
00462
00463 class vil_dicom_header_format
00464 {
00465 public:
00466
00467 vil_dicom_header_format();
00468 ~vil_dicom_header_format();
00469
00470
00471 bool isDicomFormat(vil_stream &);
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481 vil_dicom_header_info readHeader(vil_stream &fs);
00482
00483
00484
00485
00486
00487
00488 vil_dicom_header_info lastHeader(void);
00489
00490
00491
00492
00493 bool headerValid(void);
00494
00495
00496
00497
00498 vil_dicom_header_endian systemEndian(void);
00499
00500
00501
00502
00503
00504
00505 vil_dicom_header_endian fileEndian(void);
00506
00507
00508
00509
00510 vil_dicom_header_image_type imageType(void);
00511
00512 private:
00513
00514
00515
00516
00517
00518 vil_dicom_header_type determineFileType(vil_stream &fs);
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529 void readHeaderElements(vil_stream &fs);
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543 void readIdentifyingElements(short element, int dblock_size,
00544 vil_stream &fs);
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557 void readPatientElements(short element, int dblock_size,
00558 vil_stream &fs);
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572 void readAcquisitionElements(short element, int dblock_size,
00573 vil_stream &fs);
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588 void readRelationshipElements(short element, int dblock_size,
00589 vil_stream &fs);
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603 void readImageElements(short element, int dblock_size,
00604 vil_stream &fs);
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618 void readDelimiterElements(short element, int dblock_size,
00619 vil_stream &fs);
00620
00621
00622
00623
00624
00625
00626
00627 bool convertValueRepresentation(unsigned int &dblock_size,
00628 vil_stream &ifs);
00629
00630
00631
00632
00633
00634
00635
00636 bool pixelDataFound(short group, short element);
00637
00638
00639
00640
00641 void clearInfo(void);
00642
00643
00644
00645
00646
00647 vil_dicom_header_endian calculateEndian(void);
00648
00649
00650
00651
00652
00653 vil_dicom_header_endian determineMetaInfo(vil_stream &fs);
00654
00655
00656
00657
00658
00659
00660 vxl_uint_16 shortSwap(vxl_uint_16 short_in);
00661
00662
00663
00664
00665
00666
00667 vxl_uint_32 intSwap(vxl_uint_32 int_in);
00668
00669
00670
00671
00672
00673 void charSwap(char *char_in, int val_size);
00674
00675 private:
00676
00677
00678
00679
00680
00681 vil_dicom_header_info last_read_;
00682
00683
00684
00685
00686 bool info_valid_;
00687
00688
00689
00690
00691 vil_dicom_header_endian endian_;
00692
00693
00694
00695
00696 vil_dicom_header_endian file_endian_;
00697
00698
00699
00700
00701 vil_dicom_header_image_type image_type_;
00702 };
00703
00704 void vil_dicom_header_print(vcl_ostream &os, const vil_dicom_header_info &s);
00705
00706 #endif // vil_dicom_header_h_