diff --git a/Modules/DiffusionImaging/DiffusionCore/DicomImport/mitkDiffusionHeaderPhilipsDICOMFileReader.cpp b/Modules/DiffusionImaging/DiffusionCore/DicomImport/mitkDiffusionHeaderPhilipsDICOMFileReader.cpp index 4ab7e7dec2..27b9e51a69 100644 --- a/Modules/DiffusionImaging/DiffusionCore/DicomImport/mitkDiffusionHeaderPhilipsDICOMFileReader.cpp +++ b/Modules/DiffusionImaging/DiffusionCore/DicomImport/mitkDiffusionHeaderPhilipsDICOMFileReader.cpp @@ -1,74 +1,90 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkDiffusionHeaderPhilipsDICOMFileReader.h" #include mitk::DiffusionHeaderPhilipsDICOMFileReader::DiffusionHeaderPhilipsDICOMFileReader() { } mitk::DiffusionHeaderPhilipsDICOMFileReader::~DiffusionHeaderPhilipsDICOMFileReader() { } bool mitk::DiffusionHeaderPhilipsDICOMFileReader::ReadDiffusionHeader(std::string filename) { gdcm::Reader gdcmReader; gdcmReader.SetFileName( filename.c_str() ); gdcmReader.Read(); gdcm::Tag philips_bvalue_tag( 0x2001, 0x1003 ); - gdcm::Tag philips_gradient_direction( 0x2001, 0x1004 ); + //gdcm::Tag philips_gradient_direction( 0x2001, 0x1004 ); DiffusionImageDICOMHeaderInformation header_info; - std::string tagvalue_string; + //std::string tagvalue_string; //char* pEnd; // reveal b-value float bvalue = 0; if( RevealBinaryTagC( philips_bvalue_tag, gdcmReader.GetFile().GetDataSet(), (char*) &bvalue) ) { header_info.b_value = std::ceil( bvalue ); if( header_info.b_value == 0) header_info.baseline = true; } - // reveal gradient direction - tagvalue_string.clear(); - if( RevealBinaryTag( philips_gradient_direction, gdcmReader.GetFile().GetDataSet(), tagvalue_string) ) + gdcm::Tag philips_new_bvalue_tag( 0x0018,0x9087 ); + double dbvalue = 0; + if( RevealBinaryTagC( philips_new_bvalue_tag, gdcmReader.GetFile().GetDataSet(), (char*) &dbvalue) ) { - std::stringstream ssparser( tagvalue_string ); - std::string buffer; + MITK_INFO("philips.dicom.diffusion.bvalue") << dbvalue; + } + + if( header_info.baseline ) + { + // no direction in unweighted images + header_info.g_vector.fill(0); + } + else + { + MITK_INFO("philips.dicom.diffusion.gradientdir") << "Parsing gradient direction."; - unsigned int idx=0; - while( std::getline( ssparser, buffer, '\\' ) ) + gdcm::Tag philips_gradient_direction_new( 0x0018, 0x9089 ); + double gr_dir_arr[3] = {1,0,-1}; + + if( RevealBinaryTagC( philips_gradient_direction_new, gdcmReader.GetFile().GetDataSet(), (char*) &gr_dir_arr ) ) { - std::istringstream substream(buffer); - substream >> header_info.g_vector[idx++]; + MITK_INFO("philips.dicom.diffusion.gradient") << "(" << gr_dir_arr[0] <<"," << gr_dir_arr[1] <<"," <m_HeaderInformationList.push_back( header_info ); - - return false; + return true; }