]> Creatis software - gdcm.git/blob - src/gdcmHeader.h
* Test/TestWriteSimple.cxx: fix to gdcmHeader-gdcmHeaderHelper revamping.
[gdcm.git] / src / gdcmHeader.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmHeader.h,v $
5   Language:  C++
6   Date:      $Date: 2004/06/21 08:47:14 $
7   Version:   $Revision: 1.76 $
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    guint16 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    guint16 GrPixel;
108
109 public:
110    explicit 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    int GetPixelSizeGetPixelType();
129    std::string GetPixelType();
130    size_t GetPixelOffset();
131    size_t GetPixelAreaLength();
132
133    //Some image informations needed for third package imaging library
134    int GetXSize();
135    int GetYSize();
136    int GetZSize();
137
138    float GetXSpacing();
139    float GetYSpacing();
140    float GetZSpacing();
141    //void GetSpacing(float &x, float &y, float &z);
142
143    // Useful for rescaling graylevel:
144    float GetRescaleIntercept();
145    float GetRescaleSlope();
146
147    int GetNumberOfScalarComponents();
148    int GetNumberOfScalarComponentsRaw();
149
150    // This is usefull for strategy of ordering study / series
151    // Marking them as deprecated since I believe this is achieve in the 
152    // gdcmDocument operator< 
153    //std::string GetStudyUID();
154    //std::string GetSeriesUID();
155    //std::string GetClassUID();
156    //std::string GetInstanceUID();
157
158    int GetImageNumber();
159    ModalityType GetModality();
160
161    /**
162     * change GetXImagePosition -> GetXOrigin in order not to confuse reader
163     * -# GetXOrigin can return default value (=0) if it was not ImagePosition
164     * -# Image Position is different in dicomV3 <> ACR NEMA -> better use generic
165     * name
166     */
167    float GetXOrigin();
168    float GetYOrigin();
169    float GetZOrigin();
170    //void GetOrigin(float &x, float &y, float &z);
171
172    bool   HasLUT();
173    int    GetLUTNbits();
174    unsigned char * GetLUTRGBA();
175
176    std::string GetTransfertSyntaxName();
177
178    /// Accessor to \ref gdcmHeader::GrPixel
179    guint16 GetGrPixel()  {return GrPixel;}
180    
181    /// Accessor to \ref gdcmHeader::NumPixel
182    guint16 GetNumPixel() {return NumPixel;}
183
184    /// Read (used in gdcmFile)
185    void SetImageDataSize(size_t expectedSize);
186
187 protected:
188    bool AnonymizeHeader();
189    void GetImageOrientationPatient( float* iop );
190
191 private:
192   friend class gdcmSerieHeader;
193 };
194
195 //-----------------------------------------------------------------------------
196 #endif