Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkMRCHeaderObject.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkMRCHeaderObject.h,v $
00005   Language:  C++
00006   Date:      $Date: 2010-06-16 18:23:47 $
00007   Version:   $Revision: 1.3 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 
00018 #ifndef __itkMRCHeaderObject_h
00019 #define __itkMRCHeaderObject_h
00020 
00021 
00022 #include "itkLightObject.h"
00023 #include "itkByteSwapper.h"
00024 #include "itkIntTypes.h"
00025 
00026 namespace itk
00027 {
00028 
00030 const char * const magicMAP = "MAP ";
00031 
00032 
00045 class ITK_EXPORT MRCHeaderObject :
00046   public itk::LightObject
00047 {
00048 public:
00050   typedef MRCHeaderObject               Self;
00051   typedef LightObject                   Superclass;
00052   typedef SmartPointer<Self>            Pointer;
00053   typedef SmartPointer<const Self>      ConstPointer;
00054 
00055 
00063   struct Header
00064     {
00065 
00081     int32_t mode;
00082 
00084     int32_t nxstart;
00085     int32_t nystart;
00086     int32_t nzstart;
00087 
00088 
00090     int32_t mx;
00091     int32_t my;
00092     int32_t mz;
00093 
00095     float   xlen;
00096     float   ylen;
00097     float   zlen;
00098 
00099 
00101     float   alpha;
00102     float   beta;
00103     float   gamma;
00104 
00105 
00113     // These need to be set for proper scaling of
00114     // non byte data.
00131     // These two values specify the structure of data in the
00132     // extended header; their meaning depend on whether the
00133     // extended header has the Agard format, a series of
00134     // 4-byte integers then real numbers, or has data
00135     // produced by SerialEM, a series of short integers.
00136     // SerialEM stores a float as two shorts, s1 and s2, by:
00137     // value = (sign of s1)*(|s1|*256 + (|s2| modulo 256))
00138     // * 2**((sign of s2) * (|s2|/256))
00139 
00140     int16_t   nint;        // Number of integers per section (Agard format) or
00141                            // number of bytes per section (SerialEM format)
00142     int16_t   nreal;       // Number of reals per section (Agard format) or
00143       // flags for which types of short data (SerialEM format):
00144     // 1 = tilt angle * 100  (2 bytes)
00145     // 2 = piece coordinates for montage  (6 bytes)
00146     // 4 = Stage position * 25    (4 bytes)
00147     // 8 = Magnification / 100 (2 bytes)
00148     // 16 = Intensity * 25000  (2 bytes)
00149     // 32 = Exposure dose in e-/A2, a float in 4 bytes
00150     // 128, 512: Reserved for 4-byte items
00151     // 64, 256, 1024: Reserved for 2-byte items
00152     // If the number of bytes implied by these flags does
00153     // not add up to the value in nint, then nint and nreal
00154     // are interpreted as ints and reals per section
00155 
00157     int8_t    notused2[28];
00158 
00159     // Explanation of type of data.
00160     int16_t   idtype;      // ( 0 = mono, 1 = tilt, 2 = tilts, 3 = lina, 4 = lins)
00161     int16_t   lens;
00162     int16_t   nd1;         // for idtype = 1, nd1 = axis (1, 2, or 3)
00163     int16_t   nd2;
00164     int16_t   vd1;         // vd1 = 100. * tilt increment
00165     int16_t   vd2;         // vd2 = 100. * starting angle
00166 
00167     // Used to rotate model to match new rotated image.
00168     float   tiltangles[6];   // 0,1,2 = original:  3,4,5 = current
00169 
00170 
00171     // NEW-STYLE MRC image2000 HEADER - IMOD 2.6.20 and above:
00172     float   xorg;            // Origin of image.  Used to auto translate model
00173     float   yorg;            // to match a new image that has been translated.
00174     float   zorg;
00175 
00176 
00180     float   rms;
00181 
00182     // ALL HEADERS:
00186     };
00187 
00189   struct FeiExtendedHeader
00190     {
00191 
00215     float magnification; 
00216 
00218     };
00219 
00221   enum {MRCHEADER_MODE_UINT8 = 0,
00222         MRCHEADER_MODE_IN16 = 1,
00223         MRCHEADER_MODE_FLOAT = 2,
00224         MRCHEADER_MODE_COMPLEX_INT16 = 3,
00225         MRCHEADER_MODE_COMPLEX_FLOAT = 4,
00226         MRCHEADER_MODE_UINT16 = 6,
00227         MRCHEADER_MODE_RGB_BYTE = 16};
00228 
00230   enum {MRCHEADER_MAP_X = 1,
00231         MRCHEADER_MAP_Y = 2,
00232         MRCHEADER_MAP_Z = 3};
00233 
00234 public:
00235 
00236 
00238   itkNewMacro(Self);
00239 
00240 
00242   itkTypeMacro(MRCHeaderObject, LightObject);
00243 
00244 
00245   void DeepCopy(ConstPointer h);
00246 
00257   bool SetHeader(const Header *buffer);
00258   const Header & GetHeader() const;
00260 
00269   bool SetExtendedHeader(const void *buffer);
00270 
00271 
00275   size_t GetExtendedHeaderSize(void) const;
00276 
00278   size_t GetHeaderSize(void) const { return sizeof(Header); }
00279 
00283   bool IsOriginalHeaderBigEndian(void) const;
00284 
00286   Header                  m_Header;   // FIXME : This should be private and should have Get/Set Methods.
00287 
00288 protected:
00289 
00290   MRCHeaderObject(void);
00291   ~MRCHeaderObject(void);
00292 
00294   void swapHeader(bool bigEndian);
00295 
00297   void PrintSelf(std::ostream& os, Indent indent) const;
00298 
00299 private:
00300   MRCHeaderObject(const Self&); //purposely not implemented
00301   void operator=(const Self&); //purposely not implemented
00302 
00303   size_t                  m_ExtendedHeaderSize;
00304   void                *   m_ExtendedHeader;
00305 
00306   FeiExtendedHeader   *   m_ExtendedFeiHeader;
00307 
00308   bool                    m_BigEndianHeader;
00309 
00310 };
00311 
00312 } // namespace itk
00313 
00314 #endif
00315 

Generated at Mon Jul 12 2010 19:11:17 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000