Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

mitkAnalyzeImageReader.h

00001 /*=========================================================================
00002 
00003   Program:   3DMed
00004   Date:      $Date: 2014-02-25 18:30:00 +0800 $
00005   Version:   $Version: 4.6.0 $
00006   Copyright: MIPG, Institute of Automation, Chinese Academy of Sciences
00007 
00008 =========================================================================*/
00009 
00010 
00011 #ifndef __mitkAnalyzeImageReader_h
00012 #define __mitkAnalyzeImageReader_h
00013 
00014 #include "mitkVolumeReader.h"
00015 
00016 
00041 
00042 // ******************************** Definition of Analyze Header File ***************************************
00043 
00044 namespace AnalyzeImageIO
00045 {
00050 enum DataTypeKeyValues  {
00051     ANALYZE_DT_UNKNOWN      =0,  
00052     ANALYZE_DT_BINARY       =1,  
00053     ANALYZE_DT_UNSIGNED_CHAR=2,  
00054     ANALYZE_DT_SIGNED_SHORT =4,  
00055     ANALYZE_DT_SIGNED_INT   =8,  
00056     ANALYZE_DT_FLOAT        =16, 
00057     ANALYZE_DT_COMPLEX      =32, 
00058     ANALYZE_DT_DOUBLE       =64, 
00059     ANALYZE_DT_RGB          =128,
00060     ANALYZE_DT_ALL          =255,
00061     //Obsolete, using SPM, B2ANALYZE_DT_UNSIGNED_SHORT =6,  /**< Deontes that the data type is unsigned short in brains2 analyze extensions*/
00062     //Obsolete, using SPM, B2ANALYZE_DT_UNSIGNED_INT   =12, /**< Deontes that the data type is unsigned int in brains2 analyze extensions*/
00063     SPMANALYZE_DT_UNSIGNED_SHORT=132,
00064     SPMANALYZE_DT_UNSIGNED_INT  =136 
00065 };
00066 
00071 enum DataTypeIndex  {
00072     ANALYZE_DT_INDEX_UNKNOWN       =0,
00073     ANALYZE_DT_INDEX_BINARY        =1,
00074     ANALYZE_DT_INDEX_UNSIGNED_CHAR =2,
00075     ANALYZE_DT_INDEX_SIGNED_SHORT  =3,
00076     ANALYZE_DT_INDEX_SIGNED_INT    =4,
00077     ANALYZE_DT_INDEX_FLOAT         =5,
00078     ANALYZE_DT_INDEX_COMPLEX       =6,
00079     ANALYZE_DT_INDEX_DOUBLE        =7,
00080     ANALYZE_DT_INDEX_RGB           =8,
00081     ANALYZE_DT_INDEX_ALL           =9,
00082     //Obsolete, using SPM, B2ANALYZE_DT_INDEX_UNSIGNED_SHORT=10,
00083     //Obsolete, using SPM, B2ANALYZE_DT_INDEX_UNSIGNED_INT  =11,
00084     SPMANALYZE_DT_INDEX_UNSIGNED_SHORT   =10,
00085     SPMANALYZE_DT_INDEX_UNSIGNED_INT     =11
00086 };
00087 
00103 typedef enum 
00104 {
00105     ANALYZE_ORIENTATION_RPI_TRANSVERSE=0,        
00106     ANALYZE_ORIENTATION_RIP_CORONAL   =1,        
00107     ANALYZE_ORIENTATION_PIR_SAGITTAL  =2,        
00108     ANALYZE_ORIENTATION_RAI_TRANSVERSE_FLIPPED=3,
00109     ANALYZE_ORIENTATION_RSP_CORONAL_FLIPPED=4,   
00110     ANALYZE_ORIENTATION_PIL_SAGITTAL_FLIPPED=5   
00111 } /*ValidAnalyzeOrientationFlags*/;
00112 
00119 struct header_key              /*      header_key       */
00120 {/*off + size*/
00121     /*0 + 4  */int sizeof_hdr;         
00126     /*4 + 10 */char data_type[10];     
00129     /*14 + 18*/char db_name[18];       
00131     /*32 + 4 */int extents;            
00134     /*36 + 2 */short int session_error;
00136     /*38 + 1 */char regular;           
00137     /*39 + 1 */char hkey_un0;          
00138 };/* total=40  */
00139 
00148 struct image_dimension         /*      image_dimension  */
00149 {                              /* off + size*/
00150     /*0 + 16 */ short int dim[8];  
00159     /*16 + 4 */ char vox_units[4]; 
00161     /*20 + 4 */ char cal_units[8]; 
00163     /*24 + 2 */ short int unused1; 
00164     /*30 + 2 */ short int datatype;
00168     /*32 + 2 */ short int bitpix;  
00170     /*34 + 2 */ short int dim_un0; 
00171     /*36 + 32*/ float pixdim[8];   
00182     /*68 + 4 */ float vox_offset;  
00185     /*72 + 4 */ float roi_scale;   
00190     /*76 + 4 */ float funused1;    
00191     /*80 + 4 */ float funused2;    
00192     /*84 + 4 */ float cal_max;     
00196     /*88 + 4 */ float cal_min;     
00197     /*92 + 4 */ int compressed;    
00208     /*96 + 4 */ int verified;      
00209     /*100 + 4*/ int glmax;         
00219     /*104 + 4*/ int glmin;         
00220 }/*total=108 */;
00221 
00236 struct data_history   /* data_history     */
00237 {/*off + size*/
00238     /*0 + 80  */char descrip[80];   
00239     /*80 + 24 */char aux_file[24];  
00242     /*104 + 1 */char orient;        
00285     /*105 + 10*/char originator[10];
00286     /*115 + 10*/char generated[10]; 
00287     /*125 + 10*/char scannum[10];   
00288     /*135 + 10*/char patient_id[10];
00289     /*145 + 10*/char exp_date[10];  
00290     /*155 + 10*/char exp_time[10];  
00291     /*165 + 3 */char hist_un0[3];   
00292     /*168 + 4 */int views;          
00293     /*172 + 4 */int vols_added;     
00294     /*176 + 4 */int start_field;    
00295     /*180 + 4 */int field_skip;     
00296     /*184 + 4 */int omax;           
00300     /*188 + 4 */int omin;           
00301     /*192 + 4 */int smax;           
00302     /*196 + 4 */int smin;           
00303 };/* total=200 */
00304 
00319 struct dsr/*      dsr              */
00320 {/* off + size*/
00321     /*0 + 40   */ struct header_key hk;        
00322     /*40 + 108 */ struct image_dimension dime; 
00323     /*148 + 200*/ struct data_history hist;    
00324 }/*total=348*/;
00325 
00326 }
00327 // ******************************** Definition of Analyze Header File ***************************************
00328 
00329 using namespace AnalyzeImageIO;
00330 
00331 
00356 class MITK_COMMON_API mitkAnalyzeImageReader : public mitkVolumeReader
00357 {
00358 public:
00359     MITK_TYPE(mitkAnalyzeImageReader, mitkVolumeReader)
00360 
00361     virtual void PrintSelf(ostream &os);
00362 
00363     mitkAnalyzeImageReader();
00364 
00365     typedef std::streamoff SizeType;
00366 
00367     typedef enum { BigEndian, LittleEndian, OrderNotApplicable } ByteOrder;
00368 
00369     typedef enum { ASCII, Binary, TypeNotApplicable } FileType;
00370 
00371     const char * GetFileExtensions() { return ".hdr .img .img.gz"; }
00372 
00373     unsigned long long GetDataBytes();
00374 
00375 protected:
00376     virtual ~mitkAnalyzeImageReader();
00377 
00378     virtual bool Execute();
00379     bool ReadInfo();
00380     bool ReadData();
00381 
00382     bool ReadBufferAsBinary(std::istream& os, void *buffer, SizeType numberOfBytesToBeRead);
00383     ByteOrder CheckAnalyzeEndian(const struct dsr &temphdr);
00384     void SwapHeaderBytesIfNecessary( struct dsr * const imageheader );
00385     void SwapBytesIfNecessary( void* buffer, unsigned long numberOfPixels );
00386 
00387     int             m_ComponentType;
00388     unsigned int    m_NumberOfComponents;
00389     unsigned int    m_NumberOfDimensions;
00390     int             m_Dimensions[3];
00391     float           m_Spacing[3];
00392 
00393 private:
00394     mitkAnalyzeImageReader(const mitkAnalyzeImageReader&);
00395     void operator = (const mitkAnalyzeImageReader&);
00396 
00397     ByteOrder       m_ByteOrder;
00398     FileType        m_FileType;
00399 
00400     struct dsr      m_Hdr;
00401     ByteOrder       m_MachineByteOrder;
00402 };
00403 
00404 
00405 #endif
00406 

Generated on Tue Feb 25 15:00:36 2014 for MITK (Medical Imaging ToolKit) by  doxygen 1.4.3