CBICA Toolkit  1.0.0
All Classes Files Functions Variables Typedefs Enumerations Pages
DicomMetadataReader.h
1 ///////////////////////////////////////////////////////////////////////////////////////
2 // DicomMetadataReader.h
3 //
4 // Copyright (c) 2018. All rights reserved.
5 // Section of Biomedical Image Analysis
6 // Center for Biomedical Image Computing and Analytics
7 // Department of Radiology
8 // Perelman School of Medicine
9 // University of Pennsylvania
10 //
11 // Contact details: software@cbica.upenn.edu
12 //
13 // License Agreement: https://www.med.upenn.edu/cbica/software-agreement.html
14 ///////////////////////////////////////////////////////////////////////////////////////
15 
16 #ifndef DICOMMMETADATAREADER_H
17 #define DICOMMMETADATAREADER_H
18 
19 #include "itkImageSeriesReader.h"
20 #include "itkGDCMImageIO.h"
21 #include "itkGDCMSeriesFileNames.h"
22 #include <itkMapContainer.h>
23 
25 {
26 public:
27 
28  //! we may need to handle pixeltype in a template if we run into issues
29  typedef signed short PixelType;
30  const unsigned int Dimension = 2;
31  typedef itk::Image< PixelType, 2 > ImageType;
32 
33  typedef itk::ImageFileReader< ImageType > ReaderType;
34  typedef itk::GDCMSeriesFileNames NamesGeneratorType;
35  typedef itk::GDCMImageIO ImageIOType;
36  typedef std::vector<std::string> FileNamesContainer;
37  typedef itk::MetaDataDictionary DictionaryType;
38  typedef itk::MetaDataObject< std::string > MetaDataStringType;
39  typedef itk::MapContainer<std::string, std::pair<std::string, std::string>> MapContainerType; //map description: <tag, <description, value> >
40 
41  //! Constructor/Destructor
44 
45  //! Set the input file path to dicom image
46  void SetFilePath(std::string path);
47 
48  //! Read meta data
49  bool ReadMetaData();
50 
51  //! Get all metadata as a map <tag, <description, value> >
52  std::map<std::string, std::pair<std::string, std::string>> GetMetaDataMap();
53 
54  //! Get individual tag description and value for a given tag
55  bool GetTagValue(std::string tag, std::string &label, std::string &value);
56 
57 private:
58  void PrintMetaData(); // for testing purpose
59 
60  ReaderType::Pointer m_reader;
61  NamesGeneratorType::Pointer m_nameGenerator;
62  FileNamesContainer m_fileNames;
63  ImageIOType::Pointer m_dicomIO;
64  MapContainerType::Pointer m_tagvalueMap;
65  DictionaryType m_dictionary;
66  std::string m_FilePath;
67 };
68 
69 #endif // DICOMMMETADATAREADER_H
70 
Definition: DicomMetadataReader.h:24
bool GetTagValue(std::string tag, std::string &label, std::string &value)
Get individual tag description and value for a given tag.
std::map< std::string, std::pair< std::string, std::string > > GetMetaDataMap()
Get all metadata as a map <tag, <description, value> >
void SetFilePath(std::string path)
Set the input file path to dicom image.
bool ReadMetaData()
Read meta data.
DicomMetadataReader()
Constructor/Destructor.
signed short PixelType
we may need to handle pixeltype in a template if we run into issues
Definition: DicomMetadataReader.h:29