Medical Imaging Interaction Toolkit  2018.4.99-6ca56567
Medical Imaging Interaction Toolkit
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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 
16 ::DICOMGDCMImageFrameInfo(const std::string& filename, unsigned int frameNo)
17 :DICOMDatasetAccessingImageFrameInfo(filename, frameNo)
18 ,m_TagForValue()
19 {
20 }
21 
23 ::DICOMGDCMImageFrameInfo(const DICOMImageFrameInfo::Pointer& frameinfo)
26 {
27 }
28 
30 ::DICOMGDCMImageFrameInfo(const DICOMImageFrameInfo::Pointer& frameinfo, gdcm::Scanner::TagToValue const& tagToValueMapping)
32 ,m_TagForValue(tagToValueMapping)
33 {
34 }
35 
38 {
39 }
40 
44 {
45  const auto mappedValue = m_TagForValue.find( gdcm::Tag(tag.GetGroup(), tag.GetElement()) );
46  DICOMDatasetFinding result;
47 
48  if (mappedValue != m_TagForValue.cend())
49  {
50  result.isValid = true;
51 
52  if (mappedValue->second != nullptr)
53  {
54  std::string s(mappedValue->second);
55  try
56  {
57  result.value = s.erase(s.find_last_not_of(" \n\r\t")+1);
58  }
59  catch(...)
60  {
61  result.value = s;
62  }
63  }
64  else
65  {
66  result.value = "";
67  }
68  }
69  else
70  {
71  const DICOMTag tagImagePositionPatient = DICOMTag(0x0020,0x0032); // Image Position (Patient)
72  const DICOMTag tagImageOrientation = DICOMTag(0x0020, 0x0037); // Image Orientation
73 
74  if (tag == tagImagePositionPatient)
75  {
76  result.isValid = true;
77  result.value = std::string("0\\0\\0");
78  }
79  else if (tag == tagImageOrientation)
80  {
81  result.isValid = true;
82  result.value = std::string("1\\0\\0\\0\\1\\0");
83  }
84  else
85  {
86  result.isValid = false;
87  result.value = "";
88  }
89  }
90  return result;
91 }
92 
95 {
96  FindingsListType result;
97  if (path.Size() == 1 && path.IsExplicit())
98  {
99  result.push_back(this->GetTagValueAsString(path.GetFirstNode().tag));
100  }
101  return result;
102 }
103 
104 std::string
107 {
108  return this->Filename;
109 }
Class is used to identify (nested) attributes in a DICOM dataset. In contrast to the class DICOMTag...
unsigned int GetElement() const
const unsigned int FrameNo
frame number, starting with 0
Representation of a DICOM tag.
Definition: mitkDICOMTag.h:32
const gdcm::Scanner::TagToValue m_TagForValue
DICOMDatasetFinding GetTagValueAsString(const DICOMTag &) const override
Return a DICOMDatasetFinding instance of the tag. The return containes (if valid) the raw value of th...
PathIndexType Size() const
std::list< DICOMDatasetFinding > FindingsListType
const std::string Filename
absolute filename
Defines an abstract base class for DICOM image frame infos with data access.
std::string GetFilenameIfAvailable() const override
Return a filename if possible. If DICOM is not read from file but from somewhere else (network...
unsigned int GetGroup() const
NodeInfo & GetFirstNode()
DICOMGDCMImageFrameInfo(const DICOMImageFrameInfo::Pointer &frameinfo)