ITK  5.2.0
Insight Toolkit
itkGDCMImageIO.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 /*=========================================================================
19  *
20  * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21  *
22  * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23  *
24  * For complete copyright, license and disclaimer of warranty information
25  * please refer to the NOTICE file at the top of the ITK source tree.
26  *
27  *=========================================================================*/
28 #ifndef itkGDCMImageIO_h
29 #define itkGDCMImageIO_h
30 
31 #include "itkCommonEnums.h"
32 #include "itkImageIOBase.h"
33 #include "ITKIOGDCMExport.h"
34 #include <fstream>
35 #include <string>
36 
37 
38 #if !defined(ITK_LEGACY_REMOVE)
39 # define ITKIO_DEPRECATED_GDCM1_API
40 #endif
41 
42 
43 namespace itk
44 {
50 {
51 public:
56  enum class Compression : uint8_t
57  {
58  JPEG = 0,
59  JPEG2000,
60  JPEGLS,
61  RLE
62  };
63 };
64 
65 // Define how to print enumeration
66 extern ITKIOGDCM_EXPORT std::ostream &
67  operator<<(std::ostream & out, const GDCMImageIOEnums::Compression value);
108 class InternalHeader;
109 class ITKIOGDCM_EXPORT GDCMImageIO : public ImageIOBase
110 {
111 public:
112  ITK_DISALLOW_COPY_AND_MOVE(GDCMImageIO);
114 
116  using Self = GDCMImageIO;
119 
121  itkNewMacro(Self);
122 
124  itkTypeMacro(GDCMImageIO, Superclass);
125 
126  /*-------- This part of the interface deals with reading data. ------ */
127 
130  bool
131  CanReadFile(const char *) override;
132 
134  void
135  ReadImageInformation() override;
136 
138  void
139  Read(void * pointer) override;
140 
144  itkGetEnumMacro(InternalComponentType, ::itk::CommonEnums::IOComponent);
145  itkSetEnumMacro(InternalComponentType, ::itk::CommonEnums::IOComponent);
147 
148  /*-------- This part of the interfaces deals with writing data. ----- */
149 
152  bool
153  CanWriteFile(const char *) override;
154 
157  void
158  WriteImageInformation() override;
159 
162  void
163  Write(const void * buffer) override;
164 
166  itkGetConstMacro(RescaleSlope, double);
167  itkGetConstMacro(RescaleIntercept, double);
169 
173  itkGetStringMacro(UIDPrefix);
174  itkSetStringMacro(UIDPrefix);
176 
178  itkGetStringMacro(StudyInstanceUID);
179  itkGetStringMacro(SeriesInstanceUID);
180  itkGetStringMacro(FrameOfReferenceInstanceUID);
182 
184  itkSetMacro(KeepOriginalUID, bool);
185  itkGetConstMacro(KeepOriginalUID, bool);
186  itkBooleanMacro(KeepOriginalUID);
188 
191  itkSetMacro(LoadPrivateTags, bool);
192  itkGetConstMacro(LoadPrivateTags, bool);
193  itkBooleanMacro(LoadPrivateTags);
195 
198  itkSetMacro(ReadYBRtoRGB, bool);
199  itkGetConstMacro(ReadYBRtoRGB, bool);
200  itkBooleanMacro(ReadYBRtoRGB);
202 
203 #if defined(ITKIO_DEPRECATED_GDCM1_API)
204 
209  void
210  GetPatientName(char * name, size_t len = 512);
211 
212  void
213  GetPatientID(char * name, size_t len = 512);
214 
215  void
216  GetPatientSex(char * name, size_t len = 512);
217 
218  void
219  GetPatientAge(char * name, size_t len = 512);
220 
221  void
222  GetStudyID(char * name, size_t len = 512);
223 
224  void
225  GetPatientDOB(char * name, size_t len = 512);
226 
227  void
228  GetStudyDescription(char * name, size_t len = 512);
229 
230  void
231  GetBodyPart(char * name, size_t len = 512);
232 
233  void
234  GetNumberOfSeriesInStudy(char * name, size_t len = 512);
235 
236  void
237  GetNumberOfStudyRelatedSeries(char * name, size_t len = 512);
238 
239  void
240  GetStudyDate(char * name, size_t len = 512);
241 
242  void
243  GetModality(char * name, size_t len = 512);
244 
245  void
246  GetManufacturer(char * name, size_t len = 512);
247 
248  void
249  GetInstitution(char * name, size_t len = 512);
250 
251  void
252  GetModel(char * name, size_t len = 512);
253 
254  void
255  GetScanOptions(char * name, size_t len = 512);
256 #endif
257 
260  bool
261  GetValueFromTag(const std::string & tag, std::string & value);
262 
269  static bool
270  GetLabelFromTag(const std::string & tag, std::string & labelId);
271 
272 #if defined(ITKIO_DEPRECATED_GDCM1_API)
273 
279  virtual void
280  SetMaxSizeLoadEntry(const long)
281  {}
282 
287  virtual void
288  SetLoadSequences(const bool)
289  {}
290  virtual bool
291  GetLoadSequences() const
292  {
293  return true;
294  }
295  virtual void
296  LoadSequencesOn()
297  {}
298  virtual void
299  LoadSequencesOff()
300  {}
302 
310  static void
311  SetLoadSequencesDefault(bool)
312  {}
313  static void
314  LoadSequencesDefaultOn()
315  {}
316  static void
317  LoadSequencesDefaultOff()
318  {}
319  static bool
320  GetLoadSequencesDefault()
321  {
322  return true;
323  }
325 
333  static void
334  SetLoadPrivateTagsDefault(bool)
335  {}
336  static void
337  LoadPrivateTagsDefaultOn()
338  {}
339  static void
340  LoadPrivateTagsDefaultOff()
341  {}
342  static bool
343  GetLoadPrivateTagsDefault()
344  {
345  return true;
346  }
347 #endif
348 
349 
350 
352 #if !defined(ITK_LEGACY_REMOVE)
353  // We need to expose the enum values at the class level
354  // for backwards compatibility
355  static constexpr CompressionEnum JPEG = CompressionEnum::JPEG;
356  static constexpr CompressionEnum JPEG2000 = CompressionEnum::JPEG2000;
357  static constexpr CompressionEnum JPEGLS = CompressionEnum::JPEGLS;
358  static constexpr CompressionEnum RLE = CompressionEnum::RLE;
359 #endif
360 
361  itkSetEnumMacro(CompressionType, CompressionEnum);
362  itkGetEnumMacro(CompressionType, CompressionEnum);
363 
364  void
365  InternalSetCompressor(const std::string & _compressor) override;
366 
367 protected:
368  GDCMImageIO();
369  ~GDCMImageIO() override;
370  void
371  PrintSelf(std::ostream & os, Indent indent) const override;
372 
373  void
374  InternalReadImageInformation();
375 
377 
379 
380  std::string m_UIDPrefix;
381 
382  std::string m_StudyInstanceUID;
383 
384  std::string m_SeriesInstanceUID;
385 
387 
389 
391 
393 
394 private:
395 #if defined(ITKIO_DEPRECATED_GDCM1_API)
396  std::string m_PatientName;
397 
398  std::string m_PatientID;
399 
400  std::string m_PatientDOB;
401 
402  std::string m_StudyID;
403 
404  std::string m_StudyDescription;
405 
406  std::string m_BodyPart;
407 
408  std::string m_NumberOfSeriesInStudy;
409 
410  std::string m_NumberOfStudyRelatedSeries;
411 
412  std::string m_PatientSex;
413 
414  std::string m_PatientAge;
415 
416  std::string m_StudyDate;
417 
418  std::string m_Modality;
419 
420  std::string m_Manufacturer;
421 
422  std::string m_Institution;
423 
424  std::string m_Model;
425 
426  std::string m_ScanOptions;
427 #endif
428 
430 
432 
434 
436 
437  InternalHeader * m_DICOMHeader;
438 };
439 
440 } // end namespace itk
441 
442 #endif // itkGDCMImageIO_h
itk::ImageIOBase
Abstract superclass defines image IO interface.
Definition: itkImageIOBase.h:77
itk::GDCMImageIOEnums::Compression
Compression
Definition: itkGDCMImageIO.h:56
itk::uint8_t
::uint8_t uint8_t
Definition: itkIntTypes.h:29
itk::GDCMImageIO::m_SeriesInstanceUID
std::string m_SeriesInstanceUID
Definition: itkGDCMImageIO.h:384
itk::operator<<
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
Definition: itkArray.h:218
itk::GDCMImageIO::m_DICOMHeader
InternalHeader * m_DICOMHeader
Definition: itkGDCMImageIO.h:437
itk::GDCMImageIO::m_CompressionType
CompressionEnum m_CompressionType
Definition: itkGDCMImageIO.h:431
itk::GDCMImageIOEnums
Definition: itkGDCMImageIO.h:49
itk::GDCMImageIO::m_UIDPrefix
std::string m_UIDPrefix
Definition: itkGDCMImageIO.h:380
itk::GDCMImageIOEnums::Compression::RLE
itk::GDCMImageIO::m_InternalComponentType
IOComponentEnum m_InternalComponentType
Definition: itkGDCMImageIO.h:435
itk::GDCMImageIO::m_RescaleSlope
double m_RescaleSlope
Definition: itkGDCMImageIO.h:376
itk::SmartPointer< Self >
itk::CommonEnums::IOComponent
IOComponent
Definition: itkCommonEnums.h:76
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::GDCMImageIO::m_GlobalNumberOfDimensions
unsigned int m_GlobalNumberOfDimensions
Definition: itkGDCMImageIO.h:429
itk::GDCMImageIO::m_RescaleIntercept
double m_RescaleIntercept
Definition: itkGDCMImageIO.h:378
itk::GDCMImageIO::m_LoadPrivateTags
bool m_LoadPrivateTags
Definition: itkGDCMImageIO.h:390
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::GDCMImageIOEnums::Compression::JPEGLS
itk::GDCMImageIO::m_FrameOfReferenceInstanceUID
std::string m_FrameOfReferenceInstanceUID
Definition: itkGDCMImageIO.h:386
itk::GDCMImageIOEnums::Compression::JPEG2000
itk::GDCMImageIO::m_SingleBit
bool m_SingleBit
Definition: itkGDCMImageIO.h:433
itk::GDCMImageIOEnums::Compression::JPEG
itk::GDCMImageIO
ImageIO class for reading and writing DICOM V3.0 and ACR/NEMA 1&2 uncompressed images....
Definition: itkGDCMImageIO.h:109
itkImageIOBase.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::GDCMImageIO::m_KeepOriginalUID
bool m_KeepOriginalUID
Definition: itkGDCMImageIO.h:388
itkCommonEnums.h
Compression
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:62
itk::GDCMImageIO::m_ReadYBRtoRGB
bool m_ReadYBRtoRGB
Definition: itkGDCMImageIO.h:392
itk::GDCMImageIO::m_StudyInstanceUID
std::string m_StudyInstanceUID
Definition: itkGDCMImageIO.h:382