1 /*=========================================================================
4 Module: $RCSfile: gdcmFile.h,v $
6 Date: $Date: 2006/11/15 15:54:15 $
7 Version: $Revision: 1.130 $
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.
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.
17 =========================================================================*/
22 #include "gdcmDebug.h"
23 #include "gdcmDocument.h"
24 #include "gdcmTagKey.h"
31 class JPEGFragmentsInfo;
33 //-----------------------------------------------------------------------------
34 // Dicom Part 3.3 Compliant
39 BI, // Biomagnetic Imaging
40 CF, // Cinefluorography
42 CR, // Computed Radiography
44 CT, // Computed Tomography
46 DF, // Digital Fluoroscopy
48 DM, // Digital Microscopy
49 DS, // Digital Substraction Angiography
50 DX, // Digital Radiography
51 ECG, // Echocardiography
52 EPS, // Basic Cardiac EP
54 FA, // Fluorescein Angiography
59 LS, // Laser Surface Scan
60 MA, // Magnetic Resonance Angiography
61 MR, // Magnetic Resonance
62 NM, // Nuclear Medicine
64 PT, // Positron Emission Tomography
65 RF, // Radio Fluoroscopy
66 RG, // Radiographic Imaging
67 RTDOSE, // Radiotherapy Dose
68 RTIMAGE, // Radiotherapy Image
69 RTPLAN, // Radiotherapy Plan
70 RTSTRUCT, // Radiotherapy Structure Set
71 SM, // Microscopic Imaging
72 ST, // Single-photon Emission Computed Tomography
75 VF, // Videofluorography
76 XA, // X-Ray Angiography
77 XC // Photographic Imaging
80 //-----------------------------------------------------------------------------
83 * \brief DICOM elements and their corresponding values (and
84 * additionaly the corresponding DICOM dictionary entry) of the header
87 * The typical usage of instances of class File is to classify a set of
88 * dicom files according to header information e.g. to create a file hierarchy
89 * reflecting the Patient/Study/Serie informations, or extracting a given
90 * SerieId. Accessing the content (image[s] or volume[s]) is beyond the
91 * functionality of this class and belongs to gdcm::FileHelper.
92 * \note The various entries of the explicit value representation (VR) shall
93 * be managed within a dictionary which is shared by all File
95 * \note The File::Set*Tag* family members cannot be defined as
96 * protected due to Swig limitations for as Has_a dependency between
97 * File and FileHelper.
99 class GDCM_EXPORT File : public Document
104 static File *New() {return new File();}
107 // GDCM_LEGACY(bool Load( std::string const &filename ))
109 // Standard values and informations contained in the header
112 void SetFourthDimensionLocation(uint16_t group, uint16_t elem) {
113 FourthDimensionLocation = TagKey(group, elem); }
115 // Some heuristic based accessors, end user intended
116 int GetImageNumber();
117 ModalityType GetModality();
122 int GetTSize(); // unnormalized in DICOM V3
132 float GetXCosineOnX();
133 float GetXCosineOnY();
134 float GetXCosineOnZ();
135 float GetYCosineOnX();
136 float GetYCosineOnY();
137 float GetYCosineOnZ();
139 bool GetImageOrientationPatient( float iop[6] );
140 bool GetImagePositionPatient( float ipp[3] );
143 int GetBitsAllocated();
144 int GetHighBitPosition();
145 int GetSamplesPerPixel();
146 int GetPlanarConfiguration();
148 std::string GetPixelType();
149 bool IsSignedPixelData();
151 bool IsMonochrome1();
152 bool IsPaletteColor();
158 // For rescaling graylevel:
159 float GetRescaleIntercept();
160 float GetRescaleSlope();
162 int GetNumberOfScalarComponents();
163 int GetNumberOfScalarComponentsRaw();
165 /// Accessor to \ref File::GrPixel
166 uint16_t GetGrPixel() { return GrPixel; }
167 /// Accessor to \ref File::NumPixel
168 uint16_t GetNumPixel() { return NumPixel; }
170 size_t GetPixelOffset();
171 size_t GetPixelAreaLength();
173 /// returns the RLE info
174 RLEFramesInfo *GetRLEInfo() { return RLEInfo; }
175 /// Returns the JPEG Fragments info
176 JPEGFragmentsInfo *GetJPEGInfo() { return JPEGInfo; }
178 // Anonymization process
179 void AddAnonymizeElement (uint16_t group, uint16_t elem,
180 std::string const &value);
181 /// Clears the list of elements to be anonymized
182 void ClearAnonymizeList() { UserAnonymizeList.clear(); }
183 void AnonymizeNoLoad();
184 /// Replace patient's own information by info from the Anonymization list
185 bool AnonymizeFile();
187 bool Write(std::string fileName, FileType filetype);
192 /// \brief Protect the Writer from writing illegal groups
193 bool MayIWrite(uint16_t group)
194 { if (group < 8 && group !=2 ) return false; else return true; }
196 /// Store the RLE frames info obtained during parsing of pixels.
197 RLEFramesInfo *RLEInfo;
198 /// Store the JPEG fragments info obtained during parsing of pixels.
199 JPEGFragmentsInfo *JPEGInfo;
201 /// \brief In some cases (e.g. for some ACR-NEMA images) the Entry Element
202 /// Number of the 'Pixel Element' is *not* found at 0x0010. In order to
203 /// make things easier the parser shall store the proper value in
204 /// NumPixel to provide a unique access facility.
206 /// \brief In some cases (e.g. for some ACR-NEMA images) the header entry for
207 /// the group of pixels is *not* found at 0x7fe0.
208 /// In order to make things easier the parser shall store the proper value
209 /// in GrPixel to provide a unique access facility.
211 /// \brief allows user to tell gdcm in which DataElement is stored
212 ///the -unnormalized- 4th Dimension
213 TagKey FourthDimensionLocation;
216 bool DoTheLoadingJob();
217 void ComputeRLEInfo();
218 void ComputeJPEGFragmentInfo();
219 bool ReadTag(uint16_t, uint16_t);
220 uint32_t ReadTagLength(uint16_t, uint16_t);
221 void ReadEncapsulatedBasicOffsetTable();
222 uint32_t *BasicOffsetTableItemValue;
225 } // end namespace gdcm
227 //-----------------------------------------------------------------------------