Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
mitkDICOMGDCMImageFrameInfo.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3  The Medical Imaging Interaction Toolkit (MITK)
4 
5  Copyright (c) German Cancer Research Center,
6  Division of Medical and Biological Informatics.
7  All rights reserved.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without
10  even the implied warranty of MERCHANTABILITY or FITNESS FOR
11  A PARTICULAR PURPOSE.
12 
13  See LICENSE.txt or http://www.mitk.org for details.
14 
15  ===================================================================*/
16 
18 
20 ::DICOMGDCMImageFrameInfo(const std::string& filename, unsigned int frameNo)
21 :DICOMDatasetAccessingImageFrameInfo(filename, frameNo)
22 ,m_TagForValue()
23 {
24 }
25 
28 :DICOMDatasetAccessingImageFrameInfo(frameinfo->Filename, frameinfo->FrameNo)
29 ,m_TagForValue()
30 {
31 }
32 
34 ::DICOMGDCMImageFrameInfo(const DICOMImageFrameInfo::Pointer& frameinfo, gdcm::Scanner::TagToValue const& tagToValueMapping)
35 :DICOMDatasetAccessingImageFrameInfo(frameinfo->Filename, frameinfo->FrameNo)
36 ,m_TagForValue(tagToValueMapping)
37 {
38 }
39 
42 {
43 }
44 
48 {
49  const auto mappedValue = m_TagForValue.find( gdcm::Tag(tag.GetGroup(), tag.GetElement()) );
50  DICOMDatasetFinding result;
51 
52  if (mappedValue != m_TagForValue.cend())
53  {
54  result.isValid = true;
55 
56  if (mappedValue->second != nullptr)
57  {
58  std::string s(mappedValue->second);
59  try
60  {
61  result.value = s.erase(s.find_last_not_of(" \n\r\t")+1);
62  }
63  catch(...)
64  {
65  result.value = s;
66  }
67  }
68  else
69  {
70  result.value = "";
71  }
72  }
73  else
74  {
75  const DICOMTag tagImagePositionPatient = DICOMTag(0x0020,0x0032); // Image Position (Patient)
76  const DICOMTag tagImageOrientation = DICOMTag(0x0020, 0x0037); // Image Orientation
77 
78  if (tag == tagImagePositionPatient)
79  {
80  result.isValid = true;
81  result.value = std::string("0\\0\\0");
82  }
83  else if (tag == tagImageOrientation)
84  {
85  result.isValid = true;
86  result.value = std::string("1\\0\\0\\0\\1\\0");
87  }
88  else
89  {
90  result.isValid = false;
91  result.value = "";
92  }
93  }
94  return result;
95 }
96 
99 {
100  FindingsListType result;
101  if (path.Size() == 1 && path.IsExplicit())
102  {
103  result.push_back(this->GetTagValueAsString(path.GetFirstNode().tag));
104  }
105  return result;
106 }
107 
108 std::string
111 {
112  return this->Filename;
113 }
itk::SmartPointer< Self > Pointer
Class is used to identify (nested) attributes in a DICOM dataset. In contrast to the class DICOMTag...
Representation of a DICOM tag.
Definition: mitkDICOMTag.h:37
unsigned int GetGroup() const
virtual DICOMDatasetFinding GetTagValueAsString(const DICOMTag &) const override
Return a DICOMDatasetFinding instance of the tag. The return containes (if valid) the raw value of th...
bool IsExplicit() const
std::list< DICOMDatasetFinding > FindingsListType
PathIndexType Size() const
static const std::string filename
Defines an abstract base class for DICOM image frame infos with data access.
unsigned int GetElement() const
std::string GetFilenameIfAvailable() const override
Return a filename if possible. If DICOM is not read from file but from somewhere else (network...
NodeInfo & GetFirstNode()
DICOMGDCMImageFrameInfo(const DICOMImageFrameInfo::Pointer &frameinfo)