]> Creatis software - gdcm.git/blob - src/gdcmHeader.h
cbd36527205e66477f2cdeb1823967515084d3f8
[gdcm.git] / src / gdcmHeader.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmHeader.h,v $
5   Language:  C++
6   Date:      $Date: 2004/11/25 13:12:02 $
7   Version:   $Revision: 1.94 $
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.html 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 namespace gdcm 
26 {
27 //-----------------------------------------------------------------------------
28 /**
29  * \brief
30  * The purpose of an instance of Header is to act as a container of
31  * all the DICOM elements and their corresponding values (and
32  * additionaly the corresponding DICOM dictionary entry) of the header
33  * of a DICOM file.
34  *
35  * The typical usage of instances of class Header is to classify a set of
36  * dicom files according to header information e.g. to create a file hierarchy
37  * reflecting the Patient/Study/Serie informations, or extracting a given
38  * SerieId. Accessing the content (image[s] or volume[s]) is beyond the
39  * functionality of this class and belongs to gdmcFile.
40  * \note  The various entries of the explicit value representation (VR) shall
41  *        be managed within a dictionary which is shared by all Header
42  *        instances.
43  * \note  The Header::Set*Tag* family members cannot be defined as
44  *        protected due to Swig limitations for as Has_a dependency between
45  *        File and Header.
46  */
47
48 //-----------------------------------------------------------------------------
49 // Dicom Part 3.3 Compliant
50 enum ModalityType {
51    Unknow,
52    AU,       // Voice Audio
53    AS,       // Angioscopy
54    BI,       // Biomagnetic Imaging
55    CF,       // Cinefluorography
56    CP,       // Culposcopy
57    CR,       // Computed Radiography
58    CS,       // Cystoscopy
59    CT,       // Computed Tomography
60    DD,       // Duplex Dopler
61    DF,       // Digital Fluoroscopy
62    DG,       // Diaphanography
63    DM,       // Digital Microscopy
64    DS,       // Digital Substraction Angiography
65    DX,       // Digital Radiography
66    ECG,      // Echocardiography
67    EPS,      // Basic Cardiac EP
68    ES,       // Endoscopy
69    FA,       // Fluorescein Angiography
70    FS,       // Fundoscopy
71    HC,       // Hard Copy
72    HD,       // Hemodynamic
73    LP,       // Laparoscopy
74    LS,       // Laser Surface Scan
75    MA,       // Magnetic Resonance Angiography
76    MR,       // Magnetic Resonance
77    NM,       // Nuclear Medicine
78    OT,       // Other
79    PT,       // Positron Emission Tomography
80    RF,       // Radio Fluoroscopy
81    RG,       // Radiographic Imaging
82    RTDOSE,   // Radiotherapy Dose
83    RTIMAGE,  // Radiotherapy Image
84    RTPLAN,   // Radiotherapy Plan
85    RTSTRUCT, // Radiotherapy Structure Set
86    SM,       // Microscopic Imaging
87    ST,       // Single-photon Emission Computed Tomography
88    TG,       // Thermography
89    US,       // Ultrasound
90    VF,       // Videofluorography
91    XA,       // X-Ray Angiography
92    XC        // Photographic Imaging
93 };
94 //-----------------------------------------------------------------------------
95
96 class GDCM_EXPORT Header : public Document
97 {
98 protected:
99    /// \brief In some cases (e.g. for some ACR-NEMA images) the Header Entry Element
100    /// Number of the 'Pixel Element' is *not* found at 0x0010. In order to
101    /// make things easier the parser shall store the proper value in
102    /// NumPixel to provide a unique access facility. See also the constructor
103    /// \ref Header::Header
104    uint16_t NumPixel;
105    /// \brief In some cases (e.g. for some ACR-NEMA images) the header entry for
106    /// the group of pixels is *not* found at 0x7fe0. In order to
107    /// make things easier the parser shall store the proper value in
108    /// GrPixel to provide a unique access facility. See also the constructor
109    /// \ref Header::Header
110    uint16_t GrPixel;
111
112 public:
113    Header();
114    Header( std::string const & filename );
115  
116    ~Header();
117
118    // Standard values and informations contained in the header
119    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    int GetHighBitPosition();
128    bool IsSignedPixelData();
129    bool IsMonochrome();
130    bool IsPaletteColor();
131    bool IsYBRFull();
132
133    std::string GetPixelType();
134    size_t GetPixelOffset();
135    size_t GetPixelAreaLength();
136
137    //Some image informations needed for third package imaging library
138    int GetXSize();
139    int GetYSize();
140    int GetZSize();
141
142    float GetXSpacing();
143    float GetYSpacing();
144    float GetZSpacing();
145
146    // Useful for rescaling graylevel:
147    float GetRescaleIntercept();
148    float GetRescaleSlope();
149
150    int GetNumberOfScalarComponents();
151    int GetNumberOfScalarComponentsRaw();
152
153    int GetImageNumber();
154    ModalityType GetModality();
155
156    float GetXOrigin();
157    float GetYOrigin();
158    float GetZOrigin();
159
160    bool   HasLUT();
161    int    GetLUTNbits();
162
163    /// Return the Transfer Syntax as a string
164    std::string GetTransfertSyntaxName();
165
166    /// Accessor to \ref Header::GrPixel
167    uint16_t GetGrPixel()  { return GrPixel; }
168    
169    /// Accessor to \ref Header::NumPixel
170    uint16_t GetNumPixel() { return NumPixel; }
171
172    /// Read (used in File)
173    void SetImageDataSize(size_t expectedSize);
174
175    bool Write(std::string fileName, FileType filetype);
176
177    /// Initialize DICOM header when none
178    void InitializeDefaultHeader();
179  
180 protected:
181    /// Replace patient's specific information by 'anonymous'
182    bool AnonymizeHeader();
183
184    /// Helper function needed to organize DICOM files based on 
185    /// their x,y,z position
186    void GetImageOrientationPatient( float iop[6] );
187
188 private:
189   friend class SerieHeader;
190 };
191 } // end namespace gdcm
192
193 //-----------------------------------------------------------------------------
194 #endif