2 //-----------------------------------------------------------------------------
6 #include "gdcmCommon.h"
7 //#include "gdcmParser.h"
8 #include "gdcmDocument.h"
9 //-----------------------------------------------------------------------------
12 * The purpose of an instance of gdcmHeader is to act as a container of
13 * all the DICOM elements and their corresponding values (and
14 * additionaly the corresponding DICOM dictionary entry) of the header
17 * The typical usage of instances of class gdcmHeader is to classify a set of
18 * dicom files according to header information e.g. to create a file hierarchy
19 * reflecting the Patient/Study/Serie informations, or extracting a given
20 * SerieId. Accessing the content (image[s] or volume[s]) is beyond the
21 * functionality of this class and belongs to gdmcFile.
22 * \note The various entries of the explicit value representation (VR) shall
23 * be managed within a dictionary which is shared by all gdcmHeader
25 * \note The gdcmHeader::Set*Tag* family members cannot be defined as
26 * protected due to Swig limitations for as Has_a dependency between
27 * gdcmFile and gdcmHeader.
29 class GDCM_EXPORT gdcmHeader : public gdcmDocument
32 /// \brief In some cases (e.g. for some ACR-NEMA images) the Header Entry Element
33 /// Number of the 'Pixel Element' is *not* found at 0x0010. In order to
34 /// make things easier the parser shall store the proper value in
35 /// NumPixel to provide a unique access facility. See also the constructor
36 /// \ref gdcmHeader::gdcmHeader
38 /// \brief In some cases (e.g. for some ACR-NEMA images) the header entry for
39 /// the group of pixels is *not* found at 0x7fe0. In order to
40 /// make things easier the parser shall store the proper value in
41 /// GrPixel to provide a unique access facility. See also the constructor
42 /// \ref gdcmHeader::gdcmHeader
46 gdcmHeader(bool exception_on_error = false);
47 gdcmHeader(const char *filename,
48 bool exception_on_error = false,
49 bool enable_sequences = false,
50 bool skip_shadow = false);
52 virtual ~gdcmHeader();
54 // Standard values and informations contained in the header
55 virtual bool IsReadable(void);
56 bool IsJPEGBaseLineProcess1TransferSyntax(void);
57 bool IsJPEGExtendedProcess2_4TransferSyntax(void);
58 bool IsJPEGExtendedProcess3_5TransferSyntax(void);
59 bool IsJPEGSpectralSelectionProcess6_8TransferSyntax(void);
60 bool IsRLELossLessTransferSyntax(void);
61 bool IsJPEGLossless(void);
62 bool IsJPEG2000(void);
65 // Some heuristic based accessors, end user intended
66 // (to be moved to gdcmHeaderHelper?)
70 int GetBitsStored(void);
71 int GetBitsAllocated(void);
72 int GetSamplesPerPixel(void);
73 int GetPlanarConfiguration(void);
75 int GetPixelSize(void);
76 std::string GetPixelType(void);
77 size_t GetPixelOffset(void);
78 size_t GetPixelAreaLength(void);
81 int GetLUTNbits(void);
82 unsigned char * GetLUTRGBA(void);
84 std::string GetTransfertSyntaxName(void);
86 // When some proprietary shadow groups are disclosed, we can set up
87 // an additional specific dictionary to access extra information.
89 // OK : we still have *ONE* HeaderEntrySet,
90 // with both Public and Shadow Elements
91 // parsed against THE Public Dictionary and A (single) Shadow Dictionary
93 // TODO Swig int SetShaDict(std::string filename);
94 // TODO Swig int SetPubDict(std::string filename);
96 /// Accessor to \ref gdcmHeader::GrPixel
97 guint16 GetGrPixel(void) {return GrPixel;}
99 /// Accessor to \ref gdcmHeader::NumPixel
100 guint16 GetNumPixel(void) {return NumPixel;}
104 // These functions are necessary for Python because
105 // there are protected in the parent class
107 inline virtual std::string GetEntryByNumber (guint16 group, guint16 element)
108 { return(gdcmDocument::GetEntryByNumber(group,element)); }
110 inline virtual std::string GetEntryVRByNumber(guint16 group, guint16 element)
111 { return(gdcmDocument::GetEntryVRByNumber(group,element)); }
113 inline virtual int GetEntryLengthByNumber(guint16 group, guint16 element)
114 { return(gdcmDocument::GetEntryLengthByNumber(group,element)); }
116 inline virtual std::string GetEntryByName (std::string tagName)
117 { return(gdcmDocument::GetEntryByName(tagName)); }
119 inline virtual std::string GetEntryVRByName (std::string tagName)
120 { return(gdcmDocument::GetEntryVRByName(tagName)); }
122 inline virtual bool SetEntryByNumber(std::string content,
123 guint16 group, guint16 element)
124 { return(gdcmDocument::SetEntryByNumber(content,group,element)); }
126 inline virtual bool SetEntryByName(std::string content,std::string tagName)
127 { return(gdcmDocument::SetEntryByName(content,tagName)); }
129 inline virtual bool SetEntryLengthByNumber(guint32 l,
130 guint16 group, guint16 element)
131 { return(gdcmDocument::SetEntryLengthByNumber(l,group,element)); }
133 inline virtual void UpdateShaEntries(void)
134 { gdcmDocument::UpdateShaEntries(); }
136 /// Read (used in gdcmFile)
137 void SetImageDataSize(size_t ExpectedSize);
139 bool operator<(gdcmHeader &header);
141 // bool WriteEntry(gdcmDocEntry *tag,FILE *_fp,FileType type);
144 //CLEANME int write(std::ostream&);
145 //CLEANME int anonymize(std::ostream&);//FIXME: anonymize should be a friend
146 bool anonymizeHeader(void);
151 //-----------------------------------------------------------------------------