1 /*=========================================================================
4 Module: $RCSfile: gdcmFile.h,v $
6 Date: $Date: 2005/07/24 00:24:46 $
7 Version: $Revision: 1.113 $
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"
38 typedef std::pair<float, float> Res;
41 class JPEGFragmentsInfo;
43 //-----------------------------------------------------------------------------
44 // Dicom Part 3.3 Compliant
49 BI, // Biomagnetic Imaging
50 CF, // Cinefluorography
52 CR, // Computed Radiography
54 CT, // Computed Tomography
56 DF, // Digital Fluoroscopy
58 DM, // Digital Microscopy
59 DS, // Digital Substraction Angiography
60 DX, // Digital Radiography
61 ECG, // Echocardiography
62 EPS, // Basic Cardiac EP
64 FA, // Fluorescein Angiography
69 LS, // Laser Surface Scan
70 MA, // Magnetic Resonance Angiography
71 MR, // Magnetic Resonance
72 NM, // Nuclear Medicine
74 PT, // Positron Emission Tomography
75 RF, // Radio Fluoroscopy
76 RG, // Radiographic Imaging
77 RTDOSE, // Radiotherapy Dose
78 RTIMAGE, // Radiotherapy Image
79 RTPLAN, // Radiotherapy Plan
80 RTSTRUCT, // Radiotherapy Structure Set
81 SM, // Microscopic Imaging
82 ST, // Single-photon Emission Computed Tomography
85 VF, // Videofluorography
86 XA, // X-Ray Angiography
87 XC // Photographic Imaging
90 //-----------------------------------------------------------------------------
93 * \brief DICOM elements and their corresponding values (and
94 * additionaly the corresponding DICOM dictionary entry) of the header
97 * The typical usage of instances of class File is to classify a set of
98 * dicom files according to header information e.g. to create a file hierarchy
99 * reflecting the Patient/Study/Serie informations, or extracting a given
100 * SerieId. Accessing the content (image[s] or volume[s]) is beyond the
101 * functionality of this class and belongs to gdcm::FileHelper.
102 * \note The various entries of the explicit value representation (VR) shall
103 * be managed within a dictionary which is shared by all File
105 * \note The File::Set*Tag* family members cannot be defined as
106 * protected due to Swig limitations for as Has_a dependency between
107 * File and FileHelper.
109 class GDCM_EXPORT File : public Document
113 GDCM_LEGACY(File( std::string const &filename ));
117 GDCM_LEGACY(bool Load( std::string const &filename ));
119 // Standard values and informations contained in the header
122 // Some heuristic based accessors, end user intended
123 int GetImageNumber();
124 ModalityType GetModality();
138 bool GetImageOrientationPatient( float iop[6] );
141 int GetBitsAllocated();
142 int GetHighBitPosition();
143 int GetSamplesPerPixel();
144 int GetPlanarConfiguration();
146 std::string GetPixelType();
147 bool IsSignedPixelData();
149 bool IsMonochrome1();
150 bool IsPaletteColor();
156 // For rescaling graylevel:
157 float GetRescaleIntercept();
158 float GetRescaleSlope();
160 int GetNumberOfScalarComponents();
161 int GetNumberOfScalarComponentsRaw();
163 /// Accessor to \ref File::GrPixel
164 uint16_t GetGrPixel() { return GrPixel; }
165 /// Accessor to \ref File::NumPixel
166 uint16_t GetNumPixel() { return NumPixel; }
168 size_t GetPixelOffset();
169 size_t GetPixelAreaLength();
171 /// returns the RLE info
172 RLEFramesInfo *GetRLEInfo() { return RLEInfo; }
173 /// Returns the JPEG Fragments info
174 JPEGFragmentsInfo *GetJPEGInfo() { return JPEGInfo; }
176 // Anonymization process
177 void AddAnonymizeElement (uint16_t group, uint16_t elem,
178 std::string const &value);
179 /// Clears the list of elements to be anonymized
180 void ClearAnonymizeList() { AnonymizeList.clear(); }
181 void AnonymizeNoLoad();
182 /// Replace patient's own information by info from the Anonymization list
183 bool AnonymizeFile();
185 bool Write(std::string fileName, FileType filetype);
187 float TypeOrientation( );
191 /// Store the RLE frames info obtained during parsing of pixels.
192 RLEFramesInfo *RLEInfo;
193 /// Store the JPEG fragments info obtained during parsing of pixels.
194 JPEGFragmentsInfo *JPEGInfo;
196 /// \brief In some cases (e.g. for some ACR-NEMA images) the Entry Element
197 /// Number of the 'Pixel Element' is *not* found at 0x0010. In order to
198 /// make things easier the parser shall store the proper value in
199 /// NumPixel to provide a unique access facility.
201 /// \brief In some cases (e.g. for some ACR-NEMA images) the header entry for
202 /// the group of pixels is *not* found at 0x7fe0.
203 /// In order to make things easier the parser shall store the proper value
204 /// in GrPixel to provide a unique access facility.
208 bool DoTheLoadingJob();
209 void ComputeRLEInfo();
210 void ComputeJPEGFragmentInfo();
211 bool ReadTag(uint16_t, uint16_t);
212 uint32_t ReadTagLength(uint16_t, uint16_t);
213 void ReadAndSkipEncapsulatedBasicOffsetTable();
215 Res VerfCriterion(int typeCriterion, float criterionNew, Res res);
216 float CalculLikelyhood2Vec(vector3D const & refA, vector3D const & refB,
217 vector3D const & ori1, vector3D const & ori2);
218 vector3D ProductVectorial(vector3D const & vec1, vector3D const & vec2);
220 } // end namespace gdcm
222 //-----------------------------------------------------------------------------