]> Creatis software - gdcm.git/blob - src/gdcmHeader.h
c5afb10b8b484a08c1ea425d5b416b74a61dcfe3
[gdcm.git] / src / gdcmHeader.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmHeader.h,v $
5   Language:  C++
6   Date:      $Date: 2004/07/30 11:40:13 $
7   Version:   $Revision: 1.82 $
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  skip_shadow        = false);
114  
115    virtual ~gdcmHeader();
116
117    // Standard values and informations contained in the header
118    virtual 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
127    std::string GetPixelType();
128    size_t GetPixelOffset();
129    size_t GetPixelAreaLength();
130
131    //Some image informations needed for third package imaging library
132    int GetXSize();
133    int GetYSize();
134    int GetZSize();
135
136    float GetXSpacing();
137    float GetYSpacing();
138    float GetZSpacing();
139    //void GetSpacing(float &x, float &y, float &z);
140
141    // Useful for rescaling graylevel:
142    float GetRescaleIntercept();
143    float GetRescaleSlope();
144
145    int GetNumberOfScalarComponents();
146    int GetNumberOfScalarComponentsRaw();
147
148    int GetImageNumber();
149    ModalityType GetModality();
150
151    float GetXOrigin();
152    float GetYOrigin();
153    float GetZOrigin();
154    //void GetOrigin(float &x, float &y, float &z);
155
156    bool   HasLUT();
157    int    GetLUTNbits();
158    unsigned char * GetLUTRGBA();
159
160    std::string GetTransfertSyntaxName();
161
162    /// Accessor to \ref gdcmHeader::GrPixel
163    uint16_t GetGrPixel()  { return GrPixel; }
164    
165    /// Accessor to \ref gdcmHeader::NumPixel
166    uint16_t GetNumPixel() { return NumPixel; }
167
168    /// Read (used in gdcmFile)
169    void SetImageDataSize(size_t expectedSize);
170
171    void gdcmHeader::Write(FILE* fp,FileType filetype);
172  
173 protected:
174    bool AnonymizeHeader();
175    void GetImageOrientationPatient( float* iop );
176
177 private:
178   friend class gdcmSerieHeader;
179 };
180
181 //-----------------------------------------------------------------------------
182 #endif