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