Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkDiffusionHeaderPhilipsDICOMFileReader.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 
19 #include <sstream>
20 
21 #include <vnl/vnl_math.h>
22 
24 {
25 }
26 
28 {
29 
30 }
31 
33 {
34  gdcm::Reader gdcmReader;
35  gdcmReader.SetFileName( filename.c_str() );
36 
37  gdcmReader.Read();
38 
39  gdcm::Tag philips_bvalue_tag( 0x2001, 0x1003 );
40  //gdcm::Tag philips_gradient_direction( 0x2001, 0x1004 );
41 
43  //std::string tagvalue_string;
44  //char* pEnd;
45 
46  // reveal b-value
47  float bvalue = 0;
48  if( RevealBinaryTagC( philips_bvalue_tag, gdcmReader.GetFile().GetDataSet(), (char*) &bvalue) )
49  {
50 
51  header_info.b_value = std::ceil( bvalue );
52 
53  if( header_info.b_value == 0)
54  header_info.baseline = true;
55  }
56  else
57  {
58  MITK_WARN("diffusion.dicomreader.philips") << "No b-value found. Most probably no diffusion-weighted image.";
59  return false;
60  }
61 
62  gdcm::Tag philips_new_bvalue_tag( 0x0018,0x9087 );
63  double dbvalue = 0;
64  if( RevealBinaryTagC( philips_new_bvalue_tag, gdcmReader.GetFile().GetDataSet(), (char*) &dbvalue) )
65  {
66  MITK_INFO("philips.dicom.diffusion.bvalue") << dbvalue;
67  }
68 
69  if( header_info.baseline )
70  {
71  // no direction in unweighted images
72  header_info.g_vector.fill(0);
73  }
74  else
75  {
76  MITK_INFO("philips.dicom.diffusion.gradientdir") << "Parsing gradient direction.";
77 
78  gdcm::Tag philips_gradient_direction_new( 0x0018, 0x9089 );
79  double gr_dir_arr[3] = {1,0,-1};
80 
81  if( RevealBinaryTagC( philips_gradient_direction_new, gdcmReader.GetFile().GetDataSet(), (char*) &gr_dir_arr ) )
82  {
83  MITK_INFO("philips.dicom.diffusion.gradient") << "(" << gr_dir_arr[0] <<"," << gr_dir_arr[1] <<"," <<gr_dir_arr[2] <<")";
84  }
85 
86  header_info.g_vector.copy_in( &gr_dir_arr[0] );
87  if( header_info.g_vector.two_norm() < vnl_math::eps )
88  {
89  header_info.g_vector.fill(1);
90  header_info.isotropic = true;
91  }
92  }
93 
94  this->m_HeaderInformationList.push_back( header_info );
95 
96  return true;
97 }
#define MITK_INFO
Definition: mitkLogMacros.h:22
The DiffusionImageHeaderInformation struct.
#define MITK_WARN
Definition: mitkLogMacros.h:23
static const std::string filename
virtual bool ReadDiffusionHeader(std::string filename) override
MITKCORE_EXPORT const ScalarType eps
bool RevealBinaryTagC(const gdcm::Tag tag, const gdcm::DataSet &dataset, char *target_array)