]> Creatis software - gdcm.git/blob - src/gdcmHeader.h
b6cb2c21aaca4e0eeffd75e079536ce33c4857d3
[gdcm.git] / src / gdcmHeader.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmHeader.h,v $
5   Language:  C++
6   Date:      $Date: 2004/07/17 22:45:40 $
7   Version:   $Revision: 1.81 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.htm for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18
19 #ifndef GDCMHEADER_H
20 #define GDCMHEADER_H
21
22 #include "gdcmCommon.h"
23 #include "gdcmDocument.h"
24 //-----------------------------------------------------------------------------
25 /**
26  * \brief
27  * The purpose of an instance of gdcmHeader is to act as a container of
28  * all the DICOM elements and their corresponding values (and
29  * additionaly the corresponding DICOM dictionary entry) of the header
30  * of a DICOM file.
31  *
32  * The typical usage of instances of class gdcmHeader is to classify a set of
33  * dicom files according to header information e.g. to create a file hierarchy
34  * reflecting the Patient/Study/Serie informations, or extracting a given
35  * SerieId. Accessing the content (image[s] or volume[s]) is beyond the
36  * functionality of this class and belongs to gdmcFile.
37  * \note  The various entries of the explicit value representation (VR) shall
38  *        be managed within a dictionary which is shared by all gdcmHeader
39  *        instances.
40  * \note  The gdcmHeader::Set*Tag* family members cannot be defined as
41  *        protected due to Swig limitations for as Has_a dependency between
42  *        gdcmFile and gdcmHeader.
43  */
44
45 //-----------------------------------------------------------------------------
46 // Dicom Part 3.3 Compliant
47 enum ModalityType {
48    Unknow,
49    AU,       // Voice Audio
50    AS,       // Angioscopy
51    BI,       // Biomagnetic Imaging
52    CF,       // Cinefluorography
53    CP,       // Culposcopy
54    CR,       // Computed Radiography
55    CS,       // Cystoscopy
56    CT,       // Computed Tomography
57    DD,       // Duplex Dopler
58    DF,       // Digital Fluoroscopy
59    DG,       // Diaphanography
60    DM,       // Digital Microscopy
61    DS,       // Digital Substraction Angiography
62    DX,       // Digital Radiography
63    ECG,      // Echocardiography
64    EPS,      // Basic Cardiac EP
65    ES,       // Endoscopy
66    FA,       // Fluorescein Angiography
67    FS,       // Fundoscopy
68    HC,       // Hard Copy
69    HD,       // Hemodynamic
70    LP,       // Laparoscopy
71    LS,       // Laser Surface Scan
72    MA,       // Magnetic Resonance Angiography
73    MR,       // Magnetic Resonance
74    NM,       // Nuclear Medicine
75    OT,       // Other
76    PT,       // Positron Emission Tomography
77    RF,       // Radio Fluoroscopy
78    RG,       // Radiographic Imaging
79    RTDOSE,   // Radiotherapy Dose
80    RTIMAGE,  // Radiotherapy Image
81    RTPLAN,   // Radiotherapy Plan
82    RTSTRUCT, // Radiotherapy Structure Set
83    SM,       // Microscopic Imaging
84    ST,       // Single-photon Emission Computed Tomography
85    TG,       // Thermography
86    US,       // Ultrasound
87    VF,       // Videofluorography
88    XA,       // X-Ray Angiography
89    XC        // Photographic Imaging
90 };
91 //-----------------------------------------------------------------------------
92
93 class GDCM_EXPORT gdcmHeader : public gdcmDocument
94 {
95 protected:
96    /// \brief In some cases (e.g. for some ACR-NEMA images) the Header Entry Element
97    /// Number of the 'Pixel Element' is *not* found at 0x0010. In order to
98    /// make things easier the parser shall store the proper value in
99    /// NumPixel to provide a unique access facility. See also the constructor
100    /// \ref gdcmHeader::gdcmHeader
101    uint16_t NumPixel;
102    /// \brief In some cases (e.g. for some ACR-NEMA images) the header entry for
103    /// the group of pixels is *not* found at 0x7fe0. In order to
104    /// make things easier the parser shall store the proper value in
105    /// GrPixel to provide a unique access facility. See also the constructor
106    /// \ref gdcmHeader::gdcmHeader
107    uint16_t GrPixel;
108
109 public:
110    gdcmHeader(bool exception_on_error = false);
111    gdcmHeader(std::string const & filename, 
112               bool  exception_on_error = false, 
113               bool  enable_sequences   = false,
114               bool  skip_shadow        = false);
115  
116    virtual ~gdcmHeader();
117
118    // Standard values and informations contained in the header
119    virtual bool IsReadable();
120
121    // Some heuristic based accessors, end user intended 
122    int GetBitsStored();
123    int GetBitsAllocated();
124    int GetSamplesPerPixel();
125    int GetPlanarConfiguration();
126    int GetPixelSize();
127
128    std::string GetPixelType();
129    size_t GetPixelOffset();
130    size_t GetPixelAreaLength();
131
132    //Some image informations needed for third package imaging library
133    int GetXSize();
134    int GetYSize();
135    int GetZSize();
136
137    float GetXSpacing();
138    float GetYSpacing();
139    float GetZSpacing();
140    //void GetSpacing(float &x, float &y, float &z);
141
142    // Useful for rescaling graylevel:
143    float GetRescaleIntercept();
144    float GetRescaleSlope();
145
146    int GetNumberOfScalarComponents();
147    int GetNumberOfScalarComponentsRaw();
148
149    int GetImageNumber();
150    ModalityType GetModality();
151
152    float GetXOrigin();
153    float GetYOrigin();
154    float GetZOrigin();
155    //void GetOrigin(float &x, float &y, float &z);
156
157    bool   HasLUT();
158    int    GetLUTNbits();
159    unsigned char * GetLUTRGBA();
160
161    std::string GetTransfertSyntaxName();
162
163    /// Accessor to \ref gdcmHeader::GrPixel
164    uint16_t GetGrPixel()  { return GrPixel; }
165    
166    /// Accessor to \ref gdcmHeader::NumPixel
167    uint16_t GetNumPixel() { return NumPixel; }
168
169    /// Read (used in gdcmFile)
170    void SetImageDataSize(size_t expectedSize);
171
172    void gdcmHeader::Write(FILE* fp,FileType filetype);
173  
174 protected:
175    bool AnonymizeHeader();
176    void GetImageOrientationPatient( float* iop );
177
178 private:
179   friend class gdcmSerieHeader;
180 };
181
182 //-----------------------------------------------------------------------------
183 #endif