]> Creatis software - gdcm.git/blob - src/gdcmHeader.h
5d8037ba2d45d224ca0e90bf0add81797fbea56e
[gdcm.git] / src / gdcmHeader.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmHeader.h,v $
5   Language:  C++
6   Date:      $Date: 2005/01/11 15:15:38 $
7   Version:   $Revision: 1.99 $
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 // Dicom Part 3.3 Compliant
29 enum ModalityType {
30    Unknow,
31    AU,       // Voice Audio
32    AS,       // Angioscopy
33    BI,       // Biomagnetic Imaging
34    CF,       // Cinefluorography
35    CP,       // Culposcopy
36    CR,       // Computed Radiography
37    CS,       // Cystoscopy
38    CT,       // Computed Tomography
39    DD,       // Duplex Dopler
40    DF,       // Digital Fluoroscopy
41    DG,       // Diaphanography
42    DM,       // Digital Microscopy
43    DS,       // Digital Substraction Angiography
44    DX,       // Digital Radiography
45    ECG,      // Echocardiography
46    EPS,      // Basic Cardiac EP
47    ES,       // Endoscopy
48    FA,       // Fluorescein Angiography
49    FS,       // Fundoscopy
50    HC,       // Hard Copy
51    HD,       // Hemodynamic
52    LP,       // Laparoscopy
53    LS,       // Laser Surface Scan
54    MA,       // Magnetic Resonance Angiography
55    MR,       // Magnetic Resonance
56    NM,       // Nuclear Medicine
57    OT,       // Other
58    PT,       // Positron Emission Tomography
59    RF,       // Radio Fluoroscopy
60    RG,       // Radiographic Imaging
61    RTDOSE,   // Radiotherapy Dose
62    RTIMAGE,  // Radiotherapy Image
63    RTPLAN,   // Radiotherapy Plan
64    RTSTRUCT, // Radiotherapy Structure Set
65    SM,       // Microscopic Imaging
66    ST,       // Single-photon Emission Computed Tomography
67    TG,       // Thermography
68    US,       // Ultrasound
69    VF,       // Videofluorography
70    XA,       // X-Ray Angiography
71    XC        // Photographic Imaging
72 };
73
74 //-----------------------------------------------------------------------------
75 /**
76  * \brief DICOM elements and their corresponding values (and
77  * additionaly the corresponding DICOM dictionary entry) of the header
78  * of a DICOM file.
79  *
80  * The typical usage of instances of class Header is to classify a set of
81  * dicom files according to header information e.g. to create a file hierarchy
82  * reflecting the Patient/Study/Serie informations, or extracting a given
83  * SerieId. Accessing the content (image[s] or volume[s]) is beyond the
84  * functionality of this class and belongs to gdmcFile.
85  * \note  The various entries of the explicit value representation (VR) shall
86  *        be managed within a dictionary which is shared by all Header
87  *        instances.
88  * \note  The Header::Set*Tag* family members cannot be defined as
89  *        protected due to Swig limitations for as Has_a dependency between
90  *        File and Header.
91  */
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 GetTransferSyntaxName();
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