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