2 //-----------------------------------------------------------------------------
6 #include "gdcmCommon.h"
7 #include "gdcmParser.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 gdcmParser
32 /// 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 /// 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
44 /// Some DICOM files may contain several images (e.g. a icon, followd by
45 /// the image itself. Hence the tag (GrPixel,NumPixel) might appear
46 /// several times. countGrPixel is the number of occurences of the
47 /// tag of pixels (i.e. (GrPixel,NumPixel)) contained in the header.
48 /// TODO : will be dealt with SQ tree-like stucture
51 gdcmHeader(bool exception_on_error = false);
52 gdcmHeader(const char *filename,
53 bool exception_on_error = false,
54 bool enable_sequences = false,
55 bool skip_shadow = false);
57 virtual ~gdcmHeader();
59 // Standard values and informations contained in the header
60 virtual bool IsReadable(void);
61 bool IsJPEGBaseLineProcess1TransferSyntax(void);
62 bool IsJPEGExtendedProcess2_4TransferSyntax(void);
63 bool IsJPEGExtendedProcess3_5TransferSyntax(void);
64 bool IsJPEGSpectralSelectionProcess6_8TransferSyntax(void);
65 bool IsRLELossLessTransferSyntax(void);
66 bool IsJPEGLossless(void);
67 bool IsJPEG2000(void);
70 // Some heuristic based accessors, end user intended
71 // (to be moved to gdcmHeaderHelper?)
75 int GetBitsStored(void);
76 int GetBitsAllocated(void);
77 int GetSamplesPerPixel(void);
78 int GetPlanarConfiguration(void);
80 int GetPixelSize(void);
81 std::string GetPixelType(void);
82 size_t GetPixelOffset(void);
83 size_t GetPixelAreaLength(void);
86 int GetLUTNbits(void);
87 unsigned char * GetLUTRGBA(void);
89 std::string GetTransfertSyntaxName(void);
91 // When some proprietary shadow groups are disclosed, we can set up
92 // an additional specific dictionary to access extra information.
94 // OK : we still have *ONE* HeaderEntrySet,
95 // with both Public and Shadow Elements
96 // parsed against THE Public Dictionary and A (single) Shadow Dictionary
98 // TODO Swig int SetShaDict(std::string filename);
99 // TODO Swig int SetPubDict(std::string filename);
101 /// Accessor to \ref gdcmHeader::GrPixel
102 guint16 GetGrPixel(void) {return GrPixel;}
104 /// Accessor to \ref gdcmHeader::NumPixel
105 guint16 GetNumPixel(void) {return NumPixel;}
109 inline virtual std::string GetEntryByNumber (guint16 group, guint16 element)
110 { return(gdcmParser::GetEntryByNumber(group,element)); }
112 inline virtual std::string GetEntryVRByNumber(guint16 group, guint16 element)
113 { return(gdcmParser::GetEntryVRByNumber(group,element)); }
115 inline virtual int GetEntryLengthByNumber(guint16 group, guint16 element)
116 { return(gdcmParser::GetEntryLengthByNumber(group,element)); }
118 inline virtual std::string GetEntryByName (std::string tagName)
119 { return(gdcmParser::GetEntryByName(tagName)); }
121 inline virtual std::string GetEntryVRByName (std::string tagName)
122 { return(gdcmParser::GetEntryVRByName(tagName)); }
124 inline virtual bool SetEntryByNumber(std::string content,
125 guint16 group, guint16 element)
126 { return(gdcmParser::SetEntryByNumber(content,group,element)); }
128 inline virtual bool SetEntryByName(std::string content,std::string tagName)
129 { return(gdcmParser::SetEntryByName(content,tagName)); }
131 inline virtual bool SetEntryLengthByNumber(guint32 l,
132 guint16 group, guint16 element)
133 { return(gdcmParser::SetEntryLengthByNumber(l,group,element)); }
135 inline virtual void UpdateShaEntries(void)
136 { gdcmParser::UpdateShaEntries(); }
138 /// Read (used in gdcmFile)
139 void SetImageDataSize(size_t ExpectedSize);
141 bool operator<(gdcmHeader &header);
143 bool WriteEntry(gdcmHeaderEntry *tag,FILE *_fp,FileType type);
146 virtual void PrintEntryNoSQ (std::ostream &os = std::cout);
147 virtual void PrintEntryNiceSQ(std::ostream &os = std::cout);
150 //CLEANME int write(std::ostream&);
151 //CLEANME int anonymize(std::ostream&);//FIXME: anonymize should be a friend
152 bool anonymizeHeader(void);
157 //-----------------------------------------------------------------------------